/* ═══════════════════════════════════════════════════════════════════
   Le Hérisson du DU — feuille de style unique
   Palette : papier chaud / encre vert-ardoise, accent roux (le hérisson),
   vert sauge (compréhension) et iris (application clinique).
   ═══════════════════════════════════════════════════════════════════ */

:root{
  --paper:#F3F4F0;
  --surface:#FBFBF9;
  --surface-2:#EBEDE7;
  --surface-3:#E1E4DC;
  --ink:#141C1A;
  --ink-2:#3E4A46;
  --ink-3:#6B7772;
  --line:#D6DAD2;
  --line-soft:#E4E7E0;

  --roux:#A85F32;
  --roux-soft:#F1E3D9;
  --sage:#3F6B5E;
  --sage-soft:#DEE9E4;
  --iris:#5C5285;
  --iris-soft:#E4E1ED;
  --rouge:#A33B2E;
  --rouge-soft:#F3DED9;
  --or:#8A6D22;

  --on-accent:#FBFBF9;
  --shadow-1:0 1px 2px rgba(20,28,26,.05);
  --shadow-2:0 1px 2px rgba(20,28,26,.05), 0 10px 26px -18px rgba(20,28,26,.5);
  --shadow-3:0 2px 4px rgba(20,28,26,.06), 0 18px 40px -22px rgba(20,28,26,.55);
  --r:12px;
  --r-s:8px;
  --topbar-h:56px;
  color-scheme:light;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --paper:#101614; --surface:#171F1D; --surface-2:#1E2725; --surface-3:#25302D;
    --ink:#EAEEEB; --ink-2:#B4BEBA; --ink-3:#7E8A86;
    --line:#2C3835; --line-soft:#232D2B;
    --roux:#D89261; --roux-soft:#33241B;
    --sage:#7FB8A5; --sage-soft:#182724;
    --iris:#A79BD4; --iris-soft:#211F2E;
    --rouge:#E08476; --rouge-soft:#2E1C18;
    --or:#D2B569;
    --on-accent:#101614;
    --shadow-1:0 1px 2px rgba(0,0,0,.3);
    --shadow-2:0 1px 2px rgba(0,0,0,.3), 0 10px 26px -18px rgba(0,0,0,.9);
    --shadow-3:0 2px 4px rgba(0,0,0,.35), 0 18px 40px -22px rgba(0,0,0,1);
    color-scheme:dark;
  }
}
:root[data-theme="dark"]{
  --paper:#101614; --surface:#171F1D; --surface-2:#1E2725; --surface-3:#25302D;
  --ink:#EAEEEB; --ink-2:#B4BEBA; --ink-3:#7E8A86;
  --line:#2C3835; --line-soft:#232D2B;
  --roux:#D89261; --roux-soft:#33241B;
  --sage:#7FB8A5; --sage-soft:#182724;
  --iris:#A79BD4; --iris-soft:#211F2E;
  --rouge:#E08476; --rouge-soft:#2E1C18;
  --or:#D2B569;
  --on-accent:#101614;
  --shadow-1:0 1px 2px rgba(0,0,0,.3);
  --shadow-2:0 1px 2px rgba(0,0,0,.3), 0 10px 26px -18px rgba(0,0,0,.9);
  --shadow-3:0 2px 4px rgba(0,0,0,.35), 0 18px 40px -22px rgba(0,0,0,1);
  color-scheme:dark;
}

*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{
  margin:0;
  background:var(--paper);
  color:var(--ink);
  font:16px/1.6 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  -webkit-font-smoothing:antialiased;
  overscroll-behavior-y:none;
}
h1,h2,h3,h4{margin:0;line-height:1.2;text-wrap:balance;font-weight:650}
h1{font-size:1.55rem}
h2{font-size:1.22rem}
h3{font-size:1.05rem}
p{margin:0}
a{color:inherit}
button,input,textarea,select{font:inherit;color:inherit}
:focus-visible{outline:2px solid var(--roux);outline-offset:2px;border-radius:4px}
[hidden]{display:none !important}
.num{font-variant-numeric:tabular-nums}
@media (prefers-reduced-motion: reduce){*{animation:none!important;transition:none!important}}

