/* wtrack — feuille unique.
   Registre : document technique. La hiérarchie est portée par les filets, pas
   par la couleur. Angles vifs, aucune ombre, aucun dégradé de couleur.

   Trois systèmes de couleur strictement séparés :
     · les neutres      — le papier et l'encre ;
     · le sémantique    — un seul token, --caution, réservé à la fiabilité ;
     · l'accent         — décoratif et de repérage, jamais un état.
   Test de validation : l'interface reste entièrement lisible avec --accent
   réglé sur un gris neutre. */

@font-face {
  font-family: 'Mona Sans';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url('/assets/fonts/mona-sans-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: 'Mona Sans';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url('/assets/fonts/mona-sans-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-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

/* ================================================================== tokens */

:root {
  /* -- neutres : biais froid-vert à ~3 %, le gris d'un tirage offset -------- */
  --paper: #f6f8f7;
  --surface: #ffffff;
  --ink: #0f1413; /* 17,4:1 sur --paper — AAA */
  --ink-2: #49524f; /*  7,6:1 — AAA */
  --ink-3: #666f6c; /*  4,9:1 — AA  */
  --rule: #c7cecb;

  /* -- sémantique : une seule couleur, pour la seule vraie réserve --------- */
  --caution: #8a5310; /* 5,9:1 — AA */
  --caution-face: #f0e6d8;

  /* -- accent : repérage uniquement. Surchargé au démarrage depuis les
        réglages. La valeur par défaut est le gris neutre, c'est-à-dire le cas
        de test : si l'interface tient ainsi, elle tient avec n'importe quoi. */
  --accent: #5c6562;
  --accent-face: #ffffff;

  /* -- filets : quatre rôles, une signification chacun --------------------- */
  --rule-hair: 1px solid var(--rule); /* séparation DANS un ensemble */
  --rule-mid: 1px solid var(--ink-3); /* BORD d'un ensemble           */
  --rule-head: 2px solid var(--ink); /* tête de bloc, ligne de total */
  --rule-doc: 3px solid var(--ink); /* haut du panneau principal    */

  /* -- espacement : unité 4 px -------------------------------------------- */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --gutter: 16px;

  /* -- typographie -------------------------------------------------------- */
  --t-micro: 11px;
  --t-small: 13px;
  --t-base: 15px;
  --t-input: 17px;
  --t-lg: 21px;
  --t-xl: 30px;
  --t-hero: clamp(44px, 13vw, 60px);

  --row: 44px; /* ligne de lecture */
  --tap: 48px; /* cible tactile de saisie */

  /* Hachure de l'état « estimé » : arrêts francs, jamais un dégradé. */
  --hatch: repeating-linear-gradient(45deg, var(--ink) 0 1px, transparent 1px 4px);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #0c100f;
    --surface: #141918;
    --ink: #edf0ee;
    --ink-2: #9ba4a1;
    --ink-3: #828b88;
    --rule: #2b3230;
    --caution: #d9a45c;
    --caution-face: #2a2116;
    --accent: #98a19e;
    --accent-face: #0c100f;
  }
}

/* Thème forcé : `color-scheme` doit suivre, sinon les contrôles natifs, les
   barres de défilement et le clavier numérique restent dans l'autre registre. */
:root[data-theme='light'] {
  color-scheme: light;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --paper: #0c100f;
  --surface: #141918;
  --ink: #edf0ee;
  --ink-2: #9ba4a1;
  --ink-3: #828b88;
  --rule: #2b3230;
  --caution: #d9a45c;
  --caution-face: #2a2116;
  --accent: #98a19e;
  --accent-face: #0c100f;
}

/* ================================================================== socle */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Mona Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: var(--t-base);
  font-weight: 400;
  line-height: 1.5;
  /* Chiffres tabulaires posés à la racine, jamais par classe : aucune chaîne
     de chiffres ne peut y échapper par oubli. */
  font-variant-numeric: tabular-nums lining-nums;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  padding-bottom: calc(var(--tap) + 44px + env(safe-area-inset-bottom));
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  font-variant-numeric: inherit;
  border-radius: 0;
}

/* Supprime le délai de double-tap sur les cibles, sans désactiver le zoom de
   la page : l'app se manipule d'un pouce et chaque tap doit répondre tout de
   suite. */
