@font-face { font-family: "Bodoni Moda"; src: url("fonts/bodoni-moda-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Bodoni Moda"; src: url("fonts/bodoni-moda-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("fonts/manrope-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("fonts/manrope-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --lait: #FDFFFB;
  --menthe: #EAF2EC;
  --sauge: #82A38B;
  --sauge-35: rgba(130, 163, 139, .35);
  --corail: #EE6055;
  --corail-fonce: #D8483D;
  --saumon: #FF9B85;
  --foret: #18301F;
  --foret-douce: #4A5E51;
  --carte: #FFFFFF;
  --ombre: 0 1px 3px rgba(24, 48, 31, .06), 0 10px 30px rgba(24, 48, 31, .07);
  --r: 20px;
  --serif: "Bodoni Moda", Georgia, serif;
  --sans: "Manrope", -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--lait);
  color: var(--foret);
  font: 500 17px/1.45 var(--sans);
  min-height: 100dvh;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

/* En-tête */
.top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 10px;
  background: var(--lait);
  position: sticky; top: 0; z-index: 5;
  border-bottom: 1px solid var(--menthe);
}
.logo { width: 44px; height: 44px; border-radius: 50%; }
.hello-name { font: 400 24px/1.1 var(--serif); }
.hello-sub { font-size: 13px; color: var(--foret-douce); }

main { max-width: 560px; margin: 0 auto; padding: 14px 16px 24px; }

/* Barre d'onglets */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--carte);
  border-top: 1px solid var(--menthe);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabs button {
  border: 0; background: none; padding: 6px 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 12px; font-weight: 700; color: var(--foret-douce);
}
.tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { color: var(--corail-fonce); }

/* Sélecteur de jour */
.daybar { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 14px; }
.daybar button {
  width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--sauge-35); background: var(--carte); font-size: 22px; line-height: 1;
}
.daybar button:disabled { opacity: .3; cursor: default; }
.daylabel { text-align: center; }
.daylabel b { display: block; font: 400 26px/1.1 var(--serif); }
.daylabel span { font-size: 14px; color: var(--foret-douce); }

/* Cartes */
.card {
  background: var(--carte); border-radius: var(--r); box-shadow: var(--ombre);
  border: 1px solid var(--menthe);
  padding: 18px 16px; margin-bottom: 14px;
}
.card h2 { font: 400 22px/1.2 var(--serif); margin: 0 0 2px; }
.card .lead { margin: 0 0 6px; color: var(--foret-douce); font-size: 15px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--sauge); margin-bottom: 4px; }
.card.week { background: var(--menthe); border-color: var(--sauge-35); }

.field { padding: 14px 0 4px; border-top: 1px solid var(--menthe); margin-top: 10px; }
.card .field:first-of-type { border-top: 0; margin-top: 4px; }
.week .field { border-top-color: var(--sauge-35); }
.label { font-weight: 700; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; column-gap: 8px; }
.label small { font-weight: 500; color: var(--foret-douce); font-size: 13px; white-space: nowrap; }
.hint { font-size: 14px; color: var(--foret-douce); margin: 2px 0 10px; }

/* Saisie numérique */
.num { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.num input {
  width: 100%; height: 56px; padding: 0 16px;
  border: 1.5px solid var(--sauge-35); border-radius: 14px; background: var(--lait);
  font: 400 26px var(--serif); color: var(--foret);
}
.num input:focus { outline: none; border-color: var(--sauge); box-shadow: 0 0 0 4px var(--menthe); }
.num .unit { font-weight: 700; color: var(--foret-douce); min-width: 44px; }

/* Puces de choix */
.chips { display: grid; gap: 8px; margin-top: 8px; }
.tabs[hidden] { display: none; }
.chips.c2 { grid-template-columns: repeat(2, 1fr); }
.chips.c5 { grid-template-columns: repeat(5, 1fr); }
.chips.c4 { grid-template-columns: repeat(4, 1fr); }
.chips.c3 { grid-template-columns: repeat(3, 1fr); }
.chip {
  min-height: 52px; border-radius: 14px; border: 1.5px solid var(--sauge-35);
  background: var(--lait); font-weight: 700; font-size: 20px; padding: 4px;
}
.chip.small { font-size: 15px; }
.chip.on { background: var(--foret); border-color: var(--foret); color: var(--lait); }
.chip.on.alerte { background: var(--corail-fonce); border-color: var(--corail-fonce); }
.scale { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--foret-douce); margin-top: 6px; }

