/* ============================================================================
   Prépa S1PA — feuille de style unique.
   Direction : carnet de prépa. Encre, marge rouge, quadrillage Séyès,
   blocs de théorème façon polycopié. Aucune ressource externe.
   ========================================================================== */

:root {
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;

  --paper:   #FAFAF7;
  --surface: #FFFFFF;
  --sunk:    #F2F2EE;
  --ink:     #171A2C;
  --ink-2:   #5C6178;
  --ink-3:   #8B90A3;
  --rule:    #E3E4E9;
  --rule-2:  #CFD1DA;
  --seyes:   #CBD9F0;
  --red:     #C0392B;
  --red-bg:  #FCEFEC;
  --green:   #16714F;
  --green-bg:#E9F5F0;
  --amber:   #8A5D08;
  --amber-bg:#FBF2DF;
  --blue:    #24408E;
  --blue-bg: #EDF1FB;

  --r: 3px;
  --shadow: 0 1px 2px rgba(23,26,44,.05), 0 8px 24px -16px rgba(23,26,44,.18);
  --tap: 44px;
}

:root[data-theme="dark"],
html[data-theme="dark"] body {
  --paper:   #101320;
  --surface: #171B29;
  --sunk:    #1C2130;
  --ink:     #E9EAEF;
  --ink-2:   #9DA3B7;
  --ink-3:   #6E7489;
  --rule:    #272C3D;
  --rule-2:  #363C52;
  --seyes:   #223050;
  --red:     #F0796B;
  --red-bg:  #2C1C1E;
  --green:   #4FC79B;
  --green-bg:#122A24;
  --amber:   #E2AE5B;
  --amber-bg:#2A2216;
  --blue:    #8FA9F0;
  --blue-bg: #1A2138;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -16px rgba(0,0,0,.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:   #101320;
    --surface: #171B29;
    --sunk:    #1C2130;
    --ink:     #E9EAEF;
    --ink-2:   #9DA3B7;
    --ink-3:   #6E7489;
    --rule:    #272C3D;
    --rule-2:  #363C52;
    --seyes:   #223050;
    --red:     #F0796B;
    --red-bg:  #2C1C1E;
    --green:   #4FC79B;
    --green-bg:#122A24;
    --amber:   #E2AE5B;
    --amber-bg:#2A2216;
    --blue:    #8FA9F0;
    --blue-bg: #1A2138;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -16px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; }
/* Sans cela, un .btn ou une .grade-row resterait visible malgré [hidden] :
   leur `display` explicite l'emporte sur la règle par défaut du navigateur. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.65 var(--serif);
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: -.005em; }
p { margin: 0 0 .9em; }
a { color: inherit; text-decoration-color: var(--rule-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--red); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 2px; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }
ul, ol { margin: 0 0 1em; padding-left: 1.35em; }
li { margin-bottom: .35em; }
code, kbd { font-family: var(--mono); font-size: .87em; background: var(--sunk); padding: .1em .35em; border-radius: 2px; }
table { border-collapse: collapse; }

/* ------------------------------------------------------------------ éléments
   L'étiquette : petite capitale mono. Sert partout à nommer un rôle. */
.eyebrow {
  font: 600 11px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.eyebrow--red { color: var(--red); }

/* ------------------------------------------------------------------ en-tête */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.topbar__in {
  max-width: 1180px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 18px; min-height: 58px;
}
.brand { display: flex; align-items: baseline; gap: 9px; text-decoration: none; flex-shrink: 0; }
.brand__mark {
  width: 15px; height: 15px; background: var(--ink);
  display: inline-block; transform: translateY(1px);
}
.brand__name { font: 600 16px/1 var(--serif); letter-spacing: -.01em; }
.brand__sub { font: 500 10px/1 var(--mono); letter-spacing: .13em; color: var(--ink-3); text-transform: uppercase; }

.nav { display: flex; gap: 2px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav a {
  font: 500 13px/1 var(--sans); color: var(--ink-2); text-decoration: none;
  padding: 8px 11px; border-radius: var(--r); white-space: nowrap;
  transition: color .15s, background .15s;
}
.nav a:hover { color: var(--ink); background: var(--sunk); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 650; box-shadow: inset 0 -2px 0 var(--red); border-radius: 0; }

.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink-2);
  border-radius: var(--r); cursor: pointer; font-size: 15px; line-height: 1;
  transition: border-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--rule-2); color: var(--ink); }

