/* Polycop : bibliothèque des cours EPITA.
   Direction visuelle : la copie de maths française. Papier à petits carreaux,
   ligne de marge rouge, encre bleu BIC, surlignage stabilo, sommaires à
   points de conduite façon table des matières LaTeX. */

@font-face {
  font-family: 'STIX Two Text';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/stix-two-text-latin-400-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'STIX Two Text';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/assets/fonts/stix-two-text-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'STIX Two Text';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/assets/fonts/stix-two-text-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-sans-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2');
}

/* Thème par défaut : clair (la copie de maths). Le sombre reste
   disponible via [data-theme="sombre"], mémorisé en localStorage. */
:root {
  --papier: #faf9f4;
  --carreau: rgba(30, 64, 192, 0.05);
  --feuille: #ffffff;
  --bord: #e5e2d8;
  --filet: #e8eaf0;
  --encre: #191c23;
  --encre-douce: #363c49;
  --crayon: #636a78;
  --bic: #1e40c0;
  --bic-fonce: #16309a;
  --bic-pale: #e9edfb;
  --bouton: #1e40c0;
  --bouton-survol: #16309a;
  --marge: #e0455e;
  --fluo: #fff3a0;
  --selection: #fff3a0;
  --pointille: #c7cbd6;
  --marge-fond: #fffdf8;
  --champ-fond: #ffffff;
  --champ-bord: #d5d9e2;
  --chip-fond: #fcfcfa;
  --apercu-fond: #f2f1ec;
  --alerte-fond: #fdeef1;
  --alerte-texte: #8c2237;
  --estompe: #b9bec9;
  --ombre: 0 1px 3px rgba(25, 28, 35, 0.05);
  --ombre-survol: 0 6px 16px rgba(30, 64, 192, 0.1);
  color-scheme: light;
  --affiche: 'STIX Two Text', georgia, 'Times New Roman', serif;
  --ui: 'IBM Plex Sans', system-ui, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', menlo, monospace;
}

[data-theme='sombre'] {
  --papier: #0f1114;
  --carreau: rgba(124, 150, 255, 0.055);
  --feuille: #16191f;
  --bord: #272c35;
  --filet: #232831;
  --encre: #e9eaee;
  --encre-douce: #c5cad5;
  --crayon: #8d94a4;
  --bic: #8ea6ff;
  --bic-fonce: #adbdff;
  --bic-pale: #1c2440;
  --bouton: #2f4fd6;
  --bouton-survol: #4161e2;
  --marge: #ff5f78;
  --fluo: rgba(255, 228, 96, 0.16);
  --selection: #4a431c;
  --pointille: #3a404c;
  --marge-fond: #14171d;
  --champ-fond: #101317;
  --champ-bord: #343b48;
  --chip-fond: #14171c;
  --apercu-fond: #24262b;
  --alerte-fond: #2d161d;
  --alerte-texte: #ff9fae;
  --estompe: #4a505c;
  --ombre: 0 1px 3px rgba(0, 0, 0, 0.4);
  --ombre-survol: 0 6px 16px rgba(0, 0, 0, 0.45);
  --affiche: 'STIX Two Text', georgia, 'Times New Roman', serif;
  --ui: 'IBM Plex Sans', system-ui, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', menlo, monospace;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Nos display explicites ne doivent jamais l'emporter sur l'attribut hidden. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--ui);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--encre);
  background-color: var(--papier);
  background-image:
    linear-gradient(var(--carreau) 1px, transparent 1px),
    linear-gradient(90deg, var(--carreau) 1px, transparent 1px);
  background-size: 26px 26px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3,
p,
dl,
dd,
figure {
  margin: 0;
}

img,
iframe {
  max-width: 100%;
}

a {
  color: var(--bic);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

::selection {
  background: var(--selection);
  color: var(--encre);
}

:focus-visible {
  outline: 2px solid var(--bic);
  outline-offset: 2px;
  border-radius: 4px;
}

.conteneur {
  width: 100%;
  max-width: 1024px;
  margin-inline: auto;
  padding-inline: clamp(18px, 4vw, 32px);
}

.mono {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.01em;
}

.sur-titre {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--crayon);
}

/* ---------- En-tête ---------- */

.entete {
  border-bottom: 1px solid var(--bord);
  background: color-mix(in srgb, var(--papier) 82%, transparent);
  backdrop-filter: blur(6px);
}

.entete .barre {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 14px;
}

.marque {
  font-family: var(--affiche);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--encre);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.marque .point {
  color: var(--bic);
}

.entete nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.lien-nav {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--encre-douce);
  text-decoration: none;
}

