/* Glaze Matrix — feuille de style unique de l'application. */

:root {
  --encre: #1c1a17;
  --discret: #6b665e;
  --trait: #dcd7cd;
  --papier: #fbfaf7;
  --fond: #f2f0ec;
  --accent: #8a3b24;
  --jaune: #fff200;
  --rouge: #c62828; /* la marque d'une case d'où part une phase, lisible sur le jaune */
  --alerte-fond: #f8dcd6;
  --succes-fond: #e2f0d9;
  --rayon: 0.5rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--encre);
  background: var(--fond);
}

h1 { font-size: 1.5rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ en-tête */

.entete {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--papier);
  border-bottom: 1px solid var(--trait);
}

.marque {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--encre);
  text-decoration: none;
}
/* La grille des neuf pastilles : la marque de l'application, en petit. */
.marque img { width: 1.9rem; height: 1.9rem; border-radius: 0.2rem; }

/* Le logo complet, sur les écrans d'entrée où il y a la place. */
.enseigne { display: block; width: min(22rem, 100%); height: auto; margin: 0 auto 1.5rem; }

.menu { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1rem; flex: 1 1 22rem; }
.menu a { padding: 0.35rem 0; color: var(--encre); text-decoration: none; border-bottom: 2px solid transparent; }
.menu a.actif { border-bottom-color: var(--accent); font-weight: 600; }
/* Une demande d'accès attend : le lien le dit, même depuis un autre écran. */
.menu a.en-attente { color: var(--accent); font-weight: 600; }
.menu .reglage { margin-left: auto; font-size: 0.9rem; color: var(--discret); }

/* ------------------------------------------------------------------ mise en page */

.vue { max-width: 68rem; margin: 0 auto; padding: 1.25rem 1rem 4rem; }

.panneau {
  background: var(--papier);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  padding: 1rem 1.1rem;
  margin-top: 1rem;
}

