/* legal.repondia.com — une revue juridique bien composée, pas un PDF collé sur le web.
   Tokens de la charte Répondia (repris de form/styles.css). UNE SEULE famille, Geist, la même
   que la webapp (--rp-font dans src/css/atrium/typography.css) : le registre et l'application
   se lisent pareil. Police servie d'ici : aucune requête tierce au chargement. */

@font-face {
  font-family: "Geist";
  src: url("/fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --accent: #9C81D1;
  --accent-text: #6B4FB0;
  --accent-soft: #F1ECFA;
  --bg: #FAFAF9;
  --ink: #1C1917;
  --ink-soft: #57534E;
  --ink-faint: #A8A29E;
  --line: #E7E5E4;
  --sheet: #FFFFFF;
  /* Une surface qui se détache VRAIMENT du papier (un gris trop clair disparaît). */
  --wash: color-mix(in srgb, var(--line) 55%, var(--bg));

  /* Même pile que la webapp, au nom de famille près (ici Geist est servie par @font-face). */
  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --topbar-h: 56px;
  --toc-w: 304px;
  --measure: 42rem; /* ~79 signes en Source Serif 17 px. En rem, pas en ch : une seule colonne pour tous les corps */
  --hang: 4.5rem; /* marge où pendent les numéros de document */
  --gutter: clamp(20px, 2.8vw, 40px);
  --talk: 44rem; /* la colonne de l'assistant : plus large que la lecture, ses réponses sont courtes */ /* le couloir entre le sommaire et le texte : assez pour respirer, pas un fossé */
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent-text: #B9A3E3;
    --accent-soft: #2C2536;
    --bg: #171512;
    --ink: #F5F4F2;
    --ink-soft: #B8B2AC;
    --ink-faint: #6F6A63;
    --line: #35322E;
    --sheet: #211E1B;
  }
}

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

/* Pas de défilement doux : d'un document à l'autre il y a des dizaines d'écrans, et les regarder
   défiler donne le tournis. On saute, et le titre visé s'allume (animation flash) pour se repérer. */
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[id] { scroll-margin-top: calc(var(--topbar-h) + 28px); }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }

.skip {
  position: absolute;
  left: 16px;
  top: -64px;
  z-index: 30;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 6px;
  font-size: 0.875rem;
  text-decoration: none;
}
.skip:focus { top: 8px; }