/* ------------------------------------------------------------------- layout */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.wrap--read { max-width: 820px; }
.page { padding: 40px 0 96px; }
.stack > * + * { margin-top: var(--gap, 16px); }

/* La marge du cahier : filet rouge vertical. Signature du site. */
.margin-rule { position: relative; padding-left: 26px; }
.margin-rule::before {
  content: ''; position: absolute; left: 0; top: .25em; bottom: .25em;
  width: 1px; background: var(--red); opacity: .5;
}

/* Le quadrillage Séyès : réservé aux zones de travail. */
.seyes {
  background-color: var(--surface);
  background-image:
    linear-gradient(var(--seyes) 1px, transparent 1px),
    linear-gradient(90deg, var(--seyes) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: -1px -1px;
}

/* --------------------------------------------------------------- titres page */
.page-head { margin-bottom: 34px; }
.page-head h1 { font-size: clamp(30px, 5vw, 44px); margin: 8px 0 10px; }
.page-head .lede { color: var(--ink-2); font-size: 18px; max-width: 62ch; margin: 0; }

/* --------------------------------------------------------------------- carte */
.card {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r); padding: 22px;
}
.card--sunk { background: var(--sunk); }
.card__title { font-size: 19px; margin-bottom: 4px; }
.card__meta { font: 500 12px/1.4 var(--mono); color: var(--ink-3); }

/* ------------------------------------------------------------------- boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 14px/1 var(--sans); padding: 11px 18px; min-height: 40px;
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  border-radius: var(--r); cursor: pointer; text-decoration: none;
  transition: opacity .15s, transform .06s;
}
.btn:hover { opacity: .87; }
.btn:active { transform: translateY(1px); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--rule-2); }
.btn--ghost:hover { background: var(--sunk); opacity: 1; }
.btn--red { background: var(--red); border-color: var(--red); color: #fff; }
.btn--sm { font-size: 13px; padding: 8px 13px; min-height: 34px; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* --------------------------------------------------------------------- puces */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase;
  padding: 5px 9px; border-radius: 2px; border: 1px solid var(--rule-2);
  color: var(--ink-2); background: var(--surface); white-space: nowrap;
}
.chip--red   { color: var(--red);   border-color: color-mix(in srgb, var(--red) 40%, transparent);   background: var(--red-bg); }
.chip--green { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); background: var(--green-bg); }
.chip--amber { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, transparent); background: var(--amber-bg); }
.chip--blue  { color: var(--blue);  border-color: color-mix(in srgb, var(--blue) 40%, transparent);  background: var(--blue-bg); }

/* =============================================================== FORMULES ==
   Rendu produit par mathlite.js. */
.math { font-family: var(--serif); font-size: 1.03em; }
.math-display {
  display: block; text-align: center; margin: 1.1em 0; font-size: 1.1em;
  overflow-x: auto; overflow-y: hidden; padding: 2px 0 6px;
}
.math-err { color: var(--red); font-family: var(--mono); font-size: .85em; }
.m-var { font-style: italic; padding-right: .02em; }
.m-fn, .m-text, .m-num { font-style: normal; }
.m-fn { padding: 0 .12em 0 .06em; }
.m-text { font-family: var(--serif); }
.m-sym, .m-punct { font-style: normal; padding: 0 .04em; }
.m-rel { font-style: normal; margin: 0 .26em; }
.m-bin { font-style: normal; margin: 0 .19em; }
.m-prime { font-style: normal; }
.m-unary { font-style: normal; }
/* dans un indice ou un exposant, tout se resserre */
.math sub .m-rel, .math sup .m-rel, .m-lim .m-rel { margin: 0 .1em; }
.math sub .m-bin, .math sup .m-bin, .m-lim .m-bin { margin: 0 .06em; }
.m-bb, .m-cal { font-style: normal; padding: 0 .03em; }