.lien-nav:hover {
  color: var(--bic);
}

/* Sur mobile, l'en-tête passe à la ligne : le logo reste seul en haut,
   la navigation (thème, liens, bouton, compte, déconnexion) descend sur
   sa propre ligne alignée à droite et s'enroule au besoin. Cela évite
   tout débordement horizontal quel que soit le nombre d'actions. */
@media (max-width: 640px) {
  .entete .barre {
    flex-wrap: wrap;
    row-gap: 12px;
  }

  .entete nav {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px 14px;
  }

  .entete nav .btn {
    padding: 0.6em 0.95em;
    font-size: 0.86rem;
  }

  .zone-user {
    gap: 12px;
  }
}

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--ui);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.72em 1.15em;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.btn-primaire {
  background: var(--bouton);
  color: #fff;
}

.btn-primaire:hover {
  background: var(--bouton-survol);
}

.btn-primaire:active {
  transform: translateY(1px);
}

.btn-secondaire {
  background: var(--feuille);
  border-color: var(--bord);
  color: var(--encre);
}

.btn-secondaire:hover {
  border-color: var(--bic);
  color: var(--bic);
}

.btn[disabled] {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

/* ---------- Héros ---------- */

.heros {
  padding-block: clamp(44px, 8vw, 84px) clamp(20px, 4vw, 36px);
}

.heros h1 {
  font-family: var(--affiche);
  font-weight: 700;
  font-size: clamp(2.25rem, 4.8vw, 3.2rem);
  line-height: 1.08;
  letter-spacing: -0.015em;
  max-width: 21ch;
  margin-top: 14px;
  text-wrap: balance;
}

.sous-heros {
  margin-top: 18px;
  max-width: 56ch;
  font-size: 1.04rem;
  line-height: 1.65;
  color: var(--encre-douce);
}

.resume-bib {
  display: block;
  margin-top: 14px;
  color: var(--crayon);
}

/* L'année en quatre cases : la structure du site rendue visible. */

.annee {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(20px, 4vw, 40px);
  margin-top: clamp(28px, 5vw, 44px);
}

.groupe-sem {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cases {
  display: flex;
  gap: 12px;
}

.case {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 128px;
  padding: 14px 18px 12px;
  background: var(--feuille);
  border: 1px solid var(--bord);
  border-radius: 12px;
  box-shadow: var(--ombre);
  text-decoration: none;
  color: var(--encre);
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.case:hover {
  transform: translateY(-2px);
  border-color: var(--bic);
  box-shadow: var(--ombre-survol);
}

.case-code {
  font-family: var(--affiche);
  font-weight: 700;
  font-size: 1.72rem;
  line-height: 1.15;
}

.case-compte {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--crayon);
}

.case.vide .case-code {
  color: var(--estompe);
}

/* ---------- Sections bimestre ---------- */

.bibliotheque {
  padding-bottom: 40px;
}

.bimestre {
  margin-top: clamp(36px, 6vw, 56px);
  scroll-margin-top: 28px;
}

.tete-bimestre {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 14px;
}

.tete-bimestre h2 {
  font-family: var(--affiche);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.tete-bimestre .semestre-tag {
  white-space: nowrap;
}

.tete-bimestre .regle {
  flex: 1;
  border-top: 1px solid var(--bord);
  transform: translateY(-4px);
}

.tete-bimestre .compte {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--crayon);
  white-space: nowrap;
}

/* Une « feuille » posée sur le bureau quadrillé. */

.feuille {
  background: var(--feuille);
  border: 1px solid var(--bord);
  border-radius: 14px;
  box-shadow: var(--ombre);
  padding: 8px 18px;
}

.docs {
  list-style: none;
  margin: 0;
  padding: 0;
}

.docs li + li {
  border-top: 1px solid var(--filet);
}

.doc {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 12px;
  margin-inline: -6px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--encre);
  transition: background-color 130ms ease;
}

.doc:hover,
.doc:focus-visible {
  background: var(--fluo);
}

.glyphe {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-family: var(--affiche);
  font-weight: 600;
  font-size: 1.05rem;
  background: var(--papier);
  border: 1px solid var(--bord);
  border-radius: 9px;
}

.doc-corps {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.doc-titre {
  font-weight: 600;
  font-size: 0.99rem;
  line-height: 1.35;
}

.doc-sous {
  font-family: var(--mono);
  font-size: 0.73rem;
  color: var(--crayon);
}

.leader {
  flex: 1;
  min-width: 28px;
  border-bottom: 2px dotted var(--pointille);
  align-self: center;
  transform: translateY(4px);
}

.doc-meta {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--encre-douce);
  white-space: nowrap;
}

.doc-vide {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border: 1.5px dashed var(--pointille);
  border-radius: 12px;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--crayon);
  text-decoration: none;
  transition: border-color 140ms ease, color 140ms ease;
}

