@font-face { font-family: "Newsreader"; src: url("/fonts/newsreader-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("/fonts/newsreader-500i.woff2") format("woff2"); font-weight: 500; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("/fonts/atkinson-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("/fonts/atkinson-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/plex-mono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

/* Le registre comptable : papier vert d'eau, encre de Prusse, double filet rouge de marge. */
:root {
  color-scheme: light;
  --encre: #12324a;
  --encre-fort: #0b2233;
  --texte-2: #43566a;
  --texte-3: #5b6d7c;
  --papier: #eef2e6;
  --feuille: #fafbf4;
  --reglure: #d5ddcb;
  --filet: #b3261e;
  --filet-fond: #f8e4e0;
  --vert: #1a6a4c;
  --vert-fond: #dcefe3;
  --ambre: #875a00;
  --ambre-fond: #f6ebcd;
  --gouttiere: 16px;
  --marge: 26px;
  --titre: "Newsreader", Georgia, serif;
  --corps: "Atkinson Hyperlegible", Verdana, sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--encre-fort);
  background-color: var(--papier);
  /* Le double filet de marge reste à sa place d'un bout à l'autre de la page. */
  background-image:
    linear-gradient(to right, transparent 12px, var(--filet) 12px, var(--filet) 13px, transparent 13px, transparent 15px, var(--filet) 15px, var(--filet) 16px, transparent 16px);
  background-repeat: repeat-y;
  font: 400 16.5px/1.5 var(--corps);
  min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--encre); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--filet); outline-offset: 2px; }
[hidden] { display: none !important; }

