/* DeutschWeg — mobile d'abord, polices système (aucun téléchargement), thème clair/sombre */
:root {
  --bg: #F4F6F5; --surface: #FFFFFF; --ink: #17201C; --muted: #56635D; --line: #D9E1DD;
  --accent: #0E6A56; --accent-ink: #FFFFFF; --soft: #E4F0EC;
  --ok: #1C7A3A; --ok-bg: #E2F3E6; --bad: #B42318; --bad-bg: #FBE7E4;
  --tip: #FFF6D6; --tip-line: #E9C94A;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1412; --surface: #161D1A; --ink: #E5ECE8; --muted: #9AA8A1; --line: #29332F;
    --accent: #4CC3A2; --accent-ink: #0A1310; --soft: #173029;
    --ok: #62D18F; --ok-bg: #15301F; --bad: #FF8B80; --bad-bg: #3A1917;
    --tip: #2B2610; --tip-line: #6E5D1A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1412; --surface: #161D1A; --ink: #E5ECE8; --muted: #9AA8A1; --line: #29332F;
  --accent: #4CC3A2; --accent-ink: #0A1310; --soft: #173029;
  --ok: #62D18F; --ok-bg: #15301F; --bad: #FF8B80; --bad-bg: #3A1917;
  --tip: #2B2610; --tip-line: #6E5D1A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--font); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; text-wrap: balance; }
h1 { font-size: clamp(26px, 6vw, 36px); letter-spacing: -.01em; }
h2 { font-size: 20px; }
h3 { font-size: 18px; }
p { margin: 0 0 .75em; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 80px; outline: none; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.eyebrow { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.lead { font-size: 19px; color: var(--muted); }
.loading { padding: 40px 0; color: var(--muted); }
.ok-text { color: var(--ok); font-weight: 600; }

/* Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-top: max(10px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 18px; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 999px; width: 38px; height: 38px; cursor: pointer; }

/* Cartes et boutons */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 14px 0; scroll-margin-top: 120px; }
.center { text-align: center; padding: 32px 18px; }
.btn {
  display: inline-block; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px;
  padding: 11px 18px; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 44px;
}
.btn.ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.back { display: inline-block; margin: 16px 0 6px; text-decoration: none; font-weight: 600; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 12px; }

/* Accueil */
.hero { padding: 28px 0 8px; }
.levels { display: grid; gap: 12px; }
.level { display: flex; gap: 16px; text-decoration: none; color: var(--ink); margin: 0; transition: border-color .15s; }
.level:hover { border-color: var(--accent); }
.level-badge {
  flex: 0 0 auto; width: 58px; height: 58px; border-radius: 12px; display: grid; place-items: center;
  background: var(--soft); color: var(--accent); font-weight: 800; font-size: 20px;
}
.level-body { min-width: 0; }
.level-body h2 { margin-bottom: 4px; }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; margin: 8px 0 6px; }
.bar span { display: block; height: 100%; background: var(--accent); }

/* Liste des leçons */
.lessons { list-style: none; padding: 0; margin: 16px 0; }
.lesson { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); margin: 10px 0; }
.lesson:hover { border-color: var(--accent); }
.lesson.locked { opacity: .7; }
.lesson-n {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line); font-weight: 700;
}
.st-done .lesson-n { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.st-started .lesson-n { border-color: var(--accent); color: var(--accent); }
.lesson-body { display: grid; gap: 2px; flex: 1; min-width: 0; }
.lesson-tag { font-size: 13px; color: var(--accent); font-weight: 600; }

/* En-tête de leçon et sommaire */
.lesson-head { padding-top: 8px; }
.objectives ul { margin: 0; padding-left: 20px; }
.toc {
  position: sticky; top: var(--head-h, 59px); z-index: 5; display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px;
  margin: 0 -16px; background: var(--bg); border-bottom: 1px solid var(--line); scrollbar-width: none;
}
.toc::-webkit-scrollbar { display: none; }
.toc-item {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.toc-item.t-exercise { border-color: var(--accent); color: var(--accent); }
.audio-bar { margin: 8px 0; }

/* Bouton audio */
.say {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--soft); cursor: pointer; font-size: 17px; line-height: 1;
}
.say:active { transform: scale(.94); }

/* Vocabulaire */
.vocab { list-style: none; padding: 0; margin: 0; }
.vocab li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.vocab li:first-child { border-top: 0; }
.de { font-weight: 650; }
.fr { color: var(--muted); }

/* Dialogue */
.dialogue { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: end; max-width: 92%; }
.line.side-1 { margin-left: auto; }
.line .who { grid-column: 1 / -1; font-size: 13px; color: var(--muted); font-weight: 600; }
.side-1 .who { text-align: right; }
.bubble { background: var(--soft); border-radius: 14px 14px 14px 4px; padding: 10px 12px; }
.side-1 .bubble { background: var(--bg); border: 1px solid var(--line); border-radius: 14px 14px 4px 14px; }
.line.playing .bubble { outline: 2px solid var(--accent); }
.tr { display: none; font-size: 15px; margin-top: 4px; }
.show-tr .tr { display: block; }

/* Texte à lire */
.reading { display: grid; gap: 12px; }
.para { display: flex; gap: 12px; align-items: flex-start; }
.para p { margin: 0; }
.de-text { line-height: 1.7; }
.reading .tr { margin-top: 4px; }

/* Grammaire */
.prose ul { padding-left: 20px; }
.prose .ex { background: var(--soft); border-radius: 8px; padding: 8px 12px; }
.table-wrap { overflow-x: auto; margin: 12px 0; }
table { border-collapse: collapse; width: 100%; font-size: 16px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th { color: var(--muted); font-size: 14px; }
tbody th { font-weight: 600; color: var(--muted); }
td b { color: var(--accent); }
.tips { background: var(--tip); border-left: 4px solid var(--tip-line); border-radius: 8px; padding: 10px 14px; margin-top: 12px; }
.tips-title { font-weight: 700; margin-bottom: 4px; }
.tips ul { margin: 0; padding-left: 18px; }
.tips li { margin: 4px 0; }
.culture { border-left: 4px solid var(--accent); }

/* Alphabet et nombres */
.letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; margin: 12px 0; }
.letter { aspect-ratio: 1; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; font-size: 20px; font-weight: 700; cursor: pointer; }
.numbers { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin: 12px 0; }
.number { display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.number .n { font-weight: 800; color: var(--accent); min-width: 22px; flex: 0 0 auto; }
.number span[lang] { min-width: 0; overflow-wrap: anywhere; hyphens: auto; }
.de, .de-text, .chip, legend { overflow-wrap: break-word; hyphens: auto; }

/* Exercices */
.exercise { border-top: 4px solid var(--accent); }
.items { display: grid; gap: 12px; margin: 12px 0; }
.item { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0; min-width: 0; }
.item.ok { border-color: var(--ok); background: var(--ok-bg); }
.item.bad { border-color: var(--bad); background: var(--bad-bg); }
fieldset.item legend { float: left; width: 100%; font-weight: 600; margin-bottom: 8px; padding: 0; }
.opts { clear: both; display: grid; gap: 6px; }
.opt { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.opt input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.opt.is-answer { border-color: var(--ok); font-weight: 600; }
.opt.is-wrong { border-color: var(--bad); text-decoration: line-through; }
.gap { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.gap input { width: 9em; max-width: 100%; padding: 6px 10px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); }
.gap .num { color: var(--muted); }
.fix { flex-basis: 100%; font-size: 15px; color: var(--bad); margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 44px; }
.chips.line { border-bottom: 2px dashed var(--line); padding-bottom: 8px; margin-bottom: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 12px; cursor: pointer; min-height: 38px; }
.chips.line .chip { background: var(--soft); border-color: var(--accent); }
.match { display: grid; gap: 6px; }
.match .left { font-weight: 600; }
.match select { padding: 8px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); width: 100%; }
.listen-q { clear: both; display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.transcript { margin: 8px 0 0; color: var(--muted); }
.write { display: grid; gap: 10px; }
.write textarea { width: 100%; padding: 10px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); font: inherit; resize: vertical; }
.model { background: var(--tip); border-left: 4px solid var(--tip-line); border-radius: 8px; padding: 10px 14px; }
.model p { margin: 0 0 6px; }
.pre { white-space: pre-line; }
.crit { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.crit input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--accent); flex: 0 0 auto; }
.item[hidden] { display: none; }
.ex-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.result { margin: 0; font-weight: 600; }
.summary { border: 2px solid var(--accent); }

@media (min-width: 640px) {
  .match { grid-template-columns: 1fr 1fr; align-items: center; }
  .match .fix { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* Accès et paiement */
.top-actions { display: flex; align-items: center; gap: 10px; }
.access-link { font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.lang-select { font: inherit; font-size: 13px; font-weight: 600; padding: 4px 6px; border: 1.5px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--ink); cursor: pointer; }
.bad-text { color: var(--bad); font-weight: 600; }
.unlock { display: grid; gap: 8px; }
.unlock-row { display: flex; gap: 8px; flex-wrap: wrap; }
.unlock-row input { flex: 1 1 200px; min-width: 0; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--surface); font-family: ui-monospace, Consolas, monospace; letter-spacing: .05em; text-transform: uppercase; }
.steps { padding-left: 20px; margin: 0; display: grid; gap: 8px; }
.steps ul { margin: 4px 0 0; padding-left: 18px; }
.access-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }

/* Questions fréquentes, pages juridiques, pied de page */
.faq { display: grid; gap: 8px; }
.faq details { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; background: var(--bg); }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 0; color: var(--muted); }
.legal h1 { font-size: 26px; }
.legal h2 { font-size: 18px; margin-top: 1.2em; }
.legal ul { padding-left: 20px; }
.site-footer { max-width: 760px; margin: 0 auto; padding: 8px 16px 40px; text-align: center; font-size: 14px; color: var(--muted); }
.site-footer a { color: var(--muted); }

