/* ============ Thème ============ */
:root {
  --bg: #f6f8f4;
  --surface: #ffffff;
  --surface-2: #ecf1ea;
  --text: #2b2733;
  --muted: #6f6a78;
  --border: #dde5da;
  --primary: #0f8a64;
  --primary-dark: #0b6b4d;
  --primary-soft: #e0f3ea;
  --sun: #d62612;
  --ok: #2f9e5b;
  --ok-dark: #227a45;
  --ok-bg: #e3f6ea;
  --ko: #d64545;
  --ko-dark: #a83232;
  --ko-bg: #fde8e8;
  --shadow: 0 2px 0 rgba(0, 0, 0, .06), 0 6px 18px rgba(60, 40, 20, .06);
  --radius: 18px;
  --tabbar-h: 64px;
  --warn-text: #a83232;
  --banner-bg: #fff4d6;
  --banner-text: #7a5300;
  color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #151b1f;
    --surface: #1e262b;
    --surface-2: #273137;
    --text: #eef3f0;
    --muted: #9fb0aa;
    --border: #34413f;
    --primary: #3cc492;
    --primary-dark: #0f8a64;
    --primary-soft: #1b3a30;
    --ok: #46c17a;
    --ok-dark: #2f9e5b;
    --ok-bg: #1f3a2a;
    --ko: #ef6b6b;
    --ko-dark: #c94c4c;
    --ko-bg: #42232a;
    --shadow: 0 2px 0 rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    --warn-text: #ef6b6b;
    --banner-bg: #3d3218;
    --banner-text: #ffd98a;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151b1f;
    --surface: #1e262b;
    --surface-2: #273137;
    --text: #eef3f0;
    --muted: #9fb0aa;
    --border: #34413f;
    --primary: #3cc492;
    --primary-dark: #0f8a64;
    --primary-soft: #1b3a30;
    --ok: #46c17a;
    --ok-dark: #2f9e5b;
    --ok-bg: #1f3a2a;
    --ko: #ef6b6b;
    --ko-dark: #c94c4c;
    --ko-bg: #42232a;
    --shadow: 0 2px 0 rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    --warn-text: #ef6b6b;
    --banner-bg: #3d3218;
    --banner-text: #ffd98a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.block { display: block; }
.center { text-align: center; }
.row-center { display: flex; gap: 12px; align-items: center; justify-content: center; }

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; }

.screen {
  padding: 20px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
body[data-view="onboarding"] .screen,
body[data-view="result"] .screen { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* ============ Boutons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px;
  border-radius: 14px; border: 2px solid transparent;
  font-weight: 800; font-size: 1rem; letter-spacing: .01em;
  transition: transform .08s ease, background-color .15s ease, opacity .15s;
  user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-dark); }
.btn-primary:active:not(:disabled) { box-shadow: 0 2px 0 var(--primary-dark); }
.btn-primary:disabled { background: var(--border); color: var(--muted); box-shadow: none; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ok { background: var(--ok); color: #fff; box-shadow: 0 4px 0 var(--ok-dark); }
.btn-ko { background: var(--ko); color: #fff; box-shadow: 0 4px 0 var(--ko-dark); }
.btn-danger { background: var(--ko); color: #fff; box-shadow: 0 4px 0 var(--ko-dark); }
.btn-danger-ghost { background: transparent; border-color: var(--ko); color: var(--ko); }
.btn-col { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

.icon-btn {
  width: 44px; height: 44px; flex: none;
  border-radius: 12px; border: none; background: transparent;
  font-size: 1.3rem; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); }

.speak {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--surface); color: var(--primary);
  vertical-align: middle; font-size: 1.1rem;
  transition: transform .1s, background-color .15s;
}
.speak:active { transform: scale(.94); }
.speak-big { width: 72px; height: 72px; background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-dark); }
.speak-big svg { width: 34px; height: 34px; }
.speak.is-speaking { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124, 92, 196, .45); }
  50% { box-shadow: 0 0 0 10px rgba(124, 92, 196, 0); }
}

