/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg: #0f1419;
  --bg-card: #1a2332;
  --bg-elevated: #243044;
  --bg-soft: #1e2a3c;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --accent: #3dd68c;
  --accent-dim: #2a9d6a;
  /* Relevé de #2d3f56 : les séparateurs tombaient à 1,47:1 sur les cartes,
     quasi invisibles. On vise ~3:1, le minimum pour un élément d'interface. */
  --border: #3d5372;
  --score-green: #3dd68c;
  --score-orange: #f5a623;
  --score-red: #ef5350;
  --alert-bg: rgba(239, 83, 80, 0.12);
  --alert-border: rgba(239, 83, 80, 0.4);
  --warning-bg: rgba(245, 166, 35, 0.12);
  --warning-border: rgba(245, 166, 35, 0.4);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
  --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);
}

/* ── Icônes ────────────────────────────────────────────────────
   Un seul jeu, un seul tracé, une seule échelle. Les emoji précédents se
   dessinaient différemment sur chaque plateforme et ne pouvaient pas être
   colorés — ici tout hérite de currentColor. */
.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--sm {
  width: 1rem;
  height: 1rem;
}

.icon--lg {
  width: 1.75rem;
  height: 1.75rem;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(61, 214, 140, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(45, 63, 86, 0.4), transparent);
  pointer-events: none;
  z-index: -1;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

/* ── App shell ─────────────────────────────────────────────────
   Coquille d'application : hauteur d'écran fixe, en-tête et scène qui ne
   défilent pas. Seuls le contenu du panneau résultat défile. C'est ce qui
   donne la sensation « app » et supprime le score sous la ligne de flottaison.
   ─────────────────────────────────────────────────────────────── */
.app {
  position: fixed;
  inset: 0;
  max-width: 640px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

/* ── Barre d'application ───────────────────────────────────────
   Plus de position:sticky ni de backdrop-filter : la barre est hors du flux
   de défilement, donc rien à flouter en continu pendant le scroll.
   ─────────────────────────────────────────────────────────────── */
.appbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding:
    calc(0.6rem + var(--safe-top))
    calc(1rem + var(--safe-right))
    0.6rem
    calc(1rem + var(--safe-left));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.appbar__logo {
  font-size: 1.75rem;
  line-height: 1;
}

.appbar__title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent) 0%, #6ee7b7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.appbar__sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.2;
}

/* ── Scène (caméra + commandes) ────────────────────────────── */
/* Contenu tassé en haut, et non étiré : ancrer les commandes en bas creusait
   un vide au milieu — et surtout, le panneau résultat en position basse
   (190 px) venait recouvrir le bouton caméra et la saisie manuelle. */
