:root {
  --bg: #f6f7fb; --card: #fff; --text: #1d2033; --muted: #6b7088; --line: #e4e6ef;
  --brand: #4f46e5; --brand2: #7c3aed; --brand-soft: #eef0ff; --ok: #16a34a; --ok-soft: #dcfce7; --ko: #dc2626; --ko-soft: #fee2e2; --gold: #f59e0b;
  --r: 16px; --shadow: 0 1px 3px rgba(20,20,50,.06), 0 4px 16px rgba(20,20,50,.05);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11131c; --card: #1b1e2b; --text: #eceef6; --muted: #9aa0b8; --line: #2c3042; --brand-soft: #262a4a; --ok-soft: #12351f; --ko-soft: #3d1717; --shadow: none; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
body.in-lesson { padding-bottom: 0; }
body.in-lesson nav { display: none; }
#view { max-width: 640px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px 16px; }
h1 { font-size: 1.6rem; margin: 0 0 4px; } h2 { font-size: 1.2rem; } h3 { margin: 20px 0 8px; font-size: 1rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
button { font: inherit; color: inherit; cursor: pointer; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.top p { margin: 0; }
.pills { display: flex; gap: 6px; } .pill { background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; font-weight: 600; white-space: nowrap; }
.card { background: var(--card); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--line); margin-bottom: 14px; }
.row { display: flex; justify-content: space-between; align-items: center; } .row.gap { gap: 8px; flex-wrap: wrap; justify-content: flex-start; margin-top: 12px; }
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; flex: 1; margin-top: 8px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand2)); border-radius: 99px; transition: width .3s; }
.btn { background: var(--brand); color: #fff; border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 600; display: inline-block; text-align: center; }
.btn:active { transform: scale(.98); } .btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.small { padding: 8px 12px; font-size: .9rem; } .btn.danger { background: var(--ko-soft); color: var(--ko); margin-top: 10px; }
@media (prefers-color-scheme: dark) { .btn.ghost { color: #c7c9ff; } }
.lvl { display: flex; align-items: center; gap: 8px; margin: 22px 0 10px; } .lvl small { color: var(--muted); font-weight: 500; margin-left: auto; font-size: .85rem; }
.badge { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; font-size: .75rem; font-weight: 700; padding: 3px 8px; border-radius: 8px; }
.units { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.unit { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: var(--shadow); }
.unit .ico { font-size: 2rem; } .unit .ut { font-weight: 600; font-size: .92rem; text-align: center; }
.unit.done { border-color: var(--ok); }
.dots { display: flex; gap: 4px; } .dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); } .dots i.on { background: var(--ok); }
.back { background: none; border: 0; color: var(--brand); padding: 4px 0; margin-bottom: 8px; font-weight: 600; }
.unit-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; } .unit-head .big { font-size: 3rem; }
.lesson { width: 100%; display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 10px; text-align: left; box-shadow: var(--shadow); }
.lesson .ico { font-size: 1.6rem; } .lesson small { display: block; color: var(--muted); } .lesson .chk { margin-left: auto; font-size: 1.3rem; color: var(--muted); }
.lesson.done .chk { color: var(--ok); font-weight: 700; }
.words { list-style: none; padding: 0; margin: 0; } .words li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.words .lv { margin-left: auto; font-size: .8rem; white-space: nowrap; color: var(--muted); }
.spk { background: var(--brand-soft); border: 0; border-radius: 50%; width: 38px; height: 38px; flex: none; font-size: 1.05rem; vertical-align: middle; }
.spk.xl { width: 72px; height: 72px; font-size: 2rem; } .spk.slow { font-size: .95rem; }
/* Leçon */
.lesson-top { display: flex; align-items: center; gap: 12px; } .lesson-top .bar { margin: 0; }
.x { background: none; border: 0; font-size: 1.3rem; color: var(--muted); padding: 4px 8px; }
.step { padding: 18px 0 150px; } .hint { color: var(--muted); font-weight: 600; margin: 8px 0 14px; }
.q-big { font-size: 1.8rem; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.q-med { font-size: 1.25rem; font-weight: 600; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.learn .tr { font-size: 1.2rem; color: var(--brand); font-weight: 600; margin: -8px 0 14px; }
@media (prefers-color-scheme: dark) { .learn .tr { color: #a5a8ff; } }
.ex, .exs li { display: flex; gap: 10px; align-items: flex-start; } .exs { list-style: none; padding: 0; } .exs li { margin-bottom: 10px; }
.choices { display: grid; gap: 10px; }
.choice { background: var(--card); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 14px; padding: 14px; text-align: left; font-size: 1.05rem; font-weight: 500; }
.choice:disabled { opacity: 1; } .choice.right { border-color: var(--ok); background: var(--ok-soft); } .choice.wrong { border-color: var(--ko); background: var(--ko-soft); }
.inp { width: 100%; font: inherit; font-size: 1.15rem; padding: 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); color: var(--text); outline: none; }
.inp:focus { border-color: var(--brand); } .inp.right { border-color: var(--ok); } .inp.wrong { border-color: var(--ko); }
.search { margin-bottom: 4px; font-size: 1rem; }
.answer { min-height: 58px; border-bottom: 2px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; margin-bottom: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--card); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 12px; padding: 8px 12px; font-size: 1.05rem; }
.gapb { color: var(--brand); border-bottom: 2px solid var(--brand); padding: 0 4px; }
.mic { display: block; margin: 30px auto 12px; width: 96px; height: 96px; border-radius: 50%; border: 0; background: linear-gradient(135deg, var(--brand), var(--brand2)); font-size: 2.4rem; box-shadow: 0 6px 20px rgba(79,70,229,.35); }
.mic.rec { animation: pulse 1s infinite; } @keyframes pulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 14px rgba(79,70,229,.15); } }
.gram table { border-collapse: collapse; width: 100%; margin: 8px 0; } .gram td { border-bottom: 1px solid var(--line); padding: 6px 4px; }
.gram h2 { margin-top: 0; }
.dlg { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.dl small { color: var(--muted); font-weight: 600; margin-left: 4px; }
.dl .bub { display: flex; gap: 8px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 10px; max-width: 90%; }
.dl.r { align-items: flex-end; display: flex; flex-direction: column; } .dl.r .bub { border-radius: 16px 16px 4px 16px; background: var(--brand-soft); }
.dl.on .bub { outline: 2px solid var(--brand); }
.fr { display: none; font-style: normal; color: var(--muted); font-size: .9rem; margin-top: 4px; } .show-fr .fr { display: block; }
.foot { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.foot > * { max-width: 608px; width: 100%; margin: 0 auto; } .foot .btn { width: 100%; padding: 14px; font-size: 1.05rem; }
.foot.ok { background: var(--ok-soft); } .foot.ok .btn { background: var(--ok); } .foot.ok .fb b { color: var(--ok); }
.foot.ko { background: var(--ko-soft); } .foot.ko .btn { background: var(--ko); } .foot.ko .fb b { color: var(--ko); }
.fb b { font-size: 1.15rem; display: block; }
.finish { text-align: center; padding-top: 50px; } .finish .big { font-size: 4rem; } .finish .btn { width: 100%; margin-top: 24px; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin-top: 16px; } .stats3 b { font-size: 1.3rem; display: block; } .stats3 small { color: var(--muted); }
.huge { font-size: 3.5rem; font-weight: 800; color: var(--brand); } .card.center .btn { margin: 6px 4px; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 120px; margin-top: 12px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 4px; }
.chart i { width: 100%; background: var(--line); border-radius: 4px; } .chart i.met { background: linear-gradient(var(--brand2), var(--brand)); } .chart small { font-size: .7rem; color: var(--muted); }
.lvrow { display: flex; align-items: center; gap: 10px; margin-top: 10px; } .lvrow .bar { margin: 0; } .lvrow span:last-child { width: 40px; text-align: right; font-size: .9rem; }
.form label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-weight: 600; }
.form select { font: inherit; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.tog { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: .9rem; }
nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
nav button { flex: 1; max-width: 160px; background: none; border: 0; padding: 8px 0 10px; display: flex; flex-direction: column; align-items: center; font-size: .72rem; color: var(--muted); font-weight: 600; }
nav button span { font-size: 1.35rem; filter: grayscale(1); opacity: .7; } nav button.on { color: var(--brand); } nav button.on span { filter: none; opacity: 1; }
/* v2 */
.hearts { font-weight: 700; white-space: nowrap; } .hearts.lost { animation: shake .4s; } @keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.combo { font-weight: 800; color: var(--gold); }
.choice kbd { display: none; } @media (hover: hover) and (pointer: fine) { .choice kbd { display: inline-block; font: 600 .75rem/1 inherit; border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; margin-right: 10px; color: var(--muted); } }
.star { color: var(--gold); margin-left: 4px; font-size: .9rem; line-height: 8px; }
.card.hi { border: 2px solid var(--brand); } .card.hi .btn { margin: 6px 6px 0 0; }
.vt { width: 100%; border-collapse: collapse; margin-top: 8px; } .vt th { font-size: .8rem; color: var(--muted); text-align: left; padding: 4px; } .vt td { padding: 8px 4px; border-top: 1px solid var(--line); font-weight: 600; }
.vt.full td { font-weight: 500; font-size: .9rem; padding: 6px 4px; }
.unit small { font-size: .75rem; text-align: center; }
.reading .rtext p { margin: 10px 0; font-size: 1.05rem; line-height: 1.6; } .rtext.hidden { display: none; }
details { margin-top: 12px; } summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.inp.area { resize: vertical; min-height: 140px; font-size: 1rem; }
.model p { background: var(--brand-soft); padding: 10px; border-radius: 10px; }
.lead { font-size: 1.1rem; } .finish .btn.ghost { margin-top: 10px; }
.lvrow .w { width: auto !important; min-width: 64px; } .lvsub { display: block; margin-left: 44px; font-size: .75rem; }
.sel { font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.tog.big { color: var(--text); font-size: 1rem; flex-direction: row; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .mcol { display: grid; gap: 10px; align-content: start; }
.choice.mt { text-align: center; padding: 12px 8px; font-size: .98rem; } .choice.sel { border-color: var(--brand); background: var(--brand-soft); }
.choice.mt.right { opacity: .45; }
.foot .btn.small { padding: 10px; font-size: .9rem; }
/* ---- Profils, IA, tuteur ---- */
.pill.who { color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.profiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.prof { background: var(--card); border: 2px solid var(--line); border-radius: var(--r); padding: 22px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: var(--shadow); color: var(--text); font: inherit; }
.prof span { font-size: 2.6rem; } .prof b { font-size: 1.1rem; } .prof small { color: var(--muted); min-height: 1em; } .prof.on { border-color: var(--brand); }
.gbtn { display: flex; justify-content: center; margin: 22px 0 10px; height: 46px; max-height: 120px; }
.err { color: var(--ko); font-size: .9rem; min-height: 1em; margin: 6px 0; }
.aibox { background: var(--brand-soft); border-radius: 12px; padding: 12px 14px; margin-top: 10px; text-align: left; font-size: .93rem; }
.aibox p { margin: 6px 0; } .aibox ul { margin: 6px 0 10px; padding-left: 20px; } .aibox details { margin: 8px 0; } .aibox summary { font-weight: 600; cursor: pointer; }
.aibox .row { display: flex; justify-content: space-between; align-items: center; }
.fixes { list-style: none; padding: 0; margin: 6px 0; } .fixes li { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 6px 0; font-size: .9rem; }
.fixes s { color: var(--ko); } .fixes b { color: var(--ok); }
.btn.why { margin-top: 8px; }
.foot .fb .aibox { color: var(--text); }
.tutorcard { border-color: var(--brand); }
.chat-top { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; background: var(--bg); padding: 6px 0; z-index: 2; } .chat-top .back { margin: 0; } .chat-top b { flex: 1; }
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 150px; }
.msg { display: flex; flex-direction: column; max-width: 88%; } .msg.user { align-self: flex-end; align-items: flex-end; } .msg.assistant { align-self: flex-start; }
.bub { padding: 10px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.msg.user .bub { background: var(--brand); color: #fff; border-color: var(--brand); }
.bub details { margin-top: 6px; font-size: .85rem; color: var(--muted); } .bub summary { cursor: pointer; font-weight: 600; }
.bub .spk { font-size: 1rem; padding: 0 4px; }
.bub.typing { color: var(--muted); letter-spacing: 3px; } .bub.err { color: var(--ko); }
.tip { font-size: .85rem; color: var(--muted); margin: 4px 6px; }
.chat-in { align-items: flex-end; position: fixed; left: 0; right: 0; bottom: calc(62px + env(safe-area-inset-bottom)); display: flex; gap: 8px; padding: 10px 12px; background: var(--card); border-top: 1px solid var(--line); z-index: 4; max-width: 720px; margin: 0 auto; }
.chat-in textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 10px; font: inherit; background: var(--bg); color: var(--text); height: 46px; max-height: 120px; }
.mic { border: 0; background: var(--brand-soft); border-radius: 12px; font-size: 1.3rem; width: 48px; } .mic.on { background: var(--ko); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.link { background: none; border: 0; color: var(--brand); text-decoration: underline; padding: 0; font: inherit; font-size: .85rem; }