/* ============ Champs ============ */
.text-input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 2px solid var(--border); border-radius: 14px;
  background: var(--surface); font-size: 1rem;
}
.text-input:focus { border-color: var(--primary); outline: none; }
select.text-input { appearance: auto; }
.field-label { display: block; font-weight: 800; margin: 14px 0 8px; }
input[type="range"] { width: 100%; accent-color: var(--primary); margin: 4px 0 12px; }
.switch { display: flex; align-items: center; gap: 12px; margin-top: 16px; font-weight: 600; }
.switch input { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }

/* ============ Cartes ============ */
.card {
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card-title { font-size: 1.1rem; font-weight: 900; margin-bottom: 4px; }
.card p + p { margin-top: 10px; }
.page-head h1 { font-size: 1.75rem; font-weight: 900; }

/* ============ Onboarding ============ */
.onboarding { min-height: 100vh; min-height: 100dvh; justify-content: space-between; }
.ob-body { display: flex; flex-direction: column; gap: 14px; padding-top: 4vh; }
.ob-hero { font-size: 4.5rem; text-align: center; line-height: 1; animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
.ob-title { font-size: 2rem; font-weight: 900; text-align: center; color: var(--primary); }
.ob-oc-sub { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; color: var(--muted); }
.ob-text { text-align: center; font-size: 1.05rem; }
.ob-small { font-size: .875rem; color: var(--muted); text-align: center; }
.ob-warning {
  background: var(--ko-bg); color: var(--warn-text); border-radius: 12px; padding: 12px 14px; font-weight: 600;
}
.ob-list { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 10px; }
.ob-list li {
  display: flex; gap: 12px; align-items: center;
  background: var(--surface); border: 2px solid var(--border); border-radius: 14px; padding: 12px 14px; font-weight: 700;
}
.ob-list li span { font-size: 1.3rem; }
.ob-demo {
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center; display: flex; flex-direction: column; gap: 10px;
}
.ob-demo-oc { font-size: 1.5rem; font-weight: 900; }
.ob-demo-fr { color: var(--muted); }
.ob-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.ob-nav > :last-child { justify-self: end; }
.ob-nav > :first-child { justify-self: start; }
.dots { display: flex; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); transition: width .2s; }
.dot.active { width: 22px; border-radius: 4px; background: var(--primary); }

.goal-grid { display: flex; flex-direction: column; gap: 10px; }
.goal {
  display: grid; grid-template-columns: 1fr auto; text-align: left; gap: 2px 12px;
  padding: 12px 16px; border-radius: 14px;
  border: 2px solid var(--border); background: var(--surface);
}
.goal-label { font-weight: 900; }
.goal-xp { font-weight: 800; color: var(--primary); }
.goal-desc { grid-column: 1 / -1; color: var(--muted); font-size: .875rem; }
.goal.active { border-color: var(--primary); background: var(--primary-soft); }

/* ============ Accueil ============ */
.chips { display: flex; gap: 8px; flex: none; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 2px solid var(--border); font-weight: 800;
}
.bar { height: 14px; border-radius: 999px; background: var(--surface-2); overflow: hidden; flex: 1; }
.bar-fill { height: 100%; border-radius: inherit; background: var(--ok); transition: width .35s ease; min-width: 0; }
.bar-fill.sun { background: var(--sun); }

.hero-card {
  --unit: var(--primary);
  background: var(--unit); color: #fff;
  border-radius: 22px; padding: 18px;
  display: grid; grid-template-columns: auto 1fr; gap: 12px 14px; align-items: center;
  box-shadow: var(--shadow);
}
.hero-card.done { background: linear-gradient(135deg, #f2b33d, #d9653b); }
.hero-icon { font-size: 2.4rem; width: 60px; height: 60px; display: grid; place-items: center; background: rgba(255,255,255,.22); border-radius: 16px; }
.hero-kicker { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; opacity: .9; }
.hero-title { font-size: 1.35rem; font-weight: 900; }
.hero-sub { opacity: .92; font-size: .95rem; }
.hero-card .btn { grid-column: 1 / -1; background: #fff; color: #2b2733; box-shadow: 0 4px 0 rgba(0,0,0,.18); }

.review-card {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
}
.review-icon { font-size: 1.6rem; }
.review-card > span:nth-child(2) { flex: 1; }
.chev { font-size: 1.6rem; color: var(--muted); }

.install-card {
  display: flex; align-items: center; gap: 12px; position: relative;
  background: var(--primary-soft); border: 2px solid var(--primary); border-radius: var(--radius); padding: 14px 40px 14px 14px;
}
.install-icon { font-size: 1.6rem; flex: none; }
.install-text { flex: 1; min-width: 0; }
.install-text .muted { font-size: .875rem; }
.btn-sm { min-height: 40px; padding: 6px 14px; font-size: .95rem; flex: none; }
.install-close { position: absolute; top: 2px; right: 2px; width: 36px; height: 36px; font-size: 1rem; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }

/* ---- Accueil ---- */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { font-weight: 900; font-size: 1.2rem; color: var(--primary); letter-spacing: .01em; }
.chip-fire.on { border-color: var(--sun); }
.greet-oc { font-size: 1.45rem; font-weight: 900; overflow-wrap: anywhere; }

.today-card {
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.today-main { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ring { position: relative; width: 64px; height: 64px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring-bg { stroke: var(--surface-2); }
.ring-fg { stroke: var(--sun); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-inner { position: absolute; inset: 0; display: flex; align-items: baseline; justify-content: center; padding-top: 20px; line-height: 1; }
.ring-inner strong { font-size: 1.05rem; font-weight: 900; }
.ring-inner small { font-size: .7rem; color: var(--muted); font-weight: 700; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.day-dot {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: .95rem;
  background: var(--surface-2); border: 2px solid transparent;
}
.day.active .day-dot { background: color-mix(in srgb, var(--sun) 35%, var(--surface)); }
.day.today .day-dot { border-color: var(--primary); }
.day-lbl { font-size: .75rem; font-weight: 800; color: var(--muted); }
.day.today .day-lbl { color: var(--primary); }

.review-card.has-due { border-color: var(--primary); }
.review-text { flex: 1; }
.badge {
  min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px; display: grid; place-items: center;
  background: var(--ko); color: #fff; font-weight: 900; font-size: .85rem;
}

.wotd {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--sun) 22%, var(--surface)), var(--surface));
  border: 2px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
}
.wotd-text { flex: 1; min-width: 0; }
.wotd-kicker { font-size: .75rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; color: #b97a0c; }
.wotd-oc { font-size: 1.35rem; font-weight: 900; overflow-wrap: anywhere; }

.path-title { display: flex; align-items: baseline; justify-content: space-between; margin-top: 8px; }

.unit { --unit: var(--primary); display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.unit-banner {
  position: relative; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: start;
  background: var(--unit); color: #fff; border-radius: var(--radius); padding: 14px 16px 18px; overflow: hidden;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--unit) 70%, #000);
}
.unit.locked .unit-banner { filter: grayscale(.75); opacity: .75; }
.unit-kicker { font-size: .75rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; opacity: .85; }
.unit-title { font-size: 1.25rem; font-weight: 900; }
.unit-sub { opacity: .9; font-size: .9rem; }
.unit-count { font-weight: 900; background: rgba(255,255,255,.22); border-radius: 999px; padding: 2px 10px; }
.unit-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: rgba(0,0,0,.15); }
.unit-bar div { height: 100%; background: rgba(255,255,255,.85); transition: width .4s; }

.path { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 0 10px; }
.node-wrap {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  transform: translateX(var(--x, 0)); width: 130px; text-align: center;
}
.node {
  width: 74px; height: 70px; border-radius: 50%; border: none; position: relative;
  display: grid; place-items: center; font-size: 2rem;
  background: var(--unit); box-shadow: 0 6px 0 color-mix(in srgb, var(--unit) 65%, #000);
  transition: transform .1s, box-shadow .1s;
}
.node:active:not([aria-disabled="true"]) { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--unit) 65%, #000); }
.node.done { background: var(--sun); box-shadow: 0 6px 0 #c48a1d; }
.node.locked { background: var(--surface-2); box-shadow: 0 6px 0 var(--border); font-size: 1.4rem; }
.node.current { animation: bob 2s ease-in-out infinite; outline: 4px solid color-mix(in srgb, var(--unit) 30%, transparent); outline-offset: 5px; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.node-icon { filter: drop-shadow(0 1px 0 rgba(0,0,0,.15)); }
.node-title { font-weight: 800; font-size: .85rem; line-height: 1.2; }
.node.locked + .node-title { color: var(--muted); }
.node-bubble {
  position: absolute; top: -34px; white-space: nowrap; z-index: 1;
  background: var(--surface); color: var(--unit); border: 2px solid var(--border);
  font-weight: 900; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em;
  padding: 4px 10px; border-radius: 10px; animation: bob 2s ease-in-out infinite;
}
.node-bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%) rotate(45deg);
  width: 10px; height: 10px; background: var(--surface); border-right: 2px solid var(--border); border-bottom: 2px solid var(--border);
}
.node-wrap:has(.node-bubble) { margin-top: 30px; }

.stars { display: inline-flex; gap: 1px; letter-spacing: 0; }
.stars .on { color: var(--sun); }
.stars .off { color: var(--border); }
.node-stars { font-size: .9rem; margin-top: -2px; }
.result-stars { justify-content: center; font-size: 2.4rem; gap: 6px; }
.result-stars span { animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) backwards; }
.result-stars span:nth-child(2) { animation-delay: .15s; }
.result-stars span:nth-child(3) { animation-delay: .3s; }

/* ---- Leçon : série ---- */
.combo {
  flex: none; font-weight: 900; font-size: .85rem; color: #c97a00; white-space: nowrap;
  opacity: 0; transform: scale(.8); transition: opacity .2s, transform .2s; min-width: 0;
}
.combo.show { opacity: 1; transform: scale(1); }
.combo.pop { animation: comboPop .35s ease; }
@keyframes comboPop { 50% { transform: scale(1.25); } }
.fb-extra { font-size: .92rem; color: var(--muted); margin-top: 4px; }

/* ---- Lexique ---- */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-top: 10px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: none; padding: 6px 14px; border-radius: 999px; border: 2px solid var(--border);
  background: var(--surface); font-weight: 800; font-size: .9rem; color: var(--muted);
}
.filter.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.strength { display: inline-flex; gap: 3px; flex: none; }
.strength i { width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.strength i.on { background: var(--ok); }
.lex-due { font-size: .72rem; font-weight: 900; color: var(--ko); text-transform: uppercase; letter-spacing: .04em; flex: none; }

/* ---- Réglages ---- */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin-top: 8px; background: var(--surface-2); border-radius: 14px; }
.seg { min-height: 42px; border: none; border-radius: 10px; background: transparent; font-weight: 800; color: var(--muted); }
.seg.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---- Mise à jour ---- */
.update-bar {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 70;
  display: flex; align-items: center; gap: 12px; width: calc(100% - 32px); max-width: 520px;
  background: var(--surface); border: 2px solid var(--primary); border-radius: 16px; padding: 10px 10px 10px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18); font-weight: 800; animation: rise .25s ease;
}
.update-bar span { flex: 1; }

/* ============ Barre d'onglets ============ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 2px solid var(--border);
}
.tab {
  flex: 1; max-width: 180px; min-height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: none; background: transparent; border-radius: 12px;
  font-size: .8rem; font-weight: 800; color: var(--muted);
}
.tab-icon { font-size: 1.3rem; filter: grayscale(.6); }
.tab.active { color: var(--primary); background: var(--primary-soft); }
.tab.active .tab-icon { filter: none; }

/* ============ Leçon ============ */
.lesson { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.lesson-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px 4px; }
.lesson-bar { height: 16px; }
.lesson-body { flex: 1; padding: 16px; }
.lesson-foot {
  position: sticky; bottom: 0; z-index: 5;
  background: var(--bg); border-top: 2px solid var(--border);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
}
.foot-inner { display: flex; gap: 12px; }
.foot-inner .btn-primary:not(.btn-block) { flex: 1; }
.foot-hint { color: var(--muted); font-weight: 700; text-align: center; width: 100%; padding: 12px 0; }

.ex { display: flex; flex-direction: column; gap: 18px; animation: slideIn .25s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(12px); } }
.ex-kicker { font-size: 1.35rem; font-weight: 900; }

.word-card {
  background: var(--surface); border: 2px solid var(--border); border-radius: 22px;
  padding: 28px 20px; display: flex; flex-direction: column; gap: 16px; text-align: center; box-shadow: var(--shadow);
}
.word-oc { font-size: 2.2rem; font-weight: 900; color: var(--primary); overflow-wrap: anywhere; }
.word-fr { font-size: 1.25rem; font-weight: 700; }
.word-note { color: var(--muted); font-size: .95rem; }
.tip {
  background: var(--primary-soft); border-radius: 16px; padding: 14px 16px; font-size: .95rem;
  border-left: 5px solid var(--primary);
}

.prompt { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.prompt.listen { justify-content: center; padding: 10px 0; }
.prompt-oc { font-size: 1.9rem; font-weight: 900; color: var(--primary); overflow-wrap: anywhere; }
.prompt-fr { font-size: 1.6rem; font-weight: 800; overflow-wrap: anywhere; }
.prompt-sentence {
  font-size: 1.25rem; font-weight: 700;
  background: var(--surface); border: 2px solid var(--border); border-radius: 16px; padding: 12px 16px;
}

.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; text-align: left;
  padding: 10px 14px; border-radius: 16px;
  border: 2px solid var(--border); background: var(--surface); box-shadow: 0 3px 0 var(--border);
  font-size: 1.1rem; font-weight: 700;
  transition: transform .08s, border-color .12s, background-color .12s;
}
.choice:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.choice .key {
  width: 28px; height: 28px; flex: none; display: grid; place-items: center;
  border: 2px solid var(--border); border-radius: 8px; font-size: .8rem; color: var(--muted);
}
.choice.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 3px 0 var(--primary); }
.choice.selected .key { border-color: var(--primary); color: var(--primary); }
.choice.correct { border-color: var(--ok); background: var(--ok-bg); box-shadow: 0 3px 0 var(--ok); }
.choice.correct .key { border-color: var(--ok); color: var(--ok); }
.choice.wrong { border-color: var(--ko); background: var(--ko-bg); box-shadow: 0 3px 0 var(--ko); }
.choice.wrong .key { border-color: var(--ko); color: var(--ko); }
.choice:disabled:not(.correct):not(.wrong) { opacity: .6; }

.tile {
  min-height: 46px; padding: 8px 14px; border-radius: 12px;
  border: 2px solid var(--border); background: var(--surface); box-shadow: 0 3px 0 var(--border);
  font-size: 1.05rem; font-weight: 700;
}
.tile:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.tile.used { visibility: hidden; }

.build-answer {
  min-height: 116px; padding: 10px 0; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px;
  border-bottom: 2px solid var(--border);
  background-image: linear-gradient(var(--border) 2px, transparent 2px);
  background-size: 100% 58px; background-position: 0 56px;
}
.build-answer.ok .tile { border-color: var(--ok); }
.build-answer.ko .tile { border-color: var(--ko); }
.placeholder { color: var(--muted); padding: 10px 0; }
.build-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-tile { width: 100%; min-height: 56px; overflow-wrap: anywhere; }
.match-tile.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 3px 0 var(--primary); }
.match-tile.done { opacity: .35; border-color: var(--ok); box-shadow: none; }
.match-tile.bad { border-color: var(--ko); background: var(--ko-bg); animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.type-input { font-size: 1.2rem; min-height: 56px; }
.type-input.ok { border-color: var(--ok); background: var(--ok-bg); }
.type-input.ko { border-color: var(--ko); background: var(--ko-bg); }
.accents { display: flex; flex-wrap: wrap; gap: 8px; }
.accent {
  width: 44px; height: 44px; border-radius: 10px;
  border: 2px solid var(--border); background: var(--surface); font-weight: 800; font-size: 1.1rem;
}

.feedback { display: flex; flex-direction: column; gap: 12px; animation: rise .2s ease; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.lesson-foot:has(.feedback.ok) { background: var(--ok-bg); border-top-color: var(--ok); }
.lesson-foot:has(.feedback.ko) { background: var(--ko-bg); border-top-color: var(--ko); }
.feedback.ok .fb-title { color: var(--ok); }
.feedback.ko .fb-title { color: var(--ko); }
.fb-title { font-size: 1.3rem; font-weight: 900; display: block; }
.fb-answer { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 4px; font-size: 1.05rem; }
.feedback .speak { width: 38px; height: 38px; }

/* ============ Résultat ============ */
.result { align-items: stretch; text-align: left; position: relative; overflow: hidden; }
.result-hero { font-size: 5rem; text-align: center; margin-top: 4vh; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.result-title { font-size: 2rem; font-weight: 900; text-align: center; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  display: flex; flex-direction: column; align-items: center; padding: 14px 6px;
  background: var(--surface); border: 2px solid var(--border); border-radius: 16px;
}
.stat-val { font-size: 1.4rem; font-weight: 900; color: var(--primary); }
.stat-lbl { font-size: .8rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.banner { background: var(--banner-bg); color: var(--banner-text); border-radius: 14px; padding: 12px 14px; font-weight: 700; text-align: center; }
.banner.soft { background: var(--primary-soft); color: var(--text); }
.section-title { font-size: 1.1rem; font-weight: 900; margin-top: 4px; }
.word-chips { display: grid; grid-template-columns: 1fr; gap: 8px; }
.word-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 2px solid var(--border); border-radius: 14px; padding: 8px 8px 8px 14px;
}
.word-chip .speak { width: 38px; height: 38px; }
.result-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; left: calc(var(--i) * 5.5%); width: 8px; height: 14px; border-radius: 2px;
  background: hsl(calc(var(--i) * 47), 80%, 60%);
  animation: fall calc(1.8s + var(--i) * .07s) ease-in calc(var(--i) * .05s) forwards;
  opacity: 0;
}
@keyframes fall {
  0% { opacity: 1; transform: translateY(0) rotate(0); }
  100% { opacity: 0; transform: translateY(70vh) rotate(540deg); }
}

/* ============ Lexique ============ */
.search { position: sticky; top: 0; z-index: 4; background: var(--bg); padding: 4px 0 8px; }
.lex-unit { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.lex-unit-title { font-size: .85rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; color: var(--unit, var(--primary)); margin: 6px 0 2px; }
.lex-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 2px solid var(--border); border-radius: 14px; padding: 8px 8px 8px 14px;
}
.lex-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.lex-oc { font-weight: 800; overflow-wrap: anywhere; }
.lex-fr { color: var(--muted); font-size: .92rem; }
.lex-badge { color: var(--ok); font-weight: 900; }
.lex-row .speak { width: 40px; height: 40px; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

.about p { font-size: .95rem; }

/* ============ Modale & toast ============ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(20, 15, 30, .45); animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 400px; background: var(--surface); border-radius: 22px; padding: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25); display: flex; flex-direction: column; gap: 10px;
}
.modal h2 { font-size: 1.3rem; font-weight: 900; }
.modal p { color: var(--muted); }
.modal-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700;
  max-width: calc(100% - 32px); text-align: center;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 600px) {
  .word-chips { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .confetti { display: none; }
}

/* ============ Histoires & dialogues ============ */
.story-tools { display: flex; gap: 10px; flex-wrap: wrap; }
.story { display: flex; flex-direction: column; gap: 12px; }
.line { display: flex; align-items: flex-end; gap: 8px; }
.line.right { flex-direction: row-reverse; }
.line .speak { width: 38px; height: 38px; }
.avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; color: #fff; background: #1f9e8f;
}
.line.right .avatar { background: var(--terra, #d9653b); }
.bubble {
  max-width: 78%; padding: 10px 14px; border-radius: 18px; background: var(--surface);
  border: 2px solid var(--border); display: flex; flex-direction: column; gap: 2px;
}
.line.left .bubble { border-bottom-left-radius: 6px; }
.line.right .bubble { border-bottom-right-radius: 6px; background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.line.narr .bubble { max-width: none; flex: 1; border-radius: 14px; }
.who { font-size: .75rem; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.line-oc { font-size: 1.1rem; font-weight: 800; }
.line-fr { display: none; color: var(--muted); font-size: .92rem; }
.story.show-tr .line-fr { display: block; }
.line:has(.is-speaking) .bubble { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.story.compact { gap: 6px; }
.story.compact .bubble { max-width: 90%; padding: 6px 10px; }
.story.compact .line-oc { font-size: .95rem; }
.story-peek { background: var(--surface); border: 2px solid var(--border); border-radius: 14px; padding: 10px 14px; }
.story-peek summary { cursor: pointer; font-weight: 800; color: var(--primary); }
.story-peek[open] summary { margin-bottom: 10px; }
.quiz-kicker { display: flex; flex-direction: column; gap: 6px; }
.quiz-tag { align-self: flex-start; font-size: .72rem; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; color: #fff; background: #1f9e8f; padding: 3px 10px; border-radius: 999px; }

/* ============ Signalement ============ */
.report-btn { align-self: center; border: none; background: transparent; color: var(--muted); font-weight: 700; font-size: .85rem; padding: 6px 10px; border-radius: 10px; }
.report-btn:hover { background: var(--surface-2); }
.flag { width: 32px; height: 32px; flex: none; border: none; background: transparent; color: var(--muted); border-radius: 8px; font-size: .95rem; }
.flag:hover { background: var(--surface-2); color: var(--ko); }
.report-item { font-size: 1.05rem; }
.reasons { display: flex; flex-wrap: wrap; gap: 8px; }
.reason { position: relative; }
.reason input { position: absolute; opacity: 0; pointer-events: none; }
.reason span { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 2px solid var(--border); font-weight: 800; font-size: .9rem; cursor: pointer; }
.reason input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.reason input:focus-visible + span { outline: 3px solid var(--sun); outline-offset: 2px; }
textarea.text-input { resize: vertical; min-height: 80px; }

/* ============ Profil ============ */
.profile-head { display: flex; align-items: center; gap: 14px; }
.profile-head h1 { font-size: 1.6rem; font-weight: 900; overflow-wrap: anywhere; }
.avatar-big {
  width: 64px; height: 64px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.8rem; font-weight: 900; color: #fff; background: linear-gradient(135deg, var(--primary), #d9653b);
}
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.heatmap { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 10px; }
.heatmap i, .heat-legend i { aspect-ratio: 1; border-radius: 6px; background: var(--surface-2); display: block; }
.heat-legend { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 10px; }
.heat-legend i { width: 14px; border-radius: 4px; }
.lvl1 { background: color-mix(in srgb, var(--sun) 35%, var(--surface-2)) !important; }
.lvl2 { background: color-mix(in srgb, var(--sun) 70%, var(--surface-2)) !important; }
.lvl3 { background: var(--sun) !important; }
.heatmap i.today { outline: 2px solid var(--primary); outline-offset: 1px; }
.badge-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.badge-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  background: var(--surface); border: 2px solid var(--border); border-radius: 16px; padding: 14px 10px; opacity: .6;
}
.badge-card.got { opacity: 1; border-color: var(--sun); background: color-mix(in srgb, var(--sun) 10%, var(--surface)); }
.badge-icon { font-size: 2rem; }
.badge-card:not(.got) .badge-icon { filter: grayscale(1); font-size: 1.5rem; padding: 4px 0; }
.badge-won {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px;
  background: color-mix(in srgb, var(--sun) 15%, var(--surface)); border: 2px solid var(--sun); animation: pop .5s cubic-bezier(.2, 1.6, .4, 1);
}
.badge-won-icon { font-size: 2rem; }
@media (min-width: 520px) { .badge-grid { grid-template-columns: repeat(3, 1fr); } .stat-grid { grid-template-columns: repeat(4, 1fr); } }

/* ============ Synchro ============ */
.sync-code-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.sync-code {
  flex: 1; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 1.35rem; font-weight: 800; letter-spacing: .08em;
  background: var(--surface-2); border-radius: 12px; padding: 10px 14px; text-align: center;
}
.inline-form { display: flex; gap: 8px; }
.inline-form .text-input { flex: 1; text-transform: uppercase; font-family: ui-monospace, 'SF Mono', Menlo, monospace; letter-spacing: .06em; }

.hunt-card .review-icon { filter: none; }
.tab { font-size: .7rem; }
  .tab-icon { font-size: 1.15rem; }

/* ============ Cyrillique ============ */
.tr { font-style: italic; color: var(--muted); font-weight: 600; }
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand-mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: var(--primary); color: #fff; font-size: .9rem; font-weight: 900; letter-spacing: -.02em;
  box-shadow: inset 0 -4px 0 #d62612;
}
.ob-hero-letters {
  font-weight: 900; font-size: 4rem; color: #fff; width: 120px; height: 120px; margin: 0 auto;
  display: grid; place-items: center; border-radius: 30px; background: var(--primary);
  box-shadow: inset 0 -14px 0 #d62612, 0 8px 24px rgba(15, 138, 100, .25);
}
.word-tr { font-size: 1.15rem; font-style: italic; color: var(--muted); font-weight: 700; margin-top: -4px; }
.letter-big { font-size: 5rem; line-height: 1.05; letter-spacing: .06em; }
.letter-name { margin-top: 4px; }
.prompt-letter { font-size: 4.2rem; letter-spacing: .06em; }
.prompt-col { flex-direction: column; gap: 4px; }
.prompt-tr { font-size: 1.7rem; font-weight: 900; font-style: italic; color: var(--primary); }
.choice-tr .choice-label { font-style: italic; }
.choice-cyr .choice-label { font-size: 1.2rem; }
.choice-letter .choice-label { font-size: 1.6rem; letter-spacing: .05em; }

.cyr-kb { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.cyr-kb .accent { width: auto; height: 42px; padding: 0; font-size: 1.15rem; }
.cyr-kb .accent:active { background: var(--primary-soft); border-color: var(--primary); }
.cyr-kb .key-wide { grid-column: span 5; font-size: .95rem; color: var(--muted); }
.kb-hint b { color: var(--text); }
@media (max-width: 360px) { .cyr-kb .accent { height: 38px; font-size: 1rem; } }

.abc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; margin-bottom: 16px; }
.abc-cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px;
  border: 2px solid var(--border); border-radius: 14px; background: var(--surface);
  box-shadow: 0 3px 0 var(--border); color: var(--text);
}
.abc-cell:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.abc-cell.learned { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.abc-cell.learned .abc-letter { color: var(--primary); }
.abc-cell.is-speaking { background: var(--primary-soft); border-color: var(--primary); }
.abc-letter { font-size: 1.6rem; font-weight: 900; letter-spacing: .04em; color: var(--muted); }
.abc-sound { font-size: .85rem; font-weight: 700; color: var(--muted); }
.false-friends { display: flex; flex-wrap: wrap; gap: 8px; }
.ff { background: var(--surface-2); border-radius: 10px; padding: 6px 10px; font-weight: 700; }
.ff b { color: var(--primary); font-size: 1.15rem; }

/* ============ Quiz ============ */
.quiz-grid { display: grid; gap: 10px; margin-bottom: 20px; }
@media (min-width: 640px) { .quiz-grid { grid-template-columns: 1fr 1fr; } }
.quiz-card {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  padding: 14px; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface);
  box-shadow: 0 3px 0 var(--border); color: var(--text); font: inherit;
}
.quiz-card:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.quiz-card:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
.quiz-icon { font-size: 1.8rem; width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 14px; background: var(--primary-soft); }
.quiz-text { flex: 1; min-width: 0; }
.quiz-text strong { font-size: 1.05rem; }
.quiz-hint { display: inline-block; margin-top: 4px; font-size: .72rem; font-weight: 800; color: var(--banner-text); background: var(--banner-bg); border-radius: 8px; padding: 2px 7px; }
.quiz-best { flex: none; font-weight: 900; font-size: .85rem; color: var(--primary); background: var(--primary-soft); border-radius: 10px; padding: 4px 8px; }
.quiz-best.none { color: var(--muted); background: var(--surface-2); }
.quiz-score { font-weight: 900; white-space: nowrap; }
.quiz-secs { font-weight: 900; min-width: 2.6em; text-align: right; font-variant-numeric: tabular-nums; }
.bar-fill.timer { transition: width .2s linear; }
.bar-fill.timer.hurry { background: var(--ko); }
.quiz-streak { font-size: .9rem; color: var(--ko); margin-left: 6px; }
.lesson-foot.quiz-ok { background: var(--ok-bg); border-top-color: var(--ok); }
.quiz-final { text-align: center; font-size: 3.2rem; font-weight: 900; color: var(--primary); margin: 4px 0; line-height: 1.1; }
.quiz-final small { font-size: 1.1rem; color: var(--muted); font-weight: 800; }
.quiz-run .choice { transition: background .15s, border-color .15s; }
