:root {
  --stone: #eef0ec;      /* fond : pierre claire */
  --slab: #ffffff;       /* surfaces */
  --ink: #1f2a2e;        /* texte */
  --muted: #5b6862;      /* texte secondaire */
  --line: #d3d8d1;       /* filets */
  --sorgho: #a8551c;     /* accent : sorgho mûr */
  --sorgho-soft: #f4e3d4;
  --ok: #2f6b3f;  --ok-soft: #dcebdc;
  --warn: #8a6a00; --warn-soft: #f5ecc8;
  --bad: #a3322a;  --bad-soft: #f6dcd8;
  --kb: "Charis SIL", "Gentium Plus", "Noto Serif", Georgia, serif;
  --ui: "Noto Sans", "Segoe UI", system-ui, sans-serif;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --stone: #161c1d; --slab: #1f2729; --ink: #e8ece8; --muted: #a2ada7; --line: #34403f;
    --sorgho: #e39a5c; --sorgho-soft: #3a2a1d;
    --ok: #8fcf9c; --ok-soft: #1f3526; --warn: #e2c25a; --warn-soft: #3a321a; --bad: #f0958b; --bad-soft: #42221f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --stone: #161c1d; --slab: #1f2729; --ink: #e8ece8; --muted: #a2ada7; --line: #34403f;
  --sorgho: #e39a5c; --sorgho-soft: #3a2a1d;
  --ok: #8fcf9c; --ok-soft: #1f3526; --warn: #e2c25a; --warn-soft: #3a321a; --bad: #f0958b; --bad-soft: #42221f;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--stone); color: var(--ink); font-family: var(--ui); font-size: 16px; line-height: 1.5; }
.wrap { max-width: 400px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column;
  padding: 0 max(16px, env(safe-area-inset-left, 0px)) 24px max(16px, env(safe-area-inset-right, 0px)); }
header { padding-block: max(16px, env(safe-area-inset-top, 0px)) 0; }
.terraces { display: grid; gap: 3px; margin-bottom: 12px; }
.terraces span { display: block; height: 5px; background: var(--sorgho); border-radius: 2px; opacity: .85; }
.terraces span:nth-child(2) { width: 82%; opacity: .6; }
.terraces span:nth-child(3) { width: 61%; opacity: .4; }
.terraces span:nth-child(4) { width: 38%; opacity: .25; }
h1 { font-family: var(--kb); font-size: 1.6rem; line-height: 1.1; margin: 0; }
.kb { font-family: var(--kb); }
nav { display: flex; gap: 4px; margin-block: 14px; }
nav a { flex: 1 1 0; min-height: 44px; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 4px 2px; font: 500 .78rem var(--ui); line-height: 1.1; border-radius: 10px; border: 1px solid var(--line);
  background: var(--slab); color: var(--ink); text-decoration: none; }
nav a[aria-current="page"] { background: var(--ink); color: var(--stone); border-color: var(--ink); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--sorgho); outline-offset: 2px; }
#banner { margin-bottom: 10px; }
#banner:empty { display: none; }
.banner { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); border-radius: var(--r); padding: 10px 12px; font-size: .9rem; }
main { flex: 1 1 auto; }
.panel { background: var(--slab); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 12px; }
.muted { color: var(--muted); }
.btn { min-height: 44px; min-width: 44px; font: 500 1rem var(--ui); padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--slab); color: var(--ink); cursor: pointer; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--sorgho); border-color: var(--sorgho); color: var(--slab); }
.btn.again { border-color: var(--bad); color: var(--bad); }
.btn.hard { border-color: var(--warn); color: var(--warn); }
.btn.good { border-color: var(--ok); color: var(--ok); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
input[type="text"], input[type="search"], input[type="password"], select, textarea {
  min-height: 44px; font: 1rem var(--ui); padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--slab); color: var(--ink); max-width: 100%; }
footer#status { margin-top: 16px; padding-bottom: env(safe-area-inset-bottom, 0px); font-size: .8rem; color: var(--muted); }
.tonight, .block-card, .session-error { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 12px 0; }
.block-card .countdown { font: 600 2rem var(--ui); font-variant-numeric: tabular-nums; margin: 0; }
.session-bar { display: flex; justify-content: flex-end; padding-bottom: 8px; }
.session-msg { margin: 0; font-size: 1.05rem; }