/* ── Connexion ─────────────────────────────────────────────────── */
.screen-login{min-height:100dvh;display:grid;place-items:center;padding:24px}
.login-card{
  width:100%;max-width:390px;background:var(--surface);border:1px solid var(--line);
  border-radius:16px;padding:32px 28px 28px;box-shadow:var(--shadow-3);text-align:center;
}
.login-hedge{margin:0 auto 14px;width:104px;height:104px}
.login-card h1{font-size:1.35rem;margin-bottom:6px}
.login-sub{color:var(--ink-3);font-size:.9rem;margin-bottom:22px;line-height:1.45}
.login-card label{display:block;text-align:left;font-size:.82rem;font-weight:650;color:var(--ink-2);margin-bottom:6px}
.login-card input{
  width:100%;padding:12px 14px;border:1px solid var(--line);border-radius:var(--r-s);
  background:var(--paper);
}
.login-card button{
  width:100%;margin-top:16px;padding:13px;border:none;border-radius:var(--r-s);
  background:var(--roux);color:var(--on-accent);font-weight:650;cursor:pointer;
}
.login-card button:hover{filter:brightness(1.07)}
.login-card button:disabled{opacity:.55;cursor:progress}
.login-err{
  margin-top:14px;padding:9px 12px;border-radius:var(--r-s);font-size:.86rem;
  background:var(--rouge-soft);color:var(--rouge);border:1px solid var(--rouge);
}

/* ── Barre du haut ─────────────────────────────────────────────── */
.topbar{
  position:sticky;top:0;z-index:40;height:var(--topbar-h);
  display:flex;align-items:center;gap:18px;padding:0 18px;
  background:color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter:saturate(1.4) blur(10px);
  border-bottom:1px solid var(--line-soft);
}
.brand{display:flex;align-items:center;gap:9px;text-decoration:none;font-weight:700;flex-shrink:0}
.brand-mark{width:26px;height:26px;display:block}
.brand-name{font-size:.95rem;letter-spacing:-.01em}
@media(max-width:560px){.brand-name{display:none}}
.tabs{display:flex;gap:20px;margin-left:auto;margin-right:auto}
.tabs a{
  text-decoration:none;font-size:.88rem;font-weight:600;color:var(--ink-3);
  padding:17px 0;border-bottom:2px solid transparent;white-space:nowrap;
}
.tabs a:hover{color:var(--ink)}
.tabs a.on{color:var(--roux);border-bottom-color:var(--roux)}
@media(max-width:780px){.tabs{display:none}}
.sync{
  margin-left:auto;font-size:.72rem;color:var(--ink-3);display:flex;align-items:center;gap:6px;
  white-space:nowrap;
}
.sync::before{content:"";width:7px;height:7px;border-radius:50%;background:var(--sage)}
.sync.off::before{background:var(--or)}
.sync.err::before{background:var(--rouge)}
@media(max-width:400px){.sync span{display:none}}

/* ── Barre du bas (mobile) ─────────────────────────────────────── */
.bottombar{display:none}
@media(max-width:780px){
  .bottombar{
    position:fixed;left:0;right:0;bottom:0;z-index:40;display:flex;
    background:color-mix(in srgb, var(--paper) 94%, transparent);
    backdrop-filter:blur(12px);border-top:1px solid var(--line);
    padding-bottom:env(safe-area-inset-bottom);
  }
  .bottombar a{
    flex:1;display:flex;flex-direction:column;align-items:center;gap:3px;
    padding:9px 0 7px;text-decoration:none;color:var(--ink-3);font-size:.66rem;font-weight:600;
    position:relative;
  }
  .bottombar a.on{color:var(--roux)}
  .bottombar svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.8;
    stroke-linecap:round;stroke-linejoin:round}
  .bottombar .dot{
    position:absolute;top:6px;left:calc(50% + 9px);width:7px;height:7px;
    border-radius:50%;background:var(--roux);
  }
  .view{padding-bottom:86px !important}
}

