/* ==========================================================================
   EducGest — pages d'authentification « Le Cahier & l'Ardoise »
   Ardoise à la craie à gauche, page de cahier Seyès à droite.
   ========================================================================== */

:root {
    --encre: #1E3A8A;
    --encre-fonce: #152C6B;
    --texte: #1C2433;
    --texte-2: #4B5466;
    --texte-3: #5B6475;
    --bordure: #9AA2B3;
    --bordure-douce: #D5D9E2;
    --papier: #FBF8F1;
    --rouge: #B42318;
    --erreur: #B91C1C;
    --vert: #15803D;
    --craie: #F1EEE2;
    --craie-jaune: #F6D365;
    --ardoise: #23423A;
    --bois: #8A5A33;
    --police-texte: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --police-titre: 'Fraunces', Georgia, serif;
    --police-craie: 'Caveat', 'Comic Sans MS', cursive;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body.cahier {
    min-height: 100vh;
    font-family: var(--police-texte);
    color: var(--texte);
    background: var(--papier);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--encre); }
a:hover { color: var(--encre-fonce); }

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------------------
   Mise en page
   -------------------------------------------------------------------------- */

.cahier-page {
    min-height: 100vh;
    display: flex;
    flex-wrap: wrap;
}

.cahier-ardoise {
    flex: 7 1 400px;
    min-width: 0;
    background: var(--bois);
    padding: 22px 22px 0;
    display: flex;
    flex-direction: column;
}

.page-large-ardoise .cahier-ardoise { flex: 9 1 460px; }

.ardoise {
    flex: 1 1 auto;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    padding: 40px 40px 32px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    color: var(--craie);
    font-family: var(--police-craie);
    background-color: var(--ardoise);
    background-image:
        radial-gradient(ellipse at 22% 28%, rgba(255, 255, 255, .06), transparent 55%),
        radial-gradient(ellipse at 78% 78%, rgba(255, 255, 255, .05), transparent 50%);
    box-shadow: inset 0 0 70px rgba(0, 0, 0, .45);
}

.ardoise-rebord {
    height: 22px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 28px;
}