button,
a,
input,
select,
textarea,
label {
  touch-action: manipulation;
}

/* Le focus se voit toujours, et toujours en encre : l'accent est décoratif,
   il ne peut pas porter une information d'état. */
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

input[type='number'] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.wrap {
  max-width: 620px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/**
 * Fond perdu.
 *
 * Tout filet horizontal traverse la feuille de bord à bord ; la colonne de
 * texte, elle, garde sa gouttière. Le bloc ressort par une marge négative et
 * la gouttière est restituée soit par le bloc lui-même, soit par ses lignes
 * quand ce sont elles qui portent les filets — sans quoi les filets internes
 * s'arrêteraient là où les filets de structure continuent, et la page aurait
 * deux longueurs de trait sans raison.
 *
 * Les blocs encadrés — récents, suggestions, champs — gardent la gouttière :
 * un cadre collé au bord de l'écran n'est plus un cadre.
 */

@media (max-width: 360px) {
  :root {
    --gutter: 14px;
  }
}

/* ============================================================ typographie */

.eyebrow {
  display: block;
  font-size: var(--t-micro);
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.muted {
  color: var(--ink-2);
}

.small {
  font-size: var(--t-small);
  color: var(--ink-2);
  line-height: 1.45;
}

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

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s3);
  padding: calc(env(safe-area-inset-top) + var(--s4)) var(--gutter) var(--s3);
  margin-inline: calc(var(--gutter) * -1);
  border-top: var(--rule-doc);
  border-bottom: var(--rule-head);
}

.topbar h1 {
  margin: 0;
  font-size: var(--t-micro);
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}

.topbar .sub {
  display: block;
  margin-top: 2px;
  font-size: var(--t-small);
  color: var(--ink-2);
}

.topnav {
  display: flex;
  gap: var(--s3);
  font-size: var(--t-micro);
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.topnav a {
  padding: var(--s2) 0 var(--s1);
  text-decoration: none;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
}

/* Seul emploi de l'accent dans la navigation : dire OÙ l'on est. En gris
   neutre, le trait et le changement d'encre suffisent encore. */
.topnav a[aria-current='page'] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* ================================================================ sections */

.section {
  margin-top: var(--s6);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: 0 var(--gutter) var(--s2);
  margin-inline: calc(var(--gutter) * -1);
  border-bottom: var(--rule-mid);
  margin-bottom: var(--s3);
}

/* Règle Chanel — un élément retiré avant de livrer.
   Chaque tête de section portait un tiret d'accent. Cinq fois par écran, pour
   une information que le filet en dessous donne déjà : c'était le seul ornement
   pur du dessin. L'accent ne sert plus qu'au repérage — onglet courant, bouton
   principal, jour du relevé — et le système en sort plus strict. */
.section-head .eyebrow {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

/* Le sélecteur de jour vit dans la tête de section : il doit rester sur une
   ligne, sinon les deux flèches se replient l'une sous l'autre. */
.daynav {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: var(--t-small);
  white-space: nowrap;
}

.section-head .link {
  font-size: var(--t-small);
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: var(--rule-hair);
}

/* ============================================ panneau principal du jour */

.doc {
  padding: var(--s5) 0 var(--s4);
}

.doc-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s4);
  flex-wrap: wrap;
}

.figure {
  display: block;
  font-size: var(--t-hero);
  font-weight: 750;
  line-height: 0.95;
  letter-spacing: -0.025em;
}

.figure .u {
  font-size: var(--t-small);
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ink-2);
  margin-left: var(--s2);
}

/* L'écart à la cible ne porte aucune couleur : le signe, la position et
   l'épaisseur du filet le disent, et ils survivent au niveau de gris. */
.delta {
  text-align: right;
  font-size: var(--t-lg);
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  padding-top: var(--s1);
}

.delta .sub {
  display: block;
  font-size: var(--t-small);
  font-weight: 400;
  color: var(--ink-2);
  margin-top: 2px;
}

/* Sans cible, il n'y a pas d'écart : pas de filet non plus, sinon la ligne
   affirme une mesure qui n'existe pas. */
.delta--none {
  color: var(--ink-3);
  font-weight: 400;
  font-size: var(--t-base);
}

