/* Mise en page : feuille de cahier (réglure Seyès) sur fond bleu pâle, navigation en haut, cartes en grille. */
:root {
  --bg: #EEF3FA;
  --surface: #FFFFFF;
  --ink: #1B2540;
  --muted: #55627F;
  --line: #D5DEEE;
  --accent: #3556E0;
  --accent-ink: #FFFFFF;
  --accent-soft: #E3E9FD;
  --red: #B8352F;
  --red-soft: #FCE9E8;
  --green: #17734B;
  --green-soft: #DDF3E8;
  --amber: #7A4F00;
  --amber-soft: #FFF1D1;
  --seyes: #CBD8F2;
  --margin: #F0A5A1;
  --font-display: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1527; --surface: #182038; --ink: #E8EDFA; --muted: #A3AFCB; --line: #2B3656;
    --accent: #8FA6FF; --accent-ink: #0F1527; --accent-soft: #222E57;
    --red: #FF9A94; --red-soft: #3A1F26; --green: #6FD6A4; --green-soft: #17352A;
    --amber: #F2C36B; --amber-soft: #382C10; --seyes: #27325A; --margin: #6A3B44;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1527; --surface: #182038; --ink: #E8EDFA; --muted: #A3AFCB; --line: #2B3656;
  --accent: #8FA6FF; --accent-ink: #0F1527; --accent-soft: #222E57;
  --red: #FF9A94; --red-soft: #3A1F26; --green: #6FD6A4; --green-soft: #17352A;
  --amber: #F2C36B; --amber-soft: #382C10; --seyes: #27325A; --margin: #6A3B44;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 17px; line-height: 1.55;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  background: var(--surface); z-index: 30;
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(1.7rem, 5vw, 2.4rem); font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; font-weight: 750; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[tabindex="-1"]:focus { outline: none; }

.wrap {
  width: 100%; max-width: 960px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---- En-tête ---- */
.site-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; flex-wrap: wrap; }
.brand { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); position: relative; flex: none; overflow: hidden; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: var(--accent-ink); opacity: .55; }
.brand-mark::before { top: 9px; } .brand-mark::after { top: 17px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 10px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: .95rem; min-height: 44px; display: inline-flex; align-items: center; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

.preview-bar { background: var(--amber-soft); color: var(--amber); border-bottom: 1px solid var(--line); font-size: .9rem; }
.preview-bar .wrap { padding-top: 8px; padding-bottom: 8px; }

main { padding-block: 28px 56px; display: block; }
.site-footer { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .9rem; }
.site-footer .wrap { padding-top: 18px; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 8px 20px; flex-wrap: wrap; justify-content: space-between; }

.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.crumbs a { color: var(--muted); }
.stack { display: grid; gap: 20px; }
.stack-lg { display: grid; gap: 32px; }
.lead { color: var(--muted); font-size: 1.1rem; max-width: 60ch; }

/* ---- Boutons ---- */
.btn {
  appearance: none; border: 2px solid var(--accent); background: transparent; color: var(--accent);
  font: inherit; font-weight: 700; padding: 10px 18px; min-height: 48px; border-radius: 12px;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
}
.btn:hover { background: var(--accent-soft); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- Cartes & badges ---- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 8px; align-content: start; min-width: 0; }
a.card { text-decoration: none; color: inherit; }
a.card:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(53, 86, 224, .12); }
.card.off { background: transparent; border-style: dashed; color: var(--muted); }
.card .big { font-family: var(--font-display); font-size: 2.2rem; font-weight: 800; line-height: 1; }
.badge { display: inline-flex; align-items: center; font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); width: fit-content; letter-spacing: .02em; }
.badge.draft { background: var(--amber-soft); color: var(--amber); }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.soon { background: var(--line); color: var(--muted); }
.badge.ia { background: var(--amber-soft); color: var(--amber); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

/* ---- Accueil ---- */
.hero { display: grid; gap: 18px; padding: 8px 0 8px; }
.hero h1 { max-width: 18ch; }
.free-tag { display: inline-block; background: var(--green-soft); color: var(--green); font-weight: 800; padding: 4px 12px; border-radius: 99px; font-size: .9rem; width: fit-content; }
.how { counter-reset: none; }

/* ---- Onglets de chapitre ---- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 24px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.tabs a { flex: 1 1 auto; text-align: center; padding: 10px 12px; min-height: 44px; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 650; font-size: .95rem; display: inline-flex; justify-content: center; align-items: center; }
.tabs a:hover { background: var(--accent-soft); }
.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }

/* ---- Cours ---- */
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px; display: grid; gap: 28px; }
.sec { display: grid; gap: 14px; scroll-margin-top: 90px; }
.sec h2 { padding-bottom: 6px; border-bottom: 2px solid var(--accent-soft); }
.label { font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.def { background: var(--accent-soft); border-radius: 12px; padding: 16px 18px; display: grid; gap: 6px; }
.def .label { color: var(--accent); }
.def .main { font-weight: 650; font-size: 1.1rem; }
.tip { background: var(--amber-soft); color: var(--ink); border-radius: 12px; padding: 14px 18px; display: grid; gap: 4px; }
.tip .label { color: var(--amber); }
.examples { display: grid; gap: 8px; padding: 12px 14px 12px 58px; border-radius: 12px; border: 1px solid var(--line);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, var(--seyes) 31px, var(--seyes) 32px);
  background-position: 0 6px; position: relative; }