.math sup, .math sub { font-size: .72em; line-height: 0; position: relative; }
.math sup { top: -.42em; }
.math sub { bottom: -.19em; }

.m-frac {
  display: inline-flex; flex-direction: column; vertical-align: middle;
  text-align: center; margin: 0 .18em; line-height: 1.15;
}
.m-num-part { padding: 0 .3em .12em; border-bottom: 1px solid currentColor; }
.m-den-part { padding: .16em .3em 0; }
.m-frac .m-frac { font-size: .92em; }
/* un exposant au dénominateur remonterait dans la barre de fraction */
.m-frac sup { top: -.34em; }
.m-den-part:has(sup) { padding-top: .44em; }
.m-num-part:has(sub) { padding-bottom: .38em; }
.m-frac-t { font-size: .85em; }

.m-binom {
  display: inline-flex; flex-direction: column; vertical-align: middle;
  text-align: center; line-height: 1.15; padding: 0 .1em;
}

.m-sqrt { display: inline-flex; align-items: flex-start; margin: 0 .1em; }
.m-sqrt-sign { display: inline-block; transform: scaleY(1.25); transform-origin: 50% 65%; }
.m-sqrt-rad { border-top: 1px solid currentColor; padding: .1em .18em 0 .1em; margin-top: .12em; }
.m-sqrt-idx { font-size: .62em; align-self: flex-start; margin-right: -.35em; }

.m-op-stack {
  display: inline-flex; flex-direction: column; align-items: center;
  vertical-align: middle; margin: 0 .16em; line-height: 1.05;
}
.m-lim { font-size: .66em; white-space: nowrap; }
.m-lim:empty { display: none; }
.m-op-body { line-height: 1; }
.m-bigop { font-size: 1.5em; line-height: .82; display: inline-block; }
.m-int { font-size: 1.7em; transform: translateY(.06em); }

.m-bigd { display: inline-block; font-style: normal; padding: 0 .05em; transform-origin: 50% 48%; }
.m-bigd-1 { transform: scaleY(1.2); }
.m-bigd-2 { transform: scaleY(1.5); }
.m-bigd-3 { transform: scaleY(1.8); }
.m-bigd-4 { transform: scaleY(2.1); }

.m-paren-1 { display: inline-block; transform: scaleY(1.28); transform-origin: 50% 48%; padding: 0 .04em; }
.m-paren-2 { display: inline-block; transform: scaleY(1.95); transform-origin: 50% 48%; padding: 0 .06em; }

.m-acc { display: inline-block; position: relative; }
/* padding, pas margin : la boîte grandit vers le haut sans déplacer la ligne de base */
.m-acc-over  { border-top: 1px solid currentColor; padding: .1em .06em 0; }
.m-acc-under { border-bottom: 1px solid currentColor; padding: 0 .06em .08em; }
.m-acc-vec::after {
  content: '→'; position: absolute; top: -.72em; left: 50%; transform: translateX(-50%);
  font-size: .62em; line-height: 1; font-style: normal;
}
.m-acc-hat::after, .m-acc-tilde::after {
  position: absolute; top: -.62em; left: 50%; transform: translateX(-50%);
  font-size: .7em; line-height: 1; font-style: normal;
}
.m-acc-hat::after { content: '^'; }
.m-acc-tilde::after { content: '~'; }

.m-boxed { border: 1px solid currentColor; border-radius: 2px; padding: .12em .35em; display: inline-block; }
.m-brace-u { border-bottom: 1px solid currentColor; padding-bottom: .1em; display: inline-block; }
.m-brace-o { border-top: 1px solid currentColor; padding-top: .1em; display: inline-block; }
.m-neg { display: inline-block; width: 0; }
.m-neg::before { content: '/'; margin-left: -.5em; }
.m-xarrow .m-op-body { font-size: 1.05em; }
.m-xarrow .m-lim { font-size: .62em; }