.delta--under {
  border-top: 1px solid var(--ink);
}
.delta--on {
  border-top: 2px solid var(--ink);
}
.delta--over {
  border-top: 3px solid var(--ink);
  color: var(--caution);
}

/* ======================================= SIGNATURE — barre de couverture */

/* De quoi ce total est-il fait ? Aplat = pesé, hachure = estimé, vide = non
   documenté. Aucune teinte : la distinction tient à la densité d'encre. */
.cov {
  margin-top: var(--s4);
}

.cov__track {
  position: relative;
  display: flex;
  height: 10px;
  border-bottom: 1px solid var(--ink);
}

.cov__seg {
  display: block;
  height: 100%;
}

.cov__seg--logged {
  background: var(--ink);
}

.cov__seg--est {
  background-image: var(--hatch);
}

/* Le vide doit se voir comme une mesure, pas comme une absence de barre :
   sans ces deux filets, on ne sait plus où le total s'arrête et où commence
   le fond. C'est une case vide sur une réglure, pas un blanc. */
.cov__seg--void {
  background: transparent;
  border-top: 1px solid var(--ink);
  border-right: 1px solid var(--ink);
}

.cov__tick {
  position: absolute;
  top: -4px;
  bottom: -3px;
  width: 2px;
  background: var(--ink);
}

.cov__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s4);
  margin-top: var(--s2);
  font-size: var(--t-micro);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 600;
}

.cov__legend b {
  color: var(--ink);
  font-weight: 700;
}

.cov__legend .k {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
}

/* Les pastilles de légende reprennent exactement les trois traitements. */
.cov__legend .k::before {
  content: '';
  width: 10px;
  height: 10px;
  flex: none;
  border: 1px solid var(--ink);
}
.cov__legend .k--logged::before {
  background: var(--ink);
}
.cov__legend .k--est::before {
  background-image: var(--hatch);
}
.cov__legend .k--void::before {
  background: transparent;
}

/* La cible est un repère, pas un état : sa pastille reprend le trait de la
   graduation, et non un carré comme les trois états de la mesure. */
.cov__legend .k--target::before {
  width: 2px;
  height: 12px;
  border: 0;
  background: var(--ink);
}

/* Échelle « ligne de journal » : la même information, 3 px de large. */
.mark {
  flex: none;
  width: 3px;
  align-self: stretch;
  min-height: 22px;
  border: 1px solid var(--ink);
  border-width: 0 0 0 3px;
  border-left-color: var(--ink);
}
.mark--est {
  border-left-color: transparent;
  background-image: var(--hatch);
  width: 3px;
  border-left-width: 0;
  outline: 1px solid var(--ink);
  outline-offset: -1px;
}
.mark--void {
  border-left-color: var(--rule);
}

/* ========================================================= table de données */

.dtable {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--s4);
}

.dtable th {
  text-align: left;
  padding: 0 0 var(--s2);
  font-size: var(--t-micro);
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: var(--rule-head);
  white-space: nowrap;
}

.dtable td {
  padding: var(--s3) 0;
  border-bottom: var(--rule-hair);
  vertical-align: baseline;
}

.dtable tr:last-child td {
  border-bottom: 0;
}

.dtable .r {
  text-align: right;
}

.dtable .lbl {
  font-weight: 500;
}

.dtable .val {
  font-weight: 650;
}

.dtable .dim {
  color: var(--ink-2);
}

.dtable .cau {
  color: var(--caution);
  font-weight: 650;
}

.dtable tfoot td {
  border-top: var(--rule-head);
  border-bottom: 0;
  padding-top: var(--s3);
  font-weight: 650;
}

.tw {
  overflow-x: auto;
  margin-inline: calc(var(--gutter) * -1);
}

.tw .dtable th:first-child,
.tw .dtable td:first-child {
  padding-left: var(--gutter);
}

.tw .dtable th:last-child,
.tw .dtable td:last-child {
  padding-right: var(--gutter);
}

/* Liste clé/valeur — les conditions de publication du TDEE. */
.kv {
  border-top: var(--rule-head);
  margin-inline: calc(var(--gutter) * -1);
}

.kv__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) var(--gutter);
  border-bottom: var(--rule-hair);
}

.kv__row:last-child {
  border-bottom: 0;
}

