/* ── CalTrack — CSS (UI/UX v2) ──────────────────────────────────── */

:root {
  --bg-app: #f8fafc;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warn: #f59e0b;
  --danger: #ef4444;
  --macro-protein: #8b5cf6;
  --macro-carbs: #f59e0b;
  --macro-fat: #14b8a6;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px calc(72px + var(--safe-bottom));
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* ── Typography ──────────────────────────────────────────────────── */

h1, h2, h3 { font-weight: 700; }
h2 { font-size: 1.2rem; margin-bottom: 8px; }
.muted { color: var(--text-muted); font-size: .82rem; }
.center { text-align: center; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.label { display: block; font-size: .8rem; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }

/* ── Logo ────────────────────────────────────────────────────────── */

.logo { text-align: center; font-size: 1.8rem; letter-spacing: -.02em; padding: 24px 0 4px; }
.logo.small { font-size: 1.1rem; padding: 0; }

/* ── Hidden ──────────────────────────────────────────────────────── */

.hidden { display: none !important; }

/* ── Cards ───────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 8px 0;
}

/* ── Inputs ──────────────────────────────────────────────────────── */

input, select, textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  background: var(--surface);
  color: var(--text-main);
  margin-bottom: 8px;
  transition: border-color .15s;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.input-sm { width: auto; min-width: 72px; margin-bottom: 0; padding: 8px; font-size: 16px; }

/* ── Grid ────────────────────────────────────────────────────────── */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ── Buttons ─────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s, transform .05s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--bg-app); }
.btn.sm { padding: 8px 12px; font-size: .82rem; }
.btn.full { width: 100%; }
.btn-icon {
  background: none; border: none; cursor: pointer; font-size: 1rem;
  padding: 8px; border-radius: 8px; transition: background .15s, transform .05s;
  touch-action: manipulation;
}
.btn-icon:active { transform: scale(.95); }
.btn-icon:hover { background: var(--bg-app); }
.btn-icon.danger:hover { background: #fef2f2; color: var(--danger); }

/* ── Header ──────────────────────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 8px;
  margin-bottom: 4px;
  gap: 8px;
}
.header-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.header-right #user-name {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Auth ────────────────────────────────────────────────────────── */

.auth-shell { max-width: 380px; margin: 40px auto; padding: 0 4px; }

/* ── Bottom Navigation ──────────────────────────────────────────── */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 4px 0 calc(4px + var(--safe-bottom));
  z-index: 200;
}
.bottom-nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  padding: 8px 4px;
  background: none;
  border: none;
  font-size: .68rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s, transform .05s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav button:active { transform: scale(.95); }