/* Feedback panel (Task 7). Colours show agreement with the speech model, never tones. */
.feedback { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 12px 0; }
.fb-target { font-size: 1.5rem; margin: 0; }
.mk-green { color: var(--ok); }
.mk-orange { color: var(--warn); }
.mk-red { color: var(--bad); }
.mk-none { color: var(--ink); }
.fb-heard, .fb-note { margin: 0; }
.badge { display: inline-block; font-size: .8rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.low-confidence { border-color: var(--warn); color: var(--warn); }
.fb-pitch { width: 100%; }
.pitch-canvas { width: 100%; max-width: 640px; height: auto; background: var(--slab); border: 1px solid var(--line); border-radius: var(--r); }

/* Free sentence screen (step 9) */
.free-assembled .uncovered { text-decoration: underline; text-decoration-style: wavy; }
.free-suggestions { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.75rem 0; }
.free-suggestion .tag { font-size: 0.75em; opacity: 0.7; border: 1px solid currentColor; border-radius: 0.5em; padding: 0 0.4em; }
.free-input { width: 100%; box-sizing: border-box; padding: 0.6rem; font: inherit; margin-bottom: 0.5rem; }
.free-pieces, .free-matches { padding-left: 1.2rem; }

/* Progress screen (Task 14) */
.progress-section h3 { margin: 0 0 8px; }
.streak-value { font: 600 1.4rem var(--ui); margin: 0; }
.bands { display: grid; gap: 12px; margin: 12px 0; }
.band-fig { margin: 0; }
.band-fig figcaption { font-size: .9rem; color: var(--muted); }
svg.band { width: 100%; max-width: 480px; height: auto; background: var(--slab); border: 1px solid var(--line); border-radius: var(--r); }
svg.band .baseline { fill: var(--line); opacity: .45; }
svg.band .baseline-label { fill: var(--muted); font-size: 9px; }
svg.band polyline.raw { stroke: var(--sorgho); stroke-width: 2; }
svg.band polyline.avg { stroke: var(--ok); stroke-width: 2; stroke-dasharray: 4 3; }
svg.band .raw-dot { fill: var(--sorgho); }
svg.band .avg-dot { fill: var(--ok); }
.step-bar { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.step-name { flex: 0 0 11rem; font-size: .9rem; }
.step-fill { height: 12px; background: var(--sorgho); border-radius: 6px; min-width: 2px; }
.step-count { font-variant-numeric: tabular-nums; }
.anchor, .archive-pair, .archive-item { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.archive-items { list-style: none; padding: 0; margin: 0 0 12px; }
.progress audio { width: 100%; max-width: 420px; }

/* Settings screen (Task 15) */
.settings { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.set-field { display: flex; flex-direction: column; gap: 4px; }
.set-note, .set-import-msg { margin: 0; color: var(--muted); }
.set-import { display: flex; flex-direction: column; gap: 6px; }

/* Lessons, dictionary and keyboard (Task 16) */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.filters label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.filters input, .filters select { flex: 1 1 8rem; min-width: 0; }
.note { color: var(--muted); font-size: .9rem; }
.keys { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.keys button { font: 1.25rem var(--kb); width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--slab); color: var(--ink); cursor: pointer; }
.lex, .dico-list { list-style: none; padding: 0; margin: 0; display: grid; }
.lex li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.lex .kb { font-size: 1.15rem; font-weight: 700; overflow-wrap: anywhere; }
.lex .note { grid-column: 1 / -1; font-size: .82rem; margin-top: -6px; }
.badge.c-haute { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.c-moyenne { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.c-basse { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.legend { font-size: .85rem; color: var(--muted); margin-top: 18px; display: grid; gap: 4px; }
.play { font: 500 .85rem var(--ui); display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--sorgho); background: var(--sorgho-soft); color: var(--sorgho); cursor: pointer; }
.play.small { padding: 3px 9px; font-size: .75rem; }
.play svg { width: 10px; height: 10px; fill: currentColor; }
.figure { display: inline-flex; flex-wrap: wrap; align-items: flex-end; gap: 0 1px; font-size: 1.05rem; padding-top: .35em; }
.figure .syl { padding: 0 1px; }
.figure .syl.hi { color: var(--sorgho); font-weight: 700; transform: translateY(-.35em); }
.figure .sep { color: var(--muted); }
.figure .gap { width: .6em; }
.phon { font-family: var(--kb); color: var(--muted); font-size: .95rem; }
.dico-list > li { display: grid; gap: 6px; padding: 14px 2px; border-bottom: 1px solid var(--line); min-width: 0; }
.dico-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.dico-head .kb { font-size: 1.3rem; font-weight: 700; overflow-wrap: anywhere; }
.pos { font-size: .78rem; color: var(--muted); font-style: italic; }
.senses { margin: 0; overflow-wrap: anywhere; }
.examples { list-style: none; margin: 0; padding: 0 0 0 12px; border-left: 2px solid var(--sorgho-soft); display: grid; gap: 4px; font-size: .9rem; }
.examples .kb { font-weight: 700; }
.linkish { background: none; border: 0; padding: 0; color: var(--sorgho); font: inherit; text-decoration: underline; cursor: pointer; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }
