/* Maille à Maille — feuille de style unique.
   Direction « atelier éditorial » : parchemin, encre et terre cuite, une serif
   de titrage (Fraunces) contre une grotesque de données (Inter). Deux traits
   distincts — un très doux pour les bordures d'interface, un plus franc pour
   les contours du schéma, qui doivent rester lisibles. Clair et sombre. */

:root {
  color-scheme: light dark;

  /* Surfaces */
  --parchemin: #f4efe6;
  --surface:   #fffcf7;
  --surface-2: #efe8db;
  --surface-3: #e7decd;
  --scene:     #fffcf7;   /* fond du schéma : sert de halo aux cotes */

  /* Encres */
  --encre:   #241f1b;
  --encre-2: #6a5f54;
  --encre-3: #94887a;

  /* Traits */
  --trait:      #e5dccc;  /* bordures d'interface, discrètes */
  --trait-fort: #bdae97;  /* contours du dessin, qui doivent porter */

  /* Accent */
  --accent:     #a8442c;
  --accent-2:   #8a3623;
  --accent-doux:#f7e7e0;
  --sur-accent: #fff;   /* texte pose sur l'accent */

  /* Laine */
  --laine: #ede4d5;
  --fil:   #9a8a72;

  /* États */
  --ok: #4a7a54;
  --alerte: #8a5e15;
  --alerte-fond: #faf0d9;

  /* Rythme */
  --r-xs: 6px;  --r-sm: 9px;  --r-md: 12px;  --r-lg: 16px;  --r-xl: 22px;
  --ombre-1: 0 1px 2px rgba(58, 44, 32, .05);
  --ombre-2: 0 1px 2px rgba(58, 44, 32, .04), 0 8px 22px -14px rgba(58, 44, 32, .3);
  --ombre-3: 0 2px 4px rgba(58, 44, 32, .05), 0 26px 50px -24px rgba(58, 44, 32, .38);

  --police: "Inter", ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Fraunces", ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  --rail: 15.5rem;
}

/* Sombre : au reglage systeme sauf si l'on a explicitement demande le clair,
   et sur demande explicite. Les deux jeux sont declares a l'identique pour que
   la bascule gagne dans les deux sens. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --parchemin: #15120f;
    --surface:   #1d1915;
    --surface-2: #262019;
    --surface-3: #2f2820;
    --scene:     #1d1915;
    --encre:   #f2eadd;
    --encre-2: #b0a392;
    --encre-3: #8b7f6e;
    --trait:      #332b22;
    --trait-fort: #6b5c49;
    --accent:     #e08a69;
    --accent-2:   #f0a184;
    --accent-doux:#3b2419;
    --sur-accent: #211b16;
  --sur-accent: #211b16;
    --laine: #2a241d;
    --fil:   #a08d74;
    --ok: #7fae83;
    --alerte: #d6a84e;
    --alerte-fond: #2e2513;
    --ombre-1: 0 1px 2px rgba(0, 0, 0, .3);
    --ombre-2: 0 1px 2px rgba(0, 0, 0, .28), 0 8px 22px -14px rgba(0, 0, 0, .8);
    --ombre-3: 0 2px 4px rgba(0, 0, 0, .3), 0 26px 50px -24px rgba(0, 0, 0, .9);
  }
}

:root[data-theme="dark"] {
  --parchemin: #15120f;
  --surface:   #1d1915;
  --surface-2: #262019;
  --surface-3: #2f2820;
  --scene:     #1d1915;
  --encre:   #f2eadd;
  --encre-2: #b0a392;
  --encre-3: #8b7f6e;
  --trait:      #332b22;
  --trait-fort: #6b5c49;
  --accent:     #e08a69;
  --accent-2:   #f0a184;
  --accent-doux:#3b2419;
  --sur-accent: #211b16;
  --laine: #2a241d;
  --fil:   #a08d74;
  --ok: #7fae83;
  --alerte: #d6a84e;
  --alerte-fond: #2e2513;
  --ombre-1: 0 1px 2px rgba(0, 0, 0, .3);
  --ombre-2: 0 1px 2px rgba(0, 0, 0, .28), 0 8px 22px -14px rgba(0, 0, 0, .8);
  --ombre-3: 0 2px 4px rgba(0, 0, 0, .3), 0 26px 50px -24px rgba(0, 0, 0, .9);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--police);
  font-size: 15px;
  color: var(--encre);
  background: var(--parchemin);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 600; }
button, input, select { font: inherit; color: inherit; }

.serif, .patron h2, .entete h1, .panneau-tete h2, .carte-v {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-variation-settings: "SOFT" 24;
  letter-spacing: -.012em;
}

.ic { flex: none; pointer-events: none; }

:is(button, input, select, a, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ======================================================================== */
/*  Coquille                                                                */
/* ======================================================================== */

