/* Atelier — couleurs d'atelier : papier kraft, noyer, merisier. Lisible sous les néons, gros boutons pour les doigts pleins de bran de scie. */
:root {
  --fond: #f6efe4; --carte: #fffaf2; --encre: #2a1f17; --doux: #7a6a5c; --ligne: #e3d6c3;
  --noyer: #3b2a1e; --merisier: #b5562b; --merisier-pale: #f7e3d6; --vert: #2f7a4b; --rouge: #b3261e; --jaune: #fff3c4;
  --rayon: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fond); color: var(--encre); font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }

/* En-tête */
.entete { position: sticky; top: 0; z-index: 5; background: var(--noyer); color: #fff; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 10px; }
.entete .logo { font-weight: 800; letter-spacing: .5px; font-size: 19px; }
.entete .projet { margin-left: auto; background: rgba(255,255,255,.12); border: 0; color: #fff; border-radius: 999px; padding: 7px 14px; max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }

main { padding: 14px 14px 24px; max-width: 720px; margin: 0 auto; }
.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 14px; margin-bottom: 12px; }
.carte h2 { font-size: 18px; margin-bottom: 10px; }
.carte h3 { font-size: 16px; margin: 12px 0 6px; }
.aide { color: var(--doux); font-size: 14px; margin: 4px 0 0; }

/* Champs */
.champ { margin-bottom: 12px; }
.champ > label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 5px; }
.champ input, .champ select { width: 100%; padding: 12px; border: 1.5px solid var(--ligne); border-radius: 10px; background: #fff; font-size: 18px; }
.champ input:focus, .champ select:focus { outline: none; border-color: var(--merisier); }
.champ input.mauvais { border-color: var(--rouge); background: #fff5f4; }
.lu { font-size: 13px; color: var(--doux); margin-top: 3px; min-height: 17px; }
.lu.mauvais { color: var(--rouge); }
.rangee { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rangee3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* Choix en pastilles */
.choix { display: flex; flex-wrap: wrap; gap: 6px; }
.choix button { border: 1.5px solid var(--ligne); background: #fff; border-radius: 999px; padding: 9px 14px; font-size: 15px; }
.choix button.on { background: var(--merisier); border-color: var(--merisier); color: #fff; font-weight: 600; }
.pas { display: flex; align-items: center; gap: 12px; }
.pas button { width: 46px; height: 46px; border-radius: 50%; border: 1.5px solid var(--ligne); background: #fff; font-size: 24px; }
.pas b { font-size: 22px; min-width: 28px; text-align: center; }

/* Boutons */
.btn { display: block; width: 100%; border: 0; border-radius: 12px; padding: 14px; font-weight: 700; font-size: 17px; background: var(--merisier); color: #fff; margin-top: 8px; }
.btn.second { background: #fff; color: var(--noyer); border: 1.5px solid var(--ligne); }
.btn.petit { display: inline-block; width: auto; padding: 9px 14px; font-size: 15px; margin: 0; }
.btn:active, .choix button:active, .pas button:active { transform: scale(.97); }

/* Résultats */
.resultat { background: var(--merisier-pale); border-color: #ecc8b1; }
.gros { font-size: 26px; font-weight: 800; color: var(--noyer); }
.tableau { width: 100%; border-collapse: collapse; font-size: 14px; }
.tableau th { text-align: left; color: var(--doux); font-weight: 600; font-size: 13px; padding: 6px 4px; border-bottom: 1px solid #e6cdbb; }
.tableau td { padding: 7px 3px; border-bottom: 1px solid #f0dccd; vertical-align: top; }
.tableau td.m { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.avis { background: var(--jaune); border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 15px; }
.avis.rouge { background: #fde4e1; color: var(--rouge); }
.note { font-size: 14px; color: #5e4a3b; margin: 8px 0 0; }
.dessin { width: 100%; height: auto; display: block; margin: 8px 0; }
.tiroir-titre { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 4px; }
.tiroir-titre b { font-size: 17px; }

/* Liste de coupe */
.piece { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--ligne); }
.piece:last-child { border-bottom: 0; }
.piece .nom { font-weight: 600; }
.piece .dim { font-variant-numeric: tabular-nums; color: var(--noyer); }
.piece .mat { color: var(--doux); font-size: 14px; }
.piece .act { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 6px; align-items: center; }
.piece .act button { border: 1px solid var(--ligne); background: #fff; border-radius: 8px; width: 40px; height: 40px; font-size: 17px; }
.groupe-mat { font-weight: 700; color: var(--merisier); margin-top: 12px; font-size: 15px; }
.etapes { font-size: 15px; padding-left: 20px; margin: 6px 0; }
.etapes li { margin: 4px 0; }
.etapes ul { padding-left: 18px; color: #5e4a3b; }
.vide { text-align: center; color: var(--doux); padding: 18px 8px; }

/* Onglets du bas */
nav.onglets { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--carte); border-top: 1px solid var(--ligne); padding-bottom: env(safe-area-inset-bottom); }
nav.onglets button { border: 0; background: none; padding: 8px 0 9px; font-size: 12px; color: var(--doux); display: flex; flex-direction: column; align-items: center; gap: 2px; }
nav.onglets button .ic { font-size: 22px; line-height: 1; }
nav.onglets button.on { color: var(--merisier); font-weight: 700; }

/* Barre de fractions au-dessus du clavier */
#fractions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #ece2d3; border-top: 1px solid #d5c6b0; padding: 6px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
#fractions[hidden] { display: none; }
#fractions button { border: 0; border-radius: 8px; background: #fff; padding: 9px 0; font-size: 15px; font-weight: 600; box-shadow: 0 1px 0 #c9b9a2; }
#fractions button.f16 { font-size: 13px; font-weight: 500; color: var(--doux); }
#fractions button.unite { background: var(--noyer); color: #fff; }

/* Connexion */
.connexion { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 420px; margin: 0 auto; }
.connexion h1 { font-size: 34px; color: var(--noyer); }
.connexion p { color: var(--doux); }
.erreur { color: var(--rouge); font-weight: 600; min-height: 22px; margin-top: 8px; }

/* Fenêtre (projets, modifier une pièce) */
.voile { position: fixed; inset: 0; background: rgba(30,20,12,.45); z-index: 30; display: flex; align-items: flex-end; }
.feuillet { background: var(--fond); width: 100%; max-height: 88vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.feuillet h2 { margin-bottom: 12px; }
.ligne-projet { display: flex; align-items: center; gap: 8px; padding: 12px; background: var(--carte); border: 1.5px solid var(--ligne); border-radius: 12px; margin-bottom: 8px; }
.ligne-projet.on { border-color: var(--merisier); }
.ligne-projet span { flex: 1; font-weight: 600; }
.ligne-projet small { color: var(--doux); font-weight: 400; }

@media print {
  .entete, nav.onglets, .pas-imprimer, #fractions { display: none !important; }
  body { padding: 0; background: #fff; }
  .carte { break-inside: avoid; border-color: #ccc; }
}

/* Fernand */
.haut-conv { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.bulle { border-radius: 16px; padding: 10px 13px; margin: 0 0 10px; max-width: 92%; font-size: 16px; }
.bulle p { margin: 0 0 6px; } .bulle p:last-child { margin: 0; }
.bulle ul { margin: 4px 0 6px; padding-left: 20px; }
.bulle.moi { background: var(--noyer); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.bulle.fernand { background: var(--carte); border: 1px solid var(--ligne); border-bottom-left-radius: 4px; max-width: 100%; }
.bulle pre { white-space: pre-wrap; font-size: 13px; background: #f3ebdf; padding: 8px; border-radius: 8px; }
.photo-msg { display: block; width: 100%; border-radius: 10px; margin-bottom: 6px; }
.croquis { margin: 8px 0 4px; border-radius: 10px; overflow: hidden; background: #fff; border: 1px solid var(--ligne); }
.croquis img { display: block; width: 100%; height: auto; }
.croquis.sur-photo { position: relative; }
.croquis.sur-photo .calque { position: absolute; inset: 0; height: 100%; transition: opacity .2s; }
.croquis.sans-calque .calque { opacity: 0; }
.attente { color: var(--doux); }
.points i { font-style: normal; animation: clin 1.2s infinite; } .points i:nth-child(2) { animation-delay: .2s; } .points i:nth-child(3) { animation-delay: .4s; }
@keyframes clin { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }
.composer { position: fixed; left: 0; right: 0; bottom: calc(58px + env(safe-area-inset-bottom)); z-index: 4; background: var(--fond); border-top: 1px solid var(--ligne); padding: 8px 10px; }
.ligne-composer { display: flex; gap: 8px; align-items: flex-end; max-width: 720px; margin: 0 auto; }
.ligne-composer textarea { flex: 1; resize: none; border: 1.5px solid var(--ligne); border-radius: 20px; padding: 10px 14px; font: inherit; font-size: 17px; max-height: 140px; background: #fff; }
.btn-photo, .btn-envoyer { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; display: grid; place-items: center; font-size: 22px; }
.btn-photo { background: #fff; border: 1.5px solid var(--ligne); }
.btn-envoyer { background: var(--merisier); color: #fff; }
.apercu { position: relative; width: 84px; margin: 0 auto 8px 0; max-width: 720px; }
.apercu img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; display: block; }
.apercu button { position: absolute; top: -6px; right: -6px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--noyer); color: #fff; font-size: 13px; }
body:has(.composer) main { padding-bottom: 150px; }
.apercu-pdf { display: inline-flex; align-items: center; gap: 8px; background: var(--carte); border: 1px solid var(--ligne); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; font-size: 14px; max-width: 100%; }
.apercu-pdf button { border: 0; background: var(--noyer); color: #fff; width: 24px; height: 24px; border-radius: 50%; font-size: 12px; flex: none; }
.lien-pdf { display: block; color: #fff; background: rgba(255,255,255,.14); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; text-decoration: none; font-weight: 600; }
