/* Xiaomo — parcours : mise en page propre à l'appli (les composants viennent de design/). */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); }
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }
p { margin: 0; }

/* ---------- accueil, collection, parent */
.a-page { display: grid; gap: var(--s-5); padding: var(--s-4) var(--gutter) var(--s-10); }
.a-tete { display: flex; align-items: center; gap: var(--s-3); }
.a-dragon { width: 64px; height: 64px; flex: none; }
.a-nom { font-size: var(--fs-28); }
.a-bienvenue, .a-h1 { font-size: var(--fs-28); }
.a-barre { margin: 0 calc(-1 * var(--s-3)); }
.a-semaine { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: var(--s-2); }
.a-sem { font-size: var(--fs-13); font-weight: 600; color: var(--ink-2); }
.a-noeuds { display: flex; justify-content: space-between; gap: 4px; }
.a-noeuds > span { display: grid; }
.a-noeuds .x-node { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-14); font-weight: 600; background: var(--surface); border: 2px solid var(--line-2); color: var(--ink-3); }
.a-noeuds .is-done .x-node { background: var(--seal); border-color: var(--seal); color: var(--on-seal); }
.a-noeuds .is-now .x-node { border-color: var(--ink); color: var(--ink); box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.a-coll { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-3); }
.a-coll li { display: grid; grid-template-columns: auto 1fr; gap: var(--s-3); align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: var(--s-3) var(--s-4); }
.a-coll b { font-weight: 600; display: block; }
.a-mini { width: 36px; height: 36px; font-size: 18px; border-radius: 8px; }
.p-obj { display: grid; grid-template-columns: 1fr 1.4fr; gap: var(--s-3); }
.p-calc, .p-liste { margin: 0; padding-left: 1.1em; display: grid; gap: 6px; }
.p-jauge { display: grid; gap: 6px; }

/* ---------- séance */
.s-ecran { display: grid; grid-template-rows: auto 1fr; min-height: 100dvh; }
.s-tete { display: grid; grid-template-columns: var(--tap) 1fr var(--tap); align-items: center; padding: var(--s-2) var(--s-2) 0; position: sticky; top: 0; background: var(--paper); z-index: 5; }
.s-points { display: flex; gap: 6px; justify-content: center; }
.s-points i { width: 22px; height: 6px; border-radius: 3px; background: var(--line-2); }
.s-points i.is-done { background: var(--seal); }
.s-points i.is-now { background: var(--ink); width: 34px; }
.s-corps { display: grid; align-content: start; gap: var(--s-3); padding: var(--s-3) var(--gutter) var(--s-10); }
.s-but { font-family: var(--font-display); font-size: var(--fs-22); line-height: 1.2; text-wrap: balance; }
#bloc { display: grid; gap: var(--s-4); margin-top: var(--s-2); }
.s-titre .x-display { font-size: var(--fs-28); margin-top: 4px; }
.s-titre { display: grid; gap: 6px; }
.s-visite { margin: 0; padding-left: 1.3em; display: grid; gap: 10px; line-height: 1.4; }
.s-lecon { display: grid; gap: var(--s-3); justify-items: start; }
.s-texte { font-size: var(--fs-18); line-height: 1.5; }
.s-regle { border-left: 4px solid var(--seal); }
.s-general { background: var(--seal-soft); border-color: transparent; }
.s-pas { display: flex; gap: 6px; justify-content: center; }
.s-pas i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.s-pas i.is-on { background: var(--ink); }
.s-barre { margin-bottom: var(--s-2); }
.s-fin { display: grid; gap: var(--s-4); justify-items: center; text-align: center; padding: var(--s-6) 0; }
.s-sceau { width: 88px; height: 88px; font-size: 44px; border-radius: 16px; }
.s-sait { font-size: var(--fs-28); }
.s-enreg { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: var(--s-2) var(--s-3); }
.s-ok { color: var(--seal); font-weight: 700; min-width: 1em; }

/* ---------- questions */
.q-zone { display: grid; gap: var(--s-4); }
.q-consigne { font-size: var(--fs-18); font-weight: 500; line-height: 1.4; }
.q-son { justify-self: start; }
.q-grand { font-size: 44px; text-align: center; font-weight: 500; letter-spacing: .02em; line-height: 1.2; }
.q-moyen { font-size: var(--fs-22); font-weight: 500; }
.q-petit { font-size: var(--fs-14); color: var(--ink-2); font-weight: 500; }
.q-py { font-size: var(--fs-22); }
.q-tton { flex-direction: column; gap: 2px; min-height: 84px; }
.q-tton span { font-size: var(--fs-14); }
.q-tton b { font-size: var(--fs-16); }
.q-retour { display: grid; gap: var(--s-3); min-height: 28px; }
.q-ok { color: var(--seal); font-weight: 700; }
.q-ko { color: var(--ink-2); font-weight: 600; }
.q-dessin { position: relative; height: 200px; border: 1.5px solid var(--line-2); border-radius: var(--r-l); background: var(--surface) repeating-linear-gradient(to bottom, transparent 0 39px, var(--line) 39px 40px); touch-action: none; }
.q-dessin svg { position: absolute; inset: 0; }
.q-haut, .q-bas { position: absolute; left: 8px; font-size: var(--fs-12); color: var(--ink-3); }
.q-haut { top: 6px; } .q-bas { bottom: 6px; }
.q-courbes { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.q-courbes > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: var(--s-2); min-height: 110px; }
.q-signes { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); }
.q-signe { font-size: 34px; min-height: 64px; }
.q-lettres, .q-choix { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: center; }
.q-lettre { appearance: none; font: inherit; font-size: var(--fs-22); min-width: 48px; min-height: 48px; padding: 0 10px; border-radius: var(--r-m); border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer; }
.q-lettre.is-on { border-color: var(--seal); background: var(--seal-soft); color: var(--seal); }
.q-lettre:disabled { opacity: .6; }
.q-choix .q-lettre { font-size: var(--fs-18); min-width: 44px; min-height: 44px; }
.q-phrase { font-size: var(--fs-22); text-align: center; line-height: 1.8; }
.q-sy.is-cible { color: var(--seal); font-weight: 700; border-bottom: 3px solid var(--seal); }
.q-frappe { min-height: 60px; }
.q-trace-tete { display: flex; align-items: baseline; gap: var(--s-3); justify-content: center; }
.q-ecoute { align-self: center; background: none; border: 0; padding: 4px; color: var(--ink); opacity: .7; cursor: pointer; line-height: 0; }
.q-ecoute:active { opacity: 1; color: var(--seal); }
.q-regle-trace { background: var(--surface); border-left: 4px solid var(--seal); padding: var(--s-2) var(--s-3); border-radius: 0 var(--r-s) var(--r-s) 0; }
.x-trace { display: grid; place-items: center; }
.x-trace svg { position: relative; z-index: 1; }
@media (max-width: 380px) { .q-grand { font-size: 36px; } .q-tton { min-height: 76px; } }
.s-puces { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.s-puce { appearance: none; font: inherit; cursor: pointer; display: grid; justify-items: center; gap: 2px; padding: var(--s-2) var(--s-3); min-width: 84px; border-radius: var(--r-m); border: 1.5px solid var(--line-2); background: var(--paper); color: var(--ink); transition: border-color var(--d-quick), background var(--d-quick); }
.s-puce.is-on { border-color: var(--seal); background: var(--seal-soft); color: var(--seal); }
.s-py { font-size: var(--fs-28); font-weight: 500; line-height: 1.1; }
.s-puce .x-muted { font-size: var(--fs-12); }
.s-puce--fixe { cursor: default; }
.q-dessin { user-select: none; -webkit-user-select: none; }
/* ---------- niveaux HSK : mots, phrases, ordre */
.h-mot { display: inline-grid; justify-items: center; gap: 2px; }
.h-mot .h-zh { font-family: var(--font-zh); font-size: var(--fs-28); line-height: 1.1; }
.h-mot--grand .h-zh { font-size: 52px; }
.h-mot .h-py { color: var(--ink-2); font-size: var(--fs-14); transition: opacity var(--d-quick); }
.h-mot .h-sens { font-family: var(--font-display); font-size: var(--fs-16); }
.h-mot.is-cache .h-py { opacity: 0; }
.h-mot.is-cache { cursor: pointer; }
.q-centre { display: grid; justify-items: center; }
.q-fr { font-family: var(--font-display); }
.q-zh { font-family: var(--font-zh); font-size: var(--fs-22); }
.q-bulle { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: var(--s-3) var(--s-4); }
.q-modele { display: grid; gap: 2px; text-align: center; }
.q-ordre-cible { min-height: 64px; display: flex; flex-wrap: wrap; gap: var(--s-2); padding: var(--s-2); border-bottom: 2px solid var(--line-2); }
.q-ordre-src { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: center; }
.q-tuile { appearance: none; font: inherit; font-family: var(--font-zh); font-size: var(--fs-22); min-height: 48px; padding: 0 12px; border-radius: var(--r-m); border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer; }
.q-tuile.is-on { border-color: var(--seal); background: var(--seal-soft); color: var(--seal); }
.q-tuile:disabled { opacity: .35; }
.s-mots { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s-3); }
.s-motcarte { appearance: none; font: inherit; cursor: pointer; display: grid; justify-items: center; gap: 4px; padding: var(--s-4) var(--s-3); border-radius: var(--r-l); border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink); transition: border-color var(--d-quick), background var(--d-quick); }
.s-motcarte.is-on { border-color: var(--seal); background: var(--seal-soft); }
.s-motcarte .h-zh { font-family: var(--font-zh); font-size: var(--fs-36); line-height: 1.1; }
.s-motcarte .h-py { color: var(--ink-2); }
.s-motcarte .h-sens { font-family: var(--font-display); font-size: var(--fs-16); text-align: center; }
.s-exemple { display: grid; gap: 4px; }
.s-exemple .q-zh { font-size: var(--fs-28); }
.s-exemple .q-petit { font-size: var(--fs-14); }
.q-horloge { font-family: var(--font-display); font-size: var(--fs-28); font-variant-numeric: tabular-nums; }
.q-picto { width: 100%; max-width: 160px; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-m); display: block; margin: 0 auto; }
.q-opts--img { grid-template-columns: repeat(3, 1fr); }
.q-opts--img .x-tile { padding: 6px; min-height: 0; }
.q-opts--img .q-picto { max-width: none; }
.q-trou { color: var(--seal); border-bottom: 2px solid var(--seal); }
.s-chrono { text-align: right; font-variant-numeric: tabular-nums; font-size: var(--fs-16); }
.p-blocs { display: grid; gap: 4px; }
#sauv-code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; }