.kv__k {
  color: var(--ink-2);
  font-size: var(--t-small);
}

.kv__v {
  font-weight: 650;
  white-space: nowrap;
}

.kv__v .note {
  font-weight: 400;
  color: var(--ink-3);
  font-size: var(--t-small);
  margin-left: var(--s2);
}

.kv__v.cau {
  color: var(--caution);
}

/* ================================================================ journal */

.list {
  border-top: var(--rule-head);
  margin-inline: calc(var(--gutter) * -1);
}

.mealhead {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s2) var(--gutter);
  border-bottom: var(--rule-mid);
  font-size: var(--t-micro);
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.mealhead b {
  color: var(--ink-2);
  font-weight: 650;
}

.entry {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: var(--row);
  padding: var(--s2) var(--gutter);
  border-bottom: var(--rule-hair);
}

.entry:last-child {
  border-bottom: 0;
}

/* La ligne entière ouvre la modification. Le bouton n'a aucune apparence
   propre : c'est la ligne qui est la cible, pas un contrôle posé dessus. */
.entry__open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s1) 0;
  margin: 0;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
}

/* Le retour d'appui couvre toute la ligne, pas seulement le bouton : un
   surlignage qui s'arrête avant la croix de suppression désignerait mal ce
   qu'on vient de toucher. */
.entry:has(.entry__open:active) {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

.entry__body {
  flex: 1;
  min-width: 0;
}

.entry__name,
.entry__meta {
  display: block;
}

.entry__name {
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry__meta {
  font-size: var(--t-small);
  color: var(--ink-2);
  line-height: 1.35;
}

.entry__val {
  font-weight: 650;
  white-space: nowrap;
  text-align: right;
}

.entry__val .band {
  display: block;
  font-size: var(--t-micro);
  font-weight: 400;
  color: var(--ink-2);
}

/* 40 px : la suppression est le seul geste destructif de l'écran de lecture,
   c'est celui qui mérite le moins d'être raté au pouce. */
.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: none;
  border: var(--rule-hair);
  color: var(--ink-2);
  cursor: pointer;
  line-height: 1;
  font-size: var(--t-base);
}

.icon-btn:active {
  background: var(--ink);
  color: var(--paper);
}

.icon-btn[disabled] {
  opacity: 0.4;
  cursor: default;
}

/* ================================================================= récents */

/* `auto-fit` et non `auto-fill` : le second garde les colonnes vides, qui
   laissaient voir le fond du conteneur sous forme d'une case grise à côté du
   seul aliment répétable. `auto-fit` les affaisse, et un aliment unique occupe
   la largeur. */
.chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: var(--rule-hair);
}

.chip {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  min-height: 64px;
  padding: var(--s2) var(--s3);
  text-align: left;
  background: var(--surface);
  border: 0;
  cursor: pointer;
  transition: background 120ms ease-out;
}

.chip:active {
  background: var(--paper);
}

.chip__name {
  font-size: var(--t-small);
  font-weight: 500;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.chip__meta {
  margin-top: auto;
  font-size: var(--t-micro);
  color: var(--ink-2);
  letter-spacing: 0.02em;
}

.chip__meta b {
  color: var(--ink);
  font-weight: 700;
}

.chip[data-busy] {
  background: var(--paper);
}

/* ================================================== surfaces de saisie */

/* Lecture ≠ saisie : même palette, même famille, corps et rythme différents,
   et une cible tactile qui ne descend jamais sous 48 px. */
/* Lecture ≠ saisie : même palette, même famille, corps et rythme différents.
   On agrandit le texte de la surface, pas `--t-base` lui-même — sinon les
   boutons grossissent avec et leurs libellés se replient sur deux lignes. */
.entry-surface {
  font-size: var(--t-input);
}

/* L'unité reste dans le champ : une valeur sans unité n'est pas une mesure. */
.figure-field {
  position: relative;
}

.figure-field .input--figure {
  padding-right: 72px;
}

.figure-field .unit {
  position: absolute;
  right: var(--s3);
  bottom: var(--s3);
  font-size: var(--t-small);
  font-weight: 600;
  color: var(--ink-2);
  pointer-events: none;
}

.field {
  display: block;
  margin-bottom: var(--s4);
}

.field > span,
.field-label {
  display: block;
  font-size: var(--t-micro);
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--s2);
}