/* Cases à cocher d'hier */
.check {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  min-height: 60px; padding: 10px 14px; margin-top: 8px;
  border: 1.5px solid var(--sauge-35); border-radius: 14px; background: var(--lait);
}
.check .box {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  border: 2px solid var(--sauge); background: #fff; display: grid; place-items: center;
}
.check .box svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.check.on { border-color: var(--sauge); background: var(--menthe); }
.check.on .box { background: var(--sauge); }
.check.on .box svg { opacity: 1; }
.check .txt b { display: block; font-weight: 700; font-size: 16px; }
.check .txt small { display: block; font-size: 13px; color: var(--foret-douce); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 6px; }
.switch button {
  flex: none; width: 58px; height: 34px; border-radius: 99px; border: 0;
  background: var(--sauge-35); position: relative;
}
.switch button::after {
  content: ""; position: absolute; top: 4px; left: 4px; width: 26px; height: 26px;
  border-radius: 50%; background: #fff; transition: left .18s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch button[aria-pressed="true"] { background: var(--sauge); }
.switch button[aria-pressed="true"]::after { left: 28px; }

.note {
  border-radius: 14px; padding: 10px 12px; font-size: 14.5px; margin-top: 10px;
  background: var(--menthe); color: var(--foret);
}
.note.warn { background: #FFE9E3; }

/* Bouton principal */
.save {
  position: sticky; bottom: calc(76px + env(safe-area-inset-bottom));
  width: 100%; height: 58px; border: 0; border-radius: 99px;
  background: var(--corail-fonce); color: #fff; font-size: 19px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(216, 72, 61, .35); margin-top: 4px;
}
.save:disabled { background: var(--sauge); box-shadow: none; }
.btn2 {
  height: 50px; padding: 0 20px; border-radius: 99px; border: 1.5px solid var(--foret);
  background: transparent; font-weight: 700; width: 100%; margin-top: 12px;
}

/* Progression */
.hero { text-align: center; padding: 22px 16px; }
.hero .big { font: 400 56px/1 var(--serif); color: var(--corail-fonce); }
.hero .big em { font-style: italic; }
.hero .sub { color: var(--foret-douce); margin-top: 6px; }
.bar { height: 14px; border-radius: 99px; background: var(--menthe); overflow: hidden; margin: 16px 0 6px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--saumon), var(--corail)); }
.bar-legend { display: flex; justify-content: space-between; font-size: 13px; color: var(--foret-douce); }
.chart svg { width: 100%; height: auto; display: block; }
.chart .legend { display: flex; gap: 14px; font-size: 13px; color: var(--foret-douce); margin-top: 6px; flex-wrap: wrap; }
.chart .legend i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--lait); border: 1px solid var(--menthe); border-radius: 14px; padding: 12px 8px; text-align: center; }
.tile b { display: block; font: 400 26px/1.1 var(--serif); }
.tile span { font-size: 12.5px; color: var(--foret-douce); }
.empty { text-align: center; color: var(--foret-douce); padding: 26px 8px; }

/* Formulaire de départ */
textarea {
  width: 100%; margin-top: 8px; padding: 12px 14px; resize: vertical;
  border: 1.5px solid var(--sauge-35); border-radius: 14px; background: var(--lait);
  font: 500 16px/1.45 var(--sans); color: var(--foret);
}
textarea:focus { outline: none; border-color: var(--sauge); box-shadow: 0 0 0 4px var(--menthe); }

/* Outils */
.bignum { font: 400 44px/1.05 var(--serif); color: var(--corail-fonce); margin: 2px 0 6px; }
.bignum span { font: 700 14px var(--sans); color: var(--foret-douce); }
.levels { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; }
.levels li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; border: 1px solid transparent; font-size: 14.5px; }
.levels li small { display: block; font-size: 12.5px; color: var(--foret-douce); }
.levels li > span:last-child { font-weight: 700; white-space: nowrap; }
.levels li.current { background: var(--menthe); border-color: var(--sauge-35); }
.macros { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.macro { border-radius: 14px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: baseline; color: #1c1a17; }
.macro span { font-size: 14px; font-weight: 700; }
.macro b { font-size: 18px; }
.m-prot { background: #FFB3AE; }
.m-fib { background: #D4F5A8; }
.m-lip { background: #FFF1B0; }
.m-glu { background: #B5EEF2; }
.rules { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.rules li { border-radius: 12px; padding: 10px 12px; background: var(--lait); border: 1px solid var(--menthe); }
.rules li b { display: block; }
.rules li span { font-size: 14.5px; color: var(--foret-douce); }
.rules li.r-ok { background: var(--menthe); }
.rules li.r-up { background: #FFF1EC; }
.rules li.r-up2 { background: #FFE2DA; }
.btn2:disabled { opacity: .6; cursor: default; }

/* Repères */
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.steps { margin: 6px 0 0; padding-left: 20px; }
.steps li { margin: 6px 0; }
.code { font: 700 15px var(--sans); background: var(--menthe); border-radius: 10px; padding: 8px 10px; word-break: break-all; }

/* Message */
.toast {
  position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--foret); color: var(--lait); padding: 12px 20px; border-radius: 99px;
  font-weight: 700; opacity: 0; pointer-events: none; transition: .25s; z-index: 10; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Écran d'accès */
.gate { text-align: center; padding-top: 30px; }
.gate img { width: 120px; height: 120px; border-radius: 50%; }
.gate h1 { font: 400 32px/1.15 var(--serif); margin: 14px 0 6px; }
.gate h1 em { color: var(--corail-fonce); }
.gate p { color: var(--foret-douce); }
.demo-tag { display: inline-block; background: #FFE9E3; color: var(--corail-fonce); font-size: 12px; font-weight: 700; border-radius: 99px; padding: 2px 10px; margin-left: 6px; }

/* Mode consultation (Nathan) : rien n'est modifiable */
.lecture .save, .lecture [data-act="save-reperes"], .lecture [data-act="save-s1"],
.lecture [data-act="set-prot"], .lecture [data-act="install"] { display: none !important; }
.lecture .chip, .lecture .check, .lecture .switch button { cursor: default; }
.lecture input:disabled, .lecture textarea:disabled { opacity: 1; -webkit-text-fill-color: var(--foret); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
