/* Kalo — styles. Toutes les couleurs via variables CSS ; thèmes par [data-theme], fontes par [data-font]. */
:root, :root[data-theme="nuit"] {
  color-scheme: dark;
  --bg: #101418; --surface: #171c23; --control: #1b2129; --chip: #26303a; --track: #2a313b;
  --border: #262d36; --text: #e8eaed; --text-dim: #9aa3ad;
  --accent: #2e7d32; --accent-contrast: #ffffff; --accent-soft: #8fd18f;
  --danger: #c62828; --danger-bg: #5d1a1a; --badge-bg: #3a2c14;
}
:root[data-theme="aube"] {
  color-scheme: light;
  --bg: #f7f4ee; --surface: #ffffff; --control: #ece7dd; --chip: #e6e0d4; --track: #ddd6c8;
  --border: #d8d2c4; --text: #1c1c1c; --text-dim: #6b6558;
  --accent: #2e7d32; --accent-contrast: #ffffff; --accent-soft: #1b5e20;
  --danger: #c62828; --danger-bg: #f3d4d4; --badge-bg: #efe3c2;
}
:root[data-theme="ocean"] {
  color-scheme: dark;
  --bg: #0b1d2a; --surface: #10293a; --control: #14324a; --chip: #1a3a54; --track: #1e3f58;
  --border: #1c3a52; --text: #dbe7ef; --text-dim: #8aa5b8;
  --accent: #2ec4b6; --accent-contrast: #05302c; --accent-soft: #8fe3db;
  --danger: #e05252; --danger-bg: #3a1e24; --badge-bg: #3a3a1c;
}
:root[data-theme="terracotta"] {
  color-scheme: light;
  --bg: #f4e9de; --surface: #fbf5ee; --control: #efdfd0; --chip: #ead8c6; --track: #e3d2c0;
  --border: #e0cebb; --text: #3a2c24; --text-dim: #7a6a5d;
  --accent: #c96f4a; --accent-contrast: #ffffff; --accent-soft: #a04e2e;
  --danger: #b3261e; --danger-bg: #f2d5cd; --badge-bg: #eadbc4;
}
:root[data-theme="foret"] {
  color-scheme: dark;
  --bg: #0f1a14; --surface: #16241b; --control: #1b2c21; --chip: #213529; --track: #26392c;
  --border: #243629; --text: #dce8de; --text-dim: #90a795;
  --accent: #7bc96f; --accent-contrast: #0d1f0a; --accent-soft: #a8dca0;
  --danger: #d9534f; --danger-bg: #3a1f1c; --badge-bg: #333a1c;
}
:root[data-theme="minuit"] {
  color-scheme: dark;
  --bg: #0d0b14; --surface: #171329; --control: #1d1834; --chip: #241e3f; --track: #2a2348;
  --border: #282144; --text: #e6e2f2; --text-dim: #9a92bb;
  --accent: #9c7bff; --accent-contrast: #14102a; --accent-soft: #c2b0ff;
  --danger: #ef6a6a; --danger-bg: #3a1b2c; --badge-bg: #4a3d1c;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; background: var(--bg); color: var(--text); padding-bottom: 2rem; }
:root[data-font="serif"] body { font-family: Georgia, 'Times New Roman', serif; }
:root[data-font="rond"] body { font-family: 'Trebuchet MS', Verdana, system-ui; }
header { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; }
header h1 { margin: 0; font-size: 1.2rem; flex: 1; }
.hint { font-size: .7rem; opacity: .5; }
nav { display: flex; gap: .5rem; padding: 0 1rem .75rem; }
nav button, .seg button { flex: 1; padding: .6rem; background: var(--control); color: var(--text); border: none; border-radius: 10px; font-size: .95rem; }
nav button.active, .seg button.active { background: var(--accent); color: var(--accent-contrast); font-weight: 600; }
section { padding: 0 1rem; }
.card { background: var(--surface); border-radius: 14px; padding: 1rem; margin-bottom: 1rem; }
.card h3 { margin: 0 0 .6rem; }
#dayKcal { font-size: 2rem; font-weight: 700; }
.bar { height: 12px; background: var(--track); border-radius: 6px; overflow: hidden; margin: .5rem 0; }
.bar-fill { height: 100%; background: var(--accent); width: 0%; transition: width .4s; }
.bar-fill.over { background: var(--danger); }
.macros { display: flex; gap: 1rem; opacity: .85; font-size: .9rem; }
.encourage { margin-top: .5rem; font-size: .85rem; color: var(--accent-soft); min-height: 1.2em; }
.actions { display: flex; gap: .75rem; margin-bottom: 1rem; }
.big { flex: 1; padding: 1rem; font-size: 1.1rem; border: none; border-radius: 14px; background: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.big.save { background: var(--save); color: var(--save-contrast); }
.small { padding: .5rem .8rem; border: none; border-radius: 8px; background: var(--chip); color: var(--text); }
.scan-item { border-top: 1px solid var(--border); padding: .6rem 0; }
.scan-item .label { font-weight: 600; }
.scan-item .kcal { float: right; opacity: .8; font-size: .9rem; }
.scan-item input[type=range] { width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .3rem; }
.chip { padding: .3rem .6rem; border-radius: 999px; background: var(--chip); font-size: .8rem; border: none; color: var(--text); }
.chip.top { background: var(--accent); color: var(--accent-contrast); }
.chip.del, button.del { background: var(--danger-bg); color: var(--text); }
.meal { border-left: 3px solid var(--accent); padding: .5rem .75rem; margin-bottom: .6rem; background: var(--surface); border-radius: 8px; }
.meal .time { opacity: .5; font-size: .75rem; }
.badges { margin-top: 1rem; }
.badge { display: inline-block; margin: .2rem; padding: .3rem .7rem; background: var(--badge-bg); border-radius: 999px; font-size: .8rem; }
input, select { background: var(--control); color: var(--text); border: 1px solid var(--track); border-radius: 8px; padding: .5rem; font-size: 1rem; }
#profileForm label { display: block; margin-bottom: .6rem; font-size: .9rem; }
#profileForm input, #profileForm select { width: 100%; margin-top: .25rem; }
.profile-result { margin-top: 1rem; line-height: 1.6; }
.row { display: flex; gap: .5rem; margin-bottom: .5rem; }
.row input { flex: 1; }
.seg { display: flex; gap: .5rem; margin-bottom: .75rem; }
.swap { border-top: 1px solid var(--border); padding: .5rem 0; }
.swap .delta { font-weight: 700; color: var(--accent-soft); }
.swap ul { margin: .2rem 0 0 1rem; padding: 0; font-size: .85rem; opacity: .85; }

/* P2b : édition/suppression repas + santé */
.meal-actions { float: right; display: flex; gap: .3rem; }
.meal-actions .chip { padding: .1rem .5rem; }
.alt-note { margin-bottom: .4rem; }
fieldset.health { border: 1px solid var(--chip); border-radius: 8px; margin: .6rem 0; display: flex; flex-wrap: wrap; gap: .4rem; }
fieldset.health legend { font-size: .8rem; opacity: .7; padding: 0 .3rem; }
fieldset.health label { font-size: .85rem; }

/* P3a : sélecteur d'apparence (Profil → Apparence) */
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.theme-opt { border: 2px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: .5rem; font-size: .8rem; cursor: pointer; }
.theme-opt.selected { border-color: var(--accent); }
.theme-preview { display: flex; height: 28px; border-radius: 6px; overflow: hidden; margin-bottom: .4rem; border: 1px solid var(--border); }
.theme-preview span { flex: 1; }
.font-options { display: flex; gap: .6rem; }
.font-opt { flex: 1; border: 2px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: .5rem; cursor: pointer; font-size: 1.1rem; }
.font-opt.selected { border-color: var(--accent); }
.accent-options { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.accent-opt { width: 32px; height: 32px; border-radius: 999px; border: 2px solid transparent; cursor: pointer; padding: 0; }
.accent-opt.selected { border-color: var(--text); outline: 2px solid var(--accent); outline-offset: 1px; }
.accent-auto { border: 2px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: .35rem .7rem; font-size: .8rem; cursor: pointer; }
.accent-auto.selected { border-color: var(--text); }
.cand-selector { padding: .6rem .8rem; margin-top: .5rem; }
.cand-selector h3 { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; }
.cand-selector .chip.cand { display: block; width: 100%; text-align: left; background: var(--chip); }
.cand-selector .chip.cand.selected { background: var(--accent); color: var(--accent-contrast); }