.input {
  width: 100%;
  min-height: var(--tap);
  padding: var(--s2) var(--s3);
  background: var(--surface);
  border: 1px solid var(--ink-3);
  font-size: var(--t-input);
}

.input::placeholder {
  color: var(--ink-3);
}

.input:focus {
  border-color: var(--ink);
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.input--figure {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  min-height: 64px;
  padding: 0 var(--s3);
}

.macro-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s2);
}

.macro-row .input {
  text-align: center;
  font-weight: 600;
}

.seg {
  display: grid;
  grid-auto-flow: column;
  gap: 1px;
  background: var(--ink-3);
  border: 1px solid var(--ink-3);
}

.seg button {
  min-height: var(--tap);
  padding: 0 var(--s1);
  background: var(--surface);
  border: 0;
  color: var(--ink-2);
  font-size: var(--t-small);
  font-weight: 600;
  cursor: pointer;
}

.seg button[aria-pressed='true'] {
  background: var(--ink);
  color: var(--paper);
}

/* ================================================================ boutons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 0 var(--s4);
  background: var(--surface);
  border: 1px solid var(--ink);
  color: var(--ink);
  font-size: var(--t-base);
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms cubic-bezier(0.23, 1, 0.32, 1);
}

.btn:active {
  transform: scale(0.98);
}

/* L'accent en aplat : le seul endroit où il devient grand. En gris neutre,
   c'est le contraste du remplissage qui porte la primauté, pas la teinte. */
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-face);
}

.btn--ghost {
  background: transparent;
  border-color: var(--ink-3);
  color: var(--ink-2);
}

.btn--block {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: var(--s2);
  margin-top: var(--s5);
}

.btn-row .btn {
  flex: 1;
}

/* ========================================================= avertissements */

/* Un seul registre coloré dans toute l'app, et il ne dit qu'une chose : la
   fiabilité de la mesure est en cause. Jamais un jugement, jamais un refus. */
.notice {
  display: flex;
  gap: var(--s2);
  padding: var(--s3);
  margin: var(--s3) 0;
  background: var(--caution-face);
  border-left: 3px solid var(--caution);
  font-size: var(--t-small);
  line-height: 1.4;
  color: var(--ink);
}

.notice::before {
  content: '▸';
  color: var(--caution);
  font-weight: 700;
  flex: none;
}

.notice--plain {
  background: transparent;
  border-left-color: var(--ink-3);
}

.notice--plain::before {
  color: var(--ink-3);
}

.empty {
  margin-inline: calc(var(--gutter) * -1);
  padding: var(--s5) var(--gutter);
  color: var(--ink-2);
  font-size: var(--t-small);
  line-height: 1.5;
  border-top: var(--rule-hair);
  border-bottom: var(--rule-hair);
}

/* ============================================================ barre basse */

.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: var(--s2) var(--gutter) calc(var(--s2) + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: var(--rule-head);
}

.actionbar .inner {
  display: flex;
  gap: var(--s2);
  max-width: 620px;
  margin: 0 auto;
}

.actionbar .btn {
  flex: 1;
}

.actionbar .btn--wide {
  flex: 2;
}

/* ================================================================== toast */

.toast {
  position: fixed;
  left: var(--gutter);
  right: var(--gutter);
  bottom: calc(var(--tap) + 34px + env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--s4);
  max-width: 588px;
  margin: 0 auto;
  padding: var(--s3);
  background: var(--ink);
  color: var(--paper);
  font-size: var(--t-small);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 160ms cubic-bezier(0.23, 1, 0.32, 1),
    transform 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast .grow {
  flex: 1;
}

.toast button {
  background: none;
  border: 1px solid var(--paper);
  color: var(--paper);
  font-weight: 650;
  font-size: var(--t-small);
  padding: var(--s1) var(--s2);
  cursor: pointer;
  white-space: nowrap;
}

/* =============================================================== relevé */

/* Le relevé publie les trous : une journée sans saisie n'est pas une colonne
   à zéro, c'est une colonne vide sur son filet. */
.relev {
  overflow-x: auto;
  padding-bottom: var(--s2);
}

.relev__grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(18px, 1fr);
  gap: 2px;
  min-width: 100%;
}