.doc-vide:hover {
  border-color: var(--bic);
  color: var(--bic);
}

.doc-vide .action {
  white-space: nowrap;
  font-weight: 500;
}

/* ---------- Fiche d'un cours ---------- */

.fil {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--crayon);
  padding-block: 22px 18px;
}

.fil a {
  color: var(--crayon);
}

.fil a:hover {
  color: var(--bic);
}

.fil .sep {
  margin-inline: 6px;
  color: var(--pointille);
}

.fiche {
  display: grid;
  grid-template-columns: 232px 1fr;
  background: var(--feuille);
  border: 1px solid var(--bord);
  border-radius: 16px;
  box-shadow: var(--ombre);
  margin-bottom: 56px;
  overflow: hidden;
}

/* La marge de la copie : ligne rouge verticale, annotations en mono. */

.marge {
  border-right: 2px solid var(--marge);
  padding: 26px 20px 26px 24px;
  background: var(--marge-fond);
}

.marge-int {
  position: sticky;
  top: 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.marge dl {
  display: grid;
  gap: 13px;
}

.marge dt {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--crayon);
  margin-bottom: 2px;
}

.marge dd {
  font-family: var(--mono);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--encre);
  line-height: 1.45;
}

.marge .actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lien-supprimer {
  background: none;
  border: none;
  padding: 6px 0 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--crayon);
  text-align: left;
  cursor: pointer;
}

.lien-supprimer:hover {
  color: var(--marge);
  text-decoration: underline;
}

.corps {
  padding: clamp(24px, 4vw, 40px) clamp(22px, 4.5vw, 44px);
  min-width: 0;
}

.corps .sur-titre {
  margin-bottom: 10px;
}

.corps h1 {
  font-family: var(--affiche);
  font-weight: 700;
  font-size: clamp(1.65rem, 3.4vw, 2.3rem);
  line-height: 1.14;
  letter-spacing: -0.012em;
  max-width: 24ch;
  text-wrap: balance;
}

/* Citation du document, surlignée au stabilo. */

.citation {
  display: block;
  margin: 22px 0 0;
  font-family: var(--affiche);
  font-style: italic;
  font-size: 1.06rem;
  line-height: 1.75;
  color: var(--encre-douce);
  max-width: 60ch;
}