.appli {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100vh;
}
.colonne { min-width: 0; display: flex; flex-direction: column; }

/* --- Rail --------------------------------------------------------------- */

.rail {
  position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: .3rem;
  padding: 1.15rem .8rem 1rem;
  background: var(--surface);
  border-right: 1px solid var(--trait);
}

.marque {
  display: flex; align-items: center; gap: .6rem;
  padding: .1rem .35rem 1.35rem;
  color: var(--accent);
}
.marque-logo { display: grid; place-items: center; }
.marque-mot {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-variation-settings: "SOFT" 30, "WONK" 1;
  font-size: 1.06rem; font-weight: 600; letter-spacing: -.02em;
  color: var(--encre);
}
.marque-mot span { color: var(--accent); font-style: italic; padding: 0 .12em; font-weight: 400; }

.rail-titre {
  margin: 0 0 .45rem; padding: 0 .55rem;
  font-size: .69rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .11em; color: var(--encre-3);
}

.familles { display: flex; flex-direction: column; gap: 1px; }
.familles button {
  position: relative;
  display: flex; align-items: center; gap: .65rem;
  width: 100%; padding: .46rem .55rem;
  border: 0; background: none; border-radius: var(--r-sm);
  font-size: .875rem; font-weight: 500; color: var(--encre-2);
  text-align: left; cursor: pointer;
  transition: background .14s, color .14s;
}
.familles button .ic { width: 1.3rem; height: 1.3rem; opacity: .62; transition: opacity .14s; }
.familles button:hover { background: var(--surface-2); color: var(--encre); }
.familles button:hover .ic { opacity: .85; }
.familles button[aria-selected="true"] {
  background: var(--accent-doux); color: var(--accent-2); font-weight: 600;
}
.familles button[aria-selected="true"] .ic { opacity: 1; }
.familles button[aria-selected="true"]::before {
  content: ""; position: absolute; left: -.8rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 1.3rem; border-radius: 0 3px 3px 0; background: var(--accent);
}

.rail-pied {
  margin-top: auto; padding-top: .9rem;
  display: flex; align-items: center; gap: .4rem;
  border-top: 1px solid var(--trait);
}

/* --- En-tête ------------------------------------------------------------ */

.entete {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; gap: 1rem;
  align-items: flex-end; justify-content: space-between;
  padding: 1.15rem clamp(1rem, 2.6vw, 2rem) 1rem;
  background: color-mix(in srgb, var(--parchemin) 86%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--trait);
}
.entete-titre { min-width: 0; }

.nom-projet {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .1rem .45rem .1rem 0; margin-left: -.05rem;
  border: 0; background: none; cursor: pointer; border-radius: var(--r-sm);
  transition: color .14s;
}
.entete h1 { font-size: clamp(1.3rem, 2.4vw, 1.6rem); font-weight: 600; }
.nom-crayon { display: grid; place-items: center; color: var(--encre-3); opacity: 0; transition: opacity .14s; }
.nom-projet:hover { color: var(--accent-2); }
.nom-projet:hover .nom-crayon, .nom-projet:focus-visible .nom-crayon { opacity: 1; }
.sous { margin: .12rem 0 0; font-size: .84rem; color: var(--encre-2); }

.outils { display: flex; flex-wrap: wrap; gap: .45rem; }

/* --- Boutons ------------------------------------------------------------ */

.bt, .bt-secondaire {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .48rem .85rem; border-radius: var(--r-sm);
  border: 1px solid transparent; background: none;
  font-size: .85rem; font-weight: 500; line-height: 1.25;
  color: var(--encre); cursor: pointer; white-space: nowrap;
  transition: background .14s, border-color .14s, color .14s, box-shadow .14s;
}
.bt .ic { width: 1.05rem; height: 1.05rem; opacity: .7; }

.bt--primaire {
  background: var(--accent); border-color: var(--accent); color: var(--sur-accent);
  box-shadow: var(--ombre-1);
}
.bt--primaire .ic { opacity: .9; }
.bt--primaire:hover { background: var(--accent-2); border-color: var(--accent-2); }

.bt--doux, .bt-secondaire {
  background: var(--surface); border-color: var(--trait); color: var(--encre);
  box-shadow: var(--ombre-1);
}
.bt--doux:hover, .bt-secondaire:hover { border-color: var(--trait-fort); background: var(--surface-2); }

