/* Figtree, auto-hébergée : la police doit être là en forêt, sans réseau. Fichiers variables (300 à 900) repris du site. */
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 300 900; font-display: swap; src: url("fonts/figtree-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 300 900; font-display: swap; src: url("fonts/figtree-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* Cubage · l'appli de terrain.
   Langage de l'Espace Atelier en vert forêt, relevé pour le plein air : encre plus franche, cibles pour gants,
   trois lumières (Jour, Plein soleil, Sous-bois). Téléphone d'abord, tablette ensuite. */

:root, :root[data-theme="jour"] {
  --sol: #FFFFFF; --surface: #FFFFFF; --surface-2: #F1F2F5; --surface-3: #E6E8EE; --barre: #F7F7FA;
  --ligne: rgba(17,17,24,.10); --ligne-forte: rgba(17,17,24,.18);
  --encre: #111118; --encre-2: rgba(17,17,24,.78); --encre-3: rgba(17,17,24,.68);
  --accent: #1F5C3A; --accent-encre: #174A2E; --accent-sur: #FFFFFF;
  --accent-lavis: rgba(31,92,58,.10); --accent-bulle: rgba(31,92,58,.18); --accent-trace: rgba(31,92,58,.32);
  --erreur: #C8102E; --erreur-lavis: rgba(200,16,46,.09);
  --primaire: #17171F; --primaire-sur: #FFFFFF;
  --touche: #FFFFFF; --touche-bord: rgba(17,17,24,.08);
  --ombre-1: 0 1px 2px rgba(17,17,24,.06), 0 2px 8px rgba(17,17,24,.05);
  --ombre-2: 0 2px 4px rgba(17,17,24,.04), 0 10px 28px -8px rgba(17,17,24,.12);
  --ombre-touche: 0 1px 1px rgba(17,17,24,.10), 0 3px 8px -2px rgba(17,17,24,.14);
  --ombre-btn: 0 2px 6px rgba(17,17,24,.18), 0 10px 24px -10px rgba(17,17,24,.36);
  --c0:#5B3A1E; --c1:#8A5A2E; --c2:#B88A4E; --c3:#D8B97E; --c4:#6E7F8F; --c5:#9C6B8E; --c6:#7A8752; --c7:#A9746A;
  --bord: 1px;
  color-scheme: light;
}
/* Plein soleil : plus aucun gris qui porte du sens, des contours au lieu des ombres, l'accent assombri. */
:root[data-theme="soleil"] {
  --sol: #FFFFFF; --surface: #FFFFFF; --surface-2: #EDEEF1; --surface-3: #DADDE3; --barre: #FFFFFF;
  --ligne: rgba(0,0,0,.28); --ligne-forte: rgba(0,0,0,.55);
  --encre: #000000; --encre-2: #000000; --encre-3: rgba(0,0,0,.82);
  --accent: #0F4426; --accent-encre: #0B361E; --accent-sur: #FFFFFF;
  --accent-lavis: rgba(15,68,38,.12); --accent-bulle: rgba(15,68,38,.22); --accent-trace: rgba(15,68,38,.4);
  --primaire: #000000; --primaire-sur: #FFFFFF;
  --touche: #FFFFFF; --touche-bord: #000000;
  --ombre-1: none; --ombre-2: none; --ombre-touche: none; --ombre-btn: none;
  --bord: 2px;
  color-scheme: light;
}
/* Sous-bois : la nuit de l'Espace Atelier, l'accent remonte vers le clair. */
:root[data-theme="nuit"] {
  --sol: #0E1117; --surface: #141821; --surface-2: #1B2029; --surface-3: #252B36; --barre: #0B0D12;
  --ligne: rgba(232,234,239,.10); --ligne-forte: rgba(232,234,239,.2);
  --encre: #EEF0F4; --encre-2: rgba(238,240,244,.84); --encre-3: rgba(238,240,244,.70);
  --accent: #6FBF8E; --accent-encre: #9AD4AE; --accent-sur: #0B2416;
  --accent-lavis: rgba(111,191,142,.14); --accent-bulle: rgba(111,191,142,.22); --accent-trace: rgba(111,191,142,.36);
  --erreur: #FF5C7A; --erreur-lavis: rgba(255,92,122,.14);
  --primaire: #F4F5F8; --primaire-sur: #10141B;
  --touche: #1E232D; --touche-bord: rgba(232,234,239,.06);
  --ombre-1: 0 1px 2px rgba(0,0,0,.3), 0 2px 8px rgba(0,0,0,.22);
  --ombre-2: 0 2px 4px rgba(0,0,0,.26), 0 10px 28px -8px rgba(0,0,0,.5);
  --ombre-touche: 0 1px 1px rgba(0,0,0,.4), 0 3px 8px -2px rgba(0,0,0,.5);
  --ombre-btn: 0 2px 6px rgba(0,0,0,.36), 0 12px 28px -10px rgba(0,0,0,.56);
  --c0:#B07A4A; --c1:#C9945E; --c2:#DDB57C; --c3:#EBD3A2; --c4:#93A6B8; --c5:#C79BBB; --c6:#A9B47E; --c7:#D19C90;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--sol); color: var(--encre);
  font: 500 17px/1.45 "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "tnum"; -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
h1, h2, h3, p { margin: 0; }
h1, h2 { letter-spacing: -.02em; text-wrap: balance; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
::selection { background: var(--accent-bulle); color: var(--encre); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
input { caret-color: var(--accent); }

/* ── La coquille ───────────────────────────────────────────────────────── */
.app { height: 100dvh; display: grid; grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "vues" "onglets"; }
.vues { grid-area: vues; min-height: 0; position: relative; }
.vue { height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.onglets {
  grid-area: onglets; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--barre); border-top: var(--bord) solid var(--ligne);
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
}
.onglet {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; border: 0; background: none; border-radius: 16px; color: var(--encre-3);
  font-size: 14.5px; font-weight: 700;
}
.onglet svg { width: 26px; height: 26px; }
.onglet[aria-current="page"] { color: var(--accent-encre); }
.onglet[aria-current="page"]::before { content: ""; position: absolute; inset: 4px 14%; border-radius: 14px; background: var(--accent-lavis); z-index: -1; }
.onglet .compte {
  position: absolute; top: 4px; left: calc(50% + 8px); min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--encre); color: var(--sol); font-size: 13px; line-height: 20px; font-weight: 750;
}
.onglet .compte:empty, .onglet .compte[data-zero] { display: none; }
.app:not([data-ecran="chantier"]) .onglets { display: none; }
.app[data-ecran="accueil"] .toast { bottom: calc(108px + env(safe-area-inset-bottom)); }

/* ── Accueil : les chantiers ────────────────────────────────────────────── */
.vue-accueil { padding: calc(16px + env(safe-area-inset-top)) 16px calc(120px + env(safe-area-inset-bottom)); }
.accueil-tete { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.accueil-titre { min-width: 0; }
.accueil-tete h1 { font-size: 30px; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.accueil-outils { display: flex; gap: 8px; flex: none; padding-top: 2px; }
.liste-chantiers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.chantier-carte {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "corps val" "billons billons"; gap: 10px 14px; align-items: center;
  width: 100%; min-height: 88px; padding: 14px 16px 14px; border-radius: 24px; border: var(--bord) solid var(--ligne); background: var(--surface); box-shadow: var(--ombre-2); text-align: left; color: var(--encre);
}
.chantier-carte:active { transform: scale(.985); background: var(--surface-2); }
.chantier-carte .corps { grid-area: corps; min-width: 0; }
.chantier-carte .corps b { display: block; font-size: 19px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chantier-carte .corps small { display: block; margin-top: 3px; font-size: 14.5px; font-weight: 600; color: var(--encre-2); }
.chantier-carte .val { grid-area: val; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.chantier-carte .val b { font-size: 22px; font-weight: 800; letter-spacing: -.03em; line-height: 1; white-space: nowrap; }
.chantier-carte .cam { display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 0 10px 0 7px; border-radius: 999px; background: var(--accent-lavis); color: var(--accent-encre); font-size: 14px; font-weight: 800; }
.chantier-carte .cam svg { width: 20px; height: 20px; }
.chantier-carte .billons { grid-area: billons; height: 10px; }
.chantier-carte .billons:empty { display: none; }
.accueil-vide { padding-top: 12px; }
.accueil-pied { margin-top: 22px; }
.accueil-pied .note-bas { margin-top: 12px; }

.flottant {
  position: fixed; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 20;
  width: 68px; height: 68px; border-radius: 999px; border: 0; background: var(--primaire); color: var(--primaire-sur);
  display: grid; place-items: center; box-shadow: var(--ombre-btn);
}
.flottant svg { width: 32px; height: 32px; stroke-width: 2.4; }
.flottant:active { transform: scale(.94); }

/* Retour vers la liste des chantiers, en tête des onglets Arbres, Bilan et Réglages. */
.retour { display: inline-flex; align-items: center; gap: 2px; min-height: 40px; padding: 0 14px 0 8px; margin: 0 0 10px -8px; border: 0; border-radius: 999px; background: none; color: var(--accent-encre); font-size: 15.5px; font-weight: 750; }
.retour svg { width: 22px; height: 22px; }
.retour:active { background: var(--accent-lavis); }

/* ── Saisie ─────────────────────────────────────────────────────────────── */
.vue-saisie { display: flex; flex-direction: column; overflow: hidden; }
.scene { position: relative; flex: 1 1 auto; min-height: 150px; overflow: hidden; background: var(--surface-2); }
#diorama { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; inset: 0; pointer-events: none; padding: calc(10px + env(safe-area-inset-top)) 12px 0; display: flex; flex-direction: column; gap: 6px; }
.hud-haut { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hud button { pointer-events: auto; }
.hud-chantier {
  display: inline-flex; align-items: center; gap: 4px; max-width: 64%; min-height: 44px; padding: 0 10px 0 14px; border: 0; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); box-shadow: var(--ombre-1); outline: var(--bord) solid transparent;
  font-size: 15px; font-weight: 700; color: var(--encre);
}
:root[data-theme="soleil"] .hud-chantier, :root[data-theme="soleil"] .hud-btn { outline-color: var(--ligne-forte); background: var(--surface); }
.hud-chantier span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-chantier svg { width: 20px; height: 20px; }
.hud-outils { display: flex; gap: 8px; }
.hud-btn { width: 44px; height: 44px; border: 0; border-radius: 999px; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 88%, transparent); box-shadow: var(--ombre-1); outline: var(--bord) solid transparent; color: var(--encre); }
.hud-score { align-self: flex-end; padding: 8px 14px 9px; border-radius: 18px; background: color-mix(in srgb, var(--surface) 90%, transparent); box-shadow: var(--ombre-1); }
:root[data-theme="soleil"] .hud-score { outline: var(--bord) solid var(--ligne-forte); background: var(--surface); }
.valeur { display: flex; align-items: baseline; gap: 8px; }
.valeur b { font-size: clamp(26px, 7.4vw, 38px); font-weight: 800; letter-spacing: -.03em; line-height: 1.05; }
.delta { font-size: 15px; font-weight: 750; color: var(--accent-encre); opacity: 0; transform: translateY(4px); transition: opacity .25s, transform .25s; }
.delta.vu { opacity: 1; transform: none; }
.delta.baisse { color: var(--encre-2); }
.stats { display: flex; align-items: center; gap: 10px; font-size: 14.5px; color: var(--encre-2); font-weight: 600; margin-top: 2px; }
.stats b { color: var(--encre); font-weight: 800; }
.stats .sep { width: 4px; height: 4px; border-radius: 50%; background: var(--encre-3); }
.stats .cam { display: inline-flex; align-items: center; gap: 4px; }
.stats .cam svg { width: 19px; height: 19px; color: var(--accent); }
.calcul { font-size: 14px; color: var(--encre-3); margin-top: 2px; font-weight: 600; }
.alerte-calcul { color: var(--erreur); font-weight: 750; }

.saisie { flex: none; padding: 10px 12px 10px; display: flex; flex-direction: column; gap: 8px; background: var(--sol); }
.ardoise {
  display: flex; flex-direction: column;
  text-align: left; border: var(--bord) solid var(--ligne); border-radius: 22px; padding: 8px 16px 8px; background: var(--surface); box-shadow: var(--ombre-1);
}
.ard-zone {
  display: grid; grid-template-columns: 1fr; grid-template-areas: "tete" "val";
  margin: -8px -16px 0; padding: 8px 16px 0; width: calc(100% + 32px); border: 0; border-radius: 22px 22px 0 0; background: none; text-align: left; color: inherit;
}
.ard-zone:focus-visible { outline-offset: -3px; }
.ard-pied:not(:empty) { margin-top: 2px; }
.ardoise.actif-d { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bulle); }
.ard-tete { grid-area: tete; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.ard-label { font-size: 15px; font-weight: 700; color: var(--accent-encre); }
.ard-num { font-size: 14px; font-weight: 650; color: var(--encre-3); }
.ard-valeur { grid-area: val; display: flex; align-items: baseline; gap: 8px; min-height: 58px; }
.ard-valeur b { font-size: clamp(46px, 13vw, 60px); line-height: 1; font-weight: 800; letter-spacing: -.03em; }
.ard-valeur b.vide { color: var(--encre-3); }
.ard-valeur span { font-size: 22px; font-weight: 700; color: var(--encre-2); }
.ard-pied { grid-area: pied; display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; font-size: 14px; color: var(--encre-2); font-weight: 600; }
.ard-pied:empty { display: none; }
.ardoise.secoue { animation: secoue .35s; border-color: var(--erreur); }
@keyframes secoue { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.ard-pied .mini {
  display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: var(--bord) solid var(--ligne-forte);
  background: var(--surface-2); font-size: 14px; font-weight: 700; color: var(--encre);
}
.ard-pied .mini[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-sur); }
.ard-pied .mini svg { width: 17px; height: 17px; }
.ard-pied .msg { color: var(--erreur); font-weight: 700; align-self: center; }
.ard-pied .info { align-self: center; color: var(--encre-2); font-weight: 650; flex: 1 1 auto; }
.ard-pied .mini.annuler { background: var(--encre); color: var(--sol); border-color: var(--encre); min-height: 48px; padding: 0 18px; font-size: 15px; }

.puces { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.puce {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; min-height: 54px; padding: 6px 10px;
  border: var(--bord) solid var(--ligne); border-radius: 16px; background: var(--surface-2); text-align: left; overflow: hidden;
}
.puce .p-l { font-size: 14px; font-weight: 700; color: var(--encre-3); line-height: 1.2; }
.puce .p-v { font-size: 15px; font-weight: 750; color: var(--encre); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.puce.rempli { background: var(--accent-lavis); border-color: var(--accent-trace); }
.puce.rempli .p-l { color: var(--accent-encre); }
.puce[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.puce[aria-pressed="true"] .p-l, .puce[aria-pressed="true"] .p-v { color: var(--accent-sur); }

.panneau { min-height: 0; }
.pave { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.15fr); grid-auto-rows: clamp(52px, 7.6dvh, 72px); gap: 8px; }
.touche {
  border: var(--bord) solid var(--touche-bord); border-radius: 999px; background: var(--touche); box-shadow: var(--ombre-touche);
  font-size: 30px; font-weight: 650; color: var(--encre); display: grid; place-items: center; user-select: none; -webkit-user-select: none;
  transition: transform .08s, background .08s;
}
.touche:active, .touche.presse { transform: scale(.95); background: var(--surface-3); }
.touche svg { width: 28px; height: 28px; }
.t-effacer { background: var(--surface-2); }
.t-raz { font-size: 16px; font-weight: 700; color: var(--encre-2); background: var(--surface-2); }
.t-virgule { font-size: 34px; }
.t-valider {
  grid-row: span 3; grid-column: 4; background: var(--primaire); color: var(--primaire-sur); border-color: var(--primaire);
  border-radius: 28px; box-shadow: var(--ombre-btn); display: flex; flex-direction: column; gap: 6px; font-size: 17px; font-weight: 750;
}
.t-valider svg { width: 40px; height: 40px; stroke-width: 2.6; }
.t-valider:active, .t-valider.presse { background: var(--accent); border-color: var(--accent); color: var(--accent-sur); }
.pave .touche[data-k="del"] { grid-column: 4; grid-row: 1; }
.pave .t-valider { grid-row: 2 / span 3; }

.essences { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; max-height: calc(4 * clamp(52px, 7.6dvh, 72px) + 24px); overflow-y: auto; }
.essence { min-height: 60px; border-radius: 999px; border: var(--bord) solid var(--ligne-forte); background: var(--surface); box-shadow: var(--ombre-1); font-size: 18px; font-weight: 700; }
.essence[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-sur); }
.essence.aucune { background: var(--surface-2); box-shadow: none; color: var(--encre-2); }
.note-pan { display: flex; flex-direction: column; gap: 8px; }
.note-l { font-size: 15px; font-weight: 700; display: flex; flex-direction: column; }
.note-l span { font-size: 14px; font-weight: 600; color: var(--encre-3); }
textarea { width: 100%; min-height: 110px; border: var(--bord) solid var(--ligne-forte); border-radius: 18px; background: var(--surface); padding: 12px 14px; font-size: 18px; resize: none; outline: none; }
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bulle); }

/* Derniers arbres : seulement dans la colonne de la tablette en paysage. */
.derniers { display: none; }
.derniers h2 { font-size: 16px; font-weight: 800; margin-bottom: 8px; color: var(--encre-2); }
.derniers ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.derniers li { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 16px; background: var(--surface-2); }
.derniers li:first-child { background: var(--accent-lavis); }
.derniers .dn { font-weight: 800; color: var(--encre-2); text-align: center; }
.derniers .dc { min-width: 0; }
.derniers .dc b { font-weight: 800; }
.derniers .dc small { display: block; font-size: 14px; color: var(--encre-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.derniers .dv { font-weight: 800; }
.derniers p { color: var(--encre-3); font-size: 14.5px; }

/* ── Boutons ───────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 999px; border: var(--bord) solid transparent; font-size: 16px; font-weight: 700; transition: transform .1s, box-shadow .2s; }
.btn svg { width: 22px; height: 22px; }
.btn:active { transform: scale(.98); }
.btn.grand { min-height: 56px; width: 100%; font-size: 17px; }
.btn.primaire { background: var(--primaire); color: var(--primaire-sur); box-shadow: var(--ombre-btn); }
.btn.sec { background: var(--surface); color: var(--encre); border-color: var(--ligne-forte); box-shadow: var(--ombre-1); }
.btn.danger { background: var(--erreur-lavis); color: var(--erreur); }
.btn.danger.arme { background: var(--erreur); color: var(--accent-sur); }
.btn-icone { width: 48px; height: 48px; border-radius: 999px; border: 0; background: var(--surface-2); display: grid; place-items: center; color: var(--encre); }

/* ── Vues de liste, chantier, réglages ─────────────────────────────────── */
.vue-liste, .vue-chantier, .vue-reglages { padding: calc(16px + env(safe-area-inset-top)) 16px 28px; }
.vue-tete { margin-bottom: 16px; }
.vue-tete h1 { font-size: 30px; font-weight: 800; line-height: 1.1; }
.vue-sous { color: var(--encre-2); font-size: 15px; margin-top: 4px; font-weight: 600; }
.phrase { font-size: 19px; line-height: 1.4; color: var(--encre-2); margin-top: 8px; max-width: 46ch; font-weight: 600; }
.phrase b { color: var(--encre); font-weight: 800; }
.phrase .gain { color: var(--accent-encre); font-weight: 800; }

.liste-arbres { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.arbre {
  display: grid; grid-template-columns: 52px 1fr auto; grid-template-areas: "num corps val" "num billons billons"; gap: 4px 12px; align-items: center;
  width: 100%; padding: 12px 14px; border-radius: 20px; border: var(--bord) solid var(--ligne); background: var(--surface); box-shadow: var(--ombre-1); text-align: left;
}
.arbre .num { grid-area: num; width: 48px; height: 48px; border-radius: 16px; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: 17px; }
.arbre .corps { grid-area: corps; min-width: 0; }
.arbre .corps b { font-size: 19px; font-weight: 800; }
.arbre .corps small { display: block; font-size: 14px; color: var(--encre-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arbre .val { grid-area: val; text-align: right; font-weight: 800; font-size: 17px; }
.arbre .val small { display: block; font-size: 14px; color: var(--encre-3); font-weight: 650; }
.billons { grid-area: billons; display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.billons i { display: block; height: 100%; }
.arbre.invalide { border-color: var(--erreur); }
.arbre.invalide .corps small { color: var(--erreur); }
.arbre.recent { border-color: var(--accent-trace); box-shadow: 0 0 0 3px var(--accent-lavis); }

.vide-etat { padding: 28px 8px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; max-width: 44ch; }
.vide-etat h2 { font-size: 21px; font-weight: 800; }
.vide-etat p { color: var(--encre-2); font-weight: 550; }

.grille-chantier, .grille-reglages { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.bloc { background: var(--surface); border: var(--bord) solid var(--ligne); border-radius: 24px; box-shadow: var(--ombre-2); padding: 18px 16px; min-width: 0; }
.bloc h2 { font-size: 19px; font-weight: 800; margin-bottom: 12px; }
.note-bas { font-size: 14px; color: var(--encre-3); margin-top: 10px; font-weight: 550; max-width: 70ch; }
.note-bas.haut { margin: -4px 0 12px; }

.bordereau { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.ligne-prod { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.ligne-prod .nom { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 16.5px; }
.ligne-prod .nom i { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.ligne-prod .eur { font-weight: 800; text-align: right; font-size: 16.5px; }
.ligne-prod .det { grid-column: 1 / -1; font-size: 14px; color: var(--encre-2); font-weight: 600; }
.camions { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.camion-jauge { flex: 0 0 auto; width: 74px; height: 30px; }
.camion-jauge svg { width: 74px; height: 30px; stroke: none; }
.camion-jauge .bac { fill: var(--surface-2); stroke: var(--ligne-forte); stroke-width: 1; }
.camion-jauge .charge { fill: var(--accent-trace); }
.camion-jauge.plein .charge { fill: var(--accent); }
.camion-jauge .ranch { fill: none; stroke: var(--encre-3); stroke-width: 1.4; stroke-linecap: round; }
.camion-jauge.plein .ranch { stroke: var(--accent-encre); }
.camion-jauge .corps { fill: var(--encre-3); }
.camion-jauge.plein .corps { fill: var(--accent); }
.camion-jauge .vitre { fill: var(--surface); opacity: .85; }
.camion-jauge .roue { fill: var(--encre); }
.camion-jauge text { font: 800 9.5px Figtree, system-ui, sans-serif; fill: var(--encre); letter-spacing: -.01em; }
.camion-jauge.plein text { fill: var(--accent-sur); }
.total { margin-top: 14px; padding-top: 12px; border-top: var(--bord) solid var(--ligne-forte); display: flex; justify-content: space-between; font-weight: 800; font-size: 17px; }

.scenarios { display: flex; flex-direction: column; gap: 8px; }
.scen { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 14px; border-radius: 16px; background: var(--surface-2); }
.scen .n { font-weight: 700; font-size: 15.5px; }
.scen .v { font-weight: 800; font-size: 17px; text-align: right; }
.scen .d { grid-column: 1 / -1; font-size: 14px; color: var(--encre-2); font-weight: 600; }
.scen.meilleur { background: var(--accent-lavis); outline: var(--bord) solid var(--accent-trace); }
.scen.meilleur .n, .scen.meilleur .v { color: var(--accent-encre); }

.trophees { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 6px; }
.trophee { display: flex; gap: 12px; align-items: center; padding: 8px 12px; min-height: 56px; border-radius: 16px; background: var(--surface-2); font-size: 14px; font-weight: 650; color: var(--encre-3); }
.trophee svg { width: 30px; height: 30px; color: var(--encre-3); opacity: .5; }
.trophee b { display: block; font-size: 15.5px; color: var(--encre-2); font-weight: 750; }
.trophee.gagne { background: var(--accent-lavis); color: var(--encre-2); }
.trophee.gagne svg { color: var(--accent); opacity: 1; }
.trophee.gagne b { color: var(--encre); }
.exports { display: flex; flex-direction: column; gap: 10px; }
/* Ce qui arrive bientôt : un bouton en pointillés, sans fond ni ombre, qui déplie son explication. */
.avenir { margin-top: 16px; padding-top: 16px; border-top: var(--bord) solid var(--ligne); }
.btn.btn-avenir { background: transparent; color: var(--encre-2); border: var(--bord) dashed var(--ligne-forte); box-shadow: none; }
.pastille-avenir { padding: 3px 10px; border-radius: 999px; background: var(--surface-3); color: var(--encre-2); font-size: 13px; font-weight: 800; }
.vue-tete .envoyer { margin-top: 14px; max-width: 420px; }

.champ { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; min-width: 0; }
.lbl { font-size: 14.5px; font-weight: 700; color: var(--encre-2); }
.champs-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; }
.inp { display: flex; align-items: center; min-height: 52px; border-radius: 16px; background: var(--surface-2); border: var(--bord) solid var(--ligne); min-width: 0; }
/* Valeur refusée : le champ est cerclé et la raison s'affiche dessous. */
.champ.invalide .inp { border-color: var(--erreur); box-shadow: 0 0 0 3px var(--erreur-lavis); }
.err { font-size: 14px; font-weight: 700; color: var(--erreur); }
.inp:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bulle); background: var(--surface); }
.inp input, .inp select { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; outline: none; padding: 0 14px; font-size: 18px; font-weight: 650; min-height: 50px; }
.inp span { padding-right: 14px; color: var(--encre-3); font-size: 14px; font-weight: 650; white-space: nowrap; }
.segment { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); border: var(--bord) solid var(--ligne); }
.segment button { min-height: 44px; border: 0; border-radius: 999px; background: none; font-size: 14.5px; font-weight: 700; color: var(--encre-2); padding: 0 4px; }
.segment.segment-2 { grid-template-columns: repeat(2, 1fr); }
.aide { display: block; font-size: 14px; color: var(--encre-3); font-weight: 550; }
.segment button[aria-checked="true"] { background: var(--surface); color: var(--encre); box-shadow: var(--ombre-1); outline: var(--bord) solid var(--ligne-forte); }
.bascule { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: var(--bord) solid var(--ligne); cursor: pointer; }
.bascule b { display: block; font-weight: 750; }
.bascule small { display: block; font-size: 14px; color: var(--encre-3); font-weight: 550; }
.bascule input { position: absolute; opacity: 0; pointer-events: none; }
.bascule i { position: relative; flex: none; width: 56px; height: 34px; border-radius: 999px; background: var(--surface-3); border: var(--bord) solid var(--ligne-forte); transition: background .2s; }
.bascule i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: var(--ombre-touche); border: var(--bord) solid var(--ligne-forte); box-sizing: border-box; transition: transform .2s; }
.bascule input:checked + i { background: var(--accent); border-color: var(--accent); }
.bascule input:checked + i::after { transform: translateX(22px); }
.bascule input:focus-visible + i { outline: 3px solid var(--accent); outline-offset: 3px; }

.etiquettes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.etiquette { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 6px 0 16px; border-radius: 999px; background: var(--surface-2); border: var(--bord) solid var(--ligne); font-weight: 700; }
.etiquette button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; display: grid; place-items: center; color: var(--encre-3); }
.etiquette button svg { width: 18px; height: 18px; }
.ajout-ligne { display: flex; gap: 8px; }
.ajout-ligne .inp { flex: 1; }

.produits { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-bottom: 12px; }
.produit { border-radius: 20px; background: var(--surface-2); border: var(--bord) solid var(--ligne); padding: 12px; }
.produit-tete { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.produit-tete i { width: 16px; height: 16px; border-radius: 5px; flex: none; margin: 0 4px; }
.produit-tete .inp { flex: 1; background: var(--surface); }
.produit-tete .btn-icone { width: 44px; height: 44px; background: var(--surface); }
.produit-tete .btn-icone:disabled { opacity: .35; }
.produit .champs-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.produit .champs-camion { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.produit .inp { background: var(--surface); }
.produit .inp input { font-size: 17px; padding: 0 10px; }
.produit .inp span { padding-right: 10px; font-size: 14px; }
.produit .champ { margin-bottom: 8px; }
.produit .lbl { font-size: 14px; }
.produit .segment { grid-template-columns: repeat(2, 1fr); background: var(--surface); }

/* ── Toast, bannière, feuille ──────────────────────────────────────────── */
.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 30; margin: 0 auto; max-width: 520px;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; min-height: 60px; border-radius: 20px;
  background: var(--primaire); color: var(--primaire-sur); box-shadow: var(--ombre-btn); animation: monte .2s ease-out;
}
.toast-txt { flex: 1; font-weight: 700; font-size: 15.5px; }
.toast-btn { min-height: 48px; padding: 0 18px; border-radius: 999px; border: 0; background: var(--primaire-sur); color: var(--primaire); font-weight: 800; font-size: 16px; }
@keyframes monte { from { transform: translateY(12px); opacity: 0; } }
.trophee-banniere {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 31;
  display: flex; align-items: center; gap: 10px; padding: 10px 18px 10px 12px; border-radius: 999px; background: var(--accent); color: var(--accent-sur);
  box-shadow: var(--ombre-btn); animation: tombe .4s cubic-bezier(.16,1,.3,1);
}
.trophee-banniere svg { width: 34px; height: 34px; }
.trophee-banniere b { font-size: 16px; font-weight: 800; white-space: nowrap; }
@keyframes tombe { from { transform: translate(-50%, -30px); opacity: 0; } }

.feuille { border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%; max-height: 92dvh; border-radius: 28px 28px 0 0; background: var(--sol); color: var(--encre); box-shadow: var(--ombre-btn); border-top: var(--bord) solid var(--ligne); }
.feuille::backdrop { background: rgba(10,12,16,.45); }
.feuille[open] { animation: feuille .22s ease-out; }
@keyframes feuille { from { transform: translateY(30px); opacity: .5; } }
.feuille-corps { padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); overflow-y: auto; max-height: 92dvh; }
.feuille-tete { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.feuille-tete h2 { font-size: 22px; font-weight: 800; }
.edit-grille { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tag { min-height: 44px; padding: 0 16px; border-radius: 999px; border: var(--bord) solid var(--ligne-forte); background: var(--surface); font-weight: 700; font-size: 15px; }
.tag[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-sur); }
.pas { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 10px 0; border-top: var(--bord) solid var(--ligne); }
.pas b { font-weight: 750; }
.pas small { display: block; color: var(--encre-3); font-weight: 600; font-size: 14px; }
.pas-ctrl { display: flex; align-items: center; gap: 6px; }
.pas-ctrl output { min-width: 64px; text-align: center; font-weight: 800; font-size: 18px; }
.actions-feuille { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.decoupe-apercu { font-size: 14.5px; color: var(--encre-2); font-weight: 600; margin: 4px 0 12px; }
.decoupe-apercu.erreur { color: var(--erreur); font-weight: 750; }
.mini-auto { min-height: 44px; padding: 0 14px; border-radius: 999px; border: var(--bord) solid var(--ligne-forte); background: var(--surface-2); font-size: 15px; font-weight: 750; }

@media (min-width: 760px) { .hud-score { align-self: flex-start; } }

/* ── Tablette ──────────────────────────────────────────────────────────── */
@media (min-width: 760px) {
  .app { grid-template-rows: none; grid-template-columns: 96px minmax(0, 1fr); grid-template-areas: "onglets vues"; }
  .onglets { grid-template-columns: none; grid-auto-rows: 84px; align-content: start; gap: 6px; border-top: 0; border-right: var(--bord) solid var(--ligne); padding: calc(16px + env(safe-area-inset-top)) 8px 16px; }
  .onglet { font-size: 14.5px; }
  .onglet[aria-current="page"]::before { inset: 4px 6px; }
  .toast { bottom: calc(20px + env(safe-area-inset-bottom)); left: 108px; }
  .app:not([data-ecran="chantier"]) .toast { left: 12px; }
  .app[data-ecran="accueil"] .toast { bottom: calc(112px + env(safe-area-inset-bottom)); }
  .vue-liste, .vue-chantier, .vue-reglages { padding: 28px 28px 40px; }
  .app:not([data-ecran="chantier"]) { grid-template-columns: minmax(0, 1fr); grid-template-areas: "vues"; }
  .vue-accueil { padding: 28px 28px calc(120px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; width: 100%; }
  .flottant { right: 28px; bottom: calc(28px + env(safe-area-inset-bottom)); }
  .grille-chantier { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .grille-reglages { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .bloc-large { grid-column: 1 / -1; }
  .produits { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .liste-arbres { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
  .feuille { max-width: 620px; margin: auto; border-radius: 28px; }
  .saisie { padding: 14px 18px 16px; gap: 10px; }
  .pave { grid-auto-rows: clamp(60px, 8dvh, 84px); gap: 10px; }
  .touche:not(.t-valider):not(.t-raz) { font-size: 34px; }
}
/* Tablette en paysage : la place de dépôt à gauche, la saisie en colonne à droite. */
@media (min-width: 900px) and (orientation: landscape) {
  .vue-saisie { display: grid; grid-template-columns: minmax(0, 1fr) clamp(380px, 38vw, 470px); grid-template-rows: minmax(0, 1fr); }
  .scene { min-height: 0; }
  .saisie { justify-content: flex-end; border-left: var(--bord) solid var(--ligne); min-height: 0; overflow: hidden; padding-top: calc(16px + env(safe-area-inset-top)); }
  .derniers { display: flex; flex-direction: column; flex: 1 1 0; min-height: 0; }
  .derniers ol { overflow-y: auto; min-height: 0; padding-bottom: 14px; -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent); }
  .panneau, .ardoise, .puces { flex: none; }
  .pave { grid-auto-rows: clamp(60px, 10dvh, 88px); }
}
@media (min-width: 1100px) { .grille-chantier { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grille-chantier .bloc:first-child { grid-row: span 2; } }

/* Petits téléphones : la scène rétrécit, la saisie garde ses cibles. */
@media (max-height: 700px) {
  .saisie { padding: 8px 10px; gap: 6px; }
  .ard-valeur { min-height: 48px; }
  .ard-valeur b { font-size: 44px; }
  .puce { min-height: 48px; }
  .pave { grid-auto-rows: 52px; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Avertissements ────────────────────────────────────────────────────── */
/* iPhone dans Safari : à lire avant la première saisie. */
.avert { margin-bottom: 14px; padding: 14px 16px; border-radius: 20px; background: var(--accent-lavis); border: var(--bord) solid var(--accent-trace); display: flex; flex-direction: column; gap: 6px; }
.avert h2 { font-size: 17px; font-weight: 800; color: var(--accent-encre); }
.avert p { font-size: 15px; font-weight: 600; color: var(--encre-2); }
/* Enregistrement refusé : reste affiché tant que le chantier n'est pas de nouveau sur le téléphone. */
.alerte-sauve {
  position: fixed; left: 12px; right: 12px; top: calc(10px + env(safe-area-inset-top)); z-index: 40; margin: 0 auto; max-width: 560px;
  display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 20px; background: var(--erreur); color: #fff; box-shadow: var(--ombre-btn);
}
.alerte-sauve p { font-size: 15.5px; font-weight: 650; }
.alerte-sauve b { display: block; font-size: 17px; font-weight: 800; }
.alerte-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.alerte-actions .btn { background: #fff; color: var(--erreur); flex: 1 1 auto; }
.journal { margin-top: 8px; }
.journal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ── Scène compacte : des jauges à la place du dessin ──────────────────── */
.jauges { display: none; }
:root[data-scene="compacte"] .scene { flex: none; min-height: 0; overflow: visible; background: var(--sol); }
:root[data-scene="compacte"] #diorama { display: none; }
:root[data-scene="compacte"] .hud { position: static; pointer-events: auto; padding: calc(8px + env(safe-area-inset-top)) 12px 0; }
:root[data-scene="compacte"] .hud-score { align-self: stretch; display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; padding: 6px 14px; }
:root[data-scene="compacte"] .valeur b { font-size: 28px; }
:root[data-scene="compacte"] .saisie { flex: 1 1 auto; justify-content: flex-end; }
:root[data-scene="compacte"] .pave { grid-auto-rows: clamp(56px, 9dvh, 84px); }
.puce { padding-left: 8px; padding-right: 8px; }
:root[data-scene="compacte"] .jauges { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 4px 12px; list-style: none; margin: 0; padding: 4px 4px 0; }
.jauges li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; min-height: 26px; }
.j-nom { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.j-nom i { width: 10px; height: 10px; border-radius: 3px; }
.j-barre { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.j-barre b { display: block; height: 100%; }
.j-val { color: var(--encre-2); font-weight: 650; white-space: nowrap; }
@media (max-height: 500px) and (orientation: landscape) {
  .vue-saisie { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); overflow: hidden; }
  .vue-saisie .scene { overflow-y: auto; }
  .vue-saisie .saisie { overflow-y: auto; }
  .pave { grid-auto-rows: 46px; gap: 6px; }
  .ard-valeur b { font-size: 40px; }
}
