:root {
  --bg: #f7f5f0; --paper: #ffffff; --ink: #1f2430; --muted: #6b7280; --line: #e5e1d8;
  --navy: #162e4b; --red: #b12024;
  --accent: #162e4b; --accent-ink: #ffffff; --cta: #b12024; --cta-ink: #ffffff; --good: #15803d; --good-bg: #ecfdf3; --bad: #b12024; --bad-bg: #fbeeee;
  --tip: #fff7e6; --warn: #fbeeee; --rule: #eaeff6; --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(31,36,48,.06);
  --serif: "Source Serif 4", Georgia, serif; --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #12161d; --paper: #1b2230; --ink: #e8e6e1; --muted: #9aa0ad; --line: #2c3341; --accent: #9ab6df; --accent-ink: #0b1020; --cta: #d4383d; --cta-ink: #ffffff; --good: #4ade80; --good-bg: #0f2a1a; --bad: #f87171; --bad-bg: #2f1414; --tip: #2a2410; --warn: #2f1616; --rule: #1f2b3f; --shadow: 0 1px 2px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); line-height: 1.55; font-size: 16px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 2rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1.15rem; }
p { margin: 0 0 .8rem; }
code { font-family: ui-monospace, Menlo, monospace; font-size: .95em; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.lead { font-size: 1.1rem; color: var(--muted); }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.err { color: var(--bad); min-height: 1.2em; font-size: .9rem; }
.note { background: var(--tip); padding: .6rem .8rem; border-radius: 8px; font-size: .85rem; }

/* ---------- barre ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: .6rem 16px; background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-logo { width: 40px; height: 40px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; }
.brand-org { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--red); font-weight: 600; }
.nav a.btn-nav { background: var(--cta) !important; color: var(--cta-ink) !important; }
.footer { display: flex; align-items: center; justify-content: center; gap: .8rem; }
.footer-logo { width: 44px; height: 44px; }
.eyebrow { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--red); font-weight: 700; margin-bottom: .3rem; }
.hero-art { position: relative; }
.hero-logo { width: 150px; display: block; margin: 0 auto .8rem; }
.btn.primary { background: var(--cta); color: var(--cta-ink); border-color: var(--cta); }
.nav { margin-left: auto; display: flex; gap: .2rem; flex-wrap: wrap; }
.nav a { padding: .45rem .75rem; border-radius: 8px; color: var(--ink); font-weight: 500; font-size: .95rem; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--rule); color: var(--accent); }
.nav a.btn-nav { background: var(--accent); color: var(--accent-ink); }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 8px; padding: .3rem .6rem; font-size: 1.2rem; color: var(--ink); }
@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; background: var(--paper); border-bottom: 1px solid var(--line); padding: .5rem 16px 1rem; margin: 0; }
  .nav.open { display: flex; }
}

/* ---------- mise en page ---------- */
.app { max-width: 960px; margin: 0 auto; padding: 1.5rem 16px 4rem; }
.footer { text-align: left; color: var(--muted); font-size: .85rem; padding: 2rem 16px; border-top: 1px solid var(--line); }
.loading { text-align: center; color: var(--muted); padding: 4rem 0; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }
.section-title { margin: 1.5rem 0 .75rem; }
.actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; margin-top: 1rem; }

/* ---------- boutons et formulaires ---------- */
.btn { display: inline-block; padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn.ghost { background: transparent; }
.btn.big { padding: .8rem 1.4rem; font-size: 1.05rem; }
.btn.mini { padding: .25rem .6rem; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: default; }
label { display: block; font-weight: 500; font-size: .9rem; margin-bottom: .8rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input:not([type]) { display: block; width: 100%; margin-top: .3rem; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--ink); font: inherit; }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.auth { max-width: 440px; margin: 1rem auto; }
.auth form .btn { width: 100%; margin-top: .4rem; }
form.inline { display: flex; gap: .5rem; align-items: center; }
form.inline input { width: 90px; margin: 0; }

/* ---------- accueil ---------- */
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 2rem; align-items: center; padding: 2rem 0 2.5rem; }
.hero h1 { font-size: 2.8rem; }
.hero-cta { display: flex; gap: .7rem; flex-wrap: wrap; margin: 1.2rem 0 .6rem; }
.sample { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); font-family: var(--serif); font-size: 1.2rem; transform: rotate(-1.5deg); }
.blank-demo { text-decoration: underline wavy var(--bad); }
.sample-fb { margin-top: .8rem; font-family: var(--sans); font-size: .9rem; background: var(--good-bg); color: var(--good); padding: .5rem .7rem; border-radius: 8px; }
@media (max-width: 720px) { .hero { grid-template-columns: 1fr; } .hero h1 { font-size: 2.1rem; } .hero-art { display: none; } }
.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 2rem; }
.feature { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.feature-ico { font-size: 1.6rem; margin-bottom: .4rem; }
.feature p { font-size: .9rem; color: var(--muted); margin: 0; }
@media (max-width: 900px) { .features { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .features { grid-template-columns: 1fr; } }
.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: .8rem; }
@media (max-width: 900px) { .levels { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .levels { grid-template-columns: 1fr 1fr; } }
.level-card { display: block; background: var(--paper); border: 1px solid var(--line); border-top: 4px solid var(--c); border-radius: var(--radius); padding: 1rem; color: var(--ink); }
.level-card:hover { text-decoration: none; box-shadow: var(--shadow); }
.level-card h3 { font-size: 1.05rem; } .level-card p { font-size: .85rem; color: var(--muted); }
.level-id { font-weight: 700; color: var(--c); font-size: 1.3rem; }
.pricing { margin-top: 2.5rem; }
.price-card { max-width: 520px; margin: 0 auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem; text-align: center; box-shadow: var(--shadow); }
.price { font-family: var(--serif); font-size: 2rem; font-weight: 700; margin: .5rem 0 1rem; } .price span { font-size: 1rem; font-weight: 400; color: var(--muted); }
.price-card ul { text-align: left; padding-left: 1.2rem; margin-bottom: 1.5rem; }

/* ---------- tableau de bord ---------- */
.dash-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.stats { display: flex; gap: .6rem; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: .6rem 1rem; text-align: center; min-width: 92px; }
.stat b { display: block; font-size: 1.5rem; font-family: var(--serif); } .stat span { font-size: .75rem; color: var(--muted); }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: .5rem 0; }
.bar > div { height: 100%; background: var(--c, var(--accent)); border-radius: 99px; transition: width .4s; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 1rem; }
.chip { display: inline-block; padding: .3rem .7rem; border-radius: 99px; background: var(--rule); color: var(--accent); font-size: .85rem; font-weight: 500; }
.chip.mini { padding: .1rem .5rem; font-size: .75rem; }
.chip:hover { text-decoration: none; filter: brightness(.95); }

/* ---------- listes de leçons ---------- */
.level-sec { margin-bottom: 2rem; }
.level-head { margin-bottom: .5rem; }
.badge { display: inline-block; color: #fff; font-family: var(--sans); font-size: .75rem; font-weight: 700; padding: .15rem .5rem; border-radius: 6px; vertical-align: middle; }
.unit { margin: 1rem 0 .3rem; color: var(--muted); font-family: var(--sans); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.lesson-list { list-style: none; margin: 0; padding: 0; }
.lesson-list li a { display: flex; align-items: center; gap: .8rem; padding: .7rem .9rem; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; margin-bottom: .4rem; color: var(--ink); }
.lesson-list li a:hover { text-decoration: none; border-color: var(--accent); }
.lesson-list .num { flex: 0 0 auto; min-width: 26px; height: 26px; padding: 0 .4rem; display: grid; place-items: center; border-radius: 99px; background: var(--rule); color: var(--accent); font-weight: 700; font-size: .8rem; }
.lesson-list .ttl { flex: 1; } .lesson-list .meta { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 99px; background: var(--line); color: var(--muted); }
.pill.ok { background: var(--good-bg); color: var(--good); } .pill.free { background: var(--rule); color: var(--accent); } .pill.soon { opacity: .7; }
.lock { font-size: .9rem; }

/* ---------- leçon ---------- */
.lesson-head { margin-bottom: 1.5rem; } .lesson-head h1 { margin-top: .4rem; }
.lesson-body { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem 1.75rem; margin-bottom: 1.25rem; font-size: 1.05rem; }
.lesson-body > p { font-family: var(--serif); font-size: 1.1rem; }
.lesson-body.locked { max-height: 260px; overflow: hidden; position: relative; }
.lesson-body.locked::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 30%, var(--paper)); }
.blk { border-radius: 10px; padding: 1rem 1.1rem; margin: 1rem 0; }
.blk h3 { margin-bottom: .4rem; } .blk p:last-child { margin: 0; }
.blk.rule { background: var(--rule); border-left: 4px solid var(--accent); }
.blk.tip { background: var(--tip); } .blk.warn { background: var(--warn); }
.blk.tip b, .blk.warn b { display: block; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .3rem; }
.gtable { width: 100%; border-collapse: collapse; font-size: .95rem; }
.gtable th, .gtable td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); }
.gtable th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.gtable.center-t { max-width: 300px; margin: 1rem auto; }
.examples { list-style: none; padding: 0; margin: 0; }
.examples li { padding: .4rem 0; border-bottom: 1px dashed var(--line); }
.examples .fr { font-family: var(--serif); font-size: 1.1rem; display: block; }
.examples .note { font-size: .85rem; color: var(--muted); }
.paywall { border: 2px dashed var(--line); }
.scroll { overflow-x: auto; }

