/* ---------- Polices (embarquées, pour fonctionner hors ligne) ---------- */

@font-face {
  font-family: 'Fraunces';
  src: url('../fonts/fraunces.woff2') format('woff2');
  font-weight: 600 700;
  font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('../fonts/dm-sans.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'DM Mono';
  src: url('../fonts/dm-mono-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'DM Mono';
  src: url('../fonts/dm-mono-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}

/* ---------- Palette (maquette/*.dc.html) ---------- */

:root {
  --bg: #F4F1EA;
  --surface: #FFFFFF;
  --ink: #1F2A24;
  --ink-soft: #4A564E;
  --muted: #5E6B62;
  --faint: #9AA59D;
  --border: #D9D3C5;
  --divider: #ECE8DE;

  --courses: #2F6B4F;
  --courses-dark: #1F4D38;
  --articles: #B5542A;
  --tendances: #2C5A8C;
  --recettes: #7A4E8E;

  /* Couleur de la section courante (redéfinie par chaque écran) */
  --accent: var(--courses);

  --danger: #B3261E;
  --danger-bg: #FBE9E7;
  --danger-ink: #5C1A14;
  --success-bg: #E2EFE6;
  --promo-bg: #F6E6D9;
  --promo-ink: #8A3F1C;

  --serif: 'Fraunces', Georgia, serif;
  --sans: 'DM Sans', system-ui, -apple-system, sans-serif;
  --mono: 'DM Mono', ui-monospace, monospace;

  /* Marges de sécurité (encoche, barre d'accueil) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  color-scheme: light;
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--courses); }

/* Sur iPhone, un champ en dessous de 16 px fait zoomer la page au focus. */
input, select, textarea { font-size: 16px; }

:focus-visible {
  outline: 2.5px solid var(--ink);
  outline-offset: 2px;
  border-radius: 10px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.noscript { padding: 24px; font-family: var(--sans); }

/* ---------- Écrans ---------- */

.screen {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding:
    calc(var(--safe-top) + 8px)
    calc(var(--safe-right) + 20px)
    calc(var(--safe-bottom) + 24px)
    calc(var(--safe-left) + 20px);
  animation: push-in 260ms cubic-bezier(.2, .8, .2, 1);
}

.screen--home {
  padding:
    calc(var(--safe-top) + 24px)
    calc(var(--safe-right) + 28px)
    calc(var(--safe-bottom) + 32px)
    calc(var(--safe-left) + 28px);
  animation-name: fade-in;
}

@keyframes push-in {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
}

/* ---------- Textes ---------- */

.eyebrow {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.display, .title, .title-small {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-optical-sizing: auto;
  line-height: 1.1;
}
.display { font-size: 40px; }
.title { font-size: 34px; }
.title-small { font-size: 28px; line-height: 1.15; }

.lead { margin: 0; font-size: 16px; line-height: 1.5; color: var(--ink-soft); }
.summary { margin: 0; font-size: 15px; color: var(--ink-soft); }

.section-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Accueil ---------- */

.home-header { display: flex; flex-direction: column; gap: 8px; }

.home-grid {
  margin-top: 40px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 16px;
}

.home-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-radius: 20px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  touch-action: manipulation;
}

.home-tile__icon {
  width: 92px;
  height: 92px;
  border-radius: 26px;
  background: var(--accent);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(31, 42, 36, 0.16);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.home-tile:active .home-tile__icon {
  transform: scale(0.94);
  box-shadow: 0 3px 8px rgba(31, 42, 36, 0.16);
}

/* ---------- En-tête des sections ---------- */

.section-header { display: flex; flex-direction: column; gap: 6px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  min-height: 44px;
  padding: 0 8px 0 0;
  border: none;
  background: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--courses);
  text-decoration: none;
  touch-action: manipulation;
}
.back-link:active { color: var(--courses-dark); }

.section-body {
  flex-grow: 1;
  min-height: 0;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- Cartes ---------- */

.card {
  padding: 16px;
  background: var(--surface);
  border-radius: 18px;
}


.empty-line { margin: 24px 0; text-align: center; color: var(--muted); }
.empty__title { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.empty__text { margin: 0; line-height: 1.45; color: var(--ink-soft); }

/* ---------- Barres du haut (fiche, formulaire) ---------- */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
}

.top-bar__title { margin: 0; font-size: 16px; font-weight: 600; }

.pill-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  touch-action: manipulation;
}
.pill-button--accent { border: none; background: var(--accent); color: #FFFFFF; }
.pill-button:disabled { opacity: 0.6; }

.text-button {
  min-height: 44px;
  padding: 0 4px;
  border: none;
  background: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--courses);
  touch-action: manipulation;
}
.text-button--muted { color: var(--ink-soft); }

/* ---------- Champs ---------- */

.field {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
}
.field::placeholder { color: var(--muted); opacity: 1; }
.field:focus { outline: none; border-color: var(--ink); }
.field[aria-invalid='true'] { border-color: var(--danger); }
.field--mono { font-family: var(--mono); letter-spacing: 0.06em; }

select.field {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%231F2A24' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

input[type='search']::-webkit-search-cancel-button { -webkit-appearance: none; }

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
}
.field-label { padding: 0; font-size: 14px; font-weight: 600; }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-error { margin: 0; font-size: 14px; line-height: 1.4; color: var(--danger); }

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--surface);
}
.segmented__option { position: relative; display: flex; }
.segmented__option input { position: absolute; opacity: 0; pointer-events: none; }
.segmented__option span {
  flex-grow: 1;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.segmented__option input:checked + span { background: var(--ink); color: #FFFFFF; }
.segmented__option input:focus-visible + span { outline: 2.5px solid var(--ink); outline-offset: 2px; }

.form { display: flex; flex-direction: column; gap: 16px; }
.form__note { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }

/* ---------- Liste : recherche, filtres, lignes ---------- */

.toolbar { display: flex; gap: 8px; align-items: center; }
.toolbar .field { flex-grow: 1; padding: 0 16px; }

.icon-button {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  touch-action: manipulation;
}
.icon-button--accent { border: none; background: var(--accent); color: #FFFFFF; }
.icon-button:active { transform: scale(0.96); }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -20px;
  padding: 4px 20px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  position: relative;
  flex-shrink: 0;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  touch-action: manipulation;
}
/* Zone tactile de 44 px autour d'une pastille de 36 px */
.chip::after { content: ''; position: absolute; inset: -4px 0; }
.chip[aria-pressed='true'] { border-color: var(--ink); background: var(--ink); color: #FFFFFF; }

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

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px 10px 10px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  touch-action: manipulation;
}
.row:active { background: #FBFAF7; }

.thumb {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  object-fit: cover;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
}

.row__main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row__title { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.row__meta { font-size: 13px; color: var(--muted); }
.row__end { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.row__end .row__meta { font-size: 12px; }
.row__price { font-size: 15px; font-weight: 600; }
.row__price.is-empty { color: var(--faint); }

/* ---------- Fiche ---------- */

.stack { margin-top: 8px; display: flex; flex-direction: column; gap: 14px; }

.photo-area { display: flex; flex-direction: column; align-items: center; gap: 4px; }

.photo {
  position: relative;
  width: 100%;
  height: 110px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 18px;
  border: 2px dashed var(--faint);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.photo--large { height: 150px; flex-direction: column; gap: 8px; border-radius: 20px; font-size: 14px; }
/* Photo entière (pas recadrée), sur fond blanc */
.photo.has-photo { height: 200px; border: none; background: var(--surface); }
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.photo__change {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(31, 42, 36, 0.72);
  color: #FFFFFF;
  font-size: 13px;
}
.photo:has(input:focus-visible) { outline: 2.5px solid var(--ink); outline-offset: 2px; }

.detail-head { display: flex; flex-direction: column; gap: 6px; }
.detail-head__tags { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.detail-head__sub { font-size: 14px; color: var(--ink-soft); }
.detail-head .title-small { overflow-wrap: anywhere; }

.badge { padding: 4px 10px; border-radius: 12px; font-size: 13px; font-weight: 600; }

.card { display: flex; flex-direction: column; gap: 10px; }
.card .section-label { margin: 0; }
.card__text { margin: 0; font-size: 14px; line-height: 1.45; color: var(--ink-soft); }

.barcode { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.barcode svg { fill: var(--ink); max-width: 100%; }
.barcode__digits { font-family: var(--mono); font-size: 15px; letter-spacing: 0.12em; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat__label { font-size: 12px; color: var(--muted); }
.stat__value { font-size: 16px; font-weight: 600; }

.label-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.label-chip { padding: 6px 10px; border-radius: 8px; background: var(--bg); font-family: var(--mono); font-size: 13px; }

.button {
  flex-grow: 1;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  touch-action: manipulation;
}
.button--outline { border: 1.5px solid var(--border); background: var(--surface); color: var(--ink); }
.button--danger { border: none; background: var(--danger); color: #FFFFFF; }
.button--danger-outline { border: 1.5px solid var(--danger); background: none; color: var(--danger); }

.confirm {
  padding: 14px;
  border-radius: 14px;
  background: var(--danger-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.confirm p { margin: 0; font-size: 14px; line-height: 1.45; color: var(--danger-ink); }
.confirm__buttons { display: flex; gap: 8px; }
.confirm .button { min-height: 44px; border-radius: 12px; }

/* ---------- Messages ---------- */

.notice {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--success-bg);
  color: var(--courses-dark);
  font-size: 14px;
  line-height: 1.45;
}
.notice.is-busy { background: var(--surface); color: var(--ink-soft); }

.field-row { display: flex; gap: 8px; }
.text-button--start { align-self: flex-start; padding: 0; }

/* ---------- Lecteur de codes-barres ---------- */

.scanner {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #000000;
  color: #FFFFFF;
}

.scanner__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Cadre de visée, et assombrissement autour */
.scanner__frame {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(86vw, 420px);
  height: min(34vw, 170px);
  transform: translate(-50%, -50%);
  border: 3px solid #FFFFFF;
  border-radius: 18px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
}

.scanner__top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(var(--safe-top) + 8px) 16px 0;
  display: flex;
}

.scanner__close,
.scanner__manual {
  min-height: 44px;
  padding: 0 16px;
  border: none;
  border-radius: 22px;
  background: rgba(31, 42, 36, 0.8);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.scanner__bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 24px calc(var(--safe-bottom) + 28px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.scanner__message {
  margin: 0;
  max-width: 340px;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.45;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.app-footer { margin: auto 0 0; padding-top: 32px; text-align: center; font-size: 13px; line-height: 1.5; color: var(--muted); }
.app-footer p { margin: 0; }

/* ---------- Articles à valider ---------- */

.home-tile__icon { position: relative; }
.home-tile__badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 13px;
  border: 2.5px solid var(--bg);
  background: var(--danger);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  line-height: 21px;
  text-align: center;
}

.chip--alert { border-color: var(--articles); color: var(--promo-ink); background: var(--promo-bg); }
.chip--alert[aria-pressed='true'] { border-color: var(--articles); background: var(--articles); color: #FFFFFF; }

.status-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--promo-bg);
  color: var(--promo-ink);
  font-size: 12px;
  font-weight: 600;
}

.notice--action { display: flex; flex-direction: column; gap: 4px; }
.notice--action p { margin: 0; }

.review {
  padding: 14px;
  border-radius: 16px;
  background: var(--promo-bg);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.review__title { margin: 0; font-size: 15px; font-weight: 700; color: var(--promo-ink); }
.review__text { margin: 0; font-size: 14px; line-height: 1.45; color: var(--ink); }
.review__actions { display: flex; gap: 8px; margin-top: 6px; }
.review .button { min-height: 44px; border-radius: 12px; }

.button--accent { border: none; background: var(--accent); color: #FFFFFF; }
.button:disabled { opacity: 0.6; }

/* ---------- Courses ---------- */

.top-bar--compact { min-height: 44px; }

.chip--tab { min-height: 40px; padding: 0 16px; border-radius: 20px; }
.chip--tab::after { inset: -2px 0; }
.chip[aria-selected='true'] { border-color: var(--ink); background: var(--ink); color: #FFFFFF; }
.chip--add { border-style: dashed; border-color: var(--faint); background: none; color: var(--ink-soft); font-weight: 500; }

.add-bar { display: flex; flex-direction: column; gap: 6px; }

.suggestions {
  margin: 0;
  padding: 4px;
  list-style: none;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(31, 42, 36, 0.1);
}
.suggestion {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: none;
  border-radius: 10px;
  background: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  text-align: left;
  font-size: 15px;
  font-weight: 600;
}
.suggestion:active { background: var(--bg); }
.suggestion__meta { flex-shrink: 0; font-size: 13px; font-weight: 400; color: var(--muted); }

.items { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }

.item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px 6px 6px;
  border-radius: 14px;
  background: var(--surface);
  transition: opacity 150ms ease;
}
.item.is-checked { opacity: 0.55; }

.item__check {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.checkbox {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 2px solid var(--faint);
  background: var(--surface);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
}
.is-checked .checkbox { border-color: var(--accent); background: var(--accent); }

.item__body {
  flex-grow: 1;
  min-width: 0;
  min-height: 48px;
  padding: 4px 0;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  text-align: left;
  touch-action: manipulation;
}
.item__name { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.is-checked .item__name { text-decoration: line-through; }
.item__meta { font-size: 13px; color: var(--muted); }
.item__price { flex-shrink: 0; font-size: 15px; font-weight: 600; }
.item__price.is-empty { color: var(--faint); }

/* ---------- Fenêtres (du bas de l'écran) ---------- */

.sheet { position: fixed; inset: 0; z-index: 20; }

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 42, 36, 0.4);
  animation: fade-in 180ms ease;
}

.sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  max-height: calc(100dvh - var(--safe-top) - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px calc(var(--safe-right) + 20px) calc(var(--safe-bottom) + 20px) calc(var(--safe-left) + 20px);
  border-radius: 22px 22px 0 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slide-up 240ms cubic-bezier(.2, .8, .2, 1);
}
.sheet__panel--tall { height: calc(100dvh - var(--safe-top) - 24px); }

@keyframes slide-up {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet__panel, .sheet__backdrop { animation: none; }
}

.sheet__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet__title { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.sheet__buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

.stepper-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 8px 8px 16px;
  border-radius: 14px;
  background: var(--surface);
}
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 22px;
  touch-action: manipulation;
}
.stepper span { min-width: 64px; text-align: center; font-size: 17px; font-weight: 600; }

/* ---------- Scan en continu (caméra en haut, liste en bas) ---------- */

.scanner--split { display: flex; flex-direction: column; --camera-h: 46dvh; }

.scanner__camera {
  position: relative;
  flex-shrink: 0;
  height: var(--camera-h);
  overflow: hidden;
  background: #000000;
}
.scanner--split .scanner__frame { height: min(30vw, 130px); }

.scanner__top--split {
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.scanner__count {
  min-width: 0;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(31, 42, 36, 0.8);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.scanner__done {
  flex-shrink: 0;
  min-height: 48px;
  padding: 0 22px;
  border: none;
  border-radius: 24px;
  background: var(--courses);
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.scanner__panel {
  flex-grow: 1;
  min-height: 0;
  overflow-y: auto;
  margin-top: -18px;
  border-radius: 20px 20px 0 0;
  background: var(--bg);
  color: var(--ink);
  position: relative;
}

.scan-list {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--safe-bottom) + 24px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.scan-list__title { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink-soft); }

/* Cartes des articles scannés */
.flights { position: absolute; inset: 0; pointer-events: none; z-index: 2; }

.flight {
  position: absolute;
  left: calc(50% - 115px);
  top: calc(var(--camera-h) / 2 - 90px);
  width: 230px;
  padding: 16px 14px 14px;
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  opacity: 0;
  will-change: transform, opacity;
}

.flight__photo {
  width: 84px;
  height: 84px;
  border-radius: 16px;
  object-fit: contain;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 700;
}
.flight__name { font-size: 16px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.flight__sub { font-size: 13px; font-weight: 600; color: var(--courses); }

/* ---------- Classement par catégorie ---------- */

.list-tools { display: flex; justify-content: flex-end; margin: -4px 0 -6px; }

.switch {
  min-height: 44px;
  padding: 0;
  border: none;
  background: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  touch-action: manipulation;
}
.switch__track {
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: var(--border);
  position: relative;
  transition: background 150ms ease;
}
.switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 150ms ease;
}
.switch[aria-checked='true'] .switch__track { background: var(--accent); }
.switch[aria-checked='true'] .switch__thumb { transform: translateX(18px); }

.items__heading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.items__heading:first-child { padding-top: 0; }
.items__dot { width: 10px; height: 10px; border-radius: 50%; }
.items__count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--faint);
}
.chips--wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 4px 0; }

/* ---------- Saisie d'un achat ---------- */

.sheet__subtitle { margin: 2px 0 0; font-size: 14px; color: var(--ink-soft); }

.field-with-unit { position: relative; display: flex; }
.field-with-unit .field { padding-right: 72px; font-size: 18px; font-weight: 600; }
.field-with-unit__unit {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  color: var(--muted);
  pointer-events: none;
}

.field-pair--center { align-items: end; }
.field-pair--center .switch { min-height: 48px; }

.button-row { display: flex; gap: 8px; }
.button--link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

.text-button--danger { align-self: flex-start; padding: 0; color: var(--danger); }

/* ---------- Tendances ---------- */

.chart-card { gap: 14px; }
.chart-card__head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.chart-card__label { margin: 0 0 2px; font-size: 14px; color: var(--muted); }
.chart-card__price { margin: 0; font-family: var(--serif); font-size: 32px; font-weight: 700; line-height: 1.1; }

.change-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 14px;
  background: var(--bg);
  font-size: 14px;
  font-weight: 600;
  text-align: right;
}
.change-badge.is-up svg { color: var(--danger); }
.change-badge.is-down svg { color: var(--courses); }

.chart { position: relative; width: 100%; }
.chart__grid { position: absolute; right: 8px; height: 1px; background: var(--divider); }
.chart__ylabel { position: absolute; left: 0; width: 38px; font-size: 11px; color: var(--muted); text-align: right; }
.chart__line { position: absolute; left: 0; top: 0; overflow: visible; }
.chart__line path { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__xlabel { position: absolute; top: 172px; font-size: 11px; color: var(--muted); }

.chart__point {
  position: absolute;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.chart__point span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--surface);
}
.chart__point.is-selected span { width: 14px; height: 14px; background: var(--accent); }

.chart__tip {
  position: absolute;
  width: 112px;
  padding: 6px 8px;
  border-radius: 10px;
  background: var(--ink);
  color: #FFFFFF;
  text-align: center;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}
.chart__tip strong { font-size: 14px; font-weight: 600; }
.chart__tip span { font-size: 11px; opacity: 0.85; }

.stats--line { padding-top: 12px; border-top: 1px solid var(--divider); }
.stats--line .stat__value { font-size: 15px; }

.history { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.history__row {
  width: 100%;
  min-height: 48px;
  padding: 6px 8px;
  border: none;
  border-radius: 10px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  touch-action: manipulation;
}
.history__row[aria-pressed='true'] { background: #EEF2F7; }
.history__main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.history__date { font-size: 15px; font-weight: 600; }
.history__shop { font-size: 13px; color: var(--muted); }
.history__price { flex-shrink: 0; font-size: 15px; font-weight: 600; }

.promo-badge {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--promo-bg);
  color: var(--promo-ink);
  font-size: 12px;
  font-weight: 600;
}

/* ---------- Monnaie (accueil) ---------- */

.home-header__top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.currency { position: relative; }

.currency__button {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 22px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  touch-action: manipulation;
}

.currency__backdrop { position: fixed; inset: 0; z-index: 5; }

.currency__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 6;
  width: min(300px, calc(100vw - 40px));
  max-height: 62dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(31, 42, 36, 0.2);
  animation: fade-in 140ms ease;
}

.currency__title { margin: 4px 10px 6px; font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

.currency__row { display: flex; align-items: center; }

.currency__item {
  flex-grow: 1;
  min-width: 0;
  min-height: 44px;
  padding: 6px 10px;
  border: none;
  border-radius: 10px;
  background: none;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  font-size: 15px;
}
.currency__item[aria-checked='true'] { background: var(--bg); font-weight: 600; }
.currency__item:active { background: var(--bg); }
.currency__symbol { flex-shrink: 0; min-width: 48px; font-weight: 700; }
.currency__name { flex-grow: 1; min-width: 0; }

.currency__edit {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0 8px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--courses);
}

.currency__add {
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  border: 1.5px dashed var(--faint);
  border-radius: 12px;
  background: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.currency__note { margin: 8px 10px 4px; font-size: 13px; line-height: 1.4; color: var(--muted); }

.segmented--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------- Gestion des catégories ---------- */

.sheet__hint { margin: -4px 0 0; font-size: 14px; line-height: 1.45; color: var(--muted); }

.category-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }

.category-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 12px;
  border-radius: 14px;
  background: var(--surface);
}
.category-row__dot { width: 18px; height: 18px; flex-shrink: 0; border-radius: 6px; border: 2px solid; }
.category-row__main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; padding-left: 4px; }
.category-row__name { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.category-row__count { font-size: 12px; color: var(--muted); }
.category-row .text-button { padding: 0 6px; font-size: 14px; }

.icon-button--small { width: 40px; height: 40px; border-radius: 12px; }
.icon-button:disabled { opacity: 0.35; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2.5px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}
.swatch input:checked + span { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface) inset; }
.swatch input:focus-visible + span { outline: 2.5px solid var(--ink); outline-offset: 2px; }

/* ---------- Recettes ---------- */

.button--dashed {
  min-height: 52px;
  border: 1.5px dashed var(--faint);
  background: var(--surface);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}
.button--big {
  min-height: 56px;
  border-radius: 16px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.recipe-cards { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.recipe-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  touch-action: manipulation;
}
.recipe-card > svg { flex-shrink: 0; color: var(--faint); }
.recipe-card__icon {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.recipe-card__main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.recipe-card__name { font-size: 17px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.recipe-card__meta { font-size: 13px; color: var(--muted); }

.ingredients { padding: 12px; gap: 4px; }
.ingredients__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 0 4px 6px; }
.ingredients__hint { font-size: 13px; color: var(--muted); }
.ingredients__list { margin: 0; padding: 0; list-style: none; }

.ingredient {
  width: 100%;
  min-height: 48px;
  padding: 4px;
  border: none;
  border-radius: 10px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  touch-action: manipulation;
}
.ingredient .checkbox { flex-shrink: 0; border-color: var(--accent); background: var(--accent); }
.ingredient.is-owned { opacity: 0.5; }
.ingredient.is-owned .checkbox { border-color: var(--faint); background: var(--surface); }
.ingredient.is-owned .ingredient__name { text-decoration: line-through; }
.ingredient__name { flex-grow: 1; min-width: 0; font-size: 15px; overflow-wrap: anywhere; }
.ingredient__qty { flex-shrink: 0; font-size: 15px; font-weight: 600; }

.recipe-notes { white-space: pre-wrap; font-size: 15px; color: var(--ink); }

.added-banner {
  min-height: 56px;
  padding: 8px 8px 8px 16px;
  border-radius: 16px;
  background: var(--success-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--courses-dark);
}
.added-banner__link {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--surface);
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--courses-dark);
  text-decoration: none;
}

/* Formulaire : une ligne par ingrédient (nom, puis quantité et unité) */
.ingredient-rows { margin: 0 0 4px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ingredient-row {
  padding: 8px;
  border-radius: 14px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ingredient-row .field { height: 44px; border-radius: 10px; }
.ingredient-row__name { position: relative; }
.ingredient-row__linked {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--success-bg);
  color: var(--courses-dark);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}
.ingredient-row__amount { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) 40px; gap: 6px; align-items: center; }
.ingredient-row .suggestions { box-shadow: none; border: 1.5px solid var(--border); }

.field--area { height: auto; min-height: 120px; padding: 12px 14px; line-height: 1.45; resize: vertical; }

/* ---------- Recettes : import, photo, temps ---------- */

.button-row .button--dashed { flex: 1; min-width: 0; padding: 0 10px; font-size: 15px; font-weight: 600; }
.recipe-card__photo { object-fit: cover; background: var(--bg); }
.recipe-photo { width: 100%; height: 200px; border-radius: 20px; object-fit: cover; background: var(--surface); }
.recipe-times { margin: 0; font-size: 14px; color: var(--ink-soft); }
.source-link { align-self: flex-start; min-height: 44px; display: inline-flex; align-items: center; font-size: 14px; font-weight: 600; color: var(--recettes); }
.field-row .pill-button { flex-shrink: 0; min-height: 48px; }

.cost-card__total { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 700; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.cost-card__per { font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--ink-soft); }

/* ---------- Conversion de monnaie ---------- */

.conversion-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--safe-bottom) + 12px);
  z-index: 8;
  max-width: 456px;
  margin: 0 auto;
  padding: 12px 8px 12px 16px;
  border-radius: 16px;
  background: var(--ink);
  color: #FFFFFF;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  animation: slide-up 240ms cubic-bezier(.2, .8, .2, 1);
}
.conversion-banner.is-done { background: var(--courses-dark); }
.conversion-banner p { margin: 0; flex-grow: 1; font-size: 14px; line-height: 1.45; }
.conversion-banner__close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin: -6px 0;
  border: none;
  border-radius: 10px;
  background: none;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
}
.currency__note a { color: inherit; }

/* ---------- Glissement des lignes d'articles ---------- */

.swipe { position: relative; border-radius: 14px; overflow: hidden; background: var(--surface); }
.swipe .row {
  position: relative;
  z-index: 1;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 220ms cubic-bezier(.2, .8, .2, 1);
}
.swipe__actions {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  visibility: hidden;
}
.swipe.is-dragging .swipe__actions { visibility: visible; }
.swipe[data-dir='left'] .swipe__actions { background: var(--courses); }
.swipe[data-dir='right'] .swipe__actions { background: var(--tendances); }
.swipe__action {
  width: 64px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  opacity: 0.7;
  transition: transform 150ms ease, opacity 150ms ease;
}
.swipe[data-dir='left'] .swipe__action--right,
.swipe[data-dir='right'] .swipe__action--left { visibility: hidden; }
.swipe.is-armed .swipe__action { opacity: 1; transform: scale(1.08); }

.tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 8px 10px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1.5px dashed var(--border);
}
.tip p { margin: 0; flex-grow: 1; font-size: 14px; line-height: 1.45; color: var(--ink-soft); }
.tip__close { flex-shrink: 0; width: 32px; height: 32px; border: none; border-radius: 8px; background: none; color: var(--muted); display: flex; align-items: center; justify-content: center; }

.picker { display: flex; flex-direction: column; gap: 8px; }
.picker__option {
  min-height: 52px;
  padding: 0 16px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
  text-align: left;
}
.picker__option svg { color: var(--courses); flex-shrink: 0; }
.picker--wrap { flex-direction: row; flex-wrap: wrap; }
.picker__category {
  min-height: 48px;
  padding: 0 16px;
  border: 2.5px solid transparent;
  border-radius: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
}
.button--icon { display: flex; align-items: center; justify-content: center; gap: 8px; }

/* ---------- Réglages et sauvegarde ---------- */

.home-header__actions { display: flex; align-items: center; gap: 8px; }
.icon-button--round { width: 44px; height: 44px; border-radius: 22px; }

.backup-last { margin: 0; font-size: 14px; font-weight: 600; }
.button--file { cursor: pointer; }
.button--file:has(input:focus-visible) { outline: 2.5px solid var(--ink); outline-offset: 2px; }

.backup-reminder {
  margin-top: 28px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1.5px dashed var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink-soft);
  text-decoration: none;
}
.backup-reminder svg { flex-shrink: 0; color: var(--courses); }
.backup-reminder strong { color: var(--courses); }
