@font-face { font-family: "Barlow Condensed"; src: url("/fonts/barlow-condensed-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("/fonts/barlow-condensed-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("/fonts/barlow-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("/fonts/barlow-600.woff2") format("woff2"); font-weight: 600; 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; }

:root {
  color-scheme: light;
  --encre: #16191c;
  --encre-2: #4c5359;
  --encre-3: #6d747a;
  --papier: #f0eee8;
  --carte: #fbfaf6;
  --trait: #d3cfc4;
  --trait-fort: #16191c;
  --signal: #d9400f;
  --signal-fond: #fbe6dd;
  --ok: #1c6b45;
  --ok-fond: #dff0e6;
  --doute: #8a5a00;
  --doute-fond: #f7ecd0;
  --plaque: #dfe2e3;
  --plaque-sombre: #b6bbbe;
  --gouttiere: 16px;
  --titre: "Barlow Condensed", "Arial Narrow", sans-serif;
  --texte: "Barlow", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papier);
  color: var(--encre);
  font: 400 16px/1.45 var(--texte);
  min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--signal); 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(10px + env(safe-area-inset-top)) var(--gouttiere) 10px;
  background: var(--encre); color: #fff;
}
.marque {
  background: none; border: 0; padding: 4px 0; color: #fff;
  font: 700 22px/1 var(--titre); letter-spacing: .08em;
}
.marque span { color: #ff6a3a; }
.barre-note { font: 500 11px/1.2 var(--mono); color: #b7bdc2; text-align: right; }

main { max-width: 760px; margin: 0 auto; padding: 20px var(--gouttiere) 72px; outline: none; }
.apparait > * { animation: monte .34s 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(8px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

h1, h2, h3 { font-family: var(--titre); font-weight: 700; line-height: 1.05; margin: 0; }
h1 { font-size: clamp(38px, 10vw, 58px); letter-spacing: -.005em; text-transform: uppercase; }
h2 { font-size: 22px; letter-spacing: .03em; text-transform: uppercase; }
p { margin: 0; }
.chapeau { color: var(--encre-2); margin-top: 10px; max-width: 54ch; }
.discret { color: var(--encre-2); font-size: 14px; }

/* Viseur d'accueil */
.viseur {
  position: relative; margin-top: 22px; padding: 28px 22px;
  background: var(--encre); color: #fff;
  display: grid; gap: 12px;
}
.viseur::before, .viseur::after {
  content: ""; position: absolute; width: 26px; height: 26px; border: 3px solid #ff6a3a; pointer-events: none;
}
.viseur::before { top: 9px; left: 9px; border-right: 0; border-bottom: 0; }
.viseur::after { bottom: 9px; right: 9px; border-left: 0; border-top: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px;
  border: 2px solid var(--encre); background: var(--carte); color: var(--encre);
  font: 700 19px/1 var(--titre); letter-spacing: .05em; text-transform: uppercase; 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-signal { background: var(--signal); border-color: var(--signal); color: #fff; }
.btn-signal:hover { background: #bd370c; }
.btn-grand { width: 100%; min-height: 62px; font-size: 25px; }
.btn-fantome { background: transparent; border-color: #6f767c; color: #fff; }
.btn-fantome:hover { background: #2a2f33; }
.btn-lien {
  background: none; border: 0; padding: 8px 0; min-height: 40px;
  font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.rangee { display: flex; flex-wrap: wrap; gap: 10px; }
.rangee > .btn { flex: 1 1 150px; }

/* Réglages */
.reglages { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.champ { display: grid; gap: 5px; min-width: 0; }
.champ > span, .etiquette {
  font: 600 14px/1.1 var(--titre); letter-spacing: .08em; text-transform: uppercase; color: var(--encre-2);
}
.champ input, .champ select {
  width: 100%; min-height: 46px; padding: 8px 10px;
  border: 1.5px solid var(--encre); border-radius: 0; background: var(--carte);
}
.formulaire { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.formulaire .large { grid-column: 1 / -1; }

.bloc { margin-top: 30px; }
.bloc-tete {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  border-bottom: 2px solid var(--trait-fort); padding-bottom: 6px; margin-bottom: 12px;
}
.bloc-tete small { color: var(--encre-3); font: 500 11px/1.2 var(--mono); text-align: right; }

/* Historique */
.histo { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.histo button {
  display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: center; width: 100%;
  padding: 8px; text-align: left; background: var(--carte); border: 1px solid var(--trait);
}
.histo button:hover { border-color: var(--encre); }
.histo img, .histo .sans-photo { width: 72px; height: 54px; object-fit: cover; background: var(--plaque); display: block; }
.histo b { display: block; font: 700 19px/1.1 var(--titre); }
.histo em { font-style: normal; color: var(--encre-2); font-size: 13px; }

/* Préparation de la photo */
.scene { position: relative; margin-top: 16px; background: #000; line-height: 0; touch-action: none; user-select: none; }
.scene canvas { width: 100%; height: auto; display: block; cursor: crosshair; }
.astuce { margin-top: 10px; padding: 10px 12px; background: var(--doute-fond); color: #5d3e00; font-size: 14px; border-left: 4px solid var(--doute); }

.balayage { position: relative; overflow: hidden; }
.balayage::after {
  content: ""; position: absolute; left: 0; right: 0; height: 3px; top: 0;
  background: #ff6a3a; box-shadow: 0 0 18px 4px rgba(255, 106, 58, .7);
  animation: balaye 1.7s ease-in-out infinite alternate;
}
.balayage img { width: 100%; display: block; }
@keyframes balaye { to { top: calc(100% - 3px); } }
.etape { margin-top: 12px; font: 500 13px/1.4 var(--mono); color: var(--encre-2); }

/* Candidats */
.candidats { display: grid; gap: 10px; margin-top: 16px; }
.candidat {
  display: block; width: 100%; text-align: left; padding: 14px; background: var(--carte);
  border: 2px solid var(--trait); transition: border-color .15s ease;
}
.candidat:hover { border-color: var(--encre); }
.candidat.premier { border-color: var(--encre); }
.candidat-tete { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.candidat b { font: 700 25px/1.05 var(--titre); }
.candidat ul { margin: 8px 0 0; padding-left: 18px; color: var(--encre-2); font-size: 14px; }
.pastille {
  display: inline-block; white-space: nowrap; padding: 3px 7px;
  font: 500 11px/1.3 var(--mono); border: 1px solid currentColor;
}
.conf-haute { color: var(--ok); background: var(--ok-fond); }
.conf-moyenne { color: var(--doute); background: var(--doute-fond); }
.conf-basse { color: #a32e08; background: var(--signal-fond); }
.alerte { margin-top: 14px; padding: 12px 14px; border-left: 4px solid var(--signal); background: var(--signal-fond); }
.alerte-douce { border-left-color: var(--doute); background: var(--doute-fond); }

details.replie { margin-top: 18px; border-top: 1px solid var(--trait); padding-top: 8px; }
details.replie summary { cursor: pointer; font: 700 18px/1.3 var(--titre); letter-spacing: .03em; padding: 8px 0; }
details.replie[open] summary { margin-bottom: 8px; }

/* Plaque constructeur */
.plaque {
  position: relative; display: grid; grid-template-columns: 1fr; margin-top: 2px;
  background: linear-gradient(135deg, #e9ebec 0%, var(--plaque) 42%, #cdd1d3 100%);
  border: 1px solid var(--plaque-sombre);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .85), 0 2px 0 rgba(22, 25, 28, .18);
}
.plaque-photo { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: var(--encre); }
.plaque-corps { position: relative; padding: 18px 28px 20px; }
.rivet { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #8c9296 70%); box-shadow: 0 0 0 1px #8c9296; }
.rivet.a { top: 9px; left: 9px; } .rivet.b { top: 9px; right: 9px; } .rivet.c { bottom: 9px; left: 9px; } .rivet.d { bottom: 9px; right: 9px; }
.plaque h1 { font-size: clamp(36px, 9vw, 54px); }
.plaque-ligne { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font: 500 13px/1.4 var(--mono); }
.plaque-ligne b { font-weight: 500; color: var(--encre-2); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions .btn { flex: 1 1 130px; min-height: 44px; font-size: 17px; }

/* Grandes valeurs */
.cadrans { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 1px; background: var(--trait); border: 1px solid var(--trait); margin-bottom: 12px; }
.cadran { background: var(--carte); padding: 11px 12px; min-width: 0; }
.cadran .etiquette { display: block; font-size: 12.5px; }
.cadran strong { display: block; margin-top: 3px; font: 500 21px/1.2 var(--mono); overflow-wrap: anywhere; }
.cadran small { color: var(--encre-2); font-size: 12.5px; }

/* Tableau de valeurs */
.tableau { width: 100%; border-collapse: collapse; background: var(--carte); }
.tableau th, .tableau td { padding: 9px 10px; border-bottom: 1px solid var(--trait); text-align: left; vertical-align: top; }
.tableau th { width: 40%; font: 600 15px/1.25 var(--titre); letter-spacing: .03em; color: var(--encre-2); }
.tableau td { overflow-wrap: anywhere; }
.valeur-liste { margin: 0; padding: 0; list-style: none; display: grid; gap: 3px; }
.val { font-family: var(--mono); font-weight: 500; font-size: 14.5px; }
.src {
  display: inline-block; margin-left: 6px; padding: 0 5px; vertical-align: 1px;
  font: 500 10.5px/1.5 var(--mono); text-decoration: none;
  color: #fff; background: var(--encre);
}
.src:hover { background: var(--signal); }
.src-ia { background: var(--doute); }

.selecteur { margin-bottom: 12px; }
.note { margin-top: 8px; font-size: 13.5px; color: var(--encre-2); }

.rappels, .liens, .puces { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.rappels li { padding: 10px 12px; background: var(--carte); border-left: 4px solid var(--signal); }
.rappels b { display: block; font-weight: 600; }
.rappels time, .rappels .meta { font: 500 12px/1.4 var(--mono); color: var(--encre-2); }
.rappels p { margin-top: 4px; font-size: 14px; }
.liens { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.liens a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 46px; padding: 8px 12px;
  background: var(--carte); border: 1px solid var(--encre); text-decoration: none; font-weight: 600; font-size: 15px;
}
.liens a:hover { background: #fff; }
.puces li { padding-left: 16px; position: relative; }
.puces li::before { content: ""; position: absolute; left: 0; top: .55em; width: 7px; height: 7px; background: var(--signal); }
.synthese { padding: 14px; background: var(--carte); border: 1px solid var(--trait); }
.tracabilite { width: 100%; border-collapse: collapse; font: 500 12.5px/1.4 var(--mono); }
.tracabilite td { padding: 5px 0; border-bottom: 1px dotted var(--trait); vertical-align: top; overflow-wrap: anywhere; }
.tracabilite td:first-child { width: 42%; color: var(--encre-2); padding-right: 8px; }

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

@media (min-width: 680px) {
  .plaque { grid-template-columns: 46% 1fr; }
  .plaque-photo { height: 100%; aspect-ratio: auto; min-height: 240px; }
  .plaque-corps { padding: 26px 30px; align-self: center; }
}
@media (max-width: 380px) {
  .formulaire, .reglages { grid-template-columns: 1fr; }
  .tableau th { width: 44%; }
}
@media print {
  .barre, .actions { display: none; }
  body { background: #fff; }
}