.stage {
  display: grid;
  grid-template-rows: auto auto;
  align-content: start;
  min-height: 0;
  /* min-width:0 casse le piège classique grid/flex : sans lui, une rangée
     enfant qui ne doit que défiler horizontalement (l'historique) pousse la
     largeur de toute la mise en page au lieu de rester contenue. */
  min-width: 0;
  padding:
    0.75rem
    calc(1rem + var(--safe-right))
    calc(0.75rem + var(--safe-bottom))
    calc(1rem + var(--safe-left));
  gap: 0.75rem;
  /* Filet de sécurité : si le contenu dépasse malgré tout (petit écran), on
     défile plutôt que de laisser l'historique caché sous le panneau résultat,
     qui est en position fixe et couvre toujours le bas de l'écran. */
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.stage__controls {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  min-width: 0;
}

.controls-row {
  display: flex;
  gap: 0.5rem;
}

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

/* ── Zone caméra ───────────────────────────────────────────── */
/* Plafonnée et resserrée : au repos, la case ne sert qu'à indiquer où pointer
   la caméra — elle ne doit pas manger l'espace de l'historique, qui est
   souvent le seul repère visible sous le panneau résultat (position fixe,
   toujours au-dessus). Elle s'agrandit une fois la caméra allumée : c'est
   à ce moment-là seulement qu'on a besoin de voir large. */
.scanner-wrap {
  position: relative;
  width: 100%;
  min-height: 0;
  /* Hauteur en unités absolues : un pourcentage dans une rangée « auto » est
     circulaire, et faisait s'effondrer la zone à 0. */
  height: clamp(130px, 22dvh, 210px);
  align-self: start;
  border-radius: var(--radius);
  background: #0b0f14;
  border: 1px solid var(--border);
  overflow: hidden;
  isolation: isolate;
  /* Pas de transition sur height : ce serait animer le layout, précisément ce
     qu'on a supprimé sur les barres de piliers. Le passage est instantané. */
}

.scanner-wrap--active {
  height: clamp(220px, 38dvh, 340px);
}

.scanner-viewport {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #000;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.scanner-wrap--active .scanner-viewport {
  opacity: 1;
}

/* État au repos : la caméra est éteinte */
.scanner-idle {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  text-align: center;
  padding: 1.5rem;
  transition: opacity 0.2s ease;
}

.scanner-wrap--active .scanner-idle {
  opacity: 0;
  pointer-events: none;
}

/* width/height explicites : font-size n'a aucun effet sur un SVG dimensionné */
.scanner-idle__icon {
  width: 2.75rem;
  height: 2.75rem;
  stroke-width: 1.5;
  opacity: 0.45;
  margin-bottom: 0.25rem;
}

.scanner-idle__text {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.scanner-idle__hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Guide de scan — grille 3 bandes, toujours au-dessus de la vidéo */
.scan-guide {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 100;
  flex-direction: column;
  pointer-events: none;
}

.scanner-wrap--active .scan-guide {
  display: flex;
}

.scan-guide__band--top,
.scan-guide__band--bottom,
.scan-guide__side {
  background: rgba(0, 0, 0, 0.58);
}

.scan-guide__band--top,
.scan-guide__band--bottom {
  flex: 1 1 0;
  min-height: 0;
}

.scan-guide__band--middle {
  flex: 0 0 clamp(96px, 28vw, 132px);
  display: flex;
  flex-direction: row;
  width: 100%;
}

.scan-guide__side {
  flex: 1 1 0;
  min-width: 0;
}

.scan-guide__target {
  position: relative;
  flex: 0 0 78%;
  width: 78%;
  border: 5px solid #ffca28;
  border-radius: 12px;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.85),
    inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  background: transparent;
}

.scan-guide__line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  background: #ff1744;
  box-shadow: 0 0 10px #ff1744;
  animation: scan-line-pulse 1.2s ease-in-out infinite;
}

@keyframes scan-line-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.scan-guide__corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 4px solid #fff;
}

.scan-guide__corner--tl {
  top: -2px;
  left: -2px;
  border-right: none;
  border-bottom: none;
  border-radius: 8px 0 0 0;
}

.scan-guide__corner--tr {
  top: -2px;
  right: -2px;
  border-left: none;
  border-bottom: none;
  border-radius: 0 8px 0 0;
}

.scan-guide__corner--bl {
  bottom: -2px;
  left: -2px;
  border-right: none;
  border-top: none;
  border-radius: 0 0 0 8px;
}

.scan-guide__corner--br {
  bottom: -2px;
  right: -2px;
  border-left: none;
  border-top: none;
  border-radius: 0 0 8px 0;
}

.scan-status {
  font-size: 0.8125rem;
  text-align: center;
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
}

.scan-status--info {
  color: var(--text-muted);
  background: var(--surface-2, rgba(0, 0, 0, 0.04));
}

.scan-status--pending {
  color: #9a6700;
  background: rgba(255, 193, 7, 0.15);
}

.scan-status--success {
  color: #1a6b2e;
  background: rgba(40, 167, 69, 0.12);
}

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

.scanner-torch--on {
  background: #fff3cd;
  color: #856404;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn--icon {
  flex: 0 0 auto;
  width: 3rem;
  padding: 0;
  font-size: 1.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.875rem 1.25rem;
  min-height: 48px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
  touch-action: manipulation;
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  color: #0a1f14;
  width: 100%;
}