/* Carte « Installer l'application » */
.install-card { border-color: var(--accent); }
.install-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.install-actions p { margin: 0; flex-basis: 100%; }
.install-manual { background: var(--tip); border: 1px solid var(--tip-line); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 15px; }
.install-manual ul { margin: 6px 0 0; padding-left: 18px; }
.install-manual[hidden] { display: none; }

/* ---------- Apprentissage en autonomie ---------- */
.vocab-btns, .line-btns { display: flex; flex-direction: column; gap: 6px; }
.say.mic { font-size: 18px; }
.say.mic.listening { background: var(--bad); border-color: var(--bad); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .say.mic.listening { animation: none; } }
.pron { margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: var(--soft); font-size: 15px; }
.pron[hidden] { display: none; }
.pron-words { margin: 0 0 2px; font-size: 17px; }
.w-ok { color: var(--ok); font-weight: 600; }
.w-bad { color: var(--bad); font-weight: 600; text-decoration: underline wavy; text-underline-offset: 3px; }

.placement-cta { margin-top: 12px; display: inline-block; }
.coach .goal-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.coach-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.coach-actions .btn { padding: 9px 14px; font-size: 15px; }
.goal .goal-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }

.review-card { text-align: center; }
.review-card .bar { margin: 6px 0 18px; }
.rv-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.rv-de { font-size: 26px; font-weight: 700; }
.rv-tr { font-size: 22px; font-weight: 600; color: var(--accent); }
.rv-answer { margin-top: 16px; }
.rv-answer[hidden] { display: none; }
.rv-grade { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.rv-grade .btn { min-width: 140px; }
.review-card > .btn { margin-top: 18px; }
.err-lesson { font-size: 18px; margin: 26px 0 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 14px 0; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi .v { font-size: 22px; font-weight: 700; }
.kpi .l { font-size: 13px; color: var(--muted); }
.days-chart { position: relative; display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; height: 140px; padding-bottom: 20px; }
.days-chart .day { position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.days-chart .col { width: 100%; max-width: 22px; background: var(--line); border-radius: 4px 4px 0 0; }
.days-chart .col.hit { background: var(--accent); }
.days-chart .d { position: absolute; bottom: -20px; font-size: 11px; color: var(--muted); }
.days-chart .goal-line { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--tip-line); margin-bottom: 20px; z-index: 1; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.badge { display: grid; gap: 2px; justify-items: center; text-align: center; padding: 12px 8px; border: 1px dashed var(--line); border-radius: 12px; opacity: .5; filter: grayscale(1); }
.badge.got { opacity: 1; filter: none; border-style: solid; border-color: var(--accent); background: var(--soft); }
.badge .bi { font-size: 28px; }

.placement .pq { font-size: 20px; margin: 10px 0 12px; }
.placement .opt.dont-know span { color: var(--muted); font-style: italic; }
.pl-level { font-size: 44px; margin: 0 0 6px; color: var(--accent); }
.pl-bars { display: grid; gap: 8px; margin-top: 12px; }
.pl-bars .bar-row { display: grid; grid-template-columns: 40px 1fr 50px; gap: 10px; align-items: center; }
.pl-bars .bar { margin: 0; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 30px); opacity: 0; z-index: 50;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 15px;
  box-shadow: 0 6px 24px rgb(0 0 0 / .25); transition: opacity .25s, transform .25s; max-width: calc(100vw - 32px); text-align: center; }
.toast.in { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Navigation principale ---------- */
/* Téléphone : barre fixe en bas de l'écran (facile à atteindre avec le pouce) */
.mainnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -2px 12px rgb(0 0 0 / .08);
  padding: 4px 2px calc(4px + env(safe-area-inset-bottom)); }
body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.nav-item { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px;
  border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; }
.nav-item .ni { position: relative; font-size: 21px; line-height: 1; }
.nav-item .nl { display: none; }
.nav-item .ns { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item.active { color: var(--accent); background: var(--soft); }
.nav-item .nc { position: absolute; top: -6px; right: -12px; min-width: 18px; padding: 1px 5px; border-radius: 99px;
  background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; line-height: 1.3; text-align: center; }
.nav-title, .nav-level { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.toast { bottom: calc(76px + env(safe-area-inset-bottom)); }

/* Grand écran : barre latérale à gauche */
@media (min-width: 960px) {
  :root { --side-w: 240px; }
  body { padding-bottom: 0; }
  .toast { bottom: 20px; }
  .mainnav { position: fixed; top: var(--head-h, 59px); left: 0; right: auto; bottom: 0; width: var(--side-w); margin: 0; padding: 16px 12px 24px;
    flex-direction: column; justify-content: flex-start; gap: 2px; overflow-y: auto; overflow-x: hidden; background: var(--surface);
    border-top: 0; border-right: 1px solid var(--line); box-shadow: none; }
  .nav-item { flex: none; flex-direction: row; align-items: center; gap: 8px; border: 0; border-radius: 10px; padding: 9px 12px;
    background: none; color: var(--ink); font-size: 15px; white-space: normal; }
  .nav-item .ni { display: contents; font-size: 15px; filter: none; }
  .nav-item .nl { display: inline; }
  .nav-item .ns { display: none; }
  .nav-item .nc { position: static; margin-left: auto; order: 3; }
  .nav-item:hover { background: var(--soft); }
  .nav-item.active { background: var(--soft); color: var(--accent); }
  .nav-item.active .nc { background: var(--bad); color: #fff; }
  .nav-item .nc { margin-left: auto; }
  .nav-title { display: block; margin: 16px 12px 4px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .nav-level { display: flex; font-weight: 500; }
  .nav-level .ni b { display: inline-block; min-width: 30px; padding: 2px 0; border-radius: 6px; background: var(--soft); color: var(--accent); font-size: 12px; text-align: center; }
  .nav-level.active .ni b { background: var(--accent); color: var(--accent-ink); }
  .wrap, .site-footer { margin-left: calc(var(--side-w) + max(0px, (100vw - var(--side-w) - 760px) / 2)); }
}