.bt--fantome { color: var(--encre-2); }
.bt--fantome:hover { background: var(--surface-2); color: var(--encre); }

.bt--icone { width: 2.15rem; height: 2.15rem; padding: 0; flex: none; color: var(--encre-2); }
.bt--icone:hover { background: var(--surface-2); color: var(--encre); }
.bt--icone .ic { opacity: .8; }

.bt--large { flex: 1; justify-content: flex-start; padding-left: .55rem; }

.bt[aria-pressed="true"] {
  background: var(--accent-doux); border-color: transparent; color: var(--accent-2);
  box-shadow: none;
}
.bt[aria-pressed="true"] .ic { opacity: 1; }

/* Bascule de thème : on ne montre que l'état vers lequel on va. */
#bt-theme .ic-lune { display: none; }
:root[data-theme="dark"] #bt-theme .ic-lune { display: block; }
:root[data-theme="dark"] #bt-theme .ic-soleil { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #bt-theme .ic-lune { display: block; }
  :root:not([data-theme="light"]) #bt-theme .ic-soleil { display: none; }
}

/* --- Alertes ------------------------------------------------------------ */

.alertes {
  margin: 0; padding: .6rem clamp(1rem, 2.6vw, 2rem);
  list-style: none;
  background: var(--alerte-fond); color: var(--alerte);
  border-bottom: 1px solid var(--trait);
  font-size: .84rem;
}
.alertes li { position: relative; padding-left: 1.4rem; }
.alertes li::before {
  content: ""; position: absolute; left: .25rem; top: .62em;
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}

/* ======================================================================== */
/*  Atelier : schéma + inspecteur                                           */
/* ======================================================================== */

.atelier {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 21.5rem;
  gap: 1.1rem;
  padding: 1.25rem clamp(1rem, 2.6vw, 2rem);
  align-items: stretch;
}

.scene-wrap {
  display: flex; flex-direction: column; justify-content: center;
  min-height: min(64vh, 34rem);
  background: var(--scene);
  border: 1px solid var(--trait);
  border-radius: var(--r-xl);
  padding: 1.4rem 1.4rem 1rem;
  box-shadow: var(--ombre-2);
}
.scene { width: 100%; }
.schema { width: 100%; height: auto; max-height: 66vh; display: block; overflow: visible; }
.indice {
  margin: .9rem auto 0; max-width: 46ch;
  font-size: .8rem; color: var(--encre-3); text-align: center;
}

/* Zones cliquables du schéma */
.zone { cursor: pointer; }
.zone .zb { fill: var(--laine); }
.zone .zt { fill: var(--accent); opacity: .07; }
.zone .zf { stroke: none; }
.zone .zo { fill: none; stroke: var(--trait-fort); stroke-width: .45; stroke-linejoin: round; }
.trame { stroke: var(--fil); }

.zone:hover .zt, .zone:focus-visible .zt { opacity: .2; }
.zone:hover .zo { stroke: var(--encre-2); stroke-width: .7; }
.zone.est-active .zt { opacity: .26; }
.zone.est-active .zo { stroke: var(--accent); stroke-width: 1.1; }
.zone.est-vide { opacity: .3; }
.zone.est-vide .zo { stroke-dasharray: 2 2; }
.zone:focus { outline: none; }

.raglan path { fill: none; stroke: var(--accent); stroke-width: .5; stroke-dasharray: 1.6 1.6; opacity: .7; }
/* Les tours d'augmentation d'un empiècement rond : pleins, et d'autant plus
   marqués qu'ils portent plus de mailles. */
.raglan path.tour { stroke-dasharray: none; stroke-width: .42; opacity: .55; }
/* Le repere de l'epaule reelle, sous la ligne d'epaule tombante. */
.raglan path.epaule { stroke-dasharray: .8 1.2; opacity: .5; }

.cote path { fill: none; stroke: var(--encre-3); stroke-width: .3; }
/* Halo : les libellés restent lisibles même par-dessus une manche ou une trame. */
.cote text, .etiq {
  paint-order: stroke; stroke: var(--scene); stroke-width: 1.2px; stroke-linejoin: round;
}
.cote text { fill: var(--encre-2); font-size: 2.6px; font-family: var(--police); }

/* Une cote qui mène à la mesure du corps. Le trait de cote fait 0,3 mm : il
   est illusoire à viser, d'où le tracé transparent qui reçoit seul le doigt. */