.btn--primary:hover:not(:disabled) {
  background: #4de89a;
}

.btn--secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--secondary:hover:not(:disabled) {
  background: #2e4260;
}

.btn--danger {
  background: rgba(239, 83, 80, 0.15);
  color: var(--score-red);
  border: 1px solid var(--alert-border);
  width: 100%;
}

/* ── Manual Input ───────────────────────────────────────────── */
.manual-input {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}

.manual-input__label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.manual-input__row {
  display: flex;
  gap: 0.625rem;
}

.manual-input__field {
  flex: 1;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}

.manual-input__field:focus {
  border-color: var(--accent);
}

.manual-input__field::placeholder {
  color: var(--text-muted);
}

/* ── Loading ────────────────────────────────────────────────── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2.5rem 1rem;
}

.loading__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading__text {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Error ──────────────────────────────────────────────────── */
.error-banner {
  background: var(--alert-bg);
  border: 1px solid var(--alert-border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  color: var(--score-red);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

/* ── Result Card ────────────────────────────────────────────── */
/* ── Panneau résultat (bottom sheet) ───────────────────────────
   Trois états pilotés par data-state, animés UNIQUEMENT en transform : le
   compositeur s'en charge, sans recalcul de layout — 60 fps même sur mobile
   d'entrée de gamme.
   ─────────────────────────────────────────────────────────────── */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.32s ease;
}

.scrim[hidden] {
  display: none;
}

.scrim--visible {
  opacity: 1;
}

.sheet {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 0;
  width: min(100%, 640px);
  height: 92dvh;
  display: grid;
  grid-template-rows: auto auto 1fr;
  background: var(--bg-card);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  border: 1px solid var(--border);
  border-bottom: none;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
  will-change: transform;
  /* translateX centre le panneau, translateY porte l'animation */
  transform: translateX(-50%) translateY(100%);
  transition: transform 0.36s cubic-bezier(0.32, 0.72, 0, 1),
    visibility 0s linear 0.36s;
  /* iOS Safari garde la zone tactile d'un position:fixed à son emplacement
     d'origine malgré le transform : le panneau masqué avalait alors les taps
     sur le bouton caméra et « Analyser ». visibility:hidden le retire du
     hit-testing ; pointer-events:none double la protection. */
  visibility: hidden;
  pointer-events: none;
}

/* États ouverts : interactifs et visibles immédiatement */
.sheet[data-state="peek"],
.sheet[data-state="full"] {
  visibility: visible;
  pointer-events: auto;
  transition: transform 0.36s cubic-bezier(0.32, 0.72, 0, 1);
}

/* Pendant le glissement, aucune transition : le doigt pilote directement */
.sheet--dragging {
  transition: none;
}

.sheet[data-state="peek"] {
  transform: translateX(-50%) translateY(calc(92dvh - var(--sheet-peek-height)));
}

.sheet[data-state="full"] {
  transform: translateX(-50%) translateY(0);
}

:root {
  --sheet-peek-height: 190px;
}

/* Zone de préhension : poignée ET bandeau. touch-action:none empêche le
   navigateur d'interpréter le geste comme un défilement de page. */
.sheet__grip,
.sheet__peek {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* 44 px de haut : la poignée seule faisait 20 px, sous le minimum tactile */
.sheet__grip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  cursor: grab;
}

.sheet__peek {
  cursor: grab;
}

.sheet--dragging .sheet__grip,
.sheet--dragging .sheet__peek {
  cursor: grabbing;
}

.sheet__grabber {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
}

.sheet__grip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
  border-radius: var(--radius-sm);
}

/* Bandeau toujours visible : la note et le produit */
.sheet__peek {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
}

/* Vignette produit — confirme d'un coup d'œil qu'on a scanné le bon article.
   Dimensions FIXES : l'image arrive du réseau après le rendu, elle ne doit
   décaler ni la note ni le nom. */