.relev__col {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  align-items: stretch;
  text-align: center;
}

.relev__bar {
  height: 46px;
  border-bottom: 1px solid var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.relev__bar i {
  display: block;
  width: 100%;
  background: var(--ink);
}

/* La part estimée se pose au-dessus de la part pesée, dans le même traitement
   que la barre de couverture : même vocabulaire à toutes les échelles. */
.relev__bar i.est {
  background-color: transparent;
  background-image: var(--hatch);
  outline: 1px solid var(--ink);
  outline-offset: -1px;
}

.relev__w {
  height: 12px;
  display: grid;
  place-items: center;
  font-size: 9px;
  color: var(--ink-2);
}

.relev__w b {
  display: block;
  width: 4px;
  height: 4px;
  background: var(--ink);
}

/* Hauteur imposée : une case vide — journée sans séance — laisserait sinon
   remonter la ligne suivante, et la grille cesserait d'être une grille. */
.relev__t,
.relev__d {
  min-height: 11px;
  font-size: 9px;
  letter-spacing: 0.02em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.relev__col[data-today] .relev__d {
  color: var(--ink);
  font-weight: 700;
  border-bottom: 2px solid var(--accent);
}

.relev__legend {
  margin-top: var(--s2);
  font-size: var(--t-micro);
  color: var(--ink-2);
  letter-spacing: 0.04em;
}

/* =============================================================== graphes */

.chart {
  width: 100%;
  height: auto;
  display: block;
  margin-top: var(--s3);
  touch-action: pan-y;
}

.chart .grid-line {
  stroke: var(--rule);
  stroke-width: 1;
}

.chart .axis-label {
  fill: var(--ink-3);
  font-size: 10px;
}

.chart .trend {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linejoin: round;
}

/* Un trou de mesure interrompt le tracé : une ligne continue par-dessus une
   semaine sans balance affirmerait une tendance qui n'a pas été mesurée. */
.chart .trend--gap {
  stroke-dasharray: 2 3;
  stroke: var(--ink-3);
  stroke-width: 1;
}

.chart .raw-dot {
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1;
}

.chart .bar {
  fill: var(--ink);
}

.chart .bar--est {
  fill: var(--ink-3);
}

.chart .bar--void {
  fill: none;
  stroke: var(--rule);
  stroke-width: 1;
}

.chart .target-line {
  stroke: var(--ink);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

/* ============================================================ suggestions */

.suggest {
  border: var(--rule-hair);
  border-top: var(--rule-mid);
  margin-top: var(--s2);
}

.suggest__item {
  display: flex;
  width: 100%;
  gap: var(--s3);
  align-items: baseline;
  min-height: var(--tap);
  padding: var(--s2) var(--s3);
  background: var(--surface);
  border: 0;
  border-bottom: var(--rule-hair);
  text-align: left;
  cursor: pointer;
}

.suggest__item:last-child {
  border-bottom: 0;
}

.suggest__name {
  flex: 1;
  font-size: var(--t-small);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggest__kcal {
  font-size: var(--t-small);
  color: var(--ink-2);
  white-space: nowrap;
}

.suggest__src {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  border: var(--rule-hair);
  padding: 1px 4px;
}

/* Reprise de quantité, en ligne — remplace la boîte de dialogue du système. */
.qty {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  background: var(--paper);
  border-bottom: var(--rule-hair);
}

.qty .input {
  width: 96px;
  min-height: var(--tap);
  text-align: right;
  font-weight: 650;
}

.qty .unit {
  font-size: var(--t-small);
  color: var(--ink-2);
}

.qty .btn {
  min-height: var(--tap);
  padding: 0 var(--s3);
  font-size: var(--t-small);
}

/* ================================================================ divers */

.link-list {
  margin-inline: calc(var(--gutter) * -1);
}

.link-list a {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  min-height: var(--tap);
  align-items: center;
  padding: var(--s2) var(--gutter);
  border-bottom: var(--rule-hair);
  font-size: var(--t-base);
  text-decoration: none;
}

.link-list a::after {
  content: '↓';
  color: var(--ink-3);
}

.link-list a:last-child {
  border-bottom: 0;
}

.prose {
  margin: 0;
  font-size: var(--t-small);
  color: var(--ink-2);
  line-height: 1.5;
}

.prose + .prose {
  margin-top: var(--s2);
}

/* Le scanner reste une surface d'image : il garde son cadre noir. */
.scanner {
  position: relative;
  overflow: hidden;
  background: #000;
  aspect-ratio: 3 / 4;
  max-height: 58vh;
  border: 1px solid var(--ink);
  margin-top: var(--s3);
}

.scanner video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scanner .reticle {
  position: absolute;
  inset: 24% 12%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
}

/* Nuancier d'accent — le premier échantillon est le gris de validation.
   Une bande continue plutôt que des pastilles espacées : sept carrés à 48 px
   débordent d'un écran de 390 px et le septième se retrouve seul à la ligne. */
.swatches {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  margin-top: var(--s3);
  border: 1px solid var(--ink-3);
  background: var(--ink-3);
}

.swatch {
  height: var(--tap);
  border: 0;
  cursor: pointer;
  padding: 0;
}

.swatch[aria-pressed='true'] {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.swatch[data-swatch='gris'] { background: #5c6562; }
.swatch[data-swatch='bleu'] { background: #1f4e93; }
.swatch[data-swatch='vert'] { background: #1c6153; }
.swatch[data-swatch='brique'] { background: #9a3520; }
.swatch[data-swatch='outremer'] { background: #3b3fa0; }
.swatch[data-swatch='olive'] { background: #5e6413; }
.swatch[data-swatch='prune'] { background: #7a2a63; }

/* ================================================== nuancier de l'accent */

/* Chaque teinte a une valeur claire et une valeur sombre : un accent calibré
   pour le papier devient illisible sur fond noir, et réciproquement. Toutes
   ont été mesurées ≥ 3:1 en marque et ≥ 4,5:1 en texte sur pastille, dans les
   deux thèmes. Le gris ouvre la liste parce qu'il est le cas de test. */
:root[data-accent='gris'] { --accent: #5c6562; --accent-face: #ffffff; }
:root[data-accent='bleu'] { --accent: #1f4e93; --accent-face: #ffffff; }
:root[data-accent='vert'] { --accent: #1c6153; --accent-face: #ffffff; }
:root[data-accent='brique'] { --accent: #9a3520; --accent-face: #ffffff; }
:root[data-accent='outremer'] { --accent: #3b3fa0; --accent-face: #ffffff; }
:root[data-accent='olive'] { --accent: #5e6413; --accent-face: #ffffff; }
:root[data-accent='prune'] { --accent: #7a2a63; --accent-face: #ffffff; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light'])[data-accent='gris'] { --accent: #98a19e; --accent-face: #0c100f; }
  :root:not([data-theme='light'])[data-accent='bleu'] { --accent: #6e9cdb; --accent-face: #0c100f; }
  :root:not([data-theme='light'])[data-accent='vert'] { --accent: #5fb49f; --accent-face: #0c100f; }
  :root:not([data-theme='light'])[data-accent='brique'] { --accent: #e08469; --accent-face: #0c100f; }
  :root:not([data-theme='light'])[data-accent='outremer'] { --accent: #8e90e4; --accent-face: #0c100f; }
  :root:not([data-theme='light'])[data-accent='olive'] { --accent: #b6bc55; --accent-face: #0c100f; }
  :root:not([data-theme='light'])[data-accent='prune'] { --accent: #ce84b6; --accent-face: #0c100f; }
}

:root[data-theme='dark'][data-accent='gris'] { --accent: #98a19e; --accent-face: #0c100f; }
:root[data-theme='dark'][data-accent='bleu'] { --accent: #6e9cdb; --accent-face: #0c100f; }
:root[data-theme='dark'][data-accent='vert'] { --accent: #5fb49f; --accent-face: #0c100f; }
:root[data-theme='dark'][data-accent='brique'] { --accent: #e08469; --accent-face: #0c100f; }
:root[data-theme='dark'][data-accent='outremer'] { --accent: #8e90e4; --accent-face: #0c100f; }
:root[data-theme='dark'][data-accent='olive'] { --accent: #b6bc55; --accent-face: #0c100f; }
:root[data-theme='dark'][data-accent='prune'] { --accent: #ce84b6; --accent-face: #0c100f; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
