:root {
  --rojo: #D72638;
  --rojo-osc: #AB1B2A;
  --naranja: #EF7B2A;
  --amarillo: #F7B32B;
  --azul: #1F6F8B;
  --azul-osc: #14536A;
  --fondo: #FFF5F1;
  --card: #FFFFFF;
  --ink: #2A1B20;
  --ink-soft: #7A6168;
  --linea: #F2DCD4;
  --ok: #1B7F4B;
  --ok-bg: #E2F4EA;
  --ko: #C22B33;
  --ko-bg: #FCE7E7;
  --radius: 18px;
  --shadow: 0 2px 12px rgba(42, 27, 32, .08);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* les règles d'affichage ci-dessous (display:block sur .btn, flex sur .btn-row...)
   l'emportent sinon sur le [hidden] du navigateur : les boutons masqués resteraient visibles */
[hidden] { display: none !important; }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--fondo);
  color: var(--ink);
  min-height: 100dvh;
  padding-bottom: calc(74px + env(safe-area-inset-bottom));
}

/* ---------- barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--fondo);
  border-bottom: 1px solid var(--linea);
}
.brand { font-size: 1.25rem; font-weight: 800; letter-spacing: -.02em; color: var(--rojo); }
.brand span { color: var(--azul); }
.topstats { display: flex; gap: 8px; }
.stat {
  background: var(--card); border: 1px solid var(--linea); border-radius: 999px;
  padding: 4px 12px; font-size: .8rem; font-weight: 700; color: var(--ink-soft);
}
.stat strong { color: var(--rojo); }

/* ---------- écran ---------- */
.screen { padding: 16px; max-width: 580px; margin: 0 auto; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px;
}
.card h2 { font-size: 1.08rem; margin-bottom: 8px; }
.muted { color: var(--ink-soft); font-size: .88rem; line-height: 1.5; }
.small { font-size: .8rem; }
.center { text-align: center; }

.kicker {
  display: inline-block; font-size: .72rem; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--azul); margin-bottom: 6px;
}
.kicker.rojo { color: var(--rojo); }
.kicker.naranja { color: var(--naranja); }

/* ---------- boutons ---------- */
.btn {
  display: block; width: 100%; border: none; border-radius: 14px;
  padding: 15px 18px; font-size: 1rem; font-weight: 700; cursor: pointer;
  font-family: inherit; text-align: center; transition: transform .05s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--rojo); color: #fff; }