/* ── Grille générale ───────────────────────────────────────────── */
.view{max-width:820px;margin:0 auto;padding:24px 18px 60px}
.view.wide{max-width:1040px}
.stack{display:flex;flex-direction:column;gap:16px}
.row{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.spacer{flex:1}
.eyebrow{
  font-size:.7rem;letter-spacing:.11em;text-transform:uppercase;color:var(--ink-3);font-weight:650;
}
.muted{color:var(--ink-3)}
.small{font-size:.86rem}

/* ── Blocs ─────────────────────────────────────────────────────── */
.card{
  background:var(--surface);border:1px solid var(--line);border-radius:var(--r);
  padding:20px;box-shadow:var(--shadow-1);
}
.card.tight{padding:14px 16px}

.hello{display:flex;gap:18px;align-items:center}
.hello .hedge{width:82px;height:82px;flex-shrink:0}
.hello h1{margin-bottom:4px}
.hello p{color:var(--ink-2);font-size:.94rem}

.cta{
  display:flex;align-items:center;gap:16px;width:100%;text-align:left;cursor:pointer;
  background:var(--roux);color:var(--on-accent);border:none;border-radius:var(--r);
  padding:18px 20px;box-shadow:var(--shadow-2);text-decoration:none;
}
.cta:hover{filter:brightness(1.06)}
.cta .big{font-size:1.5rem;font-weight:700;line-height:1}
.cta .lbl{font-size:.86rem;opacity:.92;margin-top:3px}
.cta .arrow{margin-left:auto;font-size:1.4rem;opacity:.8}
.cta.done{background:var(--sage)}
.cta:disabled{opacity:.6;cursor:default;filter:none}

.tiles{display:grid;grid-template-columns:repeat(4,1fr);gap:1px;background:var(--line);
  border:1px solid var(--line);border-radius:var(--r);overflow:hidden}
@media(max-width:620px){.tiles{grid-template-columns:repeat(2,1fr)}}
.tile{background:var(--surface);padding:15px 16px}
.tile .n{font-size:1.55rem;font-weight:700;line-height:1;font-variant-numeric:tabular-nums}
.tile .l{font-size:.76rem;color:var(--ink-3);margin-top:5px;line-height:1.3}
.tile .n .u{font-size:.8rem;font-weight:600;color:var(--ink-3);margin-left:2px}

/* ── Badges de type ────────────────────────────────────────────── */
.badge{
  display:inline-block;font-size:.66rem;font-weight:700;letter-spacing:.07em;text-transform:uppercase;
  padding:3px 8px;border-radius:5px;white-space:nowrap;
}
.badge.MEMO {background:var(--roux-soft);color:var(--roux)}
.badge.COMPR{background:var(--sage-soft);color:var(--sage)}
.badge.APPLI{background:var(--iris-soft);color:var(--iris)}
.badge.flag {background:var(--rouge-soft);color:var(--rouge)}
.badge.plain{background:var(--surface-2);color:var(--ink-3)}

/* ── Barres de progression ─────────────────────────────────────── */
.pbar{height:7px;border-radius:4px;background:var(--surface-3);overflow:hidden;display:flex}
.pbar span{display:block;height:100%}
.pbar .acq{background:var(--sage)}
.pbar .cours{background:var(--roux)}
.pbar .rev{background:var(--rouge)}

/* ── Liste des modules ─────────────────────────────────────────── */
.modlist{display:flex;flex-direction:column;gap:10px}
.modrow{
  display:grid;grid-template-columns:38px 1fr auto;gap:14px;align-items:center;
  background:var(--surface);border:1px solid var(--line);border-radius:var(--r);
  padding:14px 16px;text-decoration:none;cursor:pointer;text-align:left;width:100%;
}
.modrow:hover{border-color:var(--roux);box-shadow:var(--shadow-1)}
.modrow .idx{
  width:34px;height:34px;border-radius:9px;background:var(--surface-2);color:var(--roux);
  display:grid;place-items:center;font-weight:700;font-size:.95rem;
}
.modrow .t{font-weight:650;font-size:.97rem}
.modrow .s{font-size:.79rem;color:var(--ink-3);margin-top:2px}
.modrow .pbar{margin-top:8px}
.modrow .pct{font-size:1.05rem;font-weight:700;font-variant-numeric:tabular-nums}
.modrow .pct small{display:block;font-size:.68rem;font-weight:500;color:var(--ink-3);text-align:right}

/* ── Fiche ─────────────────────────────────────────────────────── */
.fiche{
  background:var(--surface);border:1px solid var(--line);border-radius:var(--r);
  padding:22px 22px 20px;box-shadow:var(--shadow-2);
}
.fiche .head{display:flex;gap:10px;align-items:flex-start;margin-bottom:12px;flex-wrap:wrap}
.fiche h2{flex:1 1 14rem;min-width:0}
.fiche .sec{font-size:.76rem;color:var(--ink-3);margin-bottom:14px}
.fiche .def{font-size:1.02rem;line-height:1.62}
.fiche .det{margin-top:14px;font-size:.94rem;color:var(--ink-2)}
.fiche .det ul{margin:8px 0 0;padding-left:1.15em}
.fiche .det li{margin-bottom:4px}
.fiche .det strong{color:var(--ink)}
.fiche .ex{
  margin-top:16px;padding:13px 15px;border-radius:var(--r-s);
  background:var(--sage-soft);border-left:3px solid var(--sage);font-size:.92rem;
}
.fiche .ex b{display:block;font-size:.68rem;letter-spacing:.09em;text-transform:uppercase;
  color:var(--sage);margin-bottom:4px}
.fiche .src{
  margin-top:16px;padding-top:12px;border-top:1px solid var(--line-soft);
  font-size:.76rem;color:var(--ink-3);
}
.fils{display:flex;gap:6px;flex-wrap:wrap;margin-top:10px}
.fil{
  font-size:.72rem;padding:2px 8px;border-radius:999px;
  background:var(--surface-2);color:var(--ink-3);border:1px solid var(--line);cursor:pointer;
}
.fil:hover{color:var(--roux);border-color:var(--roux)}

/* ── Schémas (dual coding) ─────────────────────────────────────── */
.schema{margin-top:16px;padding:14px 15px;background:var(--surface-2);border-radius:var(--r-s)}
.schema .cap{font-size:.68rem;letter-spacing:.09em;text-transform:uppercase;color:var(--ink-3);
  margin-bottom:9px;font-weight:650}
.schema.chaine .items{display:flex;flex-wrap:wrap;gap:7px;align-items:center}
.schema.chaine .it{
  background:var(--surface);border:1px solid var(--line);border-radius:6px;
  padding:5px 10px;font-size:.85rem;
}
.schema.chaine .ar{color:var(--roux);font-weight:700}
.schema.cercle .items{display:flex;flex-wrap:wrap;gap:7px;align-items:center}
.schema.cercle .it{
  background:var(--roux-soft);border:1px solid var(--roux);color:var(--roux);
  border-radius:6px;padding:5px 10px;font-size:.85rem;font-weight:600;
}
.schema.cercle .ar{color:var(--roux);font-weight:700}
.schema.cercle .loop{font-size:.74rem;color:var(--roux);margin-top:8px;font-style:italic}
.schema.liste ol{margin:0;padding-left:1.4em;font-size:.89rem}
.schema.liste li{margin-bottom:4px}

/* ── Session de révision ───────────────────────────────────────── */
.sessbar{
  display:flex;align-items:center;gap:12px;margin-bottom:16px;
}
.sessbar .track{flex:1;height:5px;border-radius:3px;background:var(--surface-3);overflow:hidden}
.sessbar .track i{display:block;height:100%;background:var(--roux);transition:width .25s}
.sessbar .cnt{font-size:.8rem;color:var(--ink-3);font-variant-numeric:tabular-nums;white-space:nowrap}
.sessbar button{
  background:none;border:none;color:var(--ink-3);cursor:pointer;font-size:.8rem;
  text-decoration:underline;padding:0;
}

.q{
  background:var(--surface);border:1px solid var(--line);border-radius:var(--r);
  padding:22px;box-shadow:var(--shadow-2);
}
.q .kind{font-size:.68rem;letter-spacing:.09em;text-transform:uppercase;color:var(--ink-3);
  font-weight:650;margin-bottom:10px;display:flex;gap:8px;align-items:center}
.q .txt{font-size:1.05rem;line-height:1.55;margin-bottom:18px}
.q .txt .vignette{
  display:block;background:var(--surface-2);border-radius:var(--r-s);padding:13px 15px;
  margin-bottom:14px;font-size:.95rem;color:var(--ink-2);
}
.choices{display:flex;flex-direction:column;gap:9px}
.choice{
  display:flex;gap:11px;align-items:flex-start;text-align:left;width:100%;cursor:pointer;
  background:var(--surface);border:1px solid var(--line);border-radius:var(--r-s);
  padding:13px 15px;font-size:.95rem;line-height:1.45;
}
.choice:hover:not(:disabled){border-color:var(--roux);background:var(--surface-2)}
.choice:disabled{cursor:default}
.choice .k{
  flex-shrink:0;width:22px;height:22px;border-radius:6px;background:var(--surface-2);
  color:var(--ink-3);display:grid;place-items:center;font-size:.78rem;font-weight:700;
}
.choice.good{border-color:var(--sage);background:var(--sage-soft)}
.choice.good .k{background:var(--sage);color:var(--on-accent)}
.choice.bad{border-color:var(--rouge);background:var(--rouge-soft)}
.choice.bad .k{background:var(--rouge);color:var(--on-accent)}
.choice.dim{opacity:.5}

.answerbox{
  width:100%;min-height:96px;padding:13px 15px;border:1px solid var(--line);
  border-radius:var(--r-s);background:var(--paper);resize:vertical;line-height:1.55;
}
.model{
  margin-top:16px;padding:15px 17px;border-radius:var(--r-s);
  background:var(--sage-soft);border-left:3px solid var(--sage);
}
.model b{display:block;font-size:.68rem;letter-spacing:.09em;text-transform:uppercase;
  color:var(--sage);margin-bottom:6px}
.model p{font-size:.95rem;line-height:1.6}
.why{
  margin-top:14px;padding:12px 15px;border-radius:var(--r-s);font-size:.9rem;
  background:var(--surface-2);color:var(--ink-2);border-left:3px solid var(--ink-3);
}
.why.good{border-left-color:var(--sage)}
.why.bad{border-left-color:var(--rouge)}

.btn{
  padding:11px 18px;border-radius:var(--r-s);border:1px solid var(--line);
  background:var(--surface);cursor:pointer;font-weight:600;font-size:.92rem;
}
.btn:hover{border-color:var(--roux);color:var(--roux)}
.btn.primary{background:var(--roux);color:var(--on-accent);border-color:var(--roux)}
.btn.primary:hover{filter:brightness(1.07);color:var(--on-accent)}
.btn.ghost{background:transparent;border-color:transparent;color:var(--ink-3)}
.btn.ghost:hover{color:var(--roux)}
.btn.wide{width:100%}
.btn.sm{padding:7px 12px;font-size:.83rem}

.grades{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;margin-top:18px}
@media(max-width:520px){.grades{grid-template-columns:repeat(2,1fr)}}
.grade{
  display:flex;flex-direction:column;gap:2px;align-items:center;cursor:pointer;
  border:1px solid var(--line);border-radius:var(--r-s);padding:11px 6px;background:var(--surface);
  font-weight:650;font-size:.9rem;
}
.grade small{font-size:.68rem;font-weight:500;color:var(--ink-3);font-variant-numeric:tabular-nums}
.grade[data-g="1"]:hover{border-color:var(--rouge);color:var(--rouge)}
.grade[data-g="3"]:hover{border-color:var(--or);color:var(--or)}
.grade[data-g="4"]:hover{border-color:var(--sage);color:var(--sage)}
.grade[data-g="5"]:hover{border-color:var(--iris);color:var(--iris)}

/* ── Graphique ─────────────────────────────────────────────────── */
.chart{display:flex;align-items:flex-end;gap:2px;height:110px;padding-top:8px}
.chart .col{flex:1;min-width:2px;display:flex;flex-direction:column;justify-content:flex-end;
  height:100%;border-radius:2px 2px 0 0;overflow:hidden;background:var(--surface-2)}
.chart .col i{display:block;width:100%}
.chart .col .ok{background:var(--sage)}
.chart .col .ko{background:var(--rouge)}
.chart-x{display:flex;justify-content:space-between;font-size:.7rem;color:var(--ink-3);margin-top:7px}

/* ── Listes de fiches ──────────────────────────────────────────── */
.ficherow{
  display:flex;gap:12px;align-items:center;width:100%;text-align:left;cursor:pointer;
  background:var(--surface);border:1px solid var(--line);border-radius:var(--r-s);
  padding:11px 14px;
}
.ficherow:hover{border-color:var(--roux)}
.ficherow .t{flex:1;min-width:0;font-size:.93rem;font-weight:600}
.ficherow .t small{display:block;font-weight:400;color:var(--ink-3);font-size:.76rem;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ficherow .st{font-size:.72rem;color:var(--ink-3);white-space:nowrap;font-variant-numeric:tabular-nums}
.state-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0;background:var(--surface-3)}
.state-dot.cours{background:var(--roux)}
.state-dot.acq{background:var(--sage)}
.state-dot.rev{background:var(--rouge)}

.filters{display:flex;gap:7px;flex-wrap:wrap;margin-bottom:14px}
.filters button{
  padding:6px 12px;border-radius:999px;border:1px solid var(--line);background:var(--surface);
  font-size:.82rem;cursor:pointer;color:var(--ink-2);
}
.filters button.on{background:var(--roux);border-color:var(--roux);color:var(--on-accent)}
.search{
  width:100%;padding:10px 14px;border:1px solid var(--line);border-radius:var(--r-s);
  background:var(--surface);margin-bottom:12px;
}

/* ── Réglages ──────────────────────────────────────────────────── */
.setrow{
  display:flex;align-items:center;gap:14px;padding:14px 0;border-bottom:1px solid var(--line-soft);
}
.setrow:last-child{border-bottom:none}
.setrow .lab{flex:1;min-width:0}
.setrow .lab b{display:block;font-size:.94rem;font-weight:650}
.setrow .lab span{display:block;font-size:.81rem;color:var(--ink-3);margin-top:2px}
.setrow input[type=number]{width:82px;padding:8px 10px;border:1px solid var(--line);
  border-radius:6px;background:var(--paper);text-align:right}
.seg{display:flex;border:1px solid var(--line);border-radius:7px;overflow:hidden}
.seg button{padding:7px 12px;border:none;background:var(--surface);cursor:pointer;font-size:.84rem;
  color:var(--ink-2)}
.seg button.on{background:var(--roux);color:var(--on-accent)}
.switch{
  width:44px;height:25px;border-radius:999px;background:var(--surface-3);border:none;
  cursor:pointer;position:relative;flex-shrink:0;transition:background .16s;
}
.switch i{position:absolute;top:3px;left:3px;width:19px;height:19px;border-radius:50%;
  background:var(--surface);box-shadow:var(--shadow-1);transition:transform .16s}
.switch.on{background:var(--sage)}
.switch.on i{transform:translateX(19px)}

/* ── Divers ────────────────────────────────────────────────────── */
.toast{
  position:fixed;left:50%;transform:translateX(-50%);bottom:calc(18px + env(safe-area-inset-bottom));
  z-index:60;background:var(--ink);color:var(--paper);padding:11px 18px;border-radius:999px;
  font-size:.87rem;box-shadow:var(--shadow-3);max-width:90vw;text-align:center;
}
@media(max-width:780px){.toast{bottom:calc(76px + env(safe-area-inset-bottom))}}

.empty{text-align:center;padding:38px 20px;color:var(--ink-3)}
.empty .hedge{width:96px;height:96px;margin:0 auto 16px}
.empty h3{color:var(--ink);margin-bottom:6px}
.empty p{font-size:.92rem;max-width:34ch;margin:0 auto}

.crumb{display:flex;align-items:center;gap:8px;margin-bottom:14px;font-size:.85rem}
.crumb a{color:var(--ink-3);text-decoration:none}
.crumb a:hover{color:var(--roux)}

.sheet-back{
  position:fixed;inset:0;z-index:50;background:rgba(0,0,0,.42);
  display:flex;align-items:flex-end;justify-content:center;padding:0;
}
@media(min-width:781px){.sheet-back{align-items:center;padding:24px}}
.sheet{
  background:var(--paper);width:100%;max-width:640px;max-height:88dvh;overflow-y:auto;
  border-radius:16px 16px 0 0;padding:20px 18px calc(24px + env(safe-area-inset-bottom));
  box-shadow:var(--shadow-3);
}
@media(min-width:781px){.sheet{border-radius:16px;padding:24px}}
.sheet-close{position:sticky;top:0;display:flex;justify-content:flex-end;margin-bottom:-6px}

.legend{display:flex;gap:16px;flex-wrap:wrap;font-size:.78rem;color:var(--ink-3);margin-top:10px}
.legend i{display:inline-block;width:9px;height:9px;border-radius:2px;margin-right:5px}

/* ── Bandeau examen ────────────────────────────────────────────── */
.exam{
  background:var(--surface);border:1px solid var(--roux);border-radius:var(--r);
  padding:18px 20px;box-shadow:var(--shadow-2);
  border-left:4px solid var(--roux);
}
.exam.warn{border-color:var(--or);border-left-color:var(--or)}
.exam-top{display:flex;align-items:flex-start;gap:18px;flex-wrap:wrap}
.exam-eyebrow{
  font-size:.7rem;letter-spacing:.11em;text-transform:uppercase;color:var(--ink-3);font-weight:650;
}
.exam-j{margin-top:4px;display:flex;align-items:baseline;gap:8px}
.exam-j b{font-size:1.9rem;font-weight:700;line-height:1;color:var(--roux)}
.exam.warn .exam-j b{color:var(--or)}
.exam-j span{font-size:.86rem;color:var(--ink-2)}
.exam-quota{
  margin-left:auto;text-align:right;display:flex;align-items:baseline;gap:9px;
}
.exam-quota b{font-size:1.6rem;font-weight:700;line-height:1}
.exam-quota span{font-size:.74rem;color:var(--ink-3);line-height:1.3;text-align:left}
.exam-legend{
  display:flex;align-items:center;gap:10px;margin-top:9px;font-size:.8rem;color:var(--ink-3);
  flex-wrap:wrap;
}
.exam-legend a{color:var(--roux);font-weight:600}
.exam-verdict{
  margin-top:12px;padding-top:11px;border-top:1px solid var(--line-soft);
  font-size:.9rem;color:var(--ink-2);
}
@media(max-width:520px){
  .exam-quota{margin-left:0;width:100%;text-align:left;justify-content:flex-start;
    padding-top:10px;border-top:1px solid var(--line-soft)}
}

/* Priorité d'examen */
.badge.p1{background:var(--rouge-soft);color:var(--rouge)}
.badge.p2{background:var(--surface-2);color:var(--ink-2)}
.badge.p3{background:transparent;color:var(--ink-3);border:1px solid var(--line)}

.setrow input[type=date]{
  padding:8px 10px;border:1px solid var(--line);border-radius:6px;background:var(--paper);
  color:var(--ink);
}

/* ── Choix de la durée de session ──────────────────────────────── */
.cta-alt{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-top:-6px}
.cta-alt button{
  padding:7px 13px;border-radius:999px;border:1px solid var(--line);background:var(--surface);
  font-size:.83rem;cursor:pointer;color:var(--ink-2);font-weight:600;
}
.cta-alt button:hover{border-color:var(--roux);color:var(--roux)}
.exam-proj{
  margin-top:8px;font-size:.87rem;color:var(--ink-3);line-height:1.5;
}
.exam-proj b{color:var(--ink-2)}
.exam-quota b .sur{font-size:.95rem;font-weight:600;color:var(--ink-3)}

/* ── Mode lecture ──────────────────────────────────────────────── */
.lire-head{padding-bottom:4px}
.lire-bar{
  display:flex;gap:10px;align-items:center;flex-wrap:wrap;
  position:sticky;top:var(--topbar-h);z-index:20;padding:10px 0;
  background:color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter:blur(8px);border-bottom:1px solid var(--line-soft);
}
.toc{background:var(--surface-2);border-radius:var(--r);padding:14px 18px}
.toc b{font-size:.74rem;letter-spacing:.09em;text-transform:uppercase;color:var(--ink-3)}
.toc ol{margin:8px 0 0;padding-left:1.3em;columns:2;column-gap:28px;font-size:.89rem}
@media(max-width:620px){.toc ol{columns:1}}
.toc li{margin-bottom:4px;break-inside:avoid}
.toc a{color:var(--ink-2);text-decoration:none}
.toc a:hover{color:var(--roux)}

.lire-sec{scroll-margin-top:110px}
.lire-sec-t{
  font-size:.78rem;letter-spacing:.1em;text-transform:uppercase;color:var(--roux);
  font-weight:700;margin:10px 0 10px;padding-bottom:7px;border-bottom:1px solid var(--line);
}
.lire-card{
  background:var(--surface);border:1px solid var(--line);border-radius:var(--r);
  padding:16px 18px;margin-bottom:10px;
}
.lire-card.dense{padding:13px 16px}
.lire-card-h{display:flex;align-items:center;gap:9px;margin-bottom:7px;flex-wrap:wrap}
.lire-card-h h3{font-size:1rem;flex:1 1 12rem;min-width:0}
.lire-card .def{font-size:.95rem;line-height:1.58;color:var(--ink-2)}
.lire-card .def strong{color:var(--ink)}
.lire-card.dense .def{font-size:.92rem}
.lire-card .det{margin-top:11px;font-size:.9rem;color:var(--ink-3)}
.lire-card .ex{
  margin-top:12px;padding:11px 13px;border-radius:var(--r-s);
  background:var(--sage-soft);border-left:3px solid var(--sage);font-size:.89rem;
}
.lire-card .ex b{display:block;font-size:.66rem;letter-spacing:.09em;text-transform:uppercase;
  color:var(--sage);margin-bottom:3px}
.lire-card .schema{margin-top:11px}

.lire-foot{
  position:sticky;bottom:0;display:flex;align-items:center;gap:16px;flex-wrap:wrap;
  background:var(--surface);border:1px solid var(--roux);border-radius:var(--r);
  padding:14px 18px;box-shadow:var(--shadow-3);margin-top:8px;
}
.lire-foot b{display:block;font-size:.94rem}
.lire-foot span{display:block}
.lire-foot button{margin-left:auto}
@media(max-width:780px){
  .lire-foot{
    bottom:calc(72px + env(safe-area-inset-bottom));
    padding:10px 14px;gap:10px;flex-wrap:nowrap;align-items:center;
  }
  .lire-foot b{font-size:.85rem;line-height:1.3}
  .lire-foot .small{display:none}          /* la phrase pédagogique tient sur desktop seulement */
  .lire-foot button{flex-shrink:0;padding:9px 14px;font-size:.85rem}
}
/* de quoi faire défiler sous la barre d'action collante */
.lire{padding-bottom:12px}
.lire .lire-sec:last-of-type{padding-bottom:70px}

.cta.secondaire{
  background:var(--surface);color:var(--ink);border:1px solid var(--line);box-shadow:var(--shadow-1);
}
.cta.secondaire:hover{border-color:var(--roux);filter:none}
.cta.secondaire .big{font-size:1.15rem}
.cta.secondaire .lbl{color:var(--ink-3)}
.cta.secondaire .arrow{color:var(--roux)}

.exam.invite{border-color:var(--line);border-left-color:var(--roux);background:var(--surface-2)}
.exam-date{
  padding:9px 12px;border:1px solid var(--roux);border-radius:var(--r-s);
  background:var(--surface);color:var(--ink);font-weight:600;margin-left:auto;
}

/* ── Impression : l'aide-mémoire sur papier ────────────────────── */
@media print{
  .topbar,.bottombar,.no-print,.lire-bar,.lire-foot,.toast,.sync{display:none !important}
  body{background:#fff;color:#000;font-size:11pt}
  .view{max-width:none;padding:0}
  .lire-card{border:none;border-bottom:1px solid #ccc;border-radius:0;padding:8px 0;
    margin:0;break-inside:avoid;background:#fff}
  .lire-sec-t{color:#000;border-color:#000;margin-top:14px}
  .lire-card .def,.lire-card .det{color:#000}
  .lire-card .ex{background:#f4f4f4;border-left-color:#888}
  .badge{border:1px solid #999;color:#000 !important;background:#fff !important}
  .state-dot{display:none}
  h1{font-size:18pt}
  a{text-decoration:none;color:#000}
}

/* Ligne de contexte : de quel cours et de quelle partie vient la question */
.q .qctx{
  font-size:.79rem;color:var(--roux);font-weight:650;letter-spacing:.01em;
  margin-bottom:8px;padding-bottom:8px;border-bottom:1px solid var(--line-soft);
}

/* Revenir en arrière ──────────────────────────────────────────── */
.redo{
  display:block;width:100%;margin-top:12px;padding:10px 14px;
  background:transparent;border:1px dashed var(--line);border-radius:var(--r-s);
  color:var(--ink-3);font-size:.86rem;cursor:pointer;text-align:center;
}
.redo:hover{border-color:var(--roux);border-style:solid;color:var(--roux)}
.sessbar button[data-undo]{
  color:var(--roux);text-decoration:none;font-weight:600;white-space:nowrap;
}
.sessbar button[data-undo]:hover{text-decoration:underline}