.cote-mesure { cursor: pointer; }
.cote-mesure .cote-hit { stroke: transparent; stroke-width: 3.4; fill: none; }
/* `:not(.cote-hit)` est vital : le tracé de clic fait 3,4 mm de large et doit
   rester invisible — teint, il barre le schéma d'un trait épais. */
.cote-mesure:hover path:not(.cote-hit),
.cote-mesure:focus-visible path:not(.cote-hit) { stroke: var(--accent); }
.cote-mesure:hover text, .cote-mesure:focus-visible text { fill: var(--accent-2); }
.cote-mesure:focus { outline: none; }
.cote-mesure:focus-visible text { text-decoration: underline; }
/* Relevée sur la personne : la cote le dit, sans quoi rien ne distingue à
   l'écran un vêtement sur mesure d'un vêtement au barème. */
.cote-mesure.est-relevee path:not(.cote-hit) { stroke: var(--accent); }
.cote-mesure.est-relevee text { fill: var(--accent-2); font-weight: 600; }
.etiq { fill: var(--encre-2); font-size: 3.1px; font-family: var(--police); letter-spacing: .04em; }
.etiq-fantome { font-style: italic; opacity: .7; }

/* Détails de dessin propres à certaines pièces. */
.pompon { fill: var(--laine); stroke: var(--trait-fort); stroke-width: .4; }
.boutons circle { fill: var(--surface); stroke: var(--accent); stroke-width: .35; }
.tube-hint path { fill: none; stroke: var(--trait-fort); stroke-width: .35; stroke-dasharray: 1.4 1.4; }
.rupture { fill: none; stroke: var(--encre-3); stroke-width: .4; opacity: .7; }
.franges path { stroke: var(--fil); stroke-width: .5; opacity: .8; }

/* --- Partage : le pont vers le téléphone -------------------------------- */

