/* Coach TCF Canada — feuille de style unique (pas d'étape de compilation). */
:root {
  --brand: #b03a2e;
  --brand-strong: #8e2c22;
  --brand-soft: #fbeceA;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --border: #e4e1dc;
  --text: #1f1d1a;
  --muted: #6b665f;
  --ok: #1f7a4d;
  --ok-soft: #e5f4ec;
  --warn: #a35d00;
  --warn-soft: #fdf2e0;
  --err: #b42318;
  --err-soft: #fdecea;
  --info: #1f5fa8;
  --info-soft: #e8f0fb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 18, 15, .06), 0 2px 8px rgba(20, 18, 15, .04);
  /* Atkinson Hyperlegible : conçue pour la lisibilité (accents, l / I / 1 bien distincts). */
  --font: "Atkinson Hyperlegible Next", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
/* Thème sombre : automatique (réglage de l'appareil) sauf choix « clair » ;
   forcé quand le candidat choisit « sombre » (attribut data-theme sur <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #e0685a;
    --brand-strong: #f08476;
    --brand-soft: #3a1f1b;
    --bg: #151413;
    --surface: #1e1c1a;
    --surface-2: #242220;
    --border: #35322e;
    --text: #eeebe6;
    --muted: #a39d94;
    --ok: #5cc48d;
    --ok-soft: #173326;
    --warn: #e6a650;
    --warn-soft: #362a17;
    --err: #f07a6e;
    --err-soft: #3a1c19;
    --info: #79aef0;
    --info-soft: #18263a;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #e0685a;
  --brand-strong: #f08476;
  --brand-soft: #3a1f1b;
  --bg: #151413;
  --surface: #1e1c1a;
  --surface-2: #242220;
  --border: #35322e;
  --text: #eeebe6;
  --muted: #a39d94;
  --ok: #5cc48d;
  --ok-soft: #173326;
  --warn: #e6a650;
  --warn-soft: #362a17;
  --err: #f07a6e;
  --err-soft: #3a1c19;
  --info: #79aef0;
  --info-soft: #18263a;
  --shadow: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); }
a { color: var(--brand); }
a:hover { color: var(--brand-strong); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; margin-top: 1.6em; }
h3 { font-size: 1.08rem; margin-top: 1.2em; }
p { margin: 0 0 1em; }
img, svg { max-width: 100%; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2;
        stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* --- Mise en page --------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px;
           position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 700; color: var(--text);
         text-decoration: none; padding: 4px 10px 18px; line-height: 1.2; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff;
              display: grid; place-items: center; font-size: 15px; font-weight: 800; flex: none; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: .78rem; }
.nav-group { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
             margin: 16px 10px 6px; font-weight: 600; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px;
         color: var(--text); text-decoration: none; font-size: .95rem; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid var(--border); font-size: .88rem; }
.sidebar-foot .who { font-weight: 600; }
.sidebar-foot .mail { color: var(--muted); word-break: break-all; }
.main { padding: 32px clamp(16px, 4vw, 48px) 64px; min-width: 0; }
.container { max-width: 980px; margin: 0 auto; }
.topbar { display: none; }
.backdrop { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40; transform: translateX(-100%);
             transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; }
  .backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface);
            border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
  .topbar .brand { padding: 0; }
  .main { padding: 20px 16px 48px; }
}

/* --- Composants -------------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between;
             margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 70ch; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card > :last-child { margin-bottom: 0; }
.card-title { font-size: 1rem; font-weight: 700; margin: 0 0 10px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px;
       border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
       font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none;
       transition: background .15s, border-color .15s; min-height: 42px; }
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--err); }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: .88rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.htmx-request { opacity: .55; cursor: not-allowed; }
.icon-btn { background: none; border: 0; padding: 6px; color: var(--text); cursor: pointer; border-radius: 8px; }
.inline { display: inline; }

.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.metric .label { font-size: .82rem; color: var(--muted); }
.metric .value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.metric .sub { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.delta-up { color: var(--ok); font-weight: 600; font-size: .9rem; }
.delta-down { color: var(--err); font-weight: 600; font-size: .9rem; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 600;
         padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
         color: var(--muted); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-err { background: var(--err-soft); color: var(--err); border-color: transparent; }
.badge-brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

.alert { border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; border: 1px solid transparent; }
.alert > :last-child { margin-bottom: 0; }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert-success { background: var(--ok-soft); color: var(--ok); }
.alert-warning { background: var(--warn-soft); color: var(--warn); }
.alert-error { background: var(--err-soft); color: var(--err); }
.alert a { color: inherit; font-weight: 600; }

/* Formulaires */
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 10px 12px; min-height: 44px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.field { margin-bottom: 14px; }
.field .field-help { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.field .errorlist { list-style: none; padding: 0; margin: 6px 0 0; color: var(--err); font-size: .86rem; }
.errorlist.nonfield { background: var(--err-soft); padding: 10px 14px; border-radius: 9px; color: var(--err); list-style: none; }
textarea.writing { min-height: 340px; line-height: 1.7; font-size: 1.02rem; resize: vertical; }
input[type=range] { width: 100%; accent-color: var(--brand); }

/* Sujet, chrono, compteur */
.subject { background: var(--info-soft); color: var(--text); border-left: 4px solid var(--info);
           border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.subject .consigne { font-size: 1.04rem; }
.doc { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-top: 10px; }
.doc .doc-head { font-weight: 700; }
.doc .doc-author { font-style: italic; color: var(--muted); font-size: .9rem; margin-bottom: 4px; }
.timer { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem;
         transition: background .4s, color .4s, box-shadow .4s;
         color: var(--brand); font-variant-numeric: tabular-nums; background: var(--brand-soft);
         padding: 6px 14px; border-radius: 999px; }
.timer.over { color: #fff; background: var(--err); }
.sticky-bar { position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 10px 0; margin-bottom: 6px;
              display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
@media (max-width: 900px) { .sticky-bar { top: 57px; } }
.wordcount { font-weight: 700; }
.wordcount.ok { color: var(--ok); }
.wordcount.low { color: var(--warn); }
.wordcount.high { color: var(--err); }
.save-status { font-size: .82rem; color: var(--muted); }

/* Onglets */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto;
        scrollbar-width: thin; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; font: inherit;
               font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel[hidden] { display: none; }

/* Correction */
.copy { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px;
        line-height: 1.85; }
.copy .err { color: var(--err); font-weight: 700; text-decoration: underline wavy; text-underline-offset: 4px;
             text-decoration-thickness: 1px; }
.copy .err sup { font-size: .7em; margin-left: 1px; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600;
     background: var(--surface-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.table-wrap table th:first-child, .table-wrap table td:first-child { padding-left: 16px; }
.strike { text-decoration: line-through; color: var(--err); }
.fix { font-weight: 700; color: var(--ok); }
tr:target { background: var(--warn-soft); }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 8px; padding: 3px 0; }
.criteria { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.bar { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.coach-msg { background: var(--ok-soft); color: var(--ok); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.tip { background: var(--info-soft); color: var(--info); border-radius: 10px; padding: 12px 16px; }
details.box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; }
details.box > summary { cursor: pointer; padding: 12px 16px; font-weight: 600; list-style: none; display: flex;
                        gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
details.box > summary::-webkit-details-marker { display: none; }
details.box > summary::after { content: "▾"; color: var(--muted); }
details.box[open] > summary::after { content: "▴"; }
details.box > .box-body { padding: 0 16px 16px; }

/* Contenu pédagogique (Markdown) */
.prose blockquote { margin: 12px 0; padding: 10px 16px; border-left: 3px solid var(--brand); background: var(--surface-2);
                    border-radius: 0 8px 8px 0; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: 3px 0; }
.prose table { margin: 10px 0 16px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
               display: block; overflow-x: auto; }

/* Attente d'une correction */
.waiting { text-align: center; padding: 40px 20px; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--brand-soft);
           border-top-color: var(--brand); animation: spin 1s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.steps { list-style: none; padding: 0; margin: 16px auto 0; max-width: 360px; text-align: left; }
.steps li { padding: 4px 0; color: var(--muted); }

/* Quiz */
.question { padding: 16px 0; border-bottom: 1px solid var(--border); }
.question:last-of-type { border-bottom: 0; }
.question .enonce { font-weight: 600; margin-bottom: 8px; }
.option { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border: 1px solid var(--border);
          border-radius: 9px; margin: 6px 0; font-weight: 400; cursor: pointer; background: var(--surface); }
.option:hover { border-color: var(--brand); }
.option input { accent-color: var(--brand); width: 18px; height: 18px; margin: 0; }
.option.good { border-color: var(--ok); background: var(--ok-soft); }
.option.bad { border-color: var(--err); background: var(--err-soft); }

/* Page d'accueil publique */
.public { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.public-nav { display: flex; align-items: center; justify-content: space-between; padding: 18px 0; gap: 12px; }
.hero { padding: 48px 0 32px; display: grid; gap: 32px; grid-template-columns: 1.2fr 1fr; align-items: center; }
.hero h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); letter-spacing: -.02em; }
.hero .lead { font-size: 1.15rem; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; padding-top: 24px; } }
.feature-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--brand-soft); color: var(--brand);
                display: grid; place-items: center; margin-bottom: 10px; }
.auth-card { max-width: 440px; margin: 32px auto; }
.footer { color: var(--muted); font-size: .85rem; padding: 32px 0; text-align: center; }
.chart-box { position: relative; height: 280px; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.demo-banner { background: var(--warn-soft); color: var(--warn); text-align: center; font-size: .85rem; padding: 6px 12px; }
.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--border);
       border-radius: 11px; margin-bottom: 18px; overflow-x: auto; }
.seg a { flex: 1; text-align: center; padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted);
         font-weight: 600; font-size: .92rem; white-space: nowrap; }
.seg a:hover { background: var(--surface-2); color: var(--text); }
.seg a[aria-current="page"] { background: var(--brand); color: #fff; }

/* Bandeau « écris sans aide » */
.no-assist { background: var(--warn-soft); color: var(--text); border: 1px solid var(--warn); border-left-width: 4px;
             border-radius: 10px; padding: 12px 16px; margin-bottom: 14px; font-size: .93rem; }
.no-assist-head { display: flex; gap: 12px; align-items: flex-start; }
.no-assist-icon { font-size: 1.4rem; line-height: 1; }
.no-assist details { margin-top: 8px; }
.no-assist summary { cursor: pointer; font-weight: 600; color: var(--warn); }
.no-assist ul { margin: 8px 0; padding-left: 1.2em; }
.no-assist li { margin: 4px 0; }

/* Mémoire du coach */
.memory { border-left: 4px solid var(--info); }
.memory-list { list-style: none; padding: 0; margin: 0; }
.memory-list li { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.memory-list li:last-child { border-bottom: 0; }
.mem-ok { color: var(--ok); }

/* Message bref (copier-coller bloqué) */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); max-width: calc(100% - 32px);
         background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .92rem;
         box-shadow: 0 6px 24px rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
         z-index: 100; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Chrono : la couleur suit le temps restant */
.timer.t-ok { color: var(--ok); background: var(--ok-soft); }
.timer.t-warn { color: var(--warn); background: var(--warn-soft); box-shadow: 0 0 0 2px var(--warn); }
.timer.t-danger { color: #fff; background: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.timer.t-last { color: #fff; background: var(--err); animation: timer-pulse 1s ease-in-out infinite; }
.timer.over { color: #fff; background: var(--err); animation: none; }
.timer-bar { height: 4px; border-radius: 99px; background: var(--surface-2); overflow: hidden; flex-basis: 100%; }
.timer-bar > span { display: block; height: 100%; width: 100%; background: var(--ok); transition: width 1s linear, background .4s; }
.timer-bar.t-warn > span { background: var(--warn); }
.timer-bar.t-danger > span, .timer-bar.t-last > span, .timer-bar.over > span { background: var(--err); }
@keyframes timer-pulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(180, 35, 24, .6); }
                         50% { transform: scale(1.06); box-shadow: 0 0 0 8px rgba(180, 35, 24, 0); } }
@media (prefers-reduced-motion: reduce) { .timer.t-last { animation: none; } }

/* Sélecteur de thème */
.theme-toggle { display: inline-flex; align-items: center; gap: 6px; background: none; border: 1px solid var(--border);
                color: var(--text); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .85rem; cursor: pointer; }
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle .ti { font-size: 1rem; line-height: 1; }

/* Graphiques de progression : couleur de série validée (contraste >= 3:1 sur les deux fonds) */
:root { --viz-1: #2a78d6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --viz-1: #3987e5; } }
:root[data-theme="dark"] { --viz-1: #3987e5; }
.chart-sm { height: 210px; }
.how { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); margin: 0 0 12px; }
.how .icon { margin-top: 2px; color: var(--info); }
.headline { display: flex; gap: 10px; align-items: center; font-size: 1.02rem; font-weight: 600; }
.metric .unit { font-size: 1rem; color: var(--muted); font-weight: 600; }
.single-score { height: 120px; display: flex; align-items: baseline; justify-content: center; padding-top: 24px; font-size: 1.1rem; color: var(--muted); font-weight: 600; }
.single-score span { font-size: 3rem; font-weight: 800; color: var(--text); line-height: 1; }

/* Barres horizontales en HTML : libellés complets, lisibles sur téléphone */
.hbars { list-style: none; padding: 0; margin: 0; }
.hbars li { margin: 0 0 12px; }
.hbar-label { font-size: .9rem; color: var(--text); margin-bottom: 4px; }
.hbar-row { display: flex; align-items: center; gap: 10px; }
.hbar-bar { display: block; height: 14px; min-width: 6px; background: var(--viz-1); border-radius: 0 4px 4px 0; }
.hbar-val { font-size: .85rem; font-weight: 600; color: var(--text); white-space: nowrap; }

/* --- Responsive : rien ne doit dépasser la largeur de l'écran ---------------------------- */
/* Un élément de grille ne rétrécit pas sous la largeur de son contenu sans min-width: 0. */
.shell > * { min-width: 0; }
.grid > *, .row > * { min-width: 0; }
/* Tableaux de la méthode : défilement horizontal dans leur cadre plutôt que la page entière. */
.prose table { display: block; max-width: 100%; overflow-x: auto; }
/* Mots ou liens très longs (e-mails, références) : retour à la ligne. */
.main { overflow-wrap: break-word; }  /* coupe un mot trop long sans rétrécir les colonnes */
/* Sur téléphone : les choix de tâche et les onglets se partagent la largeur, le texte passe à la ligne. */
@media (max-width: 600px) {
  .seg { overflow: visible; }
  .seg a { white-space: normal; padding: 8px 6px; font-size: .85rem; line-height: 1.25; min-width: 0; }
  .tabs { overflow: visible; flex-wrap: wrap; row-gap: 0; }
  .tabs button { flex: 1 1 auto; white-space: normal; overflow-wrap: normal; padding: 9px 8px; font-size: .88rem;
                 line-height: 1.25; }
  .seg a { overflow-wrap: normal; }
  h1 { font-size: 1.5rem; }
}

/* Tableaux « en fiches » sur téléphone : chaque ligne devient une carte, chaque valeur a son libellé.
   La 1re cellule sert de titre de la fiche ; .cell-action = lien en bas de la fiche. */
@media (max-width: 600px) {
  .table-wrap:has(> .table-stack) { overflow: visible; }
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr { display: block; width: 100%; }
  .table-stack tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table-stack tr:last-child { border-bottom: 0; }
  .table-stack td { display: flex; justify-content: space-between; align-items: baseline;
    gap: 12px; padding: 3px 0; border: 0; text-align: right; overflow-wrap: normal; }
  .table-stack td::before { content: attr(data-label); color: var(--muted); font-size: .84rem; text-align: left; flex: none; max-width: 50%; }
  .table-wrap .table-stack td:first-child { display: block; text-align: left; padding: 0 0 6px; }
  .table-stack td:first-child::before, .table-stack td.cell-action::before { content: none; }
  .table-stack td.cell-action { justify-content: flex-start; padding-top: 8px; }
}
/* Chiffres clés : 2 par ligne sur téléphone plutôt qu'un seul. */
@media (max-width: 600px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid-4 .metric { padding: 12px; }
  .grid-4 .metric .value { font-size: 1.35rem; }
}

/* Fiches (suite) : valeurs longues sous leur libellé, tableaux de contenu (méthode) compris. */
@media (max-width: 600px) {
  .table-stack td.cell-long { display: block; text-align: left; }
  .table-stack td.cell-long::before { display: block; max-width: none; margin-bottom: 2px; }
  .prose table.table-stack { display: block; overflow: visible; border-radius: 10px; }
  .prose .table-stack td { border: 0; }
  .table-stack td:empty { display: none; }
  .table-stack .badge { white-space: nowrap; }
  .main .m-only { display: inline; }
}
.m-only { display: none; }

/* --- Barre de navigation du bas (téléphone et tablette) ------------------------------------ */
.bottom-nav { display: none; }
@media (max-width: 900px) {
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0;
    z-index: 30; background: var(--surface); border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); box-shadow: 0 -2px 10px rgba(0, 0, 0, .06); }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px;
    border-radius: 10px; color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600; min-height: 48px;
    justify-content: center; }
  .bottom-nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }
  .main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  /* Pendant la rédaction : tout l'écran pour écrire (le clavier prend déjà de la place). */
  body:has(#writing-form) .bottom-nav { display: none; }
  body:has(#writing-form) .main { padding-bottom: 48px; }
}

/* --- Repère d'étapes après une correction ----------------------------------------------------- */
.steps-bar { position: sticky; top: 0; z-index: 9; background: var(--bg); padding: 8px 0 10px; margin-bottom: 10px; }
@media (max-width: 900px) { .steps-bar { top: 57px; } }
.steps-bar ol { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.steps-bar a { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; text-decoration: none;
  color: var(--muted); background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: .9rem; height: 100%; }
.steps-bar .step-dot, .welcome-steps .step-dot { flex: none; width: 24px; height: 24px; border-radius: 50%; display: inline-grid;
  place-items: center; font-size: .8rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.steps-bar .is-done a { color: var(--ok); }
.steps-bar .is-done .step-dot { background: var(--ok); color: #fff; }
.steps-bar .is-current a { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.steps-bar .is-current .step-dot { background: var(--brand); color: #fff; }
@media (max-width: 600px) {
  .steps-bar a { flex-direction: column; gap: 3px; padding: 6px 4px; font-size: .74rem; text-align: center; }
}
#correction, #exercices, #reecrire, [id^="quiz-"] { scroll-margin-top: 130px; }

/* --- Tableau de bord : « À faire maintenant » --------------------------------------------------- */
.todo-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.todo-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; text-decoration: none;
  color: var(--text); border: 1px solid var(--border); background: var(--surface); min-height: 56px; }
.todo-item:hover { border-color: var(--brand); }
.todo-item.is-urgent { border-left: 4px solid var(--brand); }
.todo-icon { flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); }
.todo-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.todo-go { flex: none; color: var(--muted); }

/* --- Accueil des nouveaux candidats -------------------------------------------------------------- */
.welcome { border-top: 4px solid var(--brand); }
.welcome-steps { list-style: none; padding: 0; margin: 14px 0 18px; display: grid; gap: 10px; }
.welcome-steps li { display: flex; gap: 10px; align-items: flex-start; }
.welcome-steps .step-dot { background: var(--brand); color: #fff; }
.btn-lg { padding: 14px 22px; font-size: 1.05rem; }
@media (max-width: 600px) { .welcome .btn-lg { width: 100%; justify-content: center; } }

/* --- Explications du jargon (bouton « i ») ------------------------------------------------------- */
.help { display: inline-flex; vertical-align: middle; color: var(--muted); cursor: help; position: relative;
  border-radius: 50%; outline-offset: 2px; }
.help .icon { width: 15px; height: 15px; }
.help:hover, .help:focus { color: var(--brand); }
.help-tip { display: none; position: absolute; z-index: 50; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: min(280px, 80vw); padding: 10px 12px; border-radius: 10px; background: var(--text);
  color: var(--bg); font-size: .82rem; font-weight: 400; line-height: 1.45; text-align: left; white-space: normal;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2); }
.help:hover .help-tip, .help:focus .help-tip, .help:focus-within .help-tip { display: block; }

/* Pagination des tableaux : nombre de lignes à gauche, pages à droite ; sur téléphone tout passe
   sur deux lignes, avec des boutons assez grands pour le pouce. */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 10px 0 18px; }
.pager-size { display: flex; align-items: center; gap: 8px; margin: 0; font-size: .92rem; }
.pager-size select { width: auto; min-height: 36px; padding: 4px 28px 4px 10px; }
.pager-nav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.pager-page { white-space: nowrap; padding: 0 4px; }
.pager .is-disabled { opacity: .45; pointer-events: none; }
@media (max-width: 600px) {
  .pager-count { margin-left: auto; }
  .pager-nav { width: 100%; margin-left: 0; justify-content: space-between; }
  .pager-nav .btn { min-height: 44px; padding: 8px 14px; }
}
@media (max-width: 380px) { .pager-word { display: none; } }

/* Choix du thème du sujet (entraînement) */
.theme-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; }
.theme-pick label { font-weight: 600; }
.theme-pick-item { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.theme-pick select { width: auto; max-width: 100%; min-height: 40px; }
@media (max-width: 600px) { .theme-pick select { width: 100%; } .theme-pick-item { width: 100%; } }

/* Champ mot de passe avec bouton afficher / masquer */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 52px; }
.pw-toggle { position: absolute; top: 0; right: 0; height: 100%; min-width: 48px; display: inline-flex;
  align-items: center; justify-content: center; background: none; border: 0; border-radius: 0 9px 9px 0;
  color: var(--muted); cursor: pointer; }
.pw-toggle:hover { color: var(--text); }
.pw-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