.a-credit { font-size: var(--fs-12); margin: var(--s-4) 0 0; opacity: .8; }

/* Tracé : le doigt dessine, il ne fait ni défiler ni recharger la page (Hanzi Writer le bloque déjà ; ceinture et bretelles) */
.x-trace, .g-porte-kai { touch-action: none; }

/* Bandeau ordinateur : Xiaomo se trace au doigt ; sur un écran à souris, une ligne le dit, fermable, on continue quand même */
.b-ordi { display: flex; align-items: flex-start; gap: var(--s-3); max-width: 640px; margin: var(--s-3) auto 0; padding: var(--s-2) var(--s-3); background: var(--surface); border: 1px solid var(--line-2); border-left: 4px solid var(--seal); border-radius: 0 var(--r-m) var(--r-m) 0; color: var(--ink-2); font-size: var(--fs-14); line-height: 1.45; }
.b-ordi p { margin: 0; flex: 1; }
.b-ordi button { appearance: none; border: 0; background: none; color: var(--ink-2); font: inherit; font-size: 20px; line-height: 1; padding: 0 2px; cursor: pointer; }
.b-ordi button:hover { color: var(--ink); }
/* niveau 4 : remettre les phrases dans le texte, le texte de 80 caractères */
.q-ins-texte { line-height: 2.2; }
.q-ins-trou { appearance: none; font: inherit; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; min-width: 64px; margin: 2px 4px; padding: 2px 10px; border: 1.5px dashed var(--line-2); border-radius: var(--r-m); background: var(--surface-2); color: var(--ink); vertical-align: middle; }
.q-ins-trou.is-actif { border-color: var(--seal); border-style: solid; }
.q-ins-trou.is-plein { border-style: solid; background: var(--surface); }
.q-ins-trou.is-juste { border-color: var(--jade); }
.q-ins-trou.is-faux { border-color: var(--seal); color: var(--seal); }
.q-ins-num { font-family: var(--font-ui, inherit); font-size: .8em; color: var(--seal); }
.q-ins-phrase { font-size: var(--fs-18, 18px); text-align: left; justify-content: flex-start; gap: 10px; width: 100%; padding: 8px 12px; }
.q-ins-lettre { font-family: var(--font-ui, inherit); font-size: .75em; color: var(--ink-3, var(--muted)); }
.q-t80-plan { margin: 4px 0 0; padding-left: 1.4em; }
.q-t80-texte .q-zh { min-height: 2.4em; line-height: 1.9; }
.q-t80-compte { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--ink-3, var(--muted)); font-variant-numeric: tabular-nums; }
.q-t80-barre { flex: 1; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.q-t80-barre i { display: block; height: 100%; background: var(--seal); }
.q-t80-libre { width: 100%; box-sizing: border-box; font-family: var(--font-zh); font-size: var(--fs-22, 22px); line-height: 1.7; padding: 10px 12px; border: 1.5px solid var(--line-2); border-radius: var(--r-m); background: var(--surface); color: var(--ink); }
.q-ins-src { margin: var(--s-2) 0 var(--s-3); }
.q-ins-lettre { min-width: 1em; }