.partage {
  width: min(27rem, calc(100vw - 1.6rem));
  padding: 1.2rem 1.3rem 1.4rem;
  border: 1px solid var(--trait);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--encre);
  box-shadow: var(--ombre-3);
}
.partage::backdrop { background: rgba(20, 14, 10, .55); backdrop-filter: blur(2px); }
.partage-tete { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.partage-tete h2 { font-size: 1.1rem; }
.partage-aide { margin: .35rem 0 1rem; font-size: .82rem; line-height: 1.5; color: var(--encre-2); }
.partage-qr { display: flex; justify-content: center; margin-bottom: 1rem; }
/* Le code garde son fond clair dans les deux thèmes : la moitié des
   téléphones ne lit pas un QR inversé. Le cadre blanc EST la zone de
   silence — sans elle, la caméra ne trouve pas les coins. */
.qr {
  width: min(20rem, 72vw); height: auto;
  border-radius: var(--r-xs);
  border: 1px solid var(--trait);
}
.partage-lien { display: flex; gap: .35rem; }
.partage-lien input {
  flex: 1 1 auto; min-width: 0;
  padding: .45rem .6rem;
  border: 1px solid var(--trait); border-radius: var(--r-xs);
  background: var(--surface-2); color: var(--encre-3);
  font-size: .74rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-overflow: ellipsis;
}
.partage-lien .bt { flex: none; }
.partage-note { margin: .7rem 0 0; font-size: .73rem; line-height: 1.45; color: var(--encre-3); }

/* Le QR du patron imprimé : invisible à l'écran, posé en fin de feuille. */
.qr-papier { display: none; }

/* --- Mesures et profils ------------------------------------------------- */

.champ-mesure { margin-bottom: .85rem; }
.champ-mesure .aide-champ { margin-top: .25rem; }
.mesure-saisie { display: flex; align-items: center; gap: .35rem; }
.mesure-saisie input[type="number"] { flex: 1 1 auto; }
/* Le placeholder porte la valeur du barème : il doit se lire comme une
   proposition, pas comme une saisie. */
.mesure-saisie input::placeholder { color: var(--encre-3); opacity: .75; font-style: italic; }
.mesure-saisie .unite { font-size: .78rem; color: var(--encre-3); flex: none; }
.mesure-raz {
  display: grid; place-items: center; flex: none;
  width: 1.7rem; height: 1.7rem; padding: 0;
  border: 0; background: none; color: var(--encre-3);
  border-radius: var(--r-xs); cursor: pointer;
}
.mesure-raz:hover { color: var(--accent); background: var(--surface-2); }
.champ-mesure.est-relevee > label { color: var(--accent-2); }
.champ-mesure.est-relevee input[type="number"] {
  border-color: var(--accent); background: var(--accent-doux);
}

.profils { display: grid; grid-template-columns: 1fr auto; gap: .35rem .3rem; }
.profils > label, .profils > .aide-champ, .profils > .lien-raz { grid-column: 1 / -1; }
.profils > select { grid-column: 1; }
.profils > .suppr {
  display: grid; place-items: center;
  width: 2.1rem; border: 1px solid var(--trait); border-radius: var(--r-xs);
  background: var(--surface-2); color: var(--encre-3); cursor: pointer;
}
.profils > .suppr:hover { color: var(--accent); border-color: var(--trait-fort); }
.profils-enr { grid-column: 1 / -1; display: flex; gap: .3rem; }
.profils-enr input { flex: 1 1 auto; }
.profils-enr .bt-secondaire { flex: none; padding: .4rem .7rem; font-size: .78rem; }
.lien-raz {
  justify-self: start; margin-top: .1rem; padding: 0;
  border: 0; background: none; cursor: pointer;
  font-size: .74rem; color: var(--encre-3); text-decoration: underline;
}
.lien-raz:hover { color: var(--accent); }
.bt-pleine { width: 100%; justify-content: center; }

/* --- Inspecteur --------------------------------------------------------- */

.panneau {
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--r-lg);
  box-shadow: var(--ombre-2);
  padding: 1.05rem 1.15rem 1.2rem;
  align-self: start;
  position: sticky; top: 5.6rem;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
}
.panneau-tete { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.panneau-tete h2 { font-size: 1.06rem; }
.fermer {
  display: grid; place-items: center; flex: none;
  width: 1.9rem; height: 1.9rem; margin-right: -.35rem;
  border: 0; background: none; cursor: pointer;
  color: var(--encre-3); border-radius: var(--r-xs);
}
.fermer:hover { color: var(--accent); background: var(--surface-2); }
.panneau-aide { margin: .3rem 0 1.1rem; font-size: .8rem; line-height: 1.5; color: var(--encre-2); }

.champ { margin-bottom: 1.05rem; }
.champ > label {
  display: flex; justify-content: space-between; align-items: baseline; gap: .5rem;
  font-size: .78rem; font-weight: 600; letter-spacing: .005em;
  color: var(--encre-2); margin-bottom: .4rem;
}
.champ output {
  font-weight: 600; color: var(--accent-2);
  font-variant-numeric: tabular-nums; font-size: .82rem;
}
.aide-champ { margin: .4rem 0 0; font-size: .74rem; line-height: 1.45; color: var(--encre-3); }

/* Une note de panneau : ce que le réglage voisin implique ailleurs. */
.champ-note {
  margin: 0 0 .95rem; padding: .55rem .7rem;
  font-size: .78rem; line-height: 1.5; color: var(--encre-2);
  border-left: 2px solid var(--accent); background: var(--accent-doux);
  border-radius: 0 var(--r-xs) var(--r-xs) 0;
}

.champ input[type="text"], .champ input[type="number"], .champ select {
  width: 100%; padding: .48rem .6rem;
  border-radius: var(--r-xs); border: 1px solid var(--trait);
  background: var(--surface-2); color: var(--encre);
  font-size: .875rem;
  transition: border-color .14s, background .14s;
}
.champ input[type="text"]:focus, .champ input[type="number"]:focus, .champ select:focus {
  background: var(--surface); border-color: var(--trait-fort);
}
.champ input:disabled { opacity: .45; }
.champ input[type="range"] { width: 100%; accent-color: var(--accent); }

.segmente, .presets { display: flex; flex-wrap: wrap; gap: .3rem; }
.segmente button, .presets button {
  flex: 1 1 auto; padding: .38rem .55rem; font-size: .8rem; font-weight: 500;
  border: 1px solid var(--trait); background: var(--surface-2);
  color: var(--encre-2);
  border-radius: var(--r-xs); cursor: pointer; white-space: nowrap;
  transition: border-color .14s, background .14s, color .14s;
}
.segmente button:hover, .presets button:hover { border-color: var(--trait-fort); color: var(--encre); }
.segmente button.actif, .presets button.actif {
  background: var(--accent); border-color: var(--accent); color: var(--sur-accent); font-weight: 600;
}

.grille-points { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
.pt-btn {
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  padding: .4rem .25rem .35rem;
  border: 1px solid var(--trait); background: var(--surface-2);
  border-radius: var(--r-xs); cursor: pointer;
  font-size: .68rem; font-weight: 500; color: var(--encre-2); text-align: center;
  transition: border-color .14s, background .14s, color .14s;
}
.pt-btn:hover { border-color: var(--trait-fort); color: var(--encre); }
.pt-btn.actif { border-color: var(--accent); background: var(--accent-doux); color: var(--accent-2); font-weight: 600; }
.apercu { width: 100%; height: 32px; border-radius: 4px; background: var(--laine); }
.pt-btn .trame { stroke: var(--fil); stroke-width: .55; }

.bascule {
  display: flex; align-items: center; gap: .55rem;
  font-size: .82rem; color: var(--encre-2);
  margin-bottom: 1rem; cursor: pointer;
}
.bascule input { accent-color: var(--accent); width: 1rem; height: 1rem; flex: none; }

.resume {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(5.2rem, 1fr));
  gap: .4rem; margin: 1.1rem 0 0; padding-top: .95rem;
  border-top: 1px solid var(--trait);
}
.resume div { background: var(--surface-2); border-radius: var(--r-xs); padding: .45rem .55rem; }
.resume dt { font-size: .67rem; color: var(--encre-3); letter-spacing: .01em; }
.resume dd {
  margin: .05rem 0 0; font-weight: 600; font-size: .88rem;
  font-variant-numeric: tabular-nums;
}

/* Inspecteur en feuille sur mobile */
@media (max-width: 60rem) {
  .panneau {
    position: fixed; inset: auto 0 0 0; top: auto; z-index: 40;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-bottom: 0; border-left: 0; border-right: 0;
    max-height: 66vh; transform: translateY(102%);
    transition: transform .24s cubic-bezier(.32, .72, 0, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .22);
  }
  .panneau.ouvert { transform: none; }
}

/* ======================================================================== */
/*  Sorties                                                                 */
/* ======================================================================== */

.sorties {
  margin: .3rem clamp(1rem, 2.6vw, 2rem) 0;
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--r-lg);
  box-shadow: var(--ombre-2);
  overflow: hidden;
}
.onglets {
  display: flex; gap: .2rem; flex-wrap: wrap;
  padding: .5rem .6rem 0;
  border-bottom: 1px solid var(--trait);
  background: var(--surface-2);
}
.onglets button {
  padding: .5rem .8rem; border: 0; background: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-size: .86rem; font-weight: 500; color: var(--encre-2);
  transition: color .14s, border-color .14s;
}
.onglets button:hover { color: var(--encre); }
.onglets button[aria-selected="true"] {
  color: var(--accent-2); border-bottom-color: var(--accent); font-weight: 600;
}