/* ------------------------------------------------------------ barre haute */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}
.logo { height: 22px; width: auto; flex: none; display: block; }
.brand-room {
  padding-left: 14px;
  border-left: 1px solid var(--line);
  font-size: 0.8125rem;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.version {
  margin-left: auto;
  flex: none;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  white-space: nowrap;
}

.lang {
  display: flex;
  flex: none;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.lang a {
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--ink-soft);
  text-decoration: none;
}
.lang a:hover { color: var(--ink); }
.lang a:focus-visible { border-radius: 999px; }
.lang a[aria-current] { background: var(--ink); color: var(--bg); }

.print-all {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  padding: 6px 11px 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.print-all:hover { color: var(--ink); background: var(--wash); }
.print-all:focus-visible { border-radius: 999px; }
.print-all svg { width: 15px; height: 15px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------ grille */

/* Pas de max-width ici : centrer la grille décollait le sommaire du bord gauche (170 px de vide
   à 1700 px) alors que la barre haute, elle, va d'un bord à l'autre. Le sommaire se cale donc au
   bord, son padding gauche est celui de la barre, et la marque et le filtre tombent sur la même
   verticale. C'est la colonne de lecture (--measure) qui borne le texte, pas la page. */
.layout {
  display: grid;
  grid-template-columns: var(--toc-w) minmax(0, 1fr);
}

.toc {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 20px 64px 24px;
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

main {
  min-width: 0;
  padding: 0 var(--gutter) 160px calc(var(--gutter) + var(--hang));
}

/* ------------------------------------------------------------ sommaire */

.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a { text-decoration: none; }

.toc-filter {
  width: 100%;
  margin-bottom: 6px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--wash);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  -webkit-appearance: none;
  appearance: none;
}
.toc-filter::placeholder { color: var(--ink-soft); opacity: 0.85; }
.toc-filter:focus-visible { border-radius: 8px; }

.toc-part {
  display: flex;
  gap: 10px;
  margin: 26px 0 8px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.toc-part .n { color: var(--accent-text); font-variant-numeric: tabular-nums; }

.toc ol ol a {
  position: relative;
  display: flex;
  gap: 8px;
  padding: 5px 8px 5px 16px;
  border-radius: 6px;
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--ink-soft);
}
.toc ol ol a .n {
  flex: none;
  min-width: 1.5em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.toc ol ol a:hover { color: var(--ink); background: var(--wash); }
.toc ol ol a[aria-current] { color: var(--ink); font-weight: 500; }
.toc ol ol a[aria-current] .n { color: var(--accent-text); }
.toc ol ol a[aria-current]::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.78em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.toc-empty { margin: 20px 0 0; font-size: 0.875rem; color: var(--ink-soft); }

.toc-toggle, .backdrop { display: none; }

/* ------------------------------------------------------------ en-tête de la salle */

.hero { padding: 88px 0 24px; }
.hero > * { max-width: var(--measure); }
.hero h1 { max-width: 50rem; }

.hero h1 {
  margin: 0 0 22px;
  font-family: var(--sans);
  font-weight: 400;
  font-size: clamp(1.875rem, 3.2vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: -0.016em;
  text-wrap: balance;
}

/* 1er paragraphe = « Textes définitifs — version … » : une étiquette, pas une phrase. */
.hero h1 + p {
  margin: 0 0 36px;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.hero p {
  margin: 0 0 1.1em;
  font-family: var(--sans);
  font-size: 1.125rem;
  line-height: 1.6;
}

/* L'encadré : un aplat, sans filet ni ombre. */
.hero .callout {
  margin-top: 32px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  background: var(--wash);
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--ink-soft);
}
.callout strong { font-weight: 600; color: var(--ink); }

/* ------------------------------------------------------------ sections 01…06 */

.part { margin-top: 104px; }

.part-title {
  display: flex;
  align-items: baseline;
  gap: 20px;
  margin: 0 0 0 calc(-1 * var(--hang));
  padding-top: 20px;
  border-top: 1px solid var(--ink);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.part-title .n {
  font-family: var(--sans);
  font-weight: 250;
  font-size: clamp(2.25rem, 3.4vw, 2.875rem);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: lining-nums;
}
.dash { display: none; }

/* ------------------------------------------------------------ documents */

.doc { position: relative; padding-top: 72px; }
.doc + .doc { margin-top: 72px; border-top: 1px solid var(--line); }
.doc > * { max-width: var(--measure); }

.doc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  max-width: 56rem;
  margin-bottom: 40px;
}
.doc-tools { display: flex; gap: 2px; flex: none; padding-top: 0.45rem; }
.doc-tools button {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}
.doc-tools button:hover, .doc-tools button:focus-visible { color: var(--ink); background: var(--wash); }
.doc-tools button:focus-visible { border-radius: 8px; }
.doc-tools button.done { color: var(--accent-text); }
.doc-tools button.done::after {
  content: attr(data-done);
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--sans);
  font-size: 0.75rem;
  white-space: nowrap;
}

/* Arrivée par un lien ancré (mail, citation de l'assistant) : le titre visé s'allume puis s'éteint. */
@keyframes flash { from { background-color: var(--accent-soft); box-shadow: 0 0 0 10px var(--accent-soft); } }
.doc:target .doc-title, .doc h4:target, .flash { animation: flash 2.6s ease-out; border-radius: 2px; }

/* /en/ : « seule la version française fait foi », sous chaque titre — donc aussi à l'impression. */
.doc .binding, .hero .binding { /* .doc/.hero devant : sinon `.doc p` (serif 18 px) l'emporte */
  margin: -24px 0 36px;
  font-family: var(--sans);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
.hero .binding { margin: 28px 0 0; }
.binding a { color: var(--accent-text); text-underline-offset: 3px; }

.doc-title {
  margin: 0;
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(1.375rem, 2vw, 1.75rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.doc-title .n {
  position: absolute;
  left: calc(-1 * var(--hang));
  width: calc(var(--hang) - 1.1rem);
  text-align: right;
  font-weight: 300;
  color: var(--accent-text);
  font-variant-numeric: lining-nums tabular-nums;
}

.doc h4 {
  margin: 2.4em 0 0.7em;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.1875rem;
  line-height: 1.35;
  letter-spacing: -0.006em;
}
.doc h4 .art {
  display: block;
  margin-bottom: 6px;
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.doc p, .doc li {
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.68;
}
.doc p { margin: 0 0 1.05em; }
.doc strong { font-weight: 620; }

.doc ul, .doc ol { margin: 0 0 1.3em; padding-left: 1.6em; }
.doc li { margin-bottom: 0.45em; padding-left: 0.3em; }
.doc ul { list-style: none; }
.doc ul > li { position: relative; }
.doc ul > li::before {
  content: "–";
  position: absolute;
  left: -1.35em;
  color: var(--ink-faint);
}
.doc ol > li::marker {
  font-family: var(--sans);
  font-size: 0.78em;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------ tableaux (filets d'imprimeur) */

.doc > .table-wrap {
  max-width: min(100%, 64rem); /* plus large que la colonne de lecture : 5 colonnes dans 68ch étouffent */
  margin: 2em 0 2.4em;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
table {
  width: 100%;
  border-collapse: collapse;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  font-size: 0.875rem;
  line-height: 1.5;
}
th, td {
  min-width: 9.5rem;
  padding: 12px 20px 12px 0;
  text-align: left;
  vertical-align: top;
}
th {
  padding-top: 11px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ink);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}
td { border-bottom: 1px solid var(--line); color: var(--ink-soft); }
tr:last-child td { border-bottom: 0; }
td:first-child { color: var(--ink); font-weight: 500; }
th:last-child, td:last-child { padding-right: 0; }

/* ------------------------------------------------------------ assistant
   L'assistant a sa page (/assistant), il n'est plus une bulle posée sur les documents.
   La page elle-même ne défile pas : c'est la conversation qui défile, donc le champ ne
   bouge jamais, même pendant que la réponse s'écrit. */

/* L'assistant s'ouvre depuis la barre haute, à droite. Même galbe que le bouton PDF pour que la
   rangée s'aligne, mais plein quand tout le reste est en contour : c'est la seule action de la salle. */
.chat-launcher {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  padding: 6px 11px 6px 9px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-decoration: none;
}
.chat-launcher:hover { opacity: 0.86; }
.chat-launcher:focus-visible { border-radius: 999px; }
.chat-launcher svg { width: 15px; height: 15px; }

/* ---- la page de conversation */

body.on-assistant {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* le défilement appartient à la conversation, pas à la page */
}
.on-assistant .topbar { position: static; flex: none; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: -8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}
.back:hover { background: var(--wash); }

main.talk {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 var(--gutter);
  font-size: 1rem;
  line-height: 1.6;
}
.talk > * { width: 100%; max-width: var(--talk); }

.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 52px 0 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

/* ---- l'accueil : ce que l'assistant est, et ce qu'il n'est pas */

.chat-hello { margin: 0 0 34px; }
.chat-title {
  margin: 0 0 18px;
  font-family: var(--sans);
  font-weight: 380;
  font-size: clamp(2rem, 4vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: -0.018em;
}
.chat-title span {
  margin-left: 10px;
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-text);
  vertical-align: 0.5em;
}
.chat-hello p { margin: 0 0 10px; max-width: 34rem; font-size: 1.0625rem; color: var(--ink-soft); }
.chat-noscript { color: var(--accent-text); }
.chat-suggestions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 26px; }
.chat-suggestions button, .chat-restart {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
}
.chat-suggestions button:hover, .chat-restart:hover { background: var(--wash); border-color: var(--ink-faint); }
.chat-suggestions button:focus-visible, .chat-restart:focus-visible { border-radius: 999px; }

/* ---- les messages : la question est une bulle, la réponse tient toute la colonne.
   Volontairement en Geist, pas en serif : ce que dit l'assistant n'est pas le contrat. */

.chat-msg { margin-bottom: 26px; overflow-wrap: anywhere; }
.chat-msg p, .chat-msg ul, .chat-msg ol { margin: 0 0 0.7em; }
.chat-msg :last-child { margin-bottom: 0; }
.chat-msg ul, .chat-msg ol { padding-left: 1.2em; }
.chat-user {
  width: fit-content;
  max-width: 86%;
  margin-left: auto;
  padding: 10px 15px;
  border-radius: 14px 14px 4px 14px;
  background: var(--wash);
}
.chat-msg strong { font-weight: 600; }
/* Une citation = une étiquette qui ouvre l'article dans la salle. */
.chat-msg a[data-cite] {
  padding: 1px 7px 2px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.875em;
  font-weight: 500;
  text-decoration: none;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.chat-msg a[data-cite]:hover { text-decoration: underline; text-underline-offset: 3px; }
.chat-error { color: var(--ink-soft); }
.chat-error a { color: var(--accent-text); }
.chat-restart { margin-top: 12px; }

.chat-typing { display: flex; gap: 5px; padding: 6px 0; }
.chat-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faint); }
@media (prefers-reduced-motion: no-preference) {
  .chat-typing i { animation: blink 1.2s infinite; }
  .chat-typing i:nth-child(2) { animation-delay: 0.15s; }
  .chat-typing i:nth-child(3) { animation-delay: 0.3s; }
  @keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }
}

/* ---- le champ : posé au bas de l'écran, il ne bouge jamais */

.chat-form {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--sheet);
}
.chat-form[hidden] { display: none; }
.chat-form:focus-within { border-color: var(--accent); }
.chat-form textarea {
  flex: 1;
  min-width: 0;
  padding: 9px 0;
  border: 0;
  outline: none;
  box-shadow: none;
  background: none;
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
  resize: none;
}
.chat-form textarea::placeholder { color: var(--ink-soft); opacity: 0.8; }
.chat-form button {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
}
.chat-form button:focus-visible { border-radius: 50%; }
.chat-form.busy button { opacity: 0.35; pointer-events: none; }
.chat-notice {
  flex: none;
  margin: 10px 0 max(14px, env(safe-area-inset-bottom));
  font-size: 0.6875rem;
  line-height: 1.45;
  color: var(--ink-soft);
}
.chat-notice a { color: var(--accent-text); }
.chat-turnstile:empty { display: none; }

/* ------------------------------------------------------------ entrée en scène */

@media (prefers-reduced-motion: no-preference) {
  .hero > * { animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .hero > :nth-child(2) { animation-delay: 0.07s; }
  .hero > :nth-child(3) { animation-delay: 0.14s; }
  .hero > :nth-child(4) { animation-delay: 0.21s; }
  @keyframes rise { from { opacity: 0; transform: translateY(14px); } }
}

/* ------------------------------------------------------------ petit écran */

@media (max-width: 900px) {
  :root { --hang: 0rem; }
  .layout { display: block; }

  /* Cinq éléments dans la barre : le sommaire passe en icône seule, sinon la marque est coupée
     (mesuré à 390 px). Son nom est porté par l'aria-label, comme pour le PDF et l'assistant. */
  .toc-toggle span { display: none; }
  .toc-toggle svg { width: 20px; height: 20px; }
  .toc-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: -4px;
    padding: 8px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--ink);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
  }
  .brand-room { display: none; }
  .lang { order: 2; margin-left: auto; }
  .print-all { order: 3; }
  .brand { order: 4; }
  .logo { height: 20px; }

  /* Le sommaire devient un tiroir. Fermé : invisible ET hors tabulation. */
  .toc {
    position: fixed;
    inset: var(--topbar-h) auto 0 0;
    z-index: 15;
    width: min(86vw, 340px);
    height: auto;
    align-self: stretch; /* le `start` du bureau empêche une boîte fixe de s'étirer entre top et bottom */
    background: var(--bg);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0s 0.28s;
  }
  .toc:focus-visible { box-shadow: none; }
  .toc-open .toc { transform: none; visibility: visible; transition-delay: 0s; }
  .backdrop {
    display: block;
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    z-index: 14;
    background: color-mix(in srgb, var(--ink) 38%, transparent);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s;
  }
  .toc-open .backdrop { opacity: 1; pointer-events: auto; }
  /* Sur <html> seul : posé aussi sur <body>, il en fait un conteneur de défilement et casse la barre collante. */
  .toc-open { overflow: hidden; }
  .topbar { gap: 12px; padding: 0 16px; }
  .version { display: none; }
  main { padding: 0 20px 120px; }
  .hero { padding-top: 56px; }
  .part { margin-top: 96px; }
  .part-title { gap: 18px; margin-left: 0; }
  .doc { padding-top: 64px; }
  .doc + .doc { margin-top: 64px; }
  .doc-title .n { position: static; width: auto; margin-right: 0.3em; }
  .doc-head { margin-bottom: 28px; gap: 8px; }
  .print-all span { display: none; }
  .print-all { padding: 8px; border: 0; }
  .print-all svg { width: 18px; height: 18px; }
  .doc p, .doc li { font-size: 1rem; line-height: 1.65; }

  .chat-launcher { order: 3; padding: 7px 9px; }
  .chat-launcher span { display: none; } /* l'aria-label porte le nom */
  .chat-launcher svg { width: 18px; height: 18px; }
  .chat-form textarea { font-size: 1rem; } /* < 16 px : iOS zoome au focus */
  .hero p { font-size: 1.0625rem; }

  /* La page de conversation : le champ reste au bas de l'écran, au-dessus du clavier. */
  main.talk { padding: 0 16px; }
  .chat-log { padding: 32px 0 20px; }
  .chat-hello { margin-bottom: 26px; }
  .back { margin-left: -8px; }
  .back span { display: none; }
}

/* ------------------------------------------------------------ impression = le PDF
   Le client imprime les CGPS avant de signer : pas de sommaire, pas de boutons,
   un document par page. Couleurs claires forcées, même si l'écran est en sombre. */

@media print {
  @page { margin: 20mm 18mm 22mm; }
  :root {
    --accent-text: #5B3FA0; --accent-soft: #F1ECFA; --bg: #fff; --ink: #000;
    --ink-soft: #3a3a3a; --ink-faint: #8a8a8a; --line: #cfcfcf; --hang: 0rem;
  }
  body { background: #fff; font-size: 10pt; }
  .topbar, .toc, .backdrop, .skip, .doc-tools, .chat-launcher { display: none !important; }
  .doc .binding { margin: -8pt 0 14pt; font-size: 8.5pt; }
  .layout { display: block; max-width: none; }
  main { padding: 0; }
  .hero { padding-top: 0; }
  .hero > * { animation: none; }
  .hero h1 { font-size: 22pt; }
  .part { margin-top: 0; break-before: page; }
  .part-title { margin-left: 0; }
  .part-title .n { font-size: 24pt; }
  .doc { padding-top: 0; break-before: page; }
  .doc + .doc { margin-top: 0; border-top: 0; }
  .part > .doc:first-of-type { break-before: avoid; margin-top: 28pt; } /* pas de page avec le seul « 01 » */
  .doc > *, .doc-head { max-width: none; }
  .doc-head { margin-bottom: 18pt; }
  .doc-title { font-size: 16pt; }
  .doc-title .n { position: static; width: auto; margin-right: 0.25em; }
  .doc h4 { font-size: 12.5pt; break-after: avoid; }
  .doc-head, .part-title { break-after: avoid; }
  .doc p, .doc li { font-size: 10.5pt; line-height: 1.55; orphans: 3; widows: 3; }
  .doc > .table-wrap { max-width: none; overflow: visible; }
  table { font-size: 8.5pt; }
  th, td { min-width: 0; padding: 6pt 10pt 6pt 0; }
  th { white-space: normal; }
  tr, li { break-inside: avoid; }

  /* Un seul document demandé */
  .print-one .hero, .print-one .part-title, .print-one .doc:not(.print-me) { display: none; }
  .print-one .part, .print-one .print-me { break-before: auto; margin-top: 0; }
}