.barre {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(9px + env(safe-area-inset-top)) var(--gouttiere) 9px var(--marge);
  background: var(--encre); color: #fff;
}
.marque {
  background: none; border: 0; padding: 4px 0; min-height: 40px; color: #fff;
  font: 500 24px/1 var(--titre);
}
.marque i { font-style: italic; color: #f1b9a8; }
.barre-note { font: 500 11px/1.25 var(--mono); color: #bccbd6; text-align: right; }

main { max-width: 780px; margin: 0 auto; padding: 22px var(--gouttiere) 72px var(--marge); outline: none; }
.apparait > * { animation: monte .32s ease both; }
.apparait > *:nth-child(2) { animation-delay: .05s; }
.apparait > *:nth-child(3) { animation-delay: .1s; }
.apparait > *:nth-child(4) { animation-delay: .15s; }
@keyframes monte { from { opacity: 0; transform: translateY(7px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

h1, h2, h3 { font-family: var(--titre); font-weight: 500; line-height: 1.08; margin: 0; color: var(--encre); }
h1 { font-size: clamp(38px, 10.5vw, 62px); letter-spacing: -.012em; }
h1 em { font-style: italic; color: var(--filet); }
h2 { font-size: 27px; }
p { margin: 0; }
.chapeau { color: var(--texte-2); margin-top: 12px; max-width: 58ch; font-size: 17.5px; }
.discret { color: var(--texte-2); font-size: 14.5px; }
.surtitre { font: 500 12.5px/1.3 var(--mono); color: var(--texte-2); margin-bottom: 6px; overflow-wrap: anywhere; }

.pupitre {
  margin-top: 22px; padding: 16px;
  background: var(--feuille); border: 1px solid var(--encre);
  box-shadow: 5px 5px 0 var(--encre);
  display: grid; gap: 10px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 16px;
  border: 1.5px solid var(--encre); border-radius: 2px; background: var(--feuille); color: var(--encre);
  font: 700 16px/1.1 var(--corps); text-decoration: none;
  transition: transform .1s ease, background-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:hover { background: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-encre { background: var(--encre); color: #fff; }
.btn-encre:hover { background: var(--encre-fort); }
.btn-grand { width: 100%; min-height: 60px; font-size: 19px; }
.btn-lien {
  background: none; border: 0; padding: 8px 0; min-height: 44px; text-align: left;
  font-weight: 700; color: var(--encre); text-decoration: underline; text-underline-offset: 3px;
}

.reglages { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.champ { display: grid; gap: 5px; min-width: 0; align-content: start; }
.champ > span, .etiquette { font: 700 13.5px/1.2 var(--corps); color: var(--texte-2); }
.champ input, .champ select {
  width: 100%; min-height: 46px; padding: 8px 10px;
  border: 1.5px solid var(--encre); border-radius: 2px; background: var(--feuille);
}
.formulaire { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.formulaire .large { grid-column: 1 / -1; }

.bandeau {
  margin-top: 16px; padding: 10px 12px; font-size: 14.5px;
  border: 1px dashed var(--encre); color: var(--encre-fort); background: var(--feuille);
}

.bloc { margin-top: 34px; }
.bloc-tete {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  border-bottom: 2px solid var(--encre); padding-bottom: 5px; margin-bottom: 12px;
}
.bloc-tete small { color: var(--texte-3); font: 500 11.5px/1.3 var(--mono); }

/* Exemples fictifs */
.exemples { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.exemples button {
  display: grid; gap: 2px; width: 100%; height: 100%; align-content: start; padding: 0 0 10px; text-align: left;
  background: var(--feuille); border: 1px solid var(--reglure);
  transition: border-color .15s ease, transform .15s ease;
}
.exemples button:hover { border-color: var(--encre); transform: translateY(-2px); }
.exemples img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: left top; display: block; border-bottom: 1px solid var(--reglure); margin-bottom: 6px; }
.exemples b { padding: 0 10px; font-size: 15px; line-height: 1.2; }
.exemples span { padding: 0 10px; font-size: 13px; line-height: 1.25; color: var(--texte-2); }

.types { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0 14px; }

/* Historique */
.histo { display: grid; gap: 8px; list-style: none; margin: 0 0 6px; padding: 0; }
.histo button {
  display: grid; grid-template-columns: 62px 1fr; gap: 12px; align-items: center; width: 100%;
  padding: 8px; text-align: left; background: var(--feuille); border: 1px solid var(--reglure);
}
.histo button:hover { border-color: var(--encre); }
.histo img, .histo .sans-photo { width: 62px; height: 62px; object-fit: cover; object-position: top; background: var(--reglure); display: block; }
.histo b { display: block; font: 500 20px/1.1 var(--titre); color: var(--encre); }
.histo em { font-style: normal; color: var(--texte-2); font-size: 13.5px; overflow-wrap: anywhere; }

/* Préparation de la photo */
.scene { position: relative; margin-top: 16px; background: var(--encre-fort); line-height: 0; touch-action: none; user-select: none; }
.scene canvas { width: 100%; height: auto; display: block; cursor: crosshair; max-height: 76dvh; object-fit: contain; }
.astuce { margin-top: 10px; padding: 10px 12px; background: var(--ambre-fond); color: #4e3500; font-size: 14.5px; border-left: 4px solid var(--ambre); }

/* La règle du comptable descend le long du document. */
.balayage { overflow: hidden; touch-action: auto; max-height: 62dvh; }
.balayage::after {
  content: ""; position: absolute; left: 0; right: 0; height: 2px; top: 0;
  background: var(--filet); box-shadow: 0 0 0 1px rgba(255,255,255,.6), 0 10px 24px 6px rgba(179, 38, 30, .28);
  animation: regle 2.1s ease-in-out infinite alternate;
}
.balayage img { width: 100%; display: block; }
@keyframes regle { to { top: calc(100% - 2px); } }
.etape { margin-top: 12px; font: 500 13px/1.45 var(--mono); color: var(--texte-2); }

/* Choix du type */
.candidats { display: grid; gap: 10px; margin-top: 16px; }
.candidat {
  display: block; width: 100%; text-align: left; padding: 14px; background: var(--feuille);
  border: 1.5px solid var(--reglure);
}
.candidat:hover { border-color: var(--encre); }
.candidat.premier { border-color: var(--encre); }
.candidat b { font: 500 25px/1.1 var(--titre); color: var(--encre); }

.alerte { margin-top: 14px; padding: 12px 14px; border-left: 4px solid var(--filet); background: var(--filet-fond); }
.alerte-douce { border-left-color: var(--ambre); background: var(--ambre-fond); }
.signaux { margin: 6px 0; padding-left: 20px; }

details.replie { margin-top: 18px; border-top: 1px solid var(--reglure); padding-top: 6px; }
details.replie summary { cursor: pointer; font: 500 20px/1.3 var(--titre); color: var(--encre); padding: 9px 0; }
details.replie[open] summary { margin-bottom: 8px; }

/* Folio : en-tête de la fiche */
.folio { display: grid; grid-template-columns: 1fr; gap: 16px; }
.folio-corps { position: relative; min-width: 0; }
.folio h1 { font-size: clamp(34px, 8.5vw, 52px); }
.folio-photo { width: 100%; max-height: 240px; object-fit: cover; object-position: top; display: block; border: 1px solid var(--encre); box-shadow: 5px 5px 0 var(--reglure); }
.folio-ligne { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font: 500 13px/1.4 var(--mono); color: var(--texte-2); overflow-wrap: anywhere; }

/* Le tampon : l'élément qu'on retient. */
.tampon {
  display: inline-block; margin-top: 14px; padding: 5px 11px 4px;
  font: 700 15px/1.1 var(--mono); letter-spacing: .08em; text-transform: uppercase;
  border: 2.5px solid currentColor; border-radius: 3px;
  transform: rotate(-3deg);
  animation: frappe .28s cubic-bezier(.2, 1.4, .4, 1) both .25s;
}
@keyframes frappe { from { opacity: 0; transform: rotate(-3deg) scale(1.7); } }
.tampon-vert { color: var(--vert); }
.tampon-rouge { color: var(--filet); }
.tampon-ambre { color: var(--ambre); }
.tampon-gris { color: var(--texte-3); }
.tampon.petit { margin: 0; padding: 2px 6px 1px; font-size: 11px; border-width: 1.5px; letter-spacing: .05em; animation: none; white-space: nowrap; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions .btn { flex: 1 1 130px; min-height: 46px; font-size: 15px; }

/* Registre : les lignes du document */
.registre { width: 100%; border-collapse: collapse; background: var(--feuille); table-layout: fixed; }
.registre th, .registre td { padding: 10px; border-bottom: 1px solid var(--reglure); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.registre th { width: 56%; font-weight: 700; font-size: 15px; color: var(--encre); }
.registre th small { display: block; margin-top: 3px; font-weight: 400; font-size: 13.5px; line-height: 1.35; color: var(--texte-2); }
.registre td { text-align: right; }
.val { font-family: var(--mono); font-weight: 500; font-size: 14.5px; }
.pastille { display: block; width: fit-content; margin: 4px 0 0 auto; padding: 1px 5px; font: 500 10.5px/1.4 var(--mono); border: 1px solid currentColor; white-space: nowrap; }
.autre-lecture { display: block; margin-top: 4px; font: 500 12.5px/1.3 var(--mono); color: var(--filet); }
.conf-haute { color: var(--vert); background: var(--vert-fond); }
.conf-moyenne { color: var(--ambre); background: var(--ambre-fond); }
.conf-basse { color: var(--filet); background: var(--filet-fond); }

.defile { margin-top: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.operations { width: 100%; min-width: 440px; border-collapse: collapse; background: var(--feuille); font-size: 14px; }
.operations caption { text-align: left; font: 500 19px/1.3 var(--titre); color: var(--encre); padding-bottom: 6px; }
.operations th { padding: 6px 8px; text-align: left; font-size: 12.5px; color: var(--texte-2); border-bottom: 1.5px solid var(--encre); }
.operations td { padding: 6px 8px; border-bottom: 1px solid var(--reglure); }
.droite { text-align: right !important; }
.chiffre { font: 500 13.5px/1.3 var(--mono); white-space: nowrap; }

/* Contrôles */
.controles { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; background: var(--reglure); border: 1px solid var(--reglure); }
.controles li { display: grid; grid-template-columns: 74px 1fr; gap: 10px; padding: 11px 10px; background: var(--feuille); align-items: start; }
.controles .tampon { justify-self: start; }
.controles b { display: block; font-size: 15px; }
.controles p { font-size: 14px; color: var(--texte-2); overflow-wrap: anywhere; }
.calculs { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-top: 12px; }
.calcul { padding: 11px 12px; background: var(--feuille); border-top: 3px double var(--encre); min-width: 0; }
.calcul .etiquette { display: block; }
.calcul strong { display: block; margin-top: 3px; font: 500 20px/1.25 var(--mono); color: var(--encre); overflow-wrap: anywhere; }
.formule { display: block; margin-top: 2px; font: 500 11.5px/1.35 var(--mono); color: var(--texte-3); }
.calcul p { margin-top: 6px; font-size: 13.5px; line-height: 1.35; color: var(--texte-2); }

.note { margin-top: 8px; font-size: 14px; color: var(--texte-2); }
.role { font: 500 21px/1.3 var(--titre); color: var(--encre); margin-bottom: 12px; }
.puces, .liens { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.puces li { padding-left: 17px; position: relative; }
.puces li::before { content: ""; position: absolute; left: 1px; top: .62em; width: 8px; height: 2px; background: var(--encre); }
.puces-rouges li::before { background: var(--filet); }
.liens { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.liens a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 46px; height: 100%; padding: 8px 12px;
  background: var(--feuille); border: 1px solid var(--encre); text-decoration: none; font-weight: 700; font-size: 14.5px;
}
.liens a:hover { background: #fff; }

.explication { padding: 16px; background: var(--feuille); border: 1px solid var(--reglure); }
.resume { font: 500 21px/1.32 var(--titre); color: var(--encre); margin-bottom: 12px; }
.resume:last-child { margin-bottom: 0; }

.lexique { margin: 0; display: grid; gap: 2px; }
.lexique dt { font-weight: 700; margin-top: 10px; color: var(--encre); }
.lexique dt:first-child { margin-top: 0; }
.lexique dd { margin: 0; font-size: 15px; color: var(--texte-2); }

.src { margin-left: 6px; padding: 0 4px; font: 500 10.5px/1.5 var(--mono); text-decoration: none; color: #fff; background: var(--encre); }
.tracabilite { width: 100%; border-collapse: collapse; font: 500 12.5px/1.4 var(--mono); }
.tracabilite td { padding: 5px 0; border-bottom: 1px dotted var(--reglure); vertical-align: top; overflow-wrap: anywhere; }
.tracabilite td:first-child { width: 40%; color: var(--texte-2); padding-right: 8px; }

.pied { margin-top: 34px; font-size: 13px; color: var(--texte-2); }
.chargement { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--reglure); border-top-color: var(--filet); border-radius: 50%; animation: tourne .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes tourne { to { transform: rotate(360deg); } }

@media (min-width: 680px) {
  :root { --marge: 44px; }
  body { background-image: linear-gradient(to right, transparent 24px, var(--filet) 24px, var(--filet) 25px, transparent 25px, transparent 27px, var(--filet) 27px, var(--filet) 28px, transparent 28px); }
  .folio { grid-template-columns: 1fr 240px; align-items: start; gap: 24px; }
  .pupitre { grid-template-columns: 2fr 1fr; }
  .btn-grand { min-height: 56px; }
}
@media (max-width: 380px) {
  .formulaire, .reglages { grid-template-columns: 1fr; }
}
@media print {
  .barre, .actions { display: none; }
  body { background: #fff; }
}