.sheet__thumb {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

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

.sheet__name {
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  /* 2 lignes max : le bandeau garde une hauteur stable */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sheet__brand {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

.sheet__barcode {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
  font-variant-numeric: tabular-nums;
}

/* Seule zone qui défile de toute l'application */
.sheet__body {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 1rem 1.25rem calc(2rem + var(--safe-bottom));
  /* Le navigateur peut sauter le rendu du hors-écran */
  content-visibility: auto;
}

.sheet__footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.sheet__footer a {
  color: var(--accent);
}

/* ── Note + qualificatif ────────────────────────────────────── */
.score-block {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.score-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--text-muted);
}

.score-label--green { color: var(--score-green); }
.score-label--orange { color: var(--score-orange); }
.score-label--red { color: var(--score-red); }

/* ── Score Badge ────────────────────────────────────────────── */
.score-badge {
  flex-shrink: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  min-width: 82px;
  padding: 0.625rem 0.75rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 3px solid var(--border);
  transition: border-color 0.3s ease, background 0.3s ease;
}

.score-badge--green {
  border-color: var(--score-green);
  background: rgba(61, 214, 140, 0.1);
}

.score-badge--orange {
  border-color: var(--score-orange);
  background: rgba(245, 166, 35, 0.1);
}

.score-badge--red {
  border-color: var(--score-red);
  background: rgba(239, 83, 80, 0.1);
}

.score-badge__value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.score-badge--green .score-badge__value { color: var(--score-green); }
.score-badge--orange .score-badge__value { color: var(--score-orange); }
.score-badge--red .score-badge__value { color: var(--score-red); }

.score-badge__max {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-left: 0.125rem;
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alerts {
  padding: 0 1.5rem;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.alert--danger {
  background: var(--alert-bg);
  border: 1px solid var(--alert-border);
  color: #fca5a5;
}

.alert--warning {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: #fcd34d;
}

.alert--success {
  background: rgba(61, 214, 140, 0.12);
  border: 1px solid rgba(61, 214, 140, 0.4);
  color: #86efac;
}

.alert__icon {
  flex-shrink: 0;
  font-size: 1rem;
}

/* ── Pillars ────────────────────────────────────────────────── */
.pillars {
  padding: 1.25rem;
}

.pillars__title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.pillar {
  margin-bottom: 1.25rem;
}

.pillar:last-child {
  margin-bottom: 0;
}

.pillar__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.pillar__icon {
  font-size: 1.125rem;
}

.pillar__name {
  flex: 1;
  font-size: 0.9375rem;
  font-weight: 500;
}

.pillar__score {
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.pillar__bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.375rem;
}

/* Animé en scaleX et non en width : « width » relance un calcul de layout à
   chaque frame, scaleX reste sur le compositeur. */
.pillar__fill {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 3px;
  will-change: transform;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.pillar__detail {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Carcinogen panel (sous pilier additifs) ─────────────────── */
.carcinogen-panel {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

.carcinogen-panel__title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.carcinogen-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  min-height: 1.5rem;
}

.carcinogen-panel__empty {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.carcinogen-item {
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border-left: 3px solid var(--border);
}

.carcinogen-item--risk {
  border-left-color: var(--score-red);
  background: rgba(239, 83, 80, 0.06);
}

.carcinogen-item--safe {
  border-left-color: var(--score-green);
  background: rgba(61, 214, 140, 0.06);
}

.carcinogen-item__name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.carcinogen-item__desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 0.375rem;
}

.carcinogen-item__status {
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.4;
}

.carcinogen-item--risk .carcinogen-item__status {
  color: #fca5a5;
}

.carcinogen-item--safe .carcinogen-item__status {
  color: #86efac;
}

/* ── Blocs détail (calcul + composition) ─────────────────────── */
.detail-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

.detail-block__title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.625rem;
}

/* ── Carte calcul simplifiée ─────────────────────────────────── */
.calc-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.calc-card__steps {
  padding: 0.125rem 0.875rem;
}

.calc-pillar-block {
  border-bottom: 1px solid rgba(45, 63, 86, 0.35);
}

.calc-pillar-block:last-child {
  border-bottom: none;
}

.calc-pillar-block > .calc-row--pillar {
  border-bottom: none;
}

.calc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 1rem;
  align-items: center;
  padding: 0.625rem 0;
  border-bottom: 1px solid rgba(45, 63, 86, 0.4);
}

.calc-card__steps .calc-row:last-child {
  border-bottom: none;
}

.calc-row--pillar .calc-row__label {
  font-weight: 600;
  font-size: 0.9375rem;
}

.calc-row--small {
  padding: 0.3125rem 0;
  border-bottom: none;
}

.calc-row--small .calc-row__label {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.calc-row--sum {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 1rem;
  align-items: center;
  padding: 0.75rem 0.875rem;
  margin: 0;
  background: rgba(0, 0, 0, 0.18);
  border-top: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.875rem;
}

.calc-row--final {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 1rem;
  align-items: center;
  padding: 0.875rem;
  margin: 0;
  background: rgba(61, 214, 140, 0.1);
  border-top: 2px solid rgba(61, 214, 140, 0.35);
  font-weight: 700;
  font-size: 1rem;
}

.calc-row__label {
  line-height: 1.35;
  min-width: 0;
}

.calc-row__value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
  color: var(--text-muted);
}

.calc-row__value--accent {
  color: var(--accent);
}

.calc-row__value--pos {
  color: var(--score-green);
}

.calc-row__value--neg {
  color: var(--score-red);
}

.calc-row__value--final {
  color: var(--accent);
  font-size: 1.125rem;
}

.calc-expand {
  border-top: none;
  background: transparent;
}

.calc-expand--nested {
  margin: 0 0 0.5rem;
  padding-bottom: 0.25rem;
}

.calc-expand--nested .calc-expand__toggle {
  padding: 0.375rem 0 0.5rem;
  font-size: 0.75rem;
}

.calc-expand--nested .calc-expand__body {
  padding: 0 0 0.5rem 0.375rem;
  border-left: 2px solid rgba(61, 214, 140, 0.25);
  margin-left: 0.125rem;
}

.calc-expand__formula {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.calc-expand__toggle {
  display: block;
  padding: 0.625rem 0.875rem;
  font-size: 0.8125rem;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
  list-style: none;
}

.calc-expand__toggle::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s ease;
}

.calc-expand[open] .calc-expand__toggle::before {
  transform: rotate(90deg);
}

.calc-expand__body {
  padding: 0 0.875rem 0.75rem;
}

.calc-row--additive {
  grid-template-columns: minmax(0, 1fr) auto;
}

.calc-info-line {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0 0 0.5rem;
}

.calc-info-block {
  margin-bottom: 0.5rem;
}

.calc-info-block__title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.125rem;
}

.risk-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.risk-badge--l1 {
  background: rgba(61, 214, 140, 0.15);
  color: #86efac;
  border: 1px solid rgba(61, 214, 140, 0.35);
}

.risk-badge--l2 {
  background: rgba(139, 156, 179, 0.15);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.risk-badge--l3 {
  background: rgba(245, 166, 35, 0.15);
  color: #fcd34d;
  border: 1px solid rgba(245, 166, 35, 0.35);
}

.risk-badge--l4 {
  background: rgba(239, 83, 80, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 83, 80, 0.4);
}

.calc-row__value--muted {
  color: var(--text-muted);
  font-weight: 600;
}

.calc-section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0.625rem 0 0.25rem;
}

.calc-section-label:first-child {
  margin-top: 0;
}

.calc-row--sub .calc-row__label {
  font-weight: 500;
}

.calc-row--emphasis {
  border-top: 1px dashed rgba(45, 63, 86, 0.5);
  padding-top: 0.5rem;
  margin-top: 0.25rem;
}

.calc-row--emphasis:first-of-type {
  border-top: none;
  margin-top: 0;
}

.calc-card__adjustments {
  border-top: 1px solid var(--border);
  padding: 0.5rem 0.875rem 0.625rem;
  background: rgba(239, 83, 80, 0.05);
}

.calc-card__adjustments-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--score-red);
  margin-bottom: 0.375rem;
}

/* ── Composition ─────────────────────────────────────────────── */
.ingredients-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.875rem;
}