.citation mark {
  background: linear-gradient(transparent 8%, var(--fluo) 8%, var(--fluo) 92%, transparent 92%);
  color: inherit;
  padding: 0 0.15em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.citation .source {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-style: normal;
  font-size: 0.72rem;
  color: var(--crayon);
}

.description {
  margin-top: 20px;
  max-width: 66ch;
  color: var(--encre-douce);
  line-height: 1.7;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 30px;
  margin-top: 28px;
  padding: 18px 0;
  border-top: 1px solid var(--filet);
  border-bottom: 1px solid var(--filet);
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.stat b {
  font-family: var(--affiche);
  font-weight: 700;
  font-size: 1.42rem;
  line-height: 1;
}

.stat span {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--crayon);
}

.section-corps {
  margin-top: 34px;
}

.tete-section {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.tete-section .regle {
  flex: 1;
  border-top: 1px solid var(--filet);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.chip {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--encre-douce);
  background: var(--chip-fond);
  border: 1px solid var(--filet);
  border-radius: 999px;
  padding: 0.32em 0.78em;
  white-space: nowrap;
}

.chip-mini {
  font-size: 0.68rem;
  padding: 0.22em 0.6em;
  color: var(--crayon);
}

/* Sommaire : table des matières à points de conduite, comme dans le PDF. */

.sommaire {
  list-style: none;
  margin: 0;
  padding: 0;
}

.partie {
  padding: 16px 0;
}

.partie + .partie {
  border-top: 1px solid var(--filet);
}

.ligne-partie {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.romain {
  font-family: var(--affiche);
  font-weight: 700;
  font-size: 1.02rem;
  min-width: 2.1ch;
  color: var(--bic);
}

.titre-partie {
  font-weight: 600;
  font-size: 1.01rem;
}

.info-partie {
  font-family: var(--mono);
  font-size: 0.73rem;
  color: var(--encre-douce);
  white-space: nowrap;
}

.resume-partie {
  margin: 6px 0 0 calc(2.1ch + 10px);
  font-size: 0.9rem;
  color: var(--crayon);
  max-width: 60ch;
}

.chapitres {
  list-style: none;
  margin: 10px 0 0;
  padding: 0 0 0 calc(2.1ch + 10px);
  display: grid;
  gap: 7px;
}

.chapitre {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--encre-douce);
}

.chapitre .leader {
  transform: translateY(2px);
  border-bottom-width: 1.5px;
}

.chapitre .nb {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--crayon);
  white-space: nowrap;
}

.partie .chips {
  margin: 12px 0 0 calc(2.1ch + 10px);
}

/* Remarques : les annotations au crayon rouge. */

.remarques {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 9px;
}

.remarques li {
  position: relative;
  padding-left: 22px;
  font-size: 0.92rem;
  color: var(--encre-douce);
  max-width: 68ch;
}

.remarques li::before {
  content: '\00B7';
  position: absolute;
  left: 4px;
  top: -0.08em;
  font-size: 1.3em;
  font-weight: 700;
  color: var(--marge);
}

details.pliable {
  border: 1px solid var(--filet);
  border-radius: 10px;
  padding: 0;
  margin-top: 10px;
}

details.pliable summary {
  cursor: pointer;
  padding: 13px 16px;
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: 10px;
}

details.pliable summary:hover {
  color: var(--bic);
}

details.pliable[open] summary {
  border-bottom: 1px solid var(--filet);
  border-radius: 10px 10px 0 0;
}

details.pliable ul {
  margin: 0;
  padding: 14px 18px 16px 34px;
  display: grid;
  gap: 7px;
  font-size: 0.91rem;
  color: var(--encre-douce);
}

.apercu-cadre {
  border: 1px solid var(--bord);
  border-radius: 12px;
  overflow: hidden;
  background: var(--apercu-fond);
}

.apercu-cadre iframe {
  display: block;
  width: 100%;
  height: min(76vh, 880px);
  border: none;
}

.apercu-secours {
  margin-top: 10px;
  font-size: 0.86rem;
  color: var(--crayon);
}

/* ---------- Formulaire d'ajout ---------- */

.page-etroite {
  max-width: 660px;
  margin-inline: auto;
  padding-bottom: 64px;
}

.tete-page {
  padding-block: clamp(36px, 6vw, 56px) 26px;
}

.tete-page h1 {
  font-family: var(--affiche);
  font-weight: 700;
  font-size: clamp(1.9rem, 4vw, 2.5rem);
  letter-spacing: -0.012em;
  line-height: 1.1;
  margin-top: 12px;
}

.tete-page p {
  margin-top: 14px;
  color: var(--encre-douce);
  max-width: 52ch;
}

.carte-form {
  background: var(--feuille);
  border: 1px solid var(--bord);
  border-radius: 16px;
  box-shadow: var(--ombre);
  padding: clamp(22px, 4vw, 34px);
}

.groupe {
  margin-bottom: 22px;
}

.groupe > label,
fieldset.groupe legend {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 7px;
}

.indice {
  display: block;
  font-family: var(--mono);
  font-size: 0.71rem;
  color: var(--crayon);
  font-weight: 400;
  margin-top: 3px;
}

.obligatoire::after {
  content: ' *';
  color: var(--marge);
  font-weight: 700;
}

input[type='text'],
input[type='number'],
input[type='password'],
textarea,
select {
  width: 100%;
  font-family: var(--ui);
  font-size: 0.95rem;
  color: var(--encre);
  background: var(--champ-fond);
  border: 1px solid var(--champ-bord);
  border-radius: 9px;
  padding: 0.62em 0.8em;
  transition: border-color 130ms ease, box-shadow 130ms ease;
}

input[type='text']:focus,
input[type='number']:focus,
input[type='password']:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--bic);
  box-shadow: 0 0 0 3px var(--bic-pale);
}