.ardoise-rebord span { height: 8px; border-radius: 3px; }
.ardoise-rebord span:nth-child(1) { width: 46px; background: #F4F1E6; }
.ardoise-rebord span:nth-child(2) { width: 30px; background: var(--craie-jaune); }
.ardoise-rebord span:nth-child(3) { width: 22px; background: #E9A6A0; }

.cahier-feuille {
    --marge: 64px;
    flex: 13 1 600px;
    min-width: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 40px 64px 48px calc(var(--marge) + 40px);
    background-color: var(--papier);
    background-image:
        linear-gradient(90deg, transparent calc(var(--marge) - 1px), rgba(214, 69, 65, .6) calc(var(--marge) - 1px), rgba(214, 69, 65, .6) calc(var(--marge) + 1px), transparent calc(var(--marge) + 1px)),
        repeating-linear-gradient(180deg, transparent 0 31px, rgba(43, 76, 155, .20) 31px 32px),
        repeating-linear-gradient(180deg, transparent 0 7px, rgba(43, 76, 155, .07) 7px 8px);
}

.feuille-entete {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 14px;
    color: var(--texte-2);
}

.feuille-entete p { margin: 0; }

.marque {
    font-family: var(--police-titre);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--texte);
    text-decoration: none;
}

.marque span { color: var(--rouge); }
.marque:hover { color: var(--texte); }

.feuille-contenu {
    width: 100%;
    max-width: 620px;
    margin: auto 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.feuille-contenu.etroit { max-width: 440px; }

.tampon {
    position: absolute;
    right: 36px;
    bottom: 28px;
    width: 96px;
    height: 96px;
    transform: rotate(-12deg);
    opacity: .8;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Écriture à la craie
   -------------------------------------------------------------------------- */

.craie-date { font-size: 24px; text-align: right; opacity: .85; }

.craie-bloc { display: flex; flex-direction: column; gap: 4px; }

.craie-surtitre {
    font-size: 28px;
    color: var(--craie-jaune);
    text-decoration: underline;
    text-underline-offset: 6px;
}

.craie-titre {
    margin: 0;
    font-family: inherit;
    font-size: 52px;
    line-height: 1.02;
    font-weight: 700;
}

.craie-liste {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 29px;
}

.craie-liste li { display: flex; align-items: center; gap: 14px; }
.craie-liste svg { flex: none; }

.craie-note {
    font-size: 25px;
    opacity: .85;
    border-top: 2px dashed rgba(241, 238, 226, .4);
    padding-top: 16px;
}

.craie-art {
    margin-top: auto;
    display: flex;
    justify-content: flex-end;
}

.craie-soleil {
    position: absolute;
    top: 74px;
    right: 40px;
    opacity: .9;
}

/* Étapes écrites à la craie */
.craie-etapes {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.craie-etapes li {
    display: flex;
    align-items: center;
    gap: 16px;
    opacity: .55;
    transition: opacity .3s ease;
}

.craie-etapes .pastille {
    width: 46px;
    height: 46px;
    flex: none;
    border: 2.5px dashed var(--craie);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: 700;
}

.craie-etapes .pastille svg { display: none; }

.craie-etapes .texte {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.craie-etapes .libelle { font-size: 32px; }

.craie-etapes .recap {
    display: none;
    font-size: 22px;
    opacity: .75;
    margin-top: 4px;
}

.craie-etapes .ici {
    display: none;
    align-items: center;
    gap: 6px;
    color: var(--craie-jaune);
    font-size: 24px;
}

.craie-etapes li.est-actuel { opacity: 1; }
.craie-etapes li.est-actuel .pastille { border: 3px solid var(--craie); }
.craie-etapes li.est-actuel .libelle { font-weight: 700; }
.craie-etapes li.est-actuel .ici { display: flex; animation: craie-ici 1.6s ease-in-out infinite; }

.craie-etapes li.est-fait { opacity: 1; }
.craie-etapes li.est-fait .pastille { border: 3px solid var(--craie-jaune); }
.craie-etapes li.est-fait .pastille span { display: none; }
.craie-etapes li.est-fait .pastille svg { display: block; }
.craie-etapes li.est-fait .libelle {
    text-decoration: line-through;
    text-decoration-color: rgba(246, 211, 101, .75);
    text-decoration-thickness: 2px;
}
.craie-etapes li.est-fait .recap:not(:empty) { display: block; }

@keyframes craie-ici {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-6px); }
}

/* --------------------------------------------------------------------------
   Titres et textes de la feuille
   -------------------------------------------------------------------------- */

.entete-bloc { display: flex; flex-direction: column; gap: 8px; }

.titre {
    margin: 0;
    font-family: var(--police-titre);
    font-size: 42px;
    line-height: 1.06;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--texte);
}

.titre:focus { outline: none; }

.sous-titre { margin: 0; font-size: 16px; line-height: 1.5; color: var(--texte-2); }

.manuscrit {
    font-family: var(--police-craie);
    font-size: 28px;
    font-weight: 700;
    color: var(--encre);
}

.texte-pied { margin: 0; font-size: 15px; color: var(--texte-2); }
.texte-legal { margin: 0; font-size: 13px; color: var(--texte-3); }
.lien-fort { font-weight: 700; }

/* --------------------------------------------------------------------------
   Onglets de profil (Directeur / Partenaire)
   -------------------------------------------------------------------------- */

.onglets {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid var(--texte);
}

.onglet {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin-bottom: -2px;
    padding: 0 16px;
    border: 2px dashed #8A93A6;
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    background: transparent;
    color: var(--texte-2);
    font: 600 14px var(--police-texte);
    text-decoration: none;
    cursor: pointer;
}

.onglet:hover { color: var(--texte); }

.onglet.actif,
.onglet[aria-pressed="true"] {
    border: 2px solid var(--texte);
    border-bottom: 2px solid var(--craie-jaune);
    background: var(--craie-jaune);
    color: var(--texte);
}

/* --------------------------------------------------------------------------
   Champs
   -------------------------------------------------------------------------- */

.formulaire { display: flex; flex-direction: column; gap: 18px; }

.champ { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.etiquette, .champ > label { font-size: 14px; font-weight: 600; color: var(--texte); }

.champ-ligne {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.champ-ligne a { font-size: 13px; font-weight: 600; }

.optionnel { font-weight: 400; color: var(--texte-3); }

.saisie {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 0 14px;
    background: #FFFFFF;
    border: 1.5px solid var(--bordure);
    border-radius: 10px;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.saisie > svg { flex: none; color: var(--texte-3); transition: color .2s ease; }

.saisie:focus-within {
    border-color: var(--encre);
    box-shadow: 0 0 0 1px var(--encre), 0 0 0 5px rgba(30, 58, 138, .13);
}

.saisie:focus-within > svg { color: var(--encre); }

.saisie input,
.saisie select {
    flex: 1;
    min-width: 0;
    height: 48px;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    font: 500 15px var(--police-texte);
    color: var(--texte);
}

.saisie input::placeholder { color: #6B7385; font-weight: 400; }
.saisie input[readonly] { color: var(--texte-2); }

.saisie select { appearance: none; -webkit-appearance: none; cursor: pointer; }

.saisie.erreur { border-color: var(--erreur); background: #FEF2F2; }

.zone-texte {
    width: 100%;
    min-height: 96px;
    padding: 12px 14px;
    border: 1.5px solid var(--bordure);
    border-radius: 10px;
    background: #FFFFFF;
    font: 500 15px/1.5 var(--police-texte);
    color: var(--texte);
    resize: vertical;
}

.zone-texte:focus {
    outline: 0;
    border-color: var(--encre);
    box-shadow: 0 0 0 1px var(--encre), 0 0 0 5px rgba(30, 58, 138, .13);
}

.message-erreur { margin: 0; font-size: 13px; font-weight: 500; color: var(--erreur); }
.aide { margin: 0; font-size: 13px; color: var(--texte-3); }

.btn-oeil {
    width: 44px;
    height: 44px;
    flex: none;
    margin-right: -10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--texte-3);
    cursor: pointer;
}

.btn-oeil:hover { color: var(--encre); }
.btn-oeil:focus-visible { outline: 2px solid var(--encre); outline-offset: -4px; }
.btn-oeil .oeil-ferme { display: none; }
.btn-oeil.visible .oeil-ouvert { display: none; }
.btn-oeil.visible .oeil-ferme { display: block; }

.grille-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

/* Force du mot de passe */
.force { display: flex; align-items: center; gap: 8px; min-height: 16px; }

.force-barres {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
}

.force-barres span { height: 5px; border-radius: 3px; background: var(--bordure-douce); transition: background .25s ease; }
.force-texte { min-width: 64px; font-size: 12px; font-weight: 600; text-align: right; }

.force[data-niveau="1"] .force-barres span:nth-child(-n+1) { background: #DC2626; }
.force[data-niveau="2"] .force-barres span:nth-child(-n+2) { background: #D97706; }
.force[data-niveau="3"] .force-barres span:nth-child(-n+3) { background: var(--vert); }
.force[data-niveau="4"] .force-barres span { background: #166534; }
.force[data-niveau="1"] .force-texte { color: #B91C1C; }
.force[data-niveau="2"] .force-texte { color: #B45309; }
.force[data-niveau="3"] .force-texte,
.force[data-niveau="4"] .force-texte { color: var(--vert); }

.accord-mdp { min-height: 16px; font-size: 12px; font-weight: 600; }
.accord-mdp.ok { color: var(--vert); }
.accord-mdp.ko { color: var(--erreur); }

/* Téléphone (intl-tel-input) */
.saisie-tel { padding: 0 14px 0 0; }
.saisie-tel .iti { flex: 1; min-width: 0; width: 100%; }
.saisie-tel .iti input { width: 100%; }
.iti__country-list, .iti__dropdown-content {
    border: 1.5px solid var(--bordure) !important;
    border-radius: 10px !important;
    box-shadow: 4px 4px 0 rgba(28, 36, 51, .15) !important;
    z-index: 50 !important;
}
.iti__country { padding: 8px 12px !important; font-size: 14px !important; }

/* Case à cocher (accord WhatsApp) */
.case-accord {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, .85);
    border: 1.5px solid var(--bordure-douce);
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.45;
    color: #39414F;
    cursor: pointer;
}

.case-accord input {
    width: 20px;
    height: 20px;
    flex: none;
    margin: 1px 0 0;
    accent-color: var(--encre);
    cursor: pointer;
}

/* --------------------------------------------------------------------------
   Boutons
   -------------------------------------------------------------------------- */

.btn-principal {
    min-height: 54px;
    padding: 0 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 2px solid var(--texte);
    border-radius: 10px;
    background: var(--encre);
    color: #FFFFFF;
    font: 700 16px var(--police-texte);
    text-decoration: none;
    cursor: pointer;
    box-shadow: 4px 4px 0 var(--texte);
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.btn-principal:hover { color: #FFFFFF; background: var(--encre-fonce); transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--texte); }
.btn-principal:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--texte); }
.btn-principal:focus-visible { outline: 3px solid var(--craie-jaune); outline-offset: 3px; }
.btn-principal.rouge { background: var(--rouge); }
.btn-principal.rouge:hover { background: #8F1C13; }
.btn-principal.pleine-largeur { width: 100%; }
.btn-principal[disabled] { opacity: .65; cursor: wait; transform: none; }

.btn-secondaire {
    min-height: 54px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 2px dashed #8A93A6;
    border-radius: 10px;
    background: transparent;
    color: var(--texte);
    font: 600 15px var(--police-texte);
    text-decoration: none;
    cursor: pointer;
}

.btn-secondaire:hover { color: var(--encre); border-color: var(--encre); }

.btn-lien {
    padding: 0;
    border: 0;
    background: none;
    color: var(--encre);
    font: 600 14px var(--police-texte);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-lien:hover { text-decoration: underline; }
.btn-lien[disabled] { color: var(--texte-3); cursor: not-allowed; text-decoration: none; }
.btn-lien.rouge { color: var(--erreur); }

.navigation-etapes {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.navigation-etapes > :only-child { margin-left: auto; }

.chargement-rond {
    width: 18px;
    height: 18px;
    flex: none;
    border: 2.5px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: tourne .8s linear infinite;
}

@keyframes tourne { to { transform: rotate(360deg); } }

/* Coupon « Espace Parent » */
.coupon {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 2px dashed var(--rouge);
    border-radius: 12px;
    background: rgba(255, 255, 255, .75);
    color: var(--texte);
    text-decoration: none;
}

.coupon:hover { color: var(--texte); background: #FFFFFF; }
.coupon-icone {
    width: 44px; height: 44px; flex: none;
    border-radius: 50%;
    background: #FDE8E6;
    color: var(--rouge);
    display: flex; align-items: center; justify-content: center;
}
.coupon-texte { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.coupon-texte strong { font-size: 15px; }
.coupon-texte span { font-size: 13px; color: var(--texte-2); }

/* Fiche (récapitulatif) */
.fiche {
    margin: 0;
    padding: 4px 20px;
    background: #FFFFFF;
    border: 2px solid var(--texte);
    border-radius: 12px;
    box-shadow: 4px 4px 0 var(--texte);
}

.fiche-ligne {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px dashed #C9CED8;
    font-size: 15px;
}

.fiche-ligne:last-child { border-bottom: 0; }
.fiche-ligne dt { color: var(--texte-3); }
.fiche-ligne dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }

.pastille-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border: 1px solid #A7F3D0;
    border-radius: 999px;
    background: #ECFDF5;
    color: #065F46;
    font-weight: 700;
}

.btn-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border: 1.5px solid #A7F3D0;
    border-radius: 999px;
    background: #ECFDF5;
    color: #065F46;
    font: 700 14px var(--police-texte);
    cursor: pointer;
}

/* --------------------------------------------------------------------------
   Inscription en étapes
   -------------------------------------------------------------------------- */

.etape { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.etape + .etape { margin-top: 28px; }
.js-assistant .etape + .etape { margin-top: 0; }
.js-assistant .etape:not(.active) { display: none; }
.js-assistant.avec-transition .etape.active { animation: feuille-arrive .35s ease-out; }

.progression { display: none; align-items: center; gap: 14px; }
.js-assistant .progression { display: flex; }

.barre-etapes {
    flex: 1;
    max-width: 220px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.barre-etapes span { height: 8px; border-radius: 4px; background: var(--bordure-douce); transition: background .3s ease; }
.barre-etapes span.rempli { background: var(--encre); }

.sans-js-seulement { display: block; }
.js-assistant .sans-js-seulement { display: none; }
.avec-js-seulement { display: none; }
.js-assistant .avec-js-seulement { display: inline-flex; }
.js-assistant .navigation-etapes.avec-js-seulement { display: flex; }

@keyframes feuille-arrive {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Code de vérification (6 chiffres, vérifié automatiquement)
   -------------------------------------------------------------------------- */

.otp { position: relative; width: 100%; max-width: 440px; }

.otp-saisie {
    width: 100%;
    height: 60px;
    padding: 0 12px;
    border: 1.5px solid var(--bordure);
    border-radius: 10px;
    background: #FFFFFF;
    font: 700 28px ui-monospace, 'Courier New', monospace;
    letter-spacing: 12px;
    text-align: center;
    color: var(--texte);
}

.otp-saisie:focus { outline: 0; border-color: var(--encre); box-shadow: 0 0 0 1px var(--encre), 0 0 0 5px rgba(30, 58, 138, .13); }

.otp-cases { display: none; }

.otp.js .otp-saisie {
    position: absolute;
    inset: 0;
    z-index: 2;
    height: 100%;
    opacity: 0;
    font-size: 16px;
    cursor: text;
}

.otp.js .otp-cases {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
}

.otp-case {
    position: relative;
    height: 66px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bordure);
    border-radius: 12px;
    background: #FFFFFF;
    font: 700 30px var(--police-titre);
    color: var(--texte);
    transition: border-color .2s ease, background .2s ease, color .2s ease, box-shadow .2s ease;
}

.otp-case.remplie { border-color: var(--texte); animation: case-pose .18s ease-out; }

.otp.focus .otp-case.courante {
    border-color: var(--encre);
    box-shadow: 0 0 0 4px rgba(30, 58, 138, .14);
}

.otp.focus .otp-case.courante:empty::after {
    content: '';
    width: 2px;
    height: 30px;
    background: var(--encre);
    animation: curseur 1s steps(1) infinite;
}

.otp.verif .otp-case {
    border-color: var(--encre);
    animation: case-vague .9s ease-in-out infinite;
    animation-delay: calc(var(--i) * 90ms);
}

.otp.ok .otp-case {
    border-color: var(--vert);
    background: #ECFDF3;
    color: var(--vert);
    animation: case-valide .4s ease-out both;
    animation-delay: calc(var(--i) * 70ms);
}

.otp.ko .otp-cases { animation: secoue .45s ease-in-out; }
.otp.ko .otp-case { border-color: var(--erreur); background: #FEF2F2; color: var(--erreur); }

.otp-statut {
    min-height: 24px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--texte-3);
}

.otp-statut.verif { color: var(--encre); }
.otp-statut.ok { color: var(--vert); }
.otp-statut.ko { color: var(--erreur); }

@keyframes case-pose { from { transform: scale(.82); } to { transform: scale(1); } }
@keyframes curseur { 50% { opacity: 0; } }
@keyframes case-vague { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes case-valide { 0% { transform: scale(1); } 50% { transform: scale(1.14); } 100% { transform: scale(1); } }
@keyframes secoue {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-8px); }
    40%, 60% { transform: translateX(8px); }
}

/* --------------------------------------------------------------------------
   Étoiles (avis à la déconnexion)
   -------------------------------------------------------------------------- */

.etoiles { border: 0; margin: 0; padding: 16px; min-width: 0; background: rgba(255, 255, 255, .85); border: 1.5px solid var(--bordure-douce); border-radius: 12px; }
.etoiles.erreur { border-color: var(--erreur); background: #FEF2F2; }
.etoiles legend { padding: 0; margin-bottom: 8px; float: left; width: 100%; }
.etoiles-rangee { clear: both; display: flex; gap: 6px; }
.etoiles-rangee label { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 10px; cursor: pointer; }
.etoiles-rangee svg { fill: transparent; stroke: #8A93A6; transition: fill .15s ease, stroke .15s ease, transform .15s ease; }
.etoiles-rangee label.allumee svg { fill: #F2B01E; stroke: #9A6A08; }
.etoiles-rangee label:hover svg { transform: scale(1.12); }
.etoiles-rangee input:focus-visible + label { outline: 2px solid var(--encre); outline-offset: 2px; }
.etoiles-texte { min-height: 20px; margin: 6px 0 0; font-size: 14px; font-weight: 600; color: var(--texte-2); }
.requis { color: var(--erreur); }

/* --------------------------------------------------------------------------
   Notes volantes (messages)
   -------------------------------------------------------------------------- */

.toast-zone {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(420px, calc(100vw - 40px));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 2px solid var(--texte);
    border-left-width: 8px;
    border-radius: 10px;
    background: #FFFFFF;
    box-shadow: 4px 4px 0 rgba(28, 36, 51, .9);
    font-size: 14px;
    line-height: 1.45;
    color: var(--texte);
    animation: toast-arrive .3s ease-out;
    transition: opacity .3s ease, transform .3s ease;
}

.toast p { margin: 0; flex: 1; }
.toast.erreur { border-left-color: var(--erreur); }
.toast.succes { border-left-color: var(--vert); }
.toast.info { border-left-color: var(--encre); }
.toast.alerte { border-left-color: #D97706; }
.toast.sortie { opacity: 0; transform: translateX(40px); }

.toast-fermer {
    width: 28px; height: 28px; flex: none;
    margin: -4px -6px 0 0;
    border: 0; border-radius: 6px;
    background: transparent;
    color: var(--texte-3);
    cursor: pointer;
    font-size: 20px; line-height: 1;
}

@keyframes toast-arrive { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   Téléphone et petites tablettes
   -------------------------------------------------------------------------- */

@media (max-width: 860px) {
    /* Ardoise en bandeau au-dessus, la feuille prend le reste : pas de partage de la hauteur */
    .cahier-page { flex-direction: column; flex-wrap: nowrap; min-height: 100vh; min-height: 100dvh; }
    .cahier-ardoise,
    .page-large-ardoise .cahier-ardoise {
        flex: none;
        padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
    }
    .cahier-feuille {
        flex: 1 0 auto;
        padding-right: max(20px, env(safe-area-inset-right));
        padding-bottom: calc(40px + env(safe-area-inset-bottom));
    }
    .feuille-contenu { margin: 4px 0 0; }
    /* 16 px minimum : sinon l'iPhone zoome sur le champ à la saisie */
    .saisie input, .saisie select, .zone-texte { font-size: 16px; }
    .feuille-entete { font-size: 13px; }
    .navigation-etapes .btn-principal { flex: 1 1 auto; }

    /* Bannière « Installer l'App » (public/js/pwa-install.js) : en haut, posée sur le bandeau de l'ardoise
       (décoratif) plutôt qu'en bas sur le formulaire, sans réserver de place qui ferait défiler la page */
    body.cahier #educgest-pwa-floating-banner {
        top: max(10px, env(safe-area-inset-top)) !important;
        bottom: auto !important;
        /* Version compacte : elle doit tenir dans la hauteur du bandeau */
        padding: 8px 12px !important;
        gap: 10px !important;
    }
    body.cahier #educgest-pwa-floating-banner img { width: 36px !important; height: 36px !important; }
    body.cahier #educgest-pwa-floating-banner > div:nth-child(2) > div:nth-child(2) { display: none; }

    /* Connexion : tout l'écran tient sans défilement */
    .page-connexion .cahier-ardoise { padding: max(10px, env(safe-area-inset-top)) 10px 0; }
    .page-connexion .ardoise { padding: 14px 18px 12px; gap: 2px; }
    .page-connexion .craie-surtitre { font-size: 19px; }
    .page-connexion .craie-titre { font-size: 27px; }
    .page-connexion .craie-titre br { display: none; }
    .page-connexion .ardoise-rebord { height: 12px; }
    .page-connexion .cahier-feuille { padding-top: 14px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); gap: 10px; }
    .page-connexion .feuille-contenu { margin: auto 0; gap: 14px; }
    .page-connexion .titre { font-size: 28px; }
    .page-connexion .sous-titre-connexion { display: none; }
    .page-connexion .formulaire { gap: 12px; }
    .page-connexion .saisie { min-height: 48px; }
    .page-connexion .saisie input { height: 44px; }
    .page-connexion .btn-principal { min-height: 50px; }
    .page-connexion .onglet { min-height: 40px; padding: 0 12px; font-size: 13px; }
    .page-connexion .texte-pied { font-size: 14px; }
    .page-connexion .coupon { padding: 8px 12px; gap: 10px; }
    .page-connexion .coupon-icone { width: 32px; height: 32px; }
    .page-connexion .coupon-texte span { display: none; }
    .page-connexion .coupon-texte strong { font-size: 14px; }
    .ardoise { padding: 24px 22px 20px; gap: 12px; }
    .ardoise-optionnel { display: none !important; }
    .craie-titre { font-size: 36px; }
    .craie-surtitre { font-size: 24px; }
    .ardoise-rebord { height: 16px; }

    .cahier-feuille { --marge: 28px; padding-top: 24px; padding-left: max(48px, calc(env(safe-area-inset-left) + 36px)); gap: 22px; }
    .titre { font-size: 32px; }
    .grille-2 { grid-template-columns: minmax(0, 1fr); }
    .tampon { display: none; }
    .otp.js .otp-cases { gap: 6px; }
    .otp-case { height: 54px; font-size: 24px; }
    .toast-zone { left: 12px; right: 12px; top: max(12px, env(safe-area-inset-top)); max-width: none; }
}

/* Petits téléphones (environ 640 px visibles) : connexion encore plus compacte */
@media (max-width: 860px) and (max-height: 680px) {
    .page-connexion .craie-surtitre { display: none; }
    .page-connexion .craie-titre { font-size: 23px; }
    .page-connexion .ardoise { padding: 10px 16px; }
    .page-connexion .cahier-feuille { padding-top: 10px; }
    .page-connexion .feuille-contenu { gap: 10px; }
    .page-connexion .titre { font-size: 24px; }
    .page-connexion .formulaire { gap: 8px; }
    .page-connexion .saisie input { height: 40px; }
    .page-connexion .saisie { min-height: 44px; }
    .page-connexion .btn-principal { min-height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