.colonnes { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: 0 1rem; align-items: start; }
.fil { font-size: 0.9rem; color: var(--discret); margin: 0 0 0.5rem; }
.sous-titre { color: var(--discret); margin: 0; }
.conseil { margin-top: 0.9rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.etroit { max-width: 26rem; margin-inline: auto; }

.message { padding: 0.6rem 0.9rem; border-radius: var(--rayon); margin: 0.75rem 0 0; }
.message.erreur { background: var(--alerte-fond); }
.message.succes { background: var(--succes-fond); }
.message.note { background: #fdf6c9; }

/* ------------------------------------------------------------------ boutons et champs */

button, .bouton {
  display: inline-block;
  font: inherit;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: var(--rayon);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}
button.secondaire, .bouton.secondaire { background: transparent; color: var(--accent); }
button.discret { border-color: var(--trait); background: transparent; color: var(--discret); padding: 0.3rem 0.6rem; }
button.petit { padding: 0.15rem 0.5rem; font-size: 0.85rem; }
button:disabled { opacity: 0.5; cursor: default; }

input, select, textarea {
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--trait);
  border-radius: 0.35rem;
  background: #fff;
  color: var(--encre);
  max-width: 100%;
}
textarea { width: 100%; min-height: 4rem; }
input.nombre { width: 6.5rem; text-align: right; }

.champ { display: block; margin-top: 0.75rem; }
.champ > span { display: block; font-size: 0.9rem; color: var(--discret); }
.champ > input:not(.nombre), .champ > select { width: 100%; }

/* ------------------------------------------------------------------ tableaux */

table { border-collapse: collapse; width: 100%; }
th, td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--trait); text-align: left; }
th { font-size: 0.85rem; font-weight: 600; color: var(--discret); }
td.nombre, th.nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.code { white-space: nowrap; }
/* Le rôle d'une matière est une phrase : une colonne assez large pour ne pas la hacher. */
td.role { min-width: 22rem; font-size: 0.9rem; color: var(--discret); }
tr.total td { font-weight: 700; border-bottom: 0; }
tr.variable td { background: #fdf6c9; }
tr.actif td { background: var(--jaune); }
.defilant { overflow-x: auto; }

.liste { list-style: none; margin: 0; padding: 0; }
.liste li { padding: 0.6rem 0; border-bottom: 1px solid var(--trait); }
.liste li:last-child { border-bottom: 0; }
.liste small { display: block; color: var(--discret); }

.dossier > summary { font-size: 1.15rem; font-weight: 700; cursor: pointer; }
.dossier > summary small { font-weight: 400; color: var(--discret); font-size: 0.9rem; }
.dossier[open] > summary { margin-bottom: 0.5rem; }

/* Où en est une recette, d'un coup d'œil dans la liste. Le pavé garde sa ligne : sur un
   téléphone, un statut coupé en deux ne se lit plus. */
.statut {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0.05rem 0.45rem;
  border-radius: 0.8rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  vertical-align: 0.12em;
  white-space: nowrap;
}
.statut.recherche { background: #e6edf3; color: #2d5368; }
.statut.arrete { background: var(--jaune); color: var(--encre); }
.statut.production { background: #e2efe3; color: #2f5d34; }

.arbre, .arbre ul { list-style: none; margin: 0; padding-left: 1.25rem; }
.arbre { padding-left: 0; }
.arbre li { padding: 0.2rem 0; }
.arbre ul { border-left: 2px solid var(--trait); }

/* ------------------------------------------------------------------ matrice 3 × 3 */

.matrice {
  display: grid;
  grid-template-columns: minmax(3.2rem, 6rem) repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  max-width: 34rem;
}
.matrice .axe { font-size: 0.85rem; color: var(--discret); text-align: center; align-self: center; line-height: 1.25; padding: 0 0.25rem; }
.matrice .axe b { display: block; color: var(--encre); font-size: 1rem; }

.case {
  min-height: 4.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  background: #fff;
  color: var(--encre);
  border: 1px solid var(--trait);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  min-width: 0;
  overflow-wrap: anywhere;
}
.case small { font-weight: 400; color: var(--discret); }
/* Téléphone : les neuf cases restent lisibles, l'étiquette d'axe se compacte. */
@media (max-width: 34rem) {
  .matrice { gap: 0.25rem; }
  .matrice .axe { font-size: 0.72rem; padding: 0; overflow-wrap: anywhere; }
  .matrice .axe b { font-size: 0.85rem; }
  .case { font-size: 0.85rem; padding: 0.15rem; min-height: 4rem; }
  .case small { font-size: 0.7rem; }
}
.case.reference { border-style: dashed; border-color: var(--discret); }
.case.active { background: var(--jaune); border: 2px solid var(--encre); }
.case.active small { color: var(--encre); }
/* Case d'où part une phase : la marque « → phase n » se lit en rouge gras, y compris sur le
   jaune de la case ouverte, où le brun de l'accent s'éteignait. */
.case.ramifiee small,
.case.active.ramifiee small { color: var(--rouge); font-weight: 700; }

/* Dans l'arbre des phases, celle qu'on regarde : même rouge que la marque de sa case. */
.arbre .phase-active { color: var(--rouge); font-weight: 700; }

/* ------------------------------------------------------------------ formulaire des axes */

.axes { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1rem; }
.axes fieldset { border: 1px solid var(--trait); border-radius: var(--rayon); padding: 0.5rem 0.9rem 0.9rem; margin: 0; }
.axes legend { font-weight: 600; padding: 0 0.3rem; }
.pas { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: end; margin-top: 0.5rem; }
.pas label > span { display: block; font-size: 0.85rem; color: var(--discret); white-space: nowrap; }
.raccourcis { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.6rem; }

/* Une case à cocher et son étiquette, sur une ligne. */
.coche {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.75rem;
  font-weight: 600;
}
.coche input { width: 1.1rem; height: 1.1rem; margin: 0; }

/* Une matière qui n'est plus sur l'étagère : la ligne s'efface, la mention reste lisible. */
tr.absente td:first-child a { color: var(--discret); }

/* ------------------------------------------------------------------ aide contextuelle */

/* Le repère d'une recherche, « 1.2 » : l'émail et son rang, ce que porte le tesson. */
.repere {
  display: inline-block;
  margin-right: 0.45rem;
  padding: 0.05rem 0.35rem;
  border-radius: 0.25rem;
  background: var(--fond);
  color: var(--discret);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.aide { display: inline-block; vertical-align: middle; margin-left: 0.3rem; }

.aide-bouton {
  width: 1.2rem;
  height: 1.2rem;
  padding: 0;
  border: 1px solid var(--trait);
  border-radius: 50%;
  background: var(--papier);
  color: var(--discret);
  font: inherit;
  font-size: 0.78rem;
  line-height: 1;
  cursor: pointer;
}
.aide-bouton:hover, .aide-bouton[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }

/* Posée en coordonnées d'écran par aide.js, qui la ramène dans la fenêtre. */
.aide-bulle {
  position: fixed;
  z-index: 20;
  width: max-content;
  max-width: min(24rem, calc(100vw - 2rem));
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  background: var(--papier);
  box-shadow: 0 2px 10px rgb(28 26 23 / 0.15);
  color: var(--encre);
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.45;
  text-align: start;
  /* L'étiquette d'un pas est en nowrap : la bulle ne doit pas en hériter. */
  white-space: normal;
}
.apercu { margin: 0.6rem 0 0; font-variant-numeric: tabular-nums; }

.lignes-recette td { border-bottom: 0; padding-left: 0; }
.lignes-recette input:not(.nombre) { width: 100%; }

/* Une feuille qu'on emporte à l'établi : pas d'écran, des mains mouillées, et une seule page. */
@page { size: A4; margin: 14mm; }

@media print {
  .entete, .actions, button, .fil { display: none !important; }
  body { background: #fff; }
  .panneau, .panneau .interieur { border: 0; padding: 0; background: none; box-shadow: none; }
  /* Les champs de saisie deviennent leur valeur : un cadre vide se lirait comme une case à remplir. */
  input, select { border: 0 !important; padding: 0 !important; background: none !important;
    -webkit-appearance: none; appearance: none; font-weight: 600; }
  .pas label { display: inline-block; margin-right: 2rem; }
  /* Rien ne se coupe au milieu : ni une ligne de pesée, ni un tableau, ni une section. */
  tr, table, .interieur { break-inside: avoid; }
  thead { display: table-header-group; }
  h1, h2, h3 { break-after: avoid; }
  a { color: inherit; text-decoration: none; }
  .defilant { overflow: visible; }
  /* L'en-tête d'impression ne sort que là : à l'écran, le fil d'Ariane le dit déjà. */
  .impression { display: block !important; border-bottom: 1px solid var(--trait); padding-bottom: .4rem; }
  /* Ce qui s'explique à l'écran et ne sert pas pendant la séance reste à l'écran. */
  .hors-seance, .aide { display: none !important; }
  /* Les cases à renseigner au crayon : un trait, pas un cadre vide. */
  .a-noter input { border-bottom: 1px solid currentColor !important; min-width: 5rem; }
  /* Une feuille d'atelier se tient d'une main : on resserre. */
  .feuille h1 { font-size: 1.4rem; margin: .3rem 0; }
  .feuille h2 { font-size: 1.05rem; margin: .7rem 0 .2rem; }
  .feuille h3 { font-size: .95rem; margin: .5rem 0 .2rem; }
  .feuille { font-size: 8.5pt; }
  .feuille td, .feuille th { padding: .12rem .5rem; }
  .feuille li { margin: 0; }
  .feuille ol { margin: .2rem 0; padding-left: 1.2rem; }
  .feuille p { margin: .25rem 0; }
  .feuille .panneau { margin: 0 0 .4rem; }
  /* Les encarts gardent leur rôle d'alerte sans vider la cartouche d'encre. */
  .feuille .message { background: none; border-left: 2px solid var(--trait); padding: .1rem .6rem; }
}

/* Repères d'une feuille imprimée — quel émail, quand — inutiles à l'écran. */
.impression { display: none; }

/* Colonne de cases à cocher : la case au milieu de sa colonne. */
.centre { text-align: center; }
/* Un en-tête court garde son « ? » sur la même ligne que son titre. */
th.centre { white-space: nowrap; }

/* Fiche d'état : intitulé à gauche, valeur à droite, sans la largeur pleine d'un tableau de données. */
.fiche { width: auto; }
.fiche th { text-align: left; font-weight: 400; color: var(--discret); padding-right: 2rem; }

/* Matière qui tient mal en suspension : signalée sans crier, le détail en infobulle. */
.avis { color: var(--accent); font-style: italic; cursor: help; }

/* Panneau dans un panneau : une suspension à l'intérieur de sa section. */
.panneau .interieur { background: var(--fond); margin: 1rem 0; }

/* Plan des capsules : la matrice en plus petit, sans lien ni interaction. */
.matrice.plan { max-width: 30rem; }
.matrice.plan .case { min-height: 2.6rem; font-weight: 600; }
/* Le plan sert aussi à porter un volume par case : le code passe au second plan. */
.matrice.plan .case:has(strong) { min-height: 3.4rem; gap: 0.1rem; }
.matrice.plan .case .code { font-size: 0.78rem; font-weight: 500; color: var(--discret); }

/* Comptes : le bandeau d'incarnation et les actions en bout de ligne du tableau. */
.bandeau {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
}
.bandeau:not(:empty) {
  margin: 0 auto;
  max-width: var(--largeur, 70rem);
  padding: 0.6rem 1rem;
  background: #fdf3d8;
  border: 1px solid #e0c98a;
  border-radius: 0.4rem;
  font-size: 0.92rem;
}
.actions-ligne {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.actions-ligne button { padding: 0.25rem 0.55rem; font-size: 0.82rem; }
@media print { .bandeau { display: none; } }

/* ------------------------------------------------------------------ diagramme */

/* La trajectoire d'une recherche : un plan, des points, un chemin. */
.diagramme {
  display: block;
  width: 100%;
  max-width: 680px;
  height: auto;
  margin: 0.5rem 0;
}
.legende-diagramme {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--discret);
}
.legende-diagramme .pastille {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.35rem;
  border-radius: 50%;
  vertical-align: -0.05rem;
}
.legende-diagramme .pastille.creuse {
  background: var(--papier);
  border: 2px solid var(--discret);
}
/* L'anneau du tressaillage, repris du diagramme où il entoure le point : tireté, pour se
   distinguer d'une pastille creuse, qui dit autre chose. */
.legende-diagramme .pastille.anneau {
  background: var(--papier);
  border: 1px dashed var(--encre);
}
/* Les verdicts sont cernés comme les points de la carte le sont : sans ce trait, le blanc du
   cru ne se verrait pas, et le noir du coulé flotterait sans limite. */
.legende-verdicts .pastille { border: 1px solid var(--encre); }

/* L'épaisseur visée ouvre la feuille de préparation : c'est elle qui commande tous les chiffres
   d'en dessous, et une feuille imprimée doit dire à quelle épaisseur elle a été calculée. */
.epaisseur {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

/* ------------------------------------------------- interrupteur d'un réglage à cocher */
/* La case et son libellé sur une même ligne, la case d'abord : un réglage qui s'ouvre ou
   se ferme ne se lit pas comme un champ à remplir, qui porte son étiquette au-dessus. */
.interrupteur { display: flex; align-items: flex-start; gap: 0.6rem; cursor: pointer; }
.interrupteur input { margin-top: 0.3rem; flex: none; }

/* ------------------------------------------------------- verdict posé sur une case */
/* Le mot se détache du code de l'essai sans le concurrencer : c'est une observation
   ajoutée après coup, pas l'identité de la case. */
.case .verdict { font-weight: 600; color: var(--accent); }
.case.active .verdict { color: var(--encre); }

.jugement { margin-top: 1rem; border-top: 1px solid var(--trait); padding-top: 0.75rem; }
.jugement h3 { font-size: 0.95rem; margin: 0 0 0.5rem; }
.jugement label { display: block; margin-top: 0.6rem; }
.jugement label > span { display: block; font-size: 0.9rem; color: var(--discret); }
/* Les boutons passent à la ligne plutôt que de déborder : quatre mots longs ne tiennent pas
   sur une rangée dans un panneau étroit, et un libellé tronqué ne se clique pas en confiance. */
.choix { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.25rem; }
.choix button {
  padding: 0.3rem 0.7rem; font-size: 0.9rem; border: 1px solid var(--trait);
  border-radius: var(--rayon); background: var(--papier); color: var(--encre); cursor: pointer;
}
.choix button.actif { background: var(--jaune); border-color: var(--encre); font-weight: 600; }

/* ------------------------------------------------------------ contenu agrandi en plein écran */
/* Le dialog du navigateur fait le gros du travail — Échap, clic hors cadre, retour du focus.
   Il ne reste qu'à lui donner la taille et les couleurs de l'application. */
dialog.agrandi {
  width: min(96vw, 1100px); max-height: 92vh; overflow: auto;
  border: 0; border-radius: var(--rayon); padding: 1.25rem;
  background: var(--papier); color: var(--encre);
}
dialog.agrandi::backdrop { background: rgba(28, 26, 23, 0.6); }
dialog.agrandi .entete { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
dialog.agrandi .entete h2 { margin: 0; }
/* Le plafond de 680 px convient à un diagramme glissé dans un panneau ; en grand, il n'a plus
   lieu d'être — c'est toute la raison d'avoir agrandi. */
dialog.agrandi .diagramme { max-width: none; }

/* ------------------------------------------------------- bandeau de la démonstration */
/* Le même gabarit que les autres bandeaux, dans la teinte d'avertissement : on visite,
   on ne travaille pas, et ça ne doit jamais sortir du champ de vision. */
.bandeau-demo {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; background: var(--jaune);
}
; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; background: var(--jaune);
}