.examples::before { content: ""; position: absolute; top: 0; bottom: 0; left: 40px; width: 2px; background: var(--margin); }
.examples .label { color: var(--muted); margin-left: -44px; }
.ex { line-height: 32px; min-height: 32px; }
.ex .phrase { font-style: italic; font-weight: 700; }
.ex .note { color: var(--muted); }
.types { display: grid; gap: 12px; }
.type-row { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 6px; }
.type-row h3 { color: var(--accent); }
.type-row .ex { line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.chips li { background: var(--accent-soft); color: var(--accent); font-weight: 750; padding: 6px 14px; border-radius: 99px; }
.steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: start; }
.steps li::before { content: counter(s); background: var(--accent); color: var(--accent-ink); font-weight: 800; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); }
.suggest { border: 2px dashed var(--amber); background: var(--amber-soft); border-radius: 12px; padding: 14px 18px; display: grid; gap: 6px; font-size: .95rem; }
.suggest .label { color: var(--amber); }
.objectives { margin: 0; padding-left: 1.2rem; display: grid; gap: 4px; }
.summary-box { background: var(--green-soft); border-radius: 12px; padding: 16px 18px; display: grid; gap: 8px; }
.summary-box ul { margin: 0; padding-left: 1.2rem; display: grid; gap: 4px; }
.chapter-nav { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.two { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }

/* ---- Tableaux de conjugaison ---- */
.conj { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.conj-col { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.conj-col h3 { background: var(--accent-soft); color: var(--accent); padding: 8px 12px; }
.conj-col ul { list-style: none; margin: 0; padding: 4px 0; }
.conj-col li { padding: 4px 12px; border-top: 1px solid var(--line); }
.conj-col li:first-child { border-top: 0; }

/* ---- Fiche mémo ---- */
.memo { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.memo .card ul, .memo .card ol { margin: 0; padding-left: 1.2rem; display: grid; gap: 4px; }
.memo .card .ex { line-height: 1.5; }
.errors { background: var(--red-soft); border-radius: var(--radius); padding: 18px; display: grid; gap: 8px; }
.errors h2 { color: var(--red); }
.errors ul { margin: 0; padding-left: 1.2rem; display: grid; gap: 6px; }

/* ---- Flashcards ---- */
.fc-wrap { display: grid; gap: 16px; max-width: 640px; margin: 0 auto; }
.progress { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .25s; }
.fc-meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-weight: 650; font-size: .95rem; }
.fcard {
  appearance: none; width: 100%; min-height: 260px; padding: 28px 22px; text-align: center; font: inherit; color: var(--ink);
  background: var(--surface); border: 2px solid var(--line); border-radius: 18px; cursor: pointer;
  display: grid; align-content: center; justify-items: center; gap: 12px;
}
.fcard:hover { border-color: var(--accent); }
.fcard .side { font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.fcard.back { background: var(--accent-soft); border-color: var(--accent); }
.fcard .txt { font-family: var(--font-display); font-size: clamp(1.15rem, 4.5vw, 1.5rem); font-weight: 700; text-wrap: balance; }
.fcard.back .txt { font-weight: 600; font-size: clamp(1.05rem, 4vw, 1.3rem); }
.fcard .hint { color: var(--muted); font-size: .9rem; }
.fc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-know { border-color: var(--green); color: var(--green); }
.btn-know:hover { background: var(--green-soft); }
.btn-again { border-color: var(--red); color: var(--red); }
.btn-again:hover { background: var(--red-soft); }
.btn-know.on { background: var(--green); color: var(--accent-ink); }
.btn-again.on { background: var(--red); color: var(--accent-ink); }
.fc-nav { display: flex; justify-content: space-between; gap: 10px; }

/* ---- Quiz ---- */
.quiz { max-width: 720px; margin: 0 auto; display: grid; gap: 16px; }
.qcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px; display: grid; gap: 16px; }
.qcard h2 { font-size: 1.25rem; }
.opts { display: grid; gap: 10px; border: 0; padding: 0; margin: 0; min-width: 0; }
.opt { display: flex; gap: 12px; align-items: center; padding: 12px 14px; min-height: 52px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--surface); }
.opt:hover { border-color: var(--accent); }
.opt input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 0; }
.opt.ok { border-color: var(--green); background: var(--green-soft); }
.opt.ko { border-color: var(--red); background: var(--red-soft); }
.field { font: inherit; padding: 12px 14px; min-height: 52px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); width: 100%; }
.field.ok { border-color: var(--green); background: var(--green-soft); }
.field.ko { border-color: var(--red); background: var(--red-soft); }
.tokens { display: flex; flex-wrap: wrap; gap: 8px; }
.tok { font: inherit; font-weight: 650; padding: 8px 14px; min-height: 48px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.tok[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.tok.ok { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.tok.ko { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.matchrow { display: grid; gap: 6px; }
.matchrow label { font-weight: 700; }
.matchrow select { font: inherit; padding: 10px; min-height: 48px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); width: 100%; }
.matchrow select.ok { border-color: var(--green); background: var(--green-soft); }
.matchrow select.ko { border-color: var(--red); background: var(--red-soft); }
.feedback { border-radius: 12px; padding: 14px 16px; display: grid; gap: 8px; }
.feedback.ok { background: var(--green-soft); }
.feedback.ko { background: var(--red-soft); }
.feedback .ttl { font-weight: 800; font-family: var(--font-display); }
.feedback.ok .ttl { color: var(--green); }
.feedback.ko .ttl { color: var(--red); }
.score { font-family: var(--font-display); font-size: 3rem; font-weight: 800; line-height: 1; }
.notion-list { display: grid; gap: 8px; list-style: none; padding: 0; margin: 0; }
.notion-list li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 10px; background: var(--bg); }

@media (min-width: 700px) { .sheet { padding: 32px 36px; } .qcard { padding: 28px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

@media print {
  body::before, .site-header, .site-footer, .tabs, .no-print, .preview-bar { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .card, .errors { border: 1px solid #999; break-inside: avoid; background: #fff; }
  main { padding: 0; }
}