.panneau-sortie { padding: clamp(1.15rem, 2.6vw, 1.9rem); }

/* --- Patron ------------------------------------------------------------- */

.patron h2 { font-size: 1.55rem; font-weight: 600; }
.patron .sous-titre {
  color: var(--encre-2); font-size: .84rem;
  margin: .35rem 0 1.9rem; padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--trait);
}
.patron section { margin-bottom: 1.9rem; max-width: 62ch; }
.patron section:last-of-type { margin-bottom: 0; }
.patron h3, .materiel h3, .suivi h3 {
  display: flex; align-items: center; gap: .7rem;
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .12em;
  color: var(--accent-2); margin-bottom: .75rem;
}
.patron h3::after, .materiel h3::after, .suivi h3::after {
  content: ""; flex: 1; height: 1px; background: var(--trait);
}
.patron ol { margin: 0; padding-left: 1.35rem; }
.patron li { margin-bottom: .55rem; padding-left: .15rem; }
.patron li::marker { color: var(--encre-3); font-size: .82em; }
.patron b {
  font-weight: 650; font-variant-numeric: tabular-nums;
  color: var(--accent-2); background: var(--accent-doux);
  padding: .04em .32em; border-radius: 4px;
}

/* --- Fiche matériel ----------------------------------------------------- */

