/* Stepdose : système de design. Mobile d'abord, clair et sombre. */
:root {
  --bg: #f3f7f6; --bg2: #e9f1ef; --card: #ffffff; --ink: #0f2b2a; --muted: #5f7471; --line: #e2ebe8;
  --brand: #0b8a7a; --brand2: #17b897; --brand-ink: #076458; --brand-soft: #e1f5f0;
  --coral: #ff7a59; --coral-soft: #ffece6; --gold: #b67a12; --gold2: #f3b63f; --gold-soft: #fff4d9;
  --warn: #b42318; --warn-soft: #fdecea;
  --grad: linear-gradient(135deg, #0b8a7a 0%, #17b897 100%);
  --grad-gold: linear-gradient(135deg, #e9a52b 0%, #f6c95a 100%);
  --shadow: 0 1px 2px rgba(15, 43, 42, .04), 0 8px 24px rgba(15, 43, 42, .06);
  --shadow-lg: 0 12px 32px rgba(11, 138, 122, .22);
  --r: 20px; --r-sm: 14px;
  --display: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1716; --bg2: #101f1d; --card: #15201f; --ink: #e9f3f1; --muted: #93a8a4; --line: #24332f;
    --brand: #2fc9aa; --brand2: #55dcc0; --brand-ink: #7fe6cf; --brand-soft: #143029;
    --coral-soft: #3a211a; --gold: #f0bd55; --gold-soft: #33290f; --warn: #ff8a7a; --warn-soft: #3a1a17;
    --grad: linear-gradient(135deg, #0b7a6c 0%, #139a80 100%);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body { font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: radial-gradient(1200px 600px at 50% -200px, #cfeee6 0%, transparent 70%), var(--bg2); }
@media (prefers-color-scheme: dark) { body { background: #081110; } }
#app { max-width: 460px; margin: 0 auto; min-height: 100vh; background: var(--bg); display: flex; flex-direction: column; position: relative; }
@media (min-width: 520px) { #app { box-shadow: 0 0 60px rgba(15, 43, 42, .12); } }
#view { flex: 1; padding: 22px 18px 118px; outline: none; animation: rise .28s ease both; }
/* Pas de fondu d'opacité : le contenu reste lisible même si l'animation est suspendue (onglet en arrière-plan). */
@keyframes rise { from { transform: translateY(10px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

h1, h2, h3, .big, .display { font-family: var(--display); letter-spacing: -.02em; }
h1 { font-size: 1.75rem; line-height: 1.15; margin: 0 0 6px; font-weight: 800; }
h2 { font-size: 1.12rem; margin: 22px 0 8px; font-weight: 750; }
h3 { font-size: 1rem; margin: 18px 0 6px; font-weight: 700; }
p { margin: 0 0 12px; }
a { color: var(--brand-ink); }
.muted { color: var(--muted); font-size: .9rem; }
.eyebrow { font-size: .72rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--brand-ink); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin: 14px 0; box-shadow: var(--shadow); }
.card > h2:first-child, .card > .row:first-child h2 { margin-top: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.big { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.backlink { display: inline-block; margin-bottom: 10px; text-decoration: none; font-weight: 600; font-size: .9rem; color: var(--muted); }

/* Boutons */
button, .btn { font: inherit; border: 0; border-radius: 14px; padding: 13px 18px; background: var(--grad); color: #fff; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-block; text-align: center; box-shadow: 0 6px 16px rgba(11, 138, 122, .22); transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
button:active, .btn:active { transform: scale(.98); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost, .btn.ghost { background: var(--brand-soft); color: var(--brand-ink); box-shadow: none; }
button.danger { background: var(--warn-soft); color: var(--warn); box-shadow: none; }
button.gold, .btn.gold { background: var(--grad-gold); color: #3d2a00; box-shadow: 0 6px 16px rgba(233, 165, 43, .3); }
button.link { background: none; color: var(--muted); padding: 4px 6px; font-weight: 600; font-size: .85rem; box-shadow: none; }
.full { width: 100%; }
.sm { padding: 8px 12px; font-size: .85rem; border-radius: 11px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #5eead4; outline-offset: 2px; }

/* Formulaires */
label { display: block; font-size: .82rem; font-weight: 700; color: var(--muted); margin: 14px 0 5px; }
input, select, textarea { font: inherit; width: 100%; padding: 12px 13px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); transition: border-color .12s; }
input:focus, select:focus { border-color: var(--brand); outline: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; color: var(--ink); font-size: .95rem; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--brand); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Navigation flottante */
#nav { position: fixed; bottom: calc(12px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: calc(100% - 24px); max-width: 436px; background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 24px; display: flex; padding: 6px; box-shadow: 0 10px 30px rgba(15, 43, 42, .16); z-index: 10; }
#nav a { flex: 1; text-align: center; padding: 8px 2px 6px; font-size: .68rem; color: var(--muted); text-decoration: none; font-weight: 700; border-radius: 18px; transition: background .15s, color .15s; }
#nav a svg { display: block; margin: 0 auto 2px; width: 23px; height: 23px; }
#nav a.on { color: var(--brand-ink); background: var(--brand-soft); }
#nav:empty { display: none; }

/* Carte principale de l'accueil */
.hero { background: var(--grad); color: #fff; border: 0; border-radius: 26px; padding: 22px; box-shadow: var(--shadow-lg); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.hero > * { position: relative; z-index: 1; }
.hero .muted, .hero .eyebrow { color: rgba(255, 255, 255, .82); }
.hero .big { font-size: 2.6rem; }
.hero .chip { display: inline-block; background: rgba(255, 255, 255, .2); border-radius: 99px; padding: 4px 12px; font-weight: 700; font-size: .85rem; }
.hero .btn { background: #fff; color: #076458; box-shadow: none; }
.hero .spark { width: 100%; height: 56px; display: block; margin: 10px 0 2px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: rgba(255, 255, 255, .16); border-radius: 14px; padding: 9px 10px; }
.stat b { display: block; font-family: var(--display); font-size: 1.05rem; }
.stat span { font-size: .72rem; opacity: .85; }
.card:not(.hero) .stats .stat { background: var(--bg); }

/* Parcours */
.lesson { display: flex; gap: 14px; align-items: center; text-decoration: none; color: inherit; padding: 14px 16px; }
.lesson .num { flex: none; width: 40px; height: 40px; border-radius: 13px; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; font-weight: 800; font-family: var(--display); }
.lesson.done .num { background: var(--grad); color: #fff; }
.lesson b { display: block; line-height: 1.3; }
.lesson .chev { margin-left: auto; color: var(--muted); font-size: 1.2rem; }
.progress { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 10px 0; }
.progress i { display: block; height: 100%; background: var(--grad); border-radius: 99px; transition: width .4s ease; }
.ring { width: 64px; height: 64px; flex: none; }
.ring text { font-family: var(--display); font-weight: 800; font-size: 15px; fill: var(--ink); }

.warn { background: var(--warn-soft); border-left: 4px solid var(--warn); border-radius: 12px; padding: 13px 15px; margin: 14px 0; font-weight: 500; }
.info { background: var(--brand-soft); border-radius: 12px; padding: 13px 15px; margin: 14px 0; font-size: .92rem; }
.article { font-size: 1.02rem; }
.article ul { padding-left: 20px; margin: 0 0 12px; }
.article li { margin-bottom: 7px; }
.srcs { font-size: .85rem; padding-left: 18px; margin: 0; }
.srcs li { margin-bottom: 5px; }

/* Graphique des essais */
.trial { margin: 16px 0; }
.trial .t { font-size: .85rem; font-weight: 700; margin-bottom: 6px; }
.bar { display: grid; grid-template-columns: 1fr 62px; gap: 8px; align-items: center; margin: 6px 0; font-size: .82rem; }
.bar .track { background: var(--line); border-radius: 9px; height: 30px; position: relative; overflow: hidden; }
.bar .fill { position: absolute; inset: 0 auto 0 0; background: #9db0ac; border-radius: 9px; }
.bar.main .fill { background: var(--grad); }
.bar .lbl { position: absolute; left: 10px; top: 5px; white-space: nowrap; color: #fff; font-weight: 700; text-shadow: 0 0 4px rgba(0, 0, 0, .5); }
.bar .val { font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 8px; margin: 14px -18px; padding: 2px 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: var(--card); color: var(--muted); border: 1px solid var(--line); padding: 9px 14px; font-size: .88rem; white-space: nowrap; box-shadow: none; border-radius: 99px; }
.tabs button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tabs.wrap { flex-wrap: wrap; overflow: visible; margin: 12px 0; padding: 0; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: .93rem; }
.list li:last-child { border-bottom: 0; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: .74rem; font-weight: 800; background: var(--brand-soft); color: var(--brand-ink); }
.pill.gold { background: var(--gold-soft); color: var(--gold); }
.pill.red { background: var(--warn-soft); color: var(--warn); }
.chart { width: 100%; height: auto; display: block; }

/* Petits pas */
.steps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.step { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; color: var(--ink); font-weight: 600; font-size: .86rem; text-align: left; box-shadow: none; line-height: 1.25; }
.step .ic { font-size: 1.3rem; }
.step.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale button { background: var(--bg); color: var(--muted); border: 1.5px solid var(--line); box-shadow: none; padding: 10px 0; font-weight: 800; }
.scale button.on { background: var(--grad); color: #fff; border-color: transparent; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; font-size: .7rem; color: var(--muted); }
.week i { display: grid; place-items: center; height: 38px; border-radius: 12px; background: var(--bg); font-style: normal; font-weight: 800; color: var(--muted); margin-bottom: 4px; }
.week i.on { background: var(--brand-soft); color: var(--brand-ink); }

/* Badges */
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.badges.strip { grid-template-columns: repeat(4, 1fr); }
.badge { text-align: center; font-size: .74rem; font-weight: 700; line-height: 1.25; color: var(--muted); }
.badge .medal { width: 62px; height: 62px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center; font-size: 1.7rem; background: var(--bg); border: 2px dashed var(--line); filter: grayscale(1); opacity: .55; }
.badge.on { color: var(--ink); }
.badge.on .medal { background: var(--grad-gold); border: 0; filter: none; opacity: 1; box-shadow: 0 6px 16px rgba(233, 165, 43, .35); }
.badge small { display: block; font-weight: 500; color: var(--muted); margin-top: 2px; }
.toast { position: fixed; left: 0; right: 0; margin: 0 auto; width: fit-content; bottom: 104px; background: var(--ink); color: var(--bg); border-radius: 16px; padding: 12px 18px; font-weight: 700; box-shadow: var(--shadow-lg); z-index: 20; animation: rise .3s ease both; max-width: 90%; text-align: center; }

/* Menus */
.menu { padding: 6px; }
.menu a { display: flex; align-items: center; gap: 14px; padding: 13px 12px; text-decoration: none; color: inherit; border-radius: 14px; font-weight: 650; }
.menu a:active { background: var(--bg); }
.menu .ic { width: 40px; height: 40px; border-radius: 13px; background: var(--brand-soft); display: grid; place-items: center; font-size: 1.2rem; flex: none; }
.menu small { display: block; font-weight: 400; color: var(--muted); }
.menu .chev { margin-left: auto; color: var(--muted); }
.toast button.link { color: inherit; text-decoration: underline; font-size: inherit; font-weight: 800; }
.check a { color: var(--brand-ink); }

/* Premium */
.paywall { border: 1.5px solid #f0d58c; background: linear-gradient(180deg, var(--gold-soft), var(--card) 70%); }
.paywall ul { padding-left: 20px; }
.cmp { width: 100%; border-collapse: collapse; font-size: .88rem; }
.cmp th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 4px; }
.cmp td { padding: 11px 4px; border-top: 1px solid var(--line); }
.cmp td:nth-child(n+2), .cmp th:nth-child(n+2) { text-align: center; width: 64px; }
.cmp .yes { color: var(--brand); font-weight: 900; }
.cmp .no { color: var(--line); }
.cmp td:last-child { background: var(--gold-soft); }
.why { display: grid; gap: 12px; }
.why div { display: flex; gap: 12px; align-items: flex-start; }
.why .ic { font-size: 1.5rem; flex: none; }
.why b { display: block; }
.preview { position: relative; border-radius: var(--r-sm); overflow: hidden; margin: 12px 0; }
.preview .mock { filter: blur(3px); opacity: .75; pointer-events: none; user-select: none; padding: 4px 2px; }
.preview .veil { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--card) 80%, transparent)); }

/* Actualités, quiz, lexique */
.news a.item { display: block; text-decoration: none; color: inherit; padding: 13px 0; border-bottom: 1px solid var(--line); }
.news a.item:last-child { border-bottom: 0; }
.news a.item b { display: block; margin: 5px 0; line-height: 1.35; }
.opt { display: block; width: 100%; text-align: left; background: var(--bg); color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; margin: 8px 0; font-weight: 600; }
.opt.ok { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.opt.ko { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.myth q { display: block; font-family: var(--display); font-weight: 750; font-size: 1.05rem; quotes: none; margin-bottom: 8px; }
dl.gloss { margin: 0; }
dl.gloss dt { font-weight: 800; font-family: var(--display); margin-top: 14px; }
dl.gloss dd { margin: 2px 0 0; color: var(--muted); }

/* Assistant */
.chat { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.msg { max-width: 88%; padding: 11px 15px; border-radius: 18px; font-size: .95rem; }
.msg.me { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 5px; }
.msg.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 5px; box-shadow: var(--shadow); }
.ailabel { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); font-size: .72rem; color: var(--muted); }
.askbar { display: flex; gap: 8px; padding: 10px; position: sticky; bottom: 96px; }
.askbar input { flex: 1; }

@media print {
  body { background: #fff; }
  #nav, .noprint, .toast { display: none !important; }
  #app { max-width: none; background: #fff; box-shadow: none; }
  #view { padding: 0; animation: none; }
  .card { border: 0; padding: 0; box-shadow: none; }
}

/* Le mot du jour */
.daily { background: linear-gradient(135deg, var(--gold-soft), var(--card) 75%); border-color: color-mix(in srgb, var(--gold2) 45%, var(--line)); padding: 16px 18px; }
.daily .eyebrow { color: var(--gold); }
.daily p { font-family: var(--display); font-size: 1.08rem; font-weight: 650; line-height: 1.4; margin: 8px 0 4px; }
.daily a { font-size: .78rem; }

/* Leçon carte par carte */
.progress.thin { height: 5px; margin: 10px 0 0; }
.flowcard { min-height: 46vh; padding: 26px 0 8px; display: flex; flex-direction: column; justify-content: center; }
.flowcard h1 { font-size: 1.9rem; }
.counter { font-size: .74rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; display: block; }
.rule { width: 44px; height: 4px; border-radius: 4px; background: var(--grad); margin: 14px 0 20px; }
.flowactions { display: grid; gap: 10px; margin-top: 18px; }
.explain { margin-top: 14px; padding: 14px 16px; border-radius: 14px; background: var(--brand-soft); }
.explain p { margin: 6px 0 0; }
.result { text-align: center; padding: 12px 0 20px; }
.result .score { font-family: var(--display); font-weight: 800; font-size: 4.5rem; line-height: 1.1; background: var(--grad-gold); -webkit-background-clip: text; background-clip: text; color: transparent; }
button.term { all: unset; cursor: pointer; border-bottom: 2px dotted var(--brand); color: inherit; font: inherit; }
button.term:focus-visible { outline: 3px solid #5eead4; outline-offset: 2px; border-radius: 4px; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 460px; background: var(--card); border-radius: 24px 24px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); box-shadow: 0 -12px 40px rgba(15, 43, 42, .25); z-index: 30; animation: rise .25s ease both; }
dl.gloss dt .pill { font-family: system-ui, sans-serif; font-size: .66rem; vertical-align: middle; margin-left: 4px; }
input[type="search"] { background: var(--card); margin-top: 6px; }
.backlink { display: block; width: fit-content; }
.flowcard { min-width: 0; }
.flowcard > * { max-width: 100%; }
.opt:disabled { opacity: 1; cursor: default; }
.opt:disabled:not(.ok):not(.ko) { color: var(--muted); }