textarea {
  resize: vertical;
  min-height: 90px;
}

fieldset.groupe {
  border: none;
  padding: 0;
  margin-inline: 0;
}

.segments {
  display: flex;
  border: 1px solid var(--champ-bord);
  border-radius: 10px;
  overflow: hidden;
  background: var(--champ-fond);
}

.segments label {
  flex: 1;
  position: relative;
}

.segments input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.segments span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0.6em 0.4em;
  font-family: var(--mono);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--encre-douce);
  cursor: pointer;
  transition: background-color 130ms ease, color 130ms ease;
}

.segments label:not([hidden]) + label:not([hidden]) span {
  border-left: 1px solid var(--filet);
}

.segments input:checked + span {
  background: var(--bouton);
  color: #fff;
}

.segments input:focus-visible + span {
  outline: 2px solid var(--bic);
  outline-offset: -3px;
}

.segments.inactif {
  opacity: 0.5;
  pointer-events: none;
}

.note-liaison {
  font-family: var(--mono);
  font-size: 0.71rem;
  color: var(--crayon);
  margin-top: 7px;
}

.duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Zone de dépôt du PDF. */

.depot {
  border: 2px dashed var(--pointille);
  border-radius: 12px;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.depot:hover,
.depot.survol {
  border-color: var(--bic);
  background: var(--bic-pale);
}

.depot p {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--crayon);
}

.depot p b {
  color: var(--bic);
  font-weight: 500;
}

.depot input {
  display: none;
}

.fichier-choisi {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--bord);
  border-radius: 10px;
  background: var(--papier);
}

.fichier-choisi .nom {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.fichier-choisi .taille {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--crayon);
  white-space: nowrap;
  margin-left: auto;
}

.retirer-fichier {
  background: none;
  border: none;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--crayon);
  cursor: pointer;
  padding: 4px;
}

.retirer-fichier:hover {
  color: var(--marge);
}

.alerte {
  border-left: 3px solid var(--marge);
  background: var(--alerte-fond);
  color: var(--alerte-texte);
  border-radius: 0 9px 9px 0;
  padding: 12px 16px;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.succes h2 {
  font-family: var(--affiche);
  font-weight: 700;
  font-size: 1.7rem;
  letter-spacing: -0.01em;
}

.succes .resume-ajout {
  margin: 16px 0 24px;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--encre-douce);
  line-height: 1.8;
}

.succes .boutons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.form-pied {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 28px;
}

.form-pied .btn {
  min-width: 220px;
}

.form-pied .note {
  font-family: var(--mono);
  font-size: 0.71rem;
  color: var(--crayon);
}

/* ---------- États vides et erreurs de chargement ---------- */