.btn-azul { background: var(--azul); color: #fff; }
.btn-soft { background: var(--fondo); color: var(--ink); border: 1px solid var(--linea); }
.btn + .btn { margin-top: 10px; }
.btn[disabled] { opacity: .45; cursor: default; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; margin-top: 0; }
.link-btn { background: none; border: none; color: var(--azul); font-weight: 700; font-family: inherit; font-size: .9rem; cursor: pointer; padding: 0; }
.link-btn.danger { color: var(--ko); }

/* ---------- héros (accueil) ---------- */
.hero {
  background: linear-gradient(135deg, var(--rojo), var(--rojo-osc));
  color: #fff; border-radius: var(--radius); padding: 22px 18px; margin-bottom: 14px;
}
.hero .kicker { color: #FFD9B0; }
.hero h1 { font-size: 1.45rem; line-height: 1.25; margin-bottom: 6px; }
.hero p { opacity: .93; font-size: .9rem; margin-bottom: 14px; line-height: 1.5; }
.hero .btn { background: #fff; color: var(--rojo-osc); }
.hero.fait { background: linear-gradient(135deg, var(--azul), var(--azul-osc)); }
.hero.fait .btn { color: var(--azul-osc); }
.hero .btn-ghost { background: transparent; color: #fff; border: 2px solid rgba(255,255,255,.6); }

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.pill {
  background: rgba(255,255,255,.18); border-radius: 999px; padding: 4px 12px;
  font-size: .78rem; font-weight: 700;
}

/* ---------- carte d'unité ---------- */
.unidad { position: relative; border-left: 6px solid var(--amarillo); }
.unidad.ouverte { border-left-color: var(--rojo); }
.unidad-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.unidad-num {
  flex: none; width: 38px; height: 38px; border-radius: 12px; background: var(--rojo);
  color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
}
.unidad.bloquee .unidad-num { background: var(--linea); color: var(--ink-soft); }
.unidad h2 { margin-bottom: 2px; }
.unidad .sub { font-size: .84rem; color: var(--ink-soft); }
.tag {
  font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  border-radius: 999px; padding: 3px 9px; white-space: nowrap;
}
.tag.venir { background: var(--fondo); color: var(--ink-soft); border: 1px solid var(--linea); }
.tag.encours { background: var(--ok-bg); color: var(--ok); }
.tag.note { background: #FFF0DC; color: #A0530F; }
.unidad.bloquee { opacity: .62; }
.unidad.bloquee h2, .unidad.bloquee .sub { color: var(--ink-soft); }
.temas { margin-top: 12px; padding-left: 18px; }
.temas li { font-size: .84rem; color: var(--ink-soft); line-height: 1.6; }

.lecon-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: none; border: none; border-top: 1px solid var(--linea);
  padding: 13px 0 12px; font-family: inherit; cursor: pointer; color: inherit;
}
.lecon-row .num {
  flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--fondo);
  border: 1px solid var(--linea); color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 800;
}
.lecon-row.faite .num { background: var(--ok-bg); border-color: var(--ok-bg); color: var(--ok); }
.lecon-row.suivante .num { background: var(--rojo); border-color: var(--rojo); color: #fff; }
.lecon-row .txt { flex: 1; }
.lecon-row .t { display: block; font-weight: 700; font-size: .95rem; }
.lecon-row .d { display: block; font-size: .78rem; color: var(--ink-soft); margin-top: 2px; line-height: 1.35; }
.lecon-row .go { color: var(--ink-soft); font-size: 1.2rem; line-height: 1; }

/* test de fin d'unité : une marche à part, pas une leçon de plus */
.lecon-row.test { border-top: 2px dashed var(--amarillo); margin-top: 4px; }
.lecon-row.test .num { background: var(--naranja); border-color: var(--naranja); color: #fff; }
.lecon-row.test .t { color: var(--naranja); text-transform: uppercase; letter-spacing: .03em; font-size: .86rem; }
.lecon-row.test.verrouille { cursor: default; opacity: .55; }
.lecon-row.test.verrouille .num { background: var(--fondo); border-color: var(--linea); color: var(--ink-soft); }
.lecon-row.test.verrouille .t { color: var(--ink-soft); }

/* ---------- leçon ---------- */
.progressbar { height: 6px; background: var(--linea); border-radius: 3px; margin-bottom: 16px; overflow: hidden; }
.progressbar i { display: block; height: 100%; background: var(--rojo); border-radius: 3px; transition: width .3s; }
.counter { text-align: center; font-size: .8rem; color: var(--ink-soft); font-weight: 700; margin-bottom: 10px; }

.palabra { border-top: 1px solid var(--linea); padding: 14px 0; }
.palabra:first-child { border-top: none; padding-top: 2px; }
.palabra .es { font-size: 1.35rem; font-weight: 800; color: var(--rojo); line-height: 1.25; }
.palabra .fr { font-size: .98rem; font-weight: 600; margin-top: 2px; }
.palabra .pron {
  margin-top: 7px; font-size: .8rem; color: var(--azul-osc); background: #EAF4F8;
  border-radius: 9px; padding: 6px 10px; line-height: 1.45; display: block; width: fit-content;
}
.palabra .ex {
  margin-top: 9px; background: var(--fondo); border-radius: 10px; padding: 9px 12px;
  font-size: .86rem; line-height: 1.5;
}
.palabra .ex b { color: var(--rojo-osc); }
.speak {
  margin-top: 8px; background: none; border: 1px solid var(--linea); border-radius: 999px;
  padding: 5px 13px; font-size: .76rem; color: var(--ink-soft); cursor: pointer;
  font-family: inherit; display: inline-block;
}

/* dialogue */
.bubble { display: flex; margin-bottom: 10px; }
.bubble .msg { max-width: 86%; border-radius: 16px; padding: 10px 14px; font-size: .95rem; line-height: 1.4; }
.bubble.a .msg { background: var(--fondo); border: 1px solid var(--linea); border-bottom-left-radius: 5px; }
.bubble.b { justify-content: flex-end; }
.bubble.b .msg { background: var(--azul); color: #fff; border-bottom-right-radius: 5px; }
.bubble .who { display: block; font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; opacity: .65; margin-bottom: 2px; }
.bubble .fr { display: block; font-size: .79rem; opacity: .78; margin-top: 3px; }

/* grammaire */
.grama { border-top: 4px solid var(--amarillo); }
.grama .regle { font-size: .92rem; line-height: 1.55; margin-top: 4px; }
.grama table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: .9rem; }
.grama td { padding: 8px 4px; border-bottom: 1px solid var(--linea); vertical-align: top; }
.grama td:first-child { font-weight: 700; color: var(--rojo); white-space: nowrap; padding-right: 12px; }
.grama td:last-child { color: var(--ink-soft); }
.grama .note {
  margin-top: 12px; background: #FFF7E6; border: 1px solid #F6E0B0; border-radius: 10px;
  padding: 10px 12px; font-size: .85rem; line-height: 1.5;
}

/* quiz */
.quiz-q { font-size: 1.12rem; font-weight: 700; margin: 4px 0 16px; line-height: 1.4; }
.opt {
  display: block; width: 100%; text-align: left; background: var(--card);
  border: 2px solid var(--linea); border-radius: 12px; padding: 13px 15px;
  font-size: .98rem; font-weight: 600; font-family: inherit; cursor: pointer; margin-bottom: 10px;
  color: inherit;
}
.opt.correct { border-color: var(--ok); background: var(--ok-bg); }
.opt.faux { border-color: var(--ko); background: var(--ko-bg); }
.opt[disabled] { cursor: default; }
.trou-ligne { font-size: 1.05rem; line-height: 2.1; font-weight: 600; }
.trou-ligne input {
  border: none; border-bottom: 2px solid var(--rojo); background: #FFF7F4;
  font-family: inherit; font-size: 1rem; font-weight: 700; color: var(--rojo-osc);
  padding: 5px 8px; width: 9.5rem; border-radius: 6px 6px 0 0; text-align: center;
}
.trou-ligne input:focus { outline: 2px solid var(--amarillo); outline-offset: 1px; }
.aide { font-size: .82rem; color: var(--ink-soft); margin-top: 10px; }
.feedback { font-weight: 700; margin: 10px 0 12px; line-height: 1.5; }
.feedback.ok { color: var(--ok); }
.feedback.ko { color: var(--ko); }
.feedback:empty { display: none; }

/* fin de leçon */
.splash { text-align: center; padding: 38px 18px; }
.splash .big { font-size: 2.1rem; font-weight: 800; color: var(--rojo); animation: pop .4s ease; }
.splash .sub { color: var(--ink-soft); margin: 10px 0 20px; line-height: 1.5; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.reward-row { display: flex; justify-content: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.reward {
  background: var(--fondo); border: 1px solid var(--linea); border-radius: 12px;
  padding: 10px 16px; font-weight: 800; color: var(--azul-osc); font-size: .92rem;
}

/* bulletin de test */
.test-intro { border-top: 4px solid var(--naranja); }
.bulletin .note { font-size: 3.2rem; font-weight: 800; line-height: 1; animation: pop .4s ease; }
.bulletin .note span { font-size: 1.3rem; font-weight: 700; color: var(--ink-soft); }
.bulletin .note.ok { color: var(--ok); }
.bulletin .note.ko { color: var(--ko); }
.bulletin .mencion {
  margin-top: 10px; font-size: 1.05rem; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink);
}
.bulletin .sub { margin-top: 8px; }

/* ---------- révision ---------- */
.flash {
  text-align: center; padding: 34px 18px; min-height: 215px;
  display: flex; flex-direction: column; justify-content: center;
}
.flash .prompt-label {
  font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 10px;
}
.flash .prompt { font-size: 1.55rem; font-weight: 800; line-height: 1.3; }
.flash .reponse { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--linea); }
.flash .reponse .es { font-size: 1.5rem; font-weight: 800; color: var(--rojo); }
.flash .reponse .pron { font-size: .82rem; color: var(--azul-osc); margin-top: 6px; }

/* ---------- mots ---------- */
.search {
  width: 100%; border: 1px solid var(--linea); border-radius: 12px; padding: 12px 14px;
  font-size: 1rem; font-family: inherit; background: var(--card); margin-bottom: 14px;
}
details.bloc { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; }
details.bloc summary {
  list-style: none; cursor: pointer; padding: 15px 18px; font-weight: 700;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
details.bloc summary::-webkit-details-marker { display: none; }
details.bloc summary .count { font-size: .78rem; color: var(--ink-soft); font-weight: 600; }
details.bloc .body { padding: 0 18px 14px; }
.mot { padding: 10px 0; border-bottom: 1px solid var(--linea); }
.mot:last-child { border-bottom: none; }
.mot .row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.mot .es { font-weight: 800; color: var(--rojo); }
.mot .fr { color: var(--ink-soft); font-size: .88rem; text-align: right; }
.mot .pron { font-size: .78rem; color: var(--azul-osc); margin-top: 3px; }
.caja { font-size: .66rem; font-weight: 800; color: var(--azul); background: #EAF4F8; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }

/* ---------- progrès ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.stat-grid .card { margin-bottom: 0; text-align: center; padding: 16px 10px; }
.stat-grid .lbl { font-size: .74rem; color: var(--ink-soft); font-weight: 700; margin-top: 2px; }
.big-num { font-size: 2rem; font-weight: 800; color: var(--rojo); }

.goal { margin-bottom: 14px; }
.goal:last-child { margin-bottom: 0; }
.goal .goal-head { display: flex; justify-content: space-between; font-size: .85rem; font-weight: 700; margin-bottom: 5px; gap: 10px; }
.goal .goal-head span:last-child { color: var(--ink-soft); font-weight: 600; white-space: nowrap; }
.goal .bar { height: 8px; background: var(--linea); border-radius: 4px; overflow: hidden; }
.goal .bar i { display: block; height: 100%; border-radius: 4px; background: var(--rojo); transition: width .3s; }
.goal.venir .bar i { background: var(--linea); }

.setting-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--linea); gap: 10px; }
.setting-row:last-child { border-bottom: none; }
.setting-row label { font-weight: 600; font-size: .92rem; }

/* ---------- connexion & compte ---------- */
/* en mode connexion, rien de l'appli ne doit être atteignable */
.login-mode .tabbar, .login-mode .topstats { display: none; }

.fld { display: block; font-weight: 700; font-size: .82rem; margin-bottom: 12px; color: var(--ink-soft); }
.fld input {
  display: block; width: 100%; margin-top: 5px; border: 1px solid var(--linea);
  border-radius: 12px; padding: 12px 14px; font-size: 1rem; font-family: inherit;
  background: var(--card); color: var(--ink);
}
.fld input:focus { outline: 2px solid var(--amarillo); outline-offset: 1px; }

.banner {
  background: #FFF7E6; border: 1px solid #F6E0B0; border-radius: 12px;
  padding: 12px 14px; font-size: .86rem; line-height: 1.5; margin-bottom: 12px;
}

/* ---------- tableau d'administration ---------- */
/* les 4 indicateurs passent sur 2 colonnes au téléphone */
@media (min-width: 560px) { .admin-kpi { grid-template-columns: repeat(4, 1fr); } }
.table-wrap { overflow-x: auto; }
table.users { border-collapse: collapse; width: 100%; font-size: .82rem; min-width: 900px; }
table.users th, table.users td { padding: 9px 10px; border-bottom: 1px solid var(--linea); text-align: left; white-space: nowrap; vertical-align: top; }
table.users th { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
tr.row-off td { opacity: .55; }
.badge-role { background: var(--azul); color: #fff; border-radius: 999px; padding: 2px 8px; font-size: .68rem; font-weight: 700; }
.badge-off { background: var(--ko-bg); color: var(--ko); border-radius: 999px; padding: 2px 8px; font-size: .68rem; font-weight: 700; }
.mini-bar { width: 80px; height: 6px; background: var(--linea); border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; }
.mini-bar i { display: block; height: 100%; background: var(--rojo); }
.link-btn.mr { margin-right: 12px; }
.history-box { background: var(--fondo); border-radius: 10px; padding: 10px 12px; line-height: 1.6; white-space: normal; }

/* ---------- barre d'onglets ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: var(--card); border-top: 1px solid var(--linea);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: none; padding: 9px 4px 7px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-family: inherit; font-size: .68rem; font-weight: 700; color: var(--ink-soft);
  position: relative;
}
.tab svg { width: 22px; height: 22px; fill: currentColor; }
.tab.active { color: var(--rojo); }
.tab .badge {
  position: absolute; top: 4px; right: calc(50% - 22px);
  background: var(--rojo); color: #fff; font-style: normal; font-size: .62rem;
  font-weight: 800; border-radius: 999px; padding: 1px 6px;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: calc(86px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: .85rem; font-weight: 600;
  z-index: 50; max-width: 90vw; text-align: center;
}

@media (min-width: 600px) {
  .screen { padding: 22px 16px; }
  .hero h1 { font-size: 1.65rem; }
}