/* ---------- exercices ---------- */
.session-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.counter { font-weight: 700; color: var(--muted); white-space: nowrap; }
.card.ex { position: relative; padding-top: 2.2rem; }
.ex-type { position: absolute; top: .8rem; left: 1.25rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.ex-q { font-family: var(--serif); font-size: 1.3rem; margin: .5rem 0 1rem; }
.ex-q.quote { background: var(--bg); padding: .7rem 1rem; border-radius: 10px; }
.ex-instruction { font-weight: 600; margin-bottom: .3rem; }
.options { display: grid; gap: .5rem; }
.opt, .tok { font: inherit; text-align: left; padding: .6rem .9rem; border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 10px; cursor: pointer; }
.opt:hover, .tok:hover { border-color: var(--accent); }
.opt.sel, .tok.sel { border-color: var(--accent); background: var(--rule); }
.opt.good, .tok.good { border-color: var(--good); background: var(--good-bg); }
.opt.bad, .tok.bad { border-color: var(--bad); background: var(--bad-bg); }
.opt:disabled, .tok:disabled { cursor: default; }
.tokens { display: flex; flex-wrap: wrap; gap: .5rem; }
.tok { font-family: var(--serif); font-size: 1.15rem; padding: .4rem .8rem; }
.order-out { min-height: 54px; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .6rem; border: 1.5px dashed var(--line); border-radius: 10px; margin-bottom: .8rem; }
.order-out.good { border-color: var(--good); background: var(--good-bg); } .order-out.bad { border-color: var(--bad); background: var(--bad-bg); }
.tok.picked { background: var(--rule); border-color: var(--accent); }
.blank { display: inline-block; vertical-align: baseline; }
.blank-input { display: inline-block !important; width: 9ch !important; min-width: 6ch; margin: 0 .2rem !important; padding: .15rem .4rem !important; font-family: var(--serif) !important; font-size: 1.2rem !important; text-align: center; border-radius: 6px !important; }
.free-input { font-family: var(--serif) !important; font-size: 1.15rem !important; }
input.good { border-color: var(--good) !important; background: var(--good-bg) !important; }
input.bad { border-color: var(--bad) !important; background: var(--bad-bg) !important; }
.conj-table { border-collapse: collapse; margin: .5rem 0; }
.conj-table td { padding: .25rem .5rem; } .conj-table td:first-child { font-family: var(--serif); font-size: 1.05rem; white-space: nowrap; }
.conj-table input { margin: 0 !important; padding: .4rem .6rem !important; width: 260px; max-width: 60vw; }
.accent-bar { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .6rem; }
.accent-bar button { font: inherit; font-family: var(--serif); font-size: 1.05rem; width: 36px; height: 34px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 8px; cursor: pointer; }
.accent-bar button:hover { border-color: var(--accent); }
.feedback { display: none; margin-top: 1rem; padding: .9rem 1rem; border-radius: 10px; }
.feedback.show { display: block; }
.feedback.good { background: var(--good-bg); color: var(--good); } .feedback.bad { background: var(--bad-bg); color: var(--bad); }
.feedback p { margin: .3rem 0 0; color: var(--ink); } .feedback .explain { color: var(--ink); opacity: .85; font-size: .95rem; }
.ex-actions { display: flex; gap: .6rem; margin-top: 1rem; }
.result .score { font-family: var(--serif); font-size: 3.2rem; font-weight: 700; color: var(--bad); }
.result .score.ok { color: var(--good); }
.result .big-badge { display: inline-block; padding: .2rem 1.2rem; border-radius: 16px; background: var(--good-bg); }
.mini-ex { position: relative; padding-top: 2rem; }
.mini-ex .explain { color: var(--muted); font-size: .9rem; margin: 0; }
.codes { background: var(--bg); padding: .6rem; border-radius: 8px; font-size: .9rem; min-height: 1.5rem; white-space: pre-wrap; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; font-size: .9rem; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.good { background: var(--good); color: #fff; }

/* ---------- page légale ---------- */
.legal { max-width: 720px; margin: 0 auto; }
.legal h3 { margin-top: 1.4rem; }

/* ---------- nouveaux types d'exercices ---------- */
.ex-q.en { font-style: italic; }
.ex-q.cloze { line-height: 2.2; }
.match-table { border-collapse: collapse; width: 100%; max-width: 520px; }
.match-table td { padding: .35rem .5rem; } .match-table td:first-child { font-family: var(--serif); font-size: 1.1rem; }
.match-table select { width: 100%; padding: .45rem .6rem; border: 1.5px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--ink); font: inherit; }
.match-table select.good { border-color: var(--good); background: var(--good-bg); } .match-table select.bad { border-color: var(--bad); background: var(--bad-bg); }
.match-table .fix { color: var(--good); font-weight: 600; white-space: nowrap; }
.sort-list { display: flex; flex-direction: column; gap: .5rem; }
.sort-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: 10px; }
.sort-word { font-family: var(--serif); font-size: 1.1rem; flex: 1 1 120px; }
.opt.cat { padding: .35rem .7rem; font-size: .9rem; }