.etat-vide {
  text-align: center;
  padding: 60px 20px;
  color: var(--crayon);
}

.etat-vide .grand {
  font-family: var(--affiche);
  font-weight: 600;
  font-size: 1.4rem;
  color: var(--encre);
  margin-bottom: 8px;
}

/* ---------- Pied de page ---------- */

.pied {
  margin-top: auto;
  border-top: 1px solid var(--bord);
  padding-block: 22px 30px;
}

.pied .conteneur {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--crayon);
}

/* ---------- Animations ---------- */

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  .rise {
    opacity: 0;
    transform: translateY(10px);
    animation: rise 560ms cubic-bezier(0.2, 0.7, 0.25, 1) forwards;
    animation-delay: var(--d, 0ms);
  }

  @keyframes rise {
    to {
      opacity: 1;
      transform: none;
    }
  }
}

/* ---------- Écrans étroits ---------- */

@media (max-width: 880px) {
  .fiche {
    grid-template-columns: 1fr;
  }

  .marge {
    border-right: none;
    border-bottom: 1px solid var(--bord);
    border-left: 2px solid var(--marge);
    padding: 20px 22px;
  }

  .marge-int {
    position: static;
  }

  .marge dl {
    grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
    gap: 14px 18px;
  }
}

@media (max-width: 680px) {
  .leader {
    display: none;
  }

  .doc {
    flex-wrap: wrap;
  }

  .doc-corps {
    flex: 1;
    min-width: calc(100% - 53px);
  }

  .doc-vide {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .doc-meta {
    width: 100%;
    padding-left: 53px;
    white-space: normal;
  }

  .annee {
    flex-direction: column;
    gap: 18px;
  }

  .case {
    flex: 1;
    min-width: 0;
  }

  .duo {
    grid-template-columns: 1fr;
  }

  .tete-bimestre {
    flex-wrap: wrap;
    gap: 8px 14px;
  }

  .tete-bimestre .regle {
    display: none;
  }

  .chapitre .leader {
    display: block;
  }

  .ligne-partie {
    flex-wrap: wrap;
  }

  .info-partie {
    white-space: normal;
    width: 100%;
    padding-left: calc(2.1ch + 10px);
  }
}

/* ---------- Zone utilisateur et bascule de thème ---------- */

.zone-user {
  display: flex;
  align-items: center;
  gap: 14px;
}

.pastille-user {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--encre-douce);
}

.lien-deconnexion {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.73rem;
  color: var(--crayon);
  cursor: pointer;
}

.lien-deconnexion:hover {
  color: var(--marge);
  text-decoration: underline;
}

.btn-theme {
  background: var(--feuille);
  border: 1px solid var(--bord);
  border-radius: 9px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: var(--encre-douce);
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease;
}

.btn-theme:hover {
  border-color: var(--bic);
  color: var(--bic);
}

/* ---------- Page de connexion ---------- */

.page-connexion {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 18px;
}

.carte-connexion {
  width: 100%;
  max-width: 400px;
  background: var(--feuille);
  border: 1px solid var(--bord);
  border-radius: 16px;
  box-shadow: var(--ombre);
  padding: clamp(26px, 5vw, 38px);
}

.carte-connexion .marque {
  font-size: 1.8rem;
}

.carte-connexion .intro {
  margin: 10px 0 24px;
  font-size: 0.94rem;
  color: var(--crayon);
  line-height: 1.6;
}

.carte-connexion .btn {
  width: 100%;
  margin-top: 4px;
}

.note-connexion {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--crayon);
  line-height: 1.7;
}

/* ---------- Mode d'ajout (IA / manuel) ---------- */

.etat-analyse {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px dashed var(--pointille);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 22px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--encre-douce);
}

.sablier {
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--pointille);
  border-top-color: var(--bic);
  animation: tourner 0.9s linear infinite;
}

@keyframes tourner {
  to { transform: rotate(360deg); }
}

.bandeau-ia {
  border-left: 3px solid var(--bic);
  background: var(--bic-pale);
  border-radius: 0 9px 9px 0;
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--encre-douce);
  margin-bottom: 22px;
}