.m-cases { display: inline-flex; align-items: center; vertical-align: middle; }
.m-brace { display: inline-block; transform: scaleY(2.4); transform-origin: 50% 50%; margin-right: .35em; font-style: normal; }
.m-grid { display: inline-flex; flex-direction: column; gap: .25em; }
.m-row { display: flex; gap: .6em; align-items: baseline; }
.m-cell { text-align: left; }
.m-align .m-row { justify-content: center; }

/* ============================================== BLOCS DE COURS (façon amsthm) */
.thm {
  margin: 1.5em 0; padding: 0 0 0 18px; border-left: 2px solid var(--rule-2);
}
.thm__head {
  font: 600 12px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase;
  margin-bottom: .6em; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.thm__name { font-family: var(--serif); font-size: 15px; letter-spacing: 0; text-transform: none; font-weight: 600; color: var(--ink-2); font-style: italic; }
.thm__body > *:last-child { margin-bottom: 0; }

.thm--def   { border-left-color: var(--blue); }
.thm--def   .thm__head { color: var(--blue); }
.thm--thm   { border-left-color: var(--red); background: linear-gradient(90deg, var(--red-bg), transparent 55%); padding-top: 2px; padding-bottom: 2px; }
.thm--thm   .thm__head { color: var(--red); }
.thm--prop  { border-left-color: var(--ink-3); }
.thm--prop  .thm__head { color: var(--ink-2); }
.thm--meth  { border-left-color: var(--green); background: linear-gradient(90deg, var(--green-bg), transparent 55%); padding-top: 2px; padding-bottom: 2px; }
.thm--meth  .thm__head { color: var(--green); }
.thm--warn  { border-left-color: var(--amber); background: linear-gradient(90deg, var(--amber-bg), transparent 55%); padding-top: 2px; padding-bottom: 2px; }
.thm--warn  .thm__head { color: var(--amber); }
.thm--ex    { border-left-color: var(--rule-2); }
.thm--ex    .thm__head { color: var(--ink-3); }

.qed::after { content: ' ∎'; color: var(--red); }

/* tableau de vérité / tableaux de cours */
.tbl { width: 100%; font-size: 15px; margin: 1.2em 0; }
.tbl th, .tbl td { border: 1px solid var(--rule); padding: 7px 11px; text-align: center; }
.tbl th { background: var(--sunk); font: 600 12px/1.3 var(--mono); letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); }
.tbl td:first-child, .tbl th:first-child { text-align: left; }
.tbl-scroll { overflow-x: auto; margin: 1.2em 0; }
.tbl-scroll .tbl { margin: 0; min-width: 420px; }

/* ===================================================================== QCM == */
.quiz { }
.q {
  border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--surface); padding: 20px 22px; margin-bottom: 14px;
}
.q__num { font: 600 11px/1 var(--mono); letter-spacing: .1em; color: var(--ink-3); }
.q__text { font-size: 17px; margin: 8px 0 16px; }
/* sans colonne déclarée, la grille prendrait la largeur de l'option la plus longue */
.q__opts { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.opt {
  display: flex; align-items: flex-start; gap: 11px; width: 100%; text-align: left;
  padding: 12px 14px; min-height: var(--tap);
  border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--surface); color: inherit; cursor: pointer;
  font: 400 16px/1.5 var(--serif);
  transition: border-color .15s, background .15s;
}
.opt:hover:not(:disabled) { border-color: var(--rule-2); background: var(--sunk); }
/* une formule plus large que l'écran défile dans sa propre option */
.opt > span:last-child { min-width: 0; overflow-x: auto; }
.opt__key {
  flex-shrink: 0; width: 22px; height: 22px; display: grid; place-items: center;
  border: 1px solid var(--rule-2); border-radius: 50%;
  font: 600 11px/1 var(--mono); color: var(--ink-3); margin-top: 2px;
}
.opt[aria-pressed="true"] { border-color: var(--ink); }
.opt.is-right { border-color: var(--green); background: var(--green-bg); }
.opt.is-right .opt__key { border-color: var(--green); color: var(--green); }
.opt.is-wrong { border-color: var(--red); background: var(--red-bg); }
.opt.is-wrong .opt__key { border-color: var(--red); color: var(--red); }
.opt:disabled { cursor: default; }