.bottom-nav button.active { color: var(--primary); }
.bottom-nav button svg {
  width: 24px; height: 24px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ── Search / Suggestions ────────────────────────────────────────── */

.search-wrap { position: relative; }

.suggestions {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  max-height: 260px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 100;
}
.sg-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--bg-app);
  transition: background .1s, transform .05s;
}
.sg-item:active { transform: scale(.98); background: #f0f4ff; }
.sg-item:hover, .sg-item.active { background: #f0f4ff; }
.sg-item:last-child { border-bottom: none; }
.sg-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sg-name { font-weight: 500; font-size: .92rem; word-break: break-word; }
.sg-src {
  font-size: .7rem; font-weight: 600; padding: 2px 8px;
  border-radius: 4px; white-space: nowrap;
}
.sg-src.generic { background: #ecfdf5; color: #065f46; }
.sg-src.brand { background: #eff6ff; color: #1e40af; }
.sg-src.user { background: #fef3c7; color: #92400e; }
.sg-macros { font-size: .78rem; color: var(--text-muted); display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.sg-empty { padding: 16px; text-align: center; color: var(--text-muted); }
.sg-section-title {
  padding: 8px 16px 4px; font-size: .72rem; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--bg-app);
}

.sg-create {
  padding: 12px 16px; text-align: center; font-size: .85rem; font-weight: 600;
  color: var(--primary); cursor: pointer; border-top: 1px solid var(--border);
  transition: background .15s;
}
.sg-create:active { background: #f0f4ff; }

/* ── Search row (input + scan button) ────────────────────────────── */

.search-row { display: flex; gap: 8px; align-items: center; }
.search-row input { flex: 1; margin-bottom: 0; }
.btn-scan {
  flex-shrink: 0; padding: 8px; font-size: 1.1rem; line-height: 1;
  margin-bottom: 8px;
}

/* ── Scanner zone ────────────────────────────────────────────────── */

#scanner-zone {
  margin: 8px 0; border-radius: var(--radius); overflow: hidden;
  border: 2px solid var(--primary); background: #000;
}

.scanner-viewport { position: relative; width: 100%; min-height: 220px; overflow: hidden; }
#scanner-reader { width: 100%; height: 100%; }
#scanner-reader video { width: 100% !important; border-radius: 0 !important; }
#scanner-reader #qr-shaded-region { display: none !important; }
#scanner-reader img[alt="Info icon"] { display: none !important; }

.scan-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  pointer-events: none;
}

.scan-corners {
  width: 220px; height: 140px;
  filter: drop-shadow(0 0 6px rgba(239,68,68,.5));
  transition: filter .3s;
}
.scan-corner {
  fill: none; stroke: var(--danger); stroke-width: 4;
  stroke-linecap: round; transition: stroke .3s;
}

.scan-overlay::before {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 200px; height: 2px;
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
  animation: scanLine 2s ease-in-out infinite;
  transition: background .3s, box-shadow .3s;
}

@keyframes scanLine {
  0%, 100% { margin-top: -50px; }
  50% { margin-top: 50px; }
}

.scan-status {
  position: absolute; bottom: 12px;
  background: rgba(0,0,0,.7); color: #fff;
  padding: 4px 16px; border-radius: 24px;
  font-size: .78rem; font-weight: 600;
  transition: background .3s;
}

#scanner-zone.scan-found .scan-corner { stroke: var(--success); }
#scanner-zone.scan-found .scan-corners { filter: drop-shadow(0 0 8px rgba(22,163,74,.6)); }
#scanner-zone.scan-found .scan-overlay::before {
  background: var(--success); box-shadow: 0 0 8px var(--success); animation: none;
}
#scanner-zone.scan-found .scan-status { background: var(--success); }

#btn-scan-stop { border-radius: 0; border-top: 1px solid var(--border); background: var(--surface); }

/* ── Scan loader ─────────────────────────────────────────────────── */

.scan-loader {
  display: flex; align-items: center; gap: 16px;
  padding: 16px; margin-top: 8px;
  background: #eff6ff; border: 2px solid var(--primary);
  border-radius: var(--radius); animation: slideUp .15s ease;
}
.scan-loader div { display: flex; flex-direction: column; gap: 4px; }
.scan-loader strong { font-size: .88rem; }
.scan-loader .muted { font-size: .78rem; }

.scan-loader-spinner {
  width: 32px; height: 32px; flex-shrink: 0;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Create food form ────────────────────────────────────────────── */

.create-food-form {
  border: 2px solid var(--primary); margin-top: 8px;
  animation: slideUp .15s ease;
}
.cf-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; gap: 8px;
}

/* ── Selected food ───────────────────────────────────────────────── */

.sel-food { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.sel-info { margin-bottom: 8px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sel-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Donut chart ─────────────────────────────────────────────────── */

#macro-donut { padding: 8px 0; }

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 8px 0;
}

.donut-chart {
  position: relative;
  flex-shrink: 0;
  width: 128px; height: 128px;
}
.donut-chart svg { display: block; width: 100%; height: 100%; }
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.donut-kcal { font-size: 1.5rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.donut-unit { font-size: .7rem; color: var(--text-muted); font-weight: 600; }
.donut-target { font-size: .65rem; color: var(--text-muted); }

.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.donut-leg-item { }
.donut-leg-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .82rem;
}
.donut-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.donut-leg-label { font-weight: 600; }
.donut-leg-value { margin-left: auto; color: var(--text-muted); font-size: .78rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.donut-leg-bar {
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  margin-top: 4px;
  overflow: hidden;
}
.donut-leg-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .4s ease;
}

/* ── Date nav ────────────────────────────────────────────────────── */

.date-nav {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 0;
  position: sticky; top: 0; z-index: 50;
  background: var(--bg-app);
}
.date-nav input[type="date"] { width: auto; margin: 0; text-align: center; font-weight: 600; font-size: 16px; }
.date-nav .btn { min-width: 48px; min-height: 48px; padding: 8px; }

/* ── Diary entries ───────────────────────────────────────────────── */

.meal-group { margin: 8px 0; }
.meal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--bg-app);
  border-radius: 8px;
  font-weight: 600;
  font-size: .88rem;
  gap: 8px;
}
.meal-header > span { display: flex; align-items: center; gap: 6px; }
.meal-icon { width: 20px; height: 20px; flex-shrink: 0; color: var(--text-muted); }
.meal-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.meal-total { color: var(--text-muted); font-weight: 500; font-size: .78rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.meal-empty { color: var(--text-muted); font-size: .82rem; padding: 8px 16px; text-align: center; }

/* Bouton ajouter pleine largeur */
.btn-add-food-row {
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  border-top: 1px dashed var(--border);
  color: var(--primary);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background .15s, transform .05s;
  touch-action: manipulation;
}
.btn-add-food-row:active { background: rgba(37,99,235,.06); transform: scale(.98); }

/* ── Add panel ───────────────────────────────────────────────────── */

.add-panel { border: 2px solid var(--primary); }
.add-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; gap: 8px;
}

.diary-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  transition: background .1s, transform .05s;
}
.diary-row:active { background: var(--bg-app); transform: scale(.99); }
.diary-food { flex: 1; min-width: 0; }
.diary-name { font-size: .88rem; font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diary-brand { font-size: .75rem; color: var(--text-muted); }
.diary-qty { font-size: .78rem; color: var(--text-muted); white-space: nowrap; }
.diary-kcal { font-weight: 600; font-size: .82rem; white-space: nowrap; min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; }
.diary-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ── TDEE ────────────────────────────────────────────────────────── */

.tdee-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.tdee-card {
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 8px; background: var(--bg-app); border-radius: 8px; text-align: center;
}
.tdee-card.highlight { background: #eff6ff; border: 1px solid var(--primary); }
.tdee-label { font-size: .7rem; color: var(--text-muted); font-weight: 600; }
.tdee-value { font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tdee-sub { font-size: .7rem; color: var(--text-muted); }

.macro-split {
  display: flex; justify-content: center; gap: 24px;
  padding: 12px 0; border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.macro-split div { text-align: center; }
.macro-split b { display: block; font-size: 1.05rem; }
.macro-split span { font-size: .72rem; color: var(--text-muted); }

/* ── Toasts ──────────────────────────────────────────────────────── */

.toast-wrap {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 400px;
}
.toast {
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: .88rem;
  font-weight: 500;
  background: #1f2937;
  color: #fff;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .2s, transform .2s;
  pointer-events: auto;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ── Bouton repas type (★) ───────────────────────────────────────── */

.btn-tpl-meal {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--warn);
  border-radius: 50%;
  background: none;
  color: var(--warn);
  font-size: .9rem;
  cursor: pointer;
  transition: all .15s, transform .05s;
  line-height: 1;
  flex-shrink: 0;
  touch-action: manipulation;
}
.btn-tpl-meal:active { transform: scale(.9); }
.btn-tpl-meal:hover { background: var(--warn); color: #fff; }

/* ── Template cards (onglet Mes repas) ───────────────────────────── */

.tpl-card { margin-bottom: 8px; }
.tpl-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; gap: 8px;
}
.tpl-header > div { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.tpl-items { padding-top: 8px; }
.tpl-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0; font-size: .85rem; gap: 8px;
}

/* ── Builder rows ────────────────────────────────────────────────── */

.builder-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--bg-app);
}
.builder-food { flex: 1; font-size: .85rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.builder-kcal { font-weight: 600; font-size: .82rem; min-width: 56px; text-align: right; white-space: nowrap; }

/* ── Template picker (dans le journal) ───────────────────────────── */

.tpl-picker-list { margin-top: 8px; }
.tpl-picker-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--bg-app); gap: 8px;
}
.tpl-picker-item:last-child { border-bottom: none; }
.tpl-picker-item > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

/* ── Recipes ────────────────────────────────────────────────────── */

.recipe-pills {
  display: flex; gap: 8px; flex-wrap: nowrap; padding: 8px 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.recipe-pills::-webkit-scrollbar { display: none; }
.recipe-pill {
  padding: 8px 16px; border-radius: 24px; border: 1px solid var(--border);
  background: var(--surface); font-size: .82rem; font-weight: 600; cursor: pointer;
  color: var(--text-muted); transition: all .15s, transform .05s; white-space: nowrap; flex-shrink: 0;
  touch-action: manipulation;
}
.recipe-pill:active { transform: scale(.95); }
.recipe-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.recipe-card { cursor: pointer; transition: box-shadow .15s, transform .05s; }
.recipe-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.recipe-card:active { transform: scale(.98); }
.recipe-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.recipe-card-badges { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.recipe-card-name { font-size: .92rem; word-break: break-word; }
.recipe-badge {
  font-size: .72rem; font-weight: 600; padding: 4px 8px; border-radius: 12px;
  white-space: nowrap; flex-shrink: 0;
}
.recipe-card-meta { display: flex; gap: 8px; font-size: .78rem; color: var(--text-muted); margin-top: 8px; flex-wrap: wrap; }
.recipe-kcal { font-weight: 700; color: var(--text-main); }

.recipe-macros { display: flex; gap: 8px; margin-top: 8px; font-size: .78rem; font-weight: 600; }
.rm-p { color: var(--macro-protein); }
.rm-c { color: var(--macro-carbs); }
.rm-f { color: var(--macro-fat); }

/* Recipe detail modal — overlay plein écran */
#recipe-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,.4);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 8px calc(24px + var(--safe-bottom));
}
.recipe-detail {
  border: 2px solid var(--primary);
  max-width: 600px;
  margin: 0 auto;
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
.recipe-detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.recipe-detail-header h2 { font-size: 1.05rem; word-break: break-word; }

.recipe-macros-detail {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 8px 0; margin: 4px 0;
}
.rmd-item { text-align: center; padding: 8px 4px; background: var(--bg-app); border-radius: 8px; }
.rmd-val { display: block; font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.rmd-label { font-size: .68rem; color: var(--text-muted); font-weight: 600; }
.rmd-p .rmd-val { color: var(--macro-protein); }
.rmd-c .rmd-val { color: var(--macro-carbs); }
.rmd-f .rmd-val { color: var(--macro-fat); }

.recipe-ingredients { padding-left: 16px; font-size: .85rem; line-height: 1.7; }
.recipe-instructions { font-size: .85rem; line-height: 1.6; color: var(--text-main); white-space: pre-line; }
.recipe-allergens { font-size: .82rem; color: var(--text-muted); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }

/* ── Nutrition Agent ────────────────────────────────────────────── */

.nutri-badge { font-size: 1rem; line-height: 1; }

.nutri-panel { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.nutri-title { font-size: .95rem; margin-bottom: 8px; }

.nutri-macro-bar {
  display: flex; height: 8px; border-radius: 4px; overflow: hidden;
  background: var(--border); margin-bottom: 4px;
}
.nmb-seg { transition: width .4s ease; }
.nmb-p { background: var(--macro-protein); }
.nmb-c { background: var(--macro-carbs); }
.nmb-f { background: var(--macro-fat); }
.nutri-macro-labels { display: flex; gap: 8px; font-size: .72rem; font-weight: 600; margin-bottom: 16px; flex-wrap: wrap; }

.nutri-goals { display: flex; flex-direction: column; gap: 8px; }

.nutri-goal-card {
  padding: 12px 16px; background: var(--bg-app); border-radius: 8px;
  border: 1px solid transparent; transition: all .15s;
}
.nutri-goal-card.nutri-active { border-color: var(--primary); background: #eff6ff; }

.nutri-goal-header { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; font-weight: 600; gap: 8px; }
.nutri-you {
  font-size: .68rem; font-weight: 700; color: var(--primary);
  background: rgba(37,99,235,.1); padding: 4px 8px; border-radius: 12px;
  white-space: nowrap; flex-shrink: 0;
}

.nutri-score-row { display: flex; justify-content: space-between; align-items: center; margin: 4px 0; }
.nutri-verdict { font-size: .82rem; }
.nutri-score { font-size: .75rem; color: var(--text-muted); font-weight: 600; }

.nutri-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.nutri-bar-fill { height: 100%; border-radius: 4px; transition: width .4s ease; }

.nutri-tips { padding-left: 16px; margin-top: 8px; font-size: .75rem; color: var(--text-muted); line-height: 1.5; }
.nutri-tips li { margin-bottom: 4px; }

/* ── Weight tracking ─────────────────────────────────────────────── */

.wt-form {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.wt-form input.input-sm { flex: 0 0 auto; }
.wt-note-input { flex: 1 1 120px !important; min-width: 100px; }

.wt-goal-card { padding: 4px 0; }
.wt-goal-header {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: .88rem;
}
.wt-goal-progress {
  display: flex; justify-content: space-between; align-items: center;
  margin: 8px 0 4px; font-size: .82rem;
}
.wt-goal-form .wt-form { margin-bottom: 0; }

.wt-chart-svg { width: 100%; height: auto; display: block; }

.wt-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--bg-app);
  font-size: .85rem;
}
.wt-row:last-child { border-bottom: none; }
.wt-row-date { color: var(--text-muted); min-width: 48px; font-size: .82rem; }
.wt-row-kg { min-width: 64px; font-variant-numeric: tabular-nums; }
.wt-row-diff { min-width: 48px; font-size: .82rem; font-weight: 600; }
.wt-row-note { flex: 1; font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.wt-row-del { flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE — petit écran (< 400px)
   ══════════════════════════════════════════════════════════════════ */

@media (max-width: 400px) {
  body { padding: 0 8px calc(72px + var(--safe-bottom)); }

  .card { padding: 12px; margin: 8px 0; }

  .app-header { padding: 8px 0; }

  .grid-2 { grid-template-columns: 1fr; }

  .donut-wrap { flex-direction: column; gap: 16px; }
  .donut-chart { width: 120px; height: 120px; }
  .donut-kcal { font-size: 1.2rem; }

  .diary-row { padding: 8px; gap: 4px; }
  .diary-name { font-size: .82rem; }
  .diary-kcal { font-size: .78rem; min-width: 48px; }

  .meal-header { padding: 8px; font-size: .82rem; }

  .tdee-cards { grid-template-columns: 1fr; }
  .tdee-value { font-size: 1rem; }

  .recipe-macros-detail { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .rmd-val { font-size: .95rem; }

  .recipe-detail-header h2 { font-size: .95rem; }

  #recipe-modal { padding: 8px 8px calc(16px + var(--safe-bottom)); }

  .nutri-goal-header { font-size: .82rem; }

  .auth-shell { margin: 24px auto; }

  .wt-form { gap: 4px; }
  .wt-row-note { font-size: .72rem; }
}

/* ── Écran moyen (400-480px) ─────────────────────────────────────── */

@media (max-width: 480px) and (min-width: 401px) {
  .grid-2 { grid-template-columns: 1fr; }
  .donut-wrap { flex-direction: column; }
  .tdee-cards { grid-template-columns: 1fr; }
}