.cartes {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  gap: .7rem; margin-bottom: 1.9rem;
}
.carte {
  background: var(--surface-2); border: 1px solid var(--trait);
  border-radius: var(--r-md); padding: .85rem 1rem .9rem;
  display: flex; flex-direction: column; gap: .1rem;
}
.carte-t { font-size: .66rem; text-transform: uppercase; letter-spacing: .11em; color: var(--encre-3); }
.carte-v { font-size: 1.45rem; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.carte-d { font-size: .75rem; color: var(--encre-2); line-height: 1.45; }
.materiel h3 { margin-top: 1.6rem; }
.liste-materiel { margin: 0; padding-left: 1.2rem; max-width: 60ch; }
.liste-materiel li { margin-bottom: .3rem; }
.mesures { border-collapse: collapse; width: 100%; max-width: 32rem; font-size: .88rem; }
.mesures th { text-align: left; font-weight: 400; color: var(--encre-2); padding: .4rem 0; }
.mesures td { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; padding: .4rem 0; }
.mesures tr + tr th, .mesures tr + tr td { border-top: 1px solid var(--trait); }

/* --- Suivi de tricot ---------------------------------------------------- */

.progression { margin-bottom: 1.6rem; max-width: 32rem; }
.barre { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.barre span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .25s; }
.progression p { margin: .5rem 0 0; font-size: .8rem; color: var(--encre-2); font-variant-numeric: tabular-nums; }
.suivi section { margin-bottom: 1.6rem; }
.etapes { list-style: none; margin: 0; padding: 0; }
.etapes li {
  display: flex; gap: .75rem; align-items: flex-start; justify-content: space-between;
  padding: .55rem 0; border-bottom: 1px solid var(--trait); max-width: 70ch;
}
.etapes li:last-child { border-bottom: 0; }
.etapes label { display: flex; gap: .65rem; align-items: flex-start; cursor: pointer; }
.etapes input { margin-top: .32rem; accent-color: var(--ok); width: 1.02rem; height: 1.02rem; flex: none; }
.etapes li.fait span { text-decoration: line-through; color: var(--encre-3); }
.compteur { display: flex; align-items: center; gap: .25rem; flex: none; }
.compteur button {
  width: 1.85rem; height: 1.85rem; border-radius: var(--r-xs);
  border: 1px solid var(--trait); background: var(--surface-2);
  color: var(--encre-2); cursor: pointer; line-height: 1;
  transition: border-color .14s, color .14s;
}
.compteur button:hover { border-color: var(--trait-fort); color: var(--encre); }
.compteur output {
  font-variant-numeric: tabular-nums; font-size: .78rem;
  min-width: 3.6rem; text-align: center; color: var(--encre-2);
}
#bt-raz { margin-top: .5rem; }

/* ======================================================================== */
/*  Projets & pied                                                          */
/* ======================================================================== */

.projets-box { padding: 1.6rem clamp(1rem, 2.6vw, 2rem) 0; }
.projets-tete {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.projets-actions { display: flex; gap: .2rem; }
.projets-actions .bt { padding: .34rem .6rem; font-size: .78rem; }
.projets-box h2 {
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .12em;
  color: var(--encre-3); margin-bottom: .65rem;
}
.projets { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .45rem; }
.projets li {
  display: flex; align-items: center;
  background: var(--surface); border: 1px solid var(--trait);
  border-radius: var(--r-sm); box-shadow: var(--ombre-1);
  transition: border-color .14s;
}
.projets li:hover { border-color: var(--trait-fort); }
.projets button {
  border: 0; background: none; cursor: pointer;
  padding: .4rem .75rem; font-size: .82rem; font-weight: 500;
  border-radius: var(--r-sm);
}
.projets .suppr {
  display: grid; place-items: center;
  color: var(--encre-3); padding: .4rem .55rem .4rem .2rem;
}
.projets .suppr:hover { color: var(--accent); }
.projets .vide {
  padding: .4rem .75rem; font-size: .82rem; color: var(--encre-3);
  background: none; border: 1px dashed var(--trait); border-radius: var(--r-sm);
}

.pied {
  margin-top: auto;
  padding: 2rem clamp(1rem, 2.6vw, 2rem) 2.5rem;
  max-width: 62ch; font-size: .78rem; line-height: 1.6; color: var(--encre-3);
}

.toast {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%);
  background: var(--encre); color: var(--parchemin);
  padding: .6rem 1.15rem; border-radius: 999px;
  font-size: .84rem; font-weight: 500;
  z-index: 60; box-shadow: var(--ombre-3);
}

/* ======================================================================== */
/*  Mobile                                                                  */
/* ======================================================================== */

@media (max-width: 60rem) {
  .appli { grid-template-columns: minmax(0, 1fr); }

  /* Le rail se replie en deux rangs : identité + actions, puis les vêtements. */
  .rail {
    position: sticky; top: 0; z-index: 30;
    height: auto; overflow: visible;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem;
    min-width: 0;
    padding: .55rem clamp(1rem, 2.6vw, 2rem) .5rem;
    border-right: 0; border-bottom: 1px solid var(--trait);
  }
  .marque { padding: 0; margin-right: auto; }
  .rail-titre { display: none; }
  .rail-pied { margin: 0; padding: 0; border: 0; }
  .rail-pied .bt--large { flex: none; }

  .familles {
    order: 2; flex-basis: 100%; min-width: 0;
    flex-direction: row; gap: .3rem;
    overflow-x: auto; scrollbar-width: none;
    padding-bottom: .15rem; margin: .1rem -.2rem 0;
  }
  .familles::-webkit-scrollbar { display: none; }
  /* Le bord droit s'estompe : sans cela, six vêtements sur dix sont hors
     champ sans que rien ne suggère qu'on peut faire défiler. */
  .familles {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2.2rem), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 2.2rem), transparent);
  }
  .familles button {
    width: auto; flex: none; white-space: nowrap;
    padding: .38rem .7rem .38rem .5rem;
    border: 1px solid var(--trait); border-radius: 999px;
    background: var(--surface-2);
  }
  .familles button .ic { width: 1.15rem; height: 1.15rem; }
  .familles button[aria-selected="true"] { border-color: var(--accent); }
  .familles button[aria-selected="true"]::before { display: none; }

  .entete { position: static; padding-top: 1rem; backdrop-filter: none; }
  .atelier { grid-template-columns: minmax(0, 1fr); }
  .scene-wrap { padding: 1rem 1rem .8rem; border-radius: var(--r-lg); min-height: 0; }
  .grille-points { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 34rem) {
  .entete { align-items: stretch; }
  .outils { width: 100%; }
  .outils .bt { flex: 1; }
  .grille-points { grid-template-columns: repeat(3, 1fr); }
}