.ingredient-row {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr);
  column-gap: 0.625rem;
  row-gap: 0.25rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid rgba(45, 63, 86, 0.4);
  align-items: start;
}

.ingredient-row:last-child {
  border-bottom: none;
}

.ingredient-row--additive .ingredient-row__num {
  background: rgba(245, 166, 35, 0.15);
  color: #fcd34d;
}

.ingredient-row__num {
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg-elevated);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.ingredient-row__content {
  min-width: 0;
}

.ingredient-row__name {
  display: block;
  font-size: 0.875rem;
  line-height: 1.4;
  word-break: break-word;
}

.ingredient-row__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.375rem;
}

.chip {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.chip--e {
  background: rgba(245, 166, 35, 0.15);
  color: #fcd34d;
  border: 1px solid rgba(245, 166, 35, 0.35);
}

.chip--additive {
  background: rgba(139, 156, 179, 0.12);
  color: var(--text);
  border: 1px solid var(--border);
}

.additives-block {
  margin-top: 0.75rem;
}

.additives-block__label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.additives-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ── Historique des scans ──────────────────────────────────── */
/* min-width:0 + width:100% : sans eux, la rangée non-enveloppante ci-dessous
   remontait sa largeur de contenu jusqu'à .stage, qui grandissait pour la
   contenir — la mise en page entière s'étirait sur mobile au lieu de laisser
   .history__list défiler dans ses propres limites. */
.history {
  min-width: 0;
  width: 100%;
}

.history__title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.625rem;
}