.bandeau-ia b {
  color: var(--encre);
}

.encart-sommaire {
  border: 1px solid var(--filet);
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 10px;
}

.encart-sommaire .apercu-parties {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 5px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--crayon);
}

.case-a-cocher {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
}

.case-a-cocher input {
  width: 16px;
  height: 16px;
  margin-top: 3px;
  accent-color: var(--bouton);
}

/* ---------- Chat IA sur la fiche ---------- */

.chat-bouton {
  position: fixed;
  right: clamp(14px, 3vw, 28px);
  bottom: clamp(14px, 3vw, 28px);
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--bouton);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.85em 1.3em;
  font-family: var(--ui);
  font-size: 0.93rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--ombre-survol);
  transition: background-color 140ms ease, transform 140ms ease;
}

.chat-bouton:hover {
  background: var(--bouton-survol);
  transform: translateY(-1px);
}

.chat-bouton .sigma {
  font-family: var(--affiche);
  font-weight: 600;
}

.chat-panneau {
  position: fixed;
  right: clamp(14px, 3vw, 28px);
  bottom: clamp(14px, 3vw, 28px);
  z-index: 50;
  width: min(400px, calc(100vw - 24px));
  height: min(540px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  background: var(--feuille);
  border: 1px solid var(--bord);
  border-radius: 16px;
  box-shadow: var(--ombre-survol);
  overflow: hidden;
}

.chat-panneau[hidden] {
  display: none;
}

.chat-bouton[hidden] {
  display: none;
}

.chat-tete {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 16px 12px 24px;
  border-bottom: 1px solid var(--filet);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.chat-tete:active {
  cursor: grabbing;
}

/* Poignée de redimensionnement, dans le coin opposé à l'ancrage. */
.chat-poignee {
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  cursor: nwse-resize;
  touch-action: none;
  border-top-left-radius: 16px;
}

.chat-poignee::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 5px;
  width: 9px;
  height: 9px;
  border-top: 2px solid var(--pointille);
  border-left: 2px solid var(--pointille);
  border-top-left-radius: 4px;
}

.chat-poignee:hover::before {
  border-color: var(--bic);
}

.chat-tete .titre-chat {
  font-family: var(--affiche);
  font-weight: 600;
  font-size: 1.05rem;
}

.chat-tete .modele {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--crayon);
}

.chat-fermer {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--crayon);
  cursor: pointer;
  padding: 4px;
}

.chat-fermer:hover {
  color: var(--marge);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    linear-gradient(var(--carreau) 1px, transparent 1px),
    linear-gradient(90deg, var(--carreau) 1px, transparent 1px);
  background-size: 26px 26px;
  background-color: var(--papier);
}

.chat-msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

.chat-msg.etudiant {
  align-self: flex-end;
  background: var(--bic-pale);
  color: var(--encre);
  border: 1px solid transparent;
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--feuille);
  border: 1px solid var(--filet);
  border-left: 2px solid var(--marge);
  border-bottom-left-radius: 4px;
  color: var(--encre-douce);
}

.chat-msg.assistant strong {
  color: var(--encre);
}

.chat-msg.assistant code {
  font-family: var(--mono);
  font-size: 0.84em;
  background: var(--chip-fond);
  border: 1px solid var(--filet);
  border-radius: 5px;
  padding: 0.08em 0.35em;
}

.chat-msg.assistant ul {
  margin: 6px 0;
  padding-left: 20px;
}

.chat-msg.assistant p {
  margin: 0 0 8px;
}

.chat-msg.assistant p:last-child {
  margin-bottom: 0;
}

.chat-msg .discret {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--crayon);
}

.chat-msg.erreur {
  border-left-color: var(--marge);
  background: var(--alerte-fond);
  color: var(--alerte-texte);
}

.chat-attente {
  align-self: flex-start;
  display: inline-flex;
  gap: 5px;
  padding: 12px 14px;
}

.chat-attente i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--crayon);
  animation: pulser 1.2s ease-in-out infinite;
}