/* Au doigt, on vise 44 px — la densité de bureau reste intacte à la souris. */
@media (pointer: coarse) {
  .bt, .bt-secondaire, .familles button, .pt-btn,
  .segmente button, .presets button, .projets button, .nom-projet {
    min-height: 44px;
  }
  .bt--icone, .fermer, .compteur button { width: 44px; height: 44px; }
  .projets .suppr { min-width: 44px; }
  .mesure-raz, .profils > .suppr { min-height: 44px; }
  /* Au doigt, la cote se vise encore moins bien qu'à la souris. */
  .cote-mesure .cote-hit { stroke-width: 5.5; }
  .onglets button { min-height: 44px; }
  .bascule input, .etapes input { width: 1.25rem; height: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ======================================================================== */
/*  Impression                                                              */
/* ======================================================================== */

@media print {
  :root {
    --parchemin: #fff; --surface: #fff; --surface-2: #f7f3ec; --surface-3: #efe9e0;
    --scene: #fff; --laine: #f8f5ef; --encre: #000; --encre-2: #444; --encre-3: #666;
    --trait: #ddd; --trait-fort: #999; --accent: #8a3623; --accent-2: #8a3623;
    --accent-doux: #f4ebe7;
    --ombre-1: none; --ombre-2: none; --ombre-3: none;
  }
  body { background: #fff; }
  .appli { display: block; }
  .rail, .outils, .panneau, .onglets, .projets-box, .indice, .toast, .alertes,
  .nom-crayon { display: none !important; }
  .entete { position: static; padding: 0 0 .6rem; border-bottom: 1px solid #999; backdrop-filter: none; }
  .atelier { display: block; padding: .8rem 0; }
  .scene-wrap { border: 0; box-shadow: none; padding: 0; page-break-inside: avoid; }
  .schema { max-height: 46vh; }
  .sorties { margin: 0; border: 0; box-shadow: none; }
  .panneau-sortie { padding: 0; }
  /* Le patron et la fiche matériel s'impriment toujours, quel que soit l'onglet actif. */
  #onglet-patron, #onglet-materiel { display: block !important; }
  #onglet-suivi { display: none !important; }
  .patron section { page-break-inside: avoid; }
  .patron b { background: none; font-weight: 700; color: #000; }
  .carte { border: 1px solid #ccc; }
  .pied { page-break-before: avoid; padding: 1rem 0 0; }
  /* Une feuille annotée au crayon doit pouvoir ramener au projet réglé. */
  .qr-papier {
    display: flex; align-items: center; gap: .8rem;
    margin-top: 1.2rem; padding-top: .8rem; border-top: 1px solid #ccc;
    page-break-inside: avoid;
  }
  /* 34 mm : en dessous, un code de 60 modules descend sous le demi-millimètre
     par module, et une imprimante à jet d'encre ne le rend plus lisible. */
  .qr-papier .qr { width: 34mm; border: 0; }
  .qr-papier p { margin: 0; font-size: .72rem; color: #444; }
}