/* Défilement horizontal : la liste peut dépasser sans casser la mise en page */
.history__list {
  display: flex;
  min-width: 0;
  width: 100%;
  gap: 0.625rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
}

.history__list::-webkit-scrollbar {
  display: none;
}

.history-item {
  flex: 0 0 auto;
  width: 76px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: center;
  /* Retour visuel immédiat à l'appui, sans décaler la mise en page */
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.history-item:active {
  transform: scale(0.96);
}

.history-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.history-item__score {
  font-size: 0.9375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.history-item__score--green { color: var(--score-green); }
.history-item__score--orange { color: var(--score-orange); }
.history-item__score--red { color: var(--score-red); }

.history-item__name {
  font-size: 0.625rem;
  line-height: 1.25;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Squelette de chargement ────────────────────────────────────
   Placé à l'emplacement FINAL du résultat : le retour visuel naît là où la
   réponse apparaîtra, ce qui rend l'attente plus courte à la perception. */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 25%,
    var(--bg-soft) 50%,
    var(--bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
  color: transparent !important;
}

@keyframes skeleton-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.sheet--loading .score-badge,
.sheet--loading .sheet__thumb,
.sheet--loading .sheet__name,
.sheet--loading .sheet__brand,
.sheet--loading .sheet__barcode,
.sheet--loading .score-label {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 25%,
    var(--bg-soft) 50%,
    var(--bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-color: transparent;
  color: transparent !important;
}

.sheet--loading .sheet__name {
  min-height: 2.4em;
  border-radius: var(--radius-sm);
}

/* ── Responsive ─────────────────────────────────────────────── */

/* Écrans courts (iPhone SE, mode paysage) : on rend de la hauteur à la caméra */
@media (max-height: 700px) {
  :root {
    --sheet-peek-height: 168px;
  }

  .appbar__sub {
    display: none;
  }

  .manual-input__label {
    display: none;
  }
}

/* Au-delà du mobile, le panneau reste centré et ne colle plus aux bords */
@media (min-width: 641px) {
  .sheet {
    border-radius: var(--radius-lg);
    height: 88dvh;
  }
}

/* ── Accessibilité : mouvement réduit ──────────────────────────
   Respecte le réglage système. Le panneau apparaît sans glisser. */
@media (prefers-reduced-motion: reduce) {
  .sheet,
  .scrim,
  .pillar__fill,
  .scanner-viewport,
  .scanner-idle {
    transition-duration: 0.01ms;
  }

  .scan-guide__line {
    animation: none;
  }
}