.chat-attente i:nth-child(2) { animation-delay: 0.18s; }
.chat-attente i:nth-child(3) { animation-delay: 0.36s; }

@keyframes pulser {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--filet);
}

.chat-form textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  font-size: 0.92rem;
}

.chat-form .btn {
  flex: none;
}

@media (prefers-reduced-motion: reduce) {
  .sablier,
  .chat-attente i {
    animation: none;
  }
}

/* ---------- Chat : responsive mobile (feuille basse, ni déplaçable ni redimensionnable) ---------- */

@media (max-width: 719px) {
  .chat-panneau {
    left: 10px !important;
    right: 10px !important;
    top: auto !important;
    bottom: 10px !important;
    width: auto !important;
    height: min(62vh, 500px) !important;
  }

  .chat-poignee {
    display: none;
  }

  .chat-tete {
    cursor: default;
  }

  .chat-form textarea {
    font-size: 1rem;
  }
}

/* ---------- Gestion des comptes (administration) ---------- */

.trio {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.2fr;
  gap: 16px;
}

.bandeau-secret {
  border-left: 3px solid var(--bic);
  background: var(--bic-pale);
  border-radius: 0 9px 9px 0;
  padding: 14px 16px;
  margin-top: 18px;
  font-size: 0.9rem;
  color: var(--encre-douce);
}

.bandeau-secret .mdp {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.bandeau-secret code {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--encre);
  background: var(--champ-fond);
  border: 1px solid var(--champ-bord);
  border-radius: 7px;
  padding: 0.35em 0.7em;
  user-select: all;
}

.btn-mini {
  display: inline-flex;
  align-items: center;
  font-family: var(--ui);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.45em 0.8em;
  border-radius: 7px;
  border: 1px solid var(--bord);
  background: var(--feuille);
  color: var(--encre-douce);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 130ms ease, color 130ms ease;
}

.btn-mini:hover {
  border-color: var(--bic);
  color: var(--bic);
}

.btn-mini.danger:hover {
  border-color: var(--marge);
  color: var(--marge);
}

.comptes {
  list-style: none;
  margin: 0;
  padding: 0;
}

.comptes li + li {
  border-top: 1px solid var(--filet);
}

.ligne-compte {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 4px;
  flex-wrap: wrap;
}

.compte-id {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
  flex: 1;
}

.compte-id .nom {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.92rem;
  color: var(--encre);
}

.compte-id .meta {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--crayon);
}

.ligne-compte select {
  width: auto;
  font-size: 0.85rem;
  padding: 0.4em 2em 0.4em 0.7em;
}

.compte-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ligne-compte .renommage {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  min-width: 200px;
}

.ligne-compte .renommage input {
  max-width: 220px;
  font-family: var(--mono);
  font-size: 0.88rem;
  padding: 0.4em 0.6em;
}

.note-page {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 0.73rem;
  color: var(--crayon);
  line-height: 1.7;
}

@media (max-width: 680px) {
  .trio {
    grid-template-columns: 1fr;
  }

  .ligne-compte {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .compte-actions {
    width: 100%;
  }
}

/* ---------- Formules mathématiques (KaTeX) dans le chat ---------- */

.chat-msg .katex {
  font-size: 1.04em;
}

.chat-msg .katex-display {
  margin: 10px 0;
  padding: 2px 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* ---------- Indications sous les champs (alignement des formulaires) ---------- */

.groupe > .indice {
  margin-top: 6px;
}

/* ---------- Permissions personnalisées (page Comptes) ---------- */

.panneau-permissions {
  width: 100%;
  border: 1px solid var(--filet);
  border-radius: 10px;
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}

.panneau-permissions .case-a-cocher {
  font-size: 0.88rem;
  font-weight: 400;
}

.panneau-permissions .note-permissions {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--crayon);
}

.tag-perso {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--bic);
  border: 1px solid var(--bic-pale);
  background: var(--bic-pale);
  border-radius: 999px;
  padding: 0.1em 0.55em;
  margin-left: 6px;
}