.q__fb {
  margin-top: 14px; padding: 13px 16px; border-radius: var(--r);
  font-size: 15.5px; border-left: 2px solid var(--rule-2); background: var(--sunk);
}
.q__fb.is-right { border-left-color: var(--green); background: var(--green-bg); }
.q__fb.is-wrong { border-left-color: var(--red); background: var(--red-bg); }
.q__fb b { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; display: block; margin-bottom: 5px; }

/* ============================================================== FLASHCARDS == */
.flash {
  position: relative; min-height: 300px; display: grid; place-items: center;
  padding: 44px 30px; border: 1px solid var(--rule); border-radius: var(--r);
  text-align: center;
}
.flash__q { font-size: 22px; line-height: 1.45; max-width: 42ch; }
.flash__a {
  margin-top: 26px; padding-top: 22px; border-top: 1px dashed var(--rule-2);
  font-size: 18px; color: var(--ink); max-width: 52ch; text-align: left;
}
.flash__a[hidden] { display: none; }
.flash__tag { position: absolute; top: 14px; left: 16px; }
.flash__count { position: absolute; top: 14px; right: 16px; font: 500 12px/1 var(--mono); color: var(--ink-3); }
.grade-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.grade {
  padding: 13px 10px; min-height: var(--tap); border-radius: var(--r); cursor: pointer;
  border: 1px solid var(--rule-2); background: var(--surface); color: var(--ink);
  font: 600 13px/1.3 var(--sans);
}
.grade small { display: block; font: 500 11px/1.3 var(--mono); color: var(--ink-3); margin-top: 3px; }
.grade:hover { background: var(--sunk); }
.grade--again:hover { border-color: var(--red); color: var(--red); }
.grade--hard:hover  { border-color: var(--amber); color: var(--amber); }
.grade--good:hover  { border-color: var(--green); color: var(--green); }

/* =========================================================== PROGRESSION === */
/* Le ∎ : il se remplit d'encre au fil du mois. */
.qed-block {
  width: 132px; height: 132px; flex-shrink: 0;
  border: 2px solid var(--ink); position: relative; overflow: hidden;
  background: var(--surface);
}
.qed-block__fill {
  position: absolute; left: 0; right: 0; bottom: 0; background: var(--ink);
  transition: height 1.1s cubic-bezier(.22,1,.36,1);
}
.qed-block__pct {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 600 30px/1 var(--mono); mix-blend-mode: difference; color: #fff;
}

.bar { height: 5px; background: var(--rule); border-radius: 99px; overflow: hidden; }
.bar__fill { height: 100%; background: var(--ink); border-radius: 99px; transition: width .7s cubic-bezier(.22,1,.36,1); }
.bar__fill--green { background: var(--green); }
.bar__fill--amber { background: var(--amber); }
.bar__fill--red   { background: var(--red); }

.stat { display: flex; flex-direction: column; gap: 3px; }
.stat__v { font: 600 27px/1 var(--mono); letter-spacing: -.02em; }
.stat__l { font: 500 11px/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }

/* ============================================================== CALENDRIER == */
/* minmax(0,…) : sans cela une case refuse de descendre sous sa taille minimale */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal__day {
  aspect-ratio: 1; border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--surface); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; cursor: pointer;
  text-decoration: none; color: inherit; padding: 4px; position: relative;
  transition: border-color .15s, background .15s, transform .1s;
  min-height: 52px;
}
.cal__day:hover { border-color: var(--ink-3); transform: translateY(-1px); }
.cal__n { font: 600 15px/1 var(--mono); }
.cal__t { font: 500 8.5px/1.15 var(--mono); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); text-align: center; }
.cal__day.is-done { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.cal__day.is-done .cal__t { color: color-mix(in srgb, var(--paper) 65%, transparent); }
.cal__day.is-today { border-color: var(--red); border-width: 2px; }
.cal__day.is-rest { background: var(--sunk); border-style: dashed; }
.cal__day.is-ds::after {
  content: ''; position: absolute; top: 5px; right: 5px;
  width: 5px; height: 5px; background: var(--red); border-radius: 50%;
}

/* ============================================================= GRILLE CHAP == */
/* min() évite qu'une colonne impose une largeur plus grande que l'écran */
.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }

.chap {
  display: block; text-decoration: none; color: inherit;
  border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--surface); padding: 17px 18px;
  transition: border-color .15s, transform .1s;
}
.chap:hover { border-color: var(--ink-3); transform: translateY(-1px); }
.chap__top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.chap__id { font: 600 11px/1 var(--mono); color: var(--ink-3); letter-spacing: .1em; }
.chap__name { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.chap__meta { font: 500 11.5px/1.4 var(--mono); color: var(--ink-3); margin-bottom: 11px; }

/* ==================================================================== DIVERS */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 22px; overflow-x: auto; }
.tab {
  font: 600 13px/1 var(--sans); padding: 11px 14px; min-height: 40px;
  border: 0; background: none; color: var(--ink-2); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--red); }

details.fold { border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); margin-bottom: 10px; }
details.fold > summary {
  cursor: pointer; padding: 14px 18px; font: 600 15px/1.4 var(--serif);
  list-style: none; display: flex; align-items: center; gap: 10px; min-height: var(--tap);
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before {
  content: '+'; font: 400 17px/1 var(--mono); color: var(--red); width: 13px; flex-shrink: 0;
}
details.fold[open] > summary::before { content: '−'; }
details.fold > summary:hover { background: var(--sunk); }
.fold__body { padding: 2px 18px 18px 41px; }
.fold__body > *:last-child { margin-bottom: 0; }

.brouillon {
  border: 1px solid var(--rule); border-radius: var(--r);
  padding: 16px; font: 400 16px/22px var(--mono); color: var(--ink);
  width: 100%; min-height: 132px; resize: vertical;
}
.brouillon:focus { outline: 2px solid var(--red); outline-offset: -1px; }

.timer { font: 600 30px/1 var(--mono); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.timer.is-low { color: var(--red); }

.empty { text-align: center; padding: 60px 24px; color: var(--ink-2); }
.empty h3 { font-size: 20px; margin-bottom: 8px; color: var(--ink); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(120%);
  background: var(--ink); color: var(--paper); padding: 12px 20px; border-radius: var(--r);
  font: 600 14px/1 var(--sans); z-index: 200; transition: transform .3s cubic-bezier(.22,1,.36,1);
  box-shadow: var(--shadow); max-width: calc(100vw - 32px); text-align: center;
}
.toast.is-on { transform: translateX(-50%) translateY(0); }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 300; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--r); }

.muted { color: var(--ink-2); }
.small { font-size: 14.5px; }
.center { text-align: center; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }

.footer { border-top: 1px solid var(--rule); margin-top: 70px; padding: 26px 0 44px; color: var(--ink-3); font-size: 14px; }

/* ------------------------------------------------------------------ mobile */
@media (max-width: 720px) {
  body { font-size: 16.5px; }
  .topbar__in { min-height: 54px; gap: 10px; padding: 0 14px; }
  .brand__sub { display: none; }
  .nav { gap: 0; margin-left: auto; }
  .nav a { padding: 7px 8px; font-size: 12.5px; }
  .wrap { padding: 0 14px; }
  .page { padding: 26px 0 72px; }
  .card { padding: 17px; }
  .q { padding: 16px; }
  .cal { gap: 4px; }
  /* aspect-ratio + min-height forceraient une largeur de case supérieure à l'écran */
  .cal__day { aspect-ratio: auto; min-height: 46px; }
  .cal__t { display: none; }
  .grade-row { grid-template-columns: 1fr; }
  .qed-block { width: 96px; height: 96px; }
  .qed-block__pct { font-size: 22px; }
  .fold__body { padding: 2px 16px 16px 16px; }
  .margin-rule { padding-left: 16px; }
}

@media print {
  .topbar, .nav, .btn, .footer { display: none !important; }
  body { background: #fff; color: #000; }
}
