/* Webapp_Facilisto : mêmes jetons que le site et l'app (brand/tokens.css). Tailles en rem : la racine suit le réglage
   de taille du texte d'iOS, comme Dynamic Type. Le natif reste seul juge des très grandes tailles. */
html {
  font-size: 17px;
  font: -apple-system-body;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--color-background-canvas); }
body {
  position: fixed;
  inset: 0;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  color: var(--color-text-primary);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; text-align: inherit; cursor: pointer; touch-action: manipulation; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

#app { position: fixed; top: 0; left: 0; right: 0; height: 100%; display: flex; flex-direction: column; }
#stage { position: relative; flex: 1; min-height: 0; }
.screen { position: absolute; inset: 0; }
.scroller {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-top: env(safe-area-inset-top);
}
.courses { display: flex; flex-direction: column; gap: 16px; padding: 16px; padding-bottom: 92px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-s { display: flex; flex-direction: column; gap: 8px; }
.stack-xs { display: flex; flex-direction: column; gap: 4px; }

/* Onglets */
#tabs {
  flex: none;
  display: flex;
  background: var(--color-background-surface);
  border-top: 1px solid var(--color-separator-line);
  padding-bottom: env(safe-area-inset-bottom);
}
.keyboard-open #tabs { display: none; }
.tab {
  flex: 1;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: .62rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}
.tab.is-selected { color: var(--color-accent-default); }

/* Titres et textes */
.large-title { flex: 0 1 auto; font-size: 2rem; font-weight: 700; color: var(--color-text-title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.title-line { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.list-title { display: flex; flex: 0 0 auto; align-items: baseline; gap: 8px; max-width: 72%; min-height: 44px; font-size: inherit; }
.title-line > .list-title:only-child { flex: 1 1 auto; max-width: 100%; }
.title-store { display: flex; flex: 0 1 auto; align-items: center; gap: 4px; min-width: 0; min-height: 44px; font-size: .882rem; line-height: 1.15; font-weight: 600; color: var(--color-accent-default); }
.title-store-name { min-width: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.title-store svg { flex: none; }
.list-title.is-menu svg { flex: none; color: var(--color-accent-default); align-self: center; }
.hint { font-size: .765rem; color: var(--color-text-secondary); display: block; }
.card-title { display: flex; align-items: center; gap: 6px; font-size: 1rem; font-weight: 600; color: var(--color-text-title); }

/* Le rond d'ajout, en bas à droite, au-dessus des onglets */
.add-round { position: absolute; right: 16px; bottom: 14px; z-index: 6; display: flex; align-items: center; justify-content: center; width: 62px; height: 62px; color: var(--color-text-on-accent); background: var(--color-accent-default); border-radius: 50%; box-shadow: 0 3px 8px rgba(0,0,0,.28); transition: bottom .18s; }
.add-round:active { background: var(--color-accent-pressed); }

/* Mot de la liste */
/* Sans fond : une ligne de petits points, comme une ligne à compléter sur un formulaire. Le texte est petit, la cible reste à 44. */
.note { display: block; width: 100%; min-height: 44px; padding: 10px 0; margin: -10px 0 -6px; }
.has-dots { text-decoration: underline dotted var(--color-text-secondary) 1.5px; text-underline-offset: 4px; }
.note-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; white-space: pre-wrap; }
.note-text.is-compact { font-size: .882rem; -webkit-line-clamp: 2; }
.note.is-open .note-text { -webkit-line-clamp: unset; }
.note-add { display: block; width: 100%; min-height: 44px; padding: 10px 0; margin: -10px 0 -6px; font-size: .882rem; color: var(--color-text-secondary); }
.note-field { resize: none; overflow: hidden; display: block; width: 100%; }
.note-done { align-self: flex-end; }

/* Champs */
.field {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  font-size: max(16px, 1rem);
  background: var(--color-background-sunken);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}
.field:focus { border-color: var(--color-focus); }
.field::placeholder { color: var(--color-text-placeholder); opacity: 1; }
.capture-row { display: flex; align-items: center; gap: 8px; }
.capture-add { flex: none; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--color-accent-default); }
.capture-add.is-disabled { color: var(--color-text-disabled); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 12px;
  font-size: .882rem;
  font-weight: 600;
  background: var(--color-background-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
}
.chip.is-suggestion { align-self: flex-start; background: var(--color-background-sunken); border: 0; color: var(--color-accent-default); }

/* Sélecteur à deux choix */
.segmented { display: flex; gap: 2px; padding: 2px; background: var(--color-background-sunken); border-radius: 10px; }
.segment { flex: 1; min-height: 44px; padding: 0 8px; text-align: center; font-size: .882rem; font-weight: 500; color: var(--color-text-secondary); border-radius: 8px; }
.segment.is-selected { font-weight: 700; color: var(--color-text-primary); background: var(--color-background-surface); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

/* Boutons */
.button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; padding: 12px 16px; text-align: center; font-weight: 600; border-radius: 12px; }
.button.primary { background: var(--color-accent-default); color: var(--color-text-on-accent); }
.button.secondary { background: var(--color-background-surface); color: var(--color-accent-default); box-shadow: inset 0 0 0 2px var(--color-accent-default); }
.button-row { display: flex; gap: 8px; }
.text-button { display: inline-flex; align-items: center; gap: 4px; min-width: 44px; min-height: 44px; font-weight: 600; color: var(--color-accent-default); }
.icon-button { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; color: var(--color-text-secondary); }

/* Cartes */
.card { padding: 16px; background: var(--color-background-surface); border-radius: 16px; }
.due-name { display: block; font-weight: 600; }

/* Magasin */
.progress-track { display: block; width: 100%; height: 6px; border-radius: 3px; background: var(--color-separator-line); overflow: hidden; }
.progress-fill { display: block; height: 100%; border-radius: 3px; background: var(--color-accent-default); transition: width .25s; }
.brand-check { display: inline-block; flex: none; background: var(--color-accent-default); -webkit-mask-image: url(brand/check-path.svg); mask-image: url(brand/check-path.svg); -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
/* « Rien oublié ? » : griffonné au marqueur au-dessus du cadre, la fourmi passe la tête (retour de Fred) */
.ideas { display: flex; flex-direction: column; }
.ideas-head { position: relative; display: flex; align-items: flex-end; gap: 6px; min-height: 44px; margin-bottom: -2px; padding-left: 4px; }
.ideas-title { font-size: 1.41rem; font-weight: 800; color: var(--color-text-title); transform: rotate(-2deg); transform-origin: left bottom; margin-bottom: 8px; }
.ideas-marker { padding: 0 6px; background: linear-gradient(transparent 68%, var(--color-background-brand) 68%, var(--color-background-brand) 94%, transparent 94%); border-radius: 4px; }
.ideas-ant { display: block; flex: none; transform: translateY(5px) rotate(8deg); }
.ideas-close { margin-left: auto; align-self: center; }
.ideas-title.pops { animation: ideas-pop .24s cubic-bezier(.2,1.4,.4,1); }
.ideas-ant.pops { animation: ideas-peek .24s cubic-bezier(.2,1.4,.4,1); }
@keyframes ideas-pop { from { transform: rotate(-6deg) scale(.86); opacity: 0; } }
@keyframes ideas-peek { from { transform: translateY(24px) rotate(0); } }
@media (prefers-reduced-motion: reduce) { .ideas-title.pops, .ideas-ant.pops { animation: none; } }
.complements { position: relative; padding: 4px 4px 8px 16px; }
/* La ligne qui ferme la liste : ce qui suit est déjà dans le chariot */
.list-done { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.list-done hr { width: 100%; height: 2px; margin: 0; border: 0; background: var(--color-text-title); border-radius: 1px; }
.list-done p { font-size: 1rem; font-weight: 700; text-align: center; color: var(--color-text-title); }
.complement { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 4px 12px 4px 0; color: var(--color-accent-default); border-top: 1px solid var(--color-separator-line); }
.complement:first-of-type { border-top: 0; }
.idea-name { display: block; color: var(--color-text-primary); }
.loyalty-invite, .loyalty-panel { display: flex; flex-direction: column; gap: 8px; width: 100%; text-align: left; }
.loyalty-text { font-size: .882rem; color: var(--color-text-primary); }
.barcode { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 12px 6px; background: #fff; border-radius: 8px; }
.barcode svg { display: block; width: 100%; }
.barcode-number { font-size: .824rem; font-variant-numeric: tabular-nums; letter-spacing: 1px; color: #000; }
.barcode-number.is-alone { display: block; padding: 16px 12px; font-size: 1.18rem; text-align: center; background: #fff; border-radius: 8px; }
.overlay.is-card { z-index: 30; display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 24px; padding: 24px; background: #fff; }
.card-screen-title { font-size: 1.3rem; font-weight: 700; text-align: center; color: #000; }
.card-screen-close { align-self: center; min-width: 200px; min-height: 52px; font-weight: 600; text-align: center; color: #fff; background: #2E5E4E; border-radius: 12px; }
.card-number { flex: none; width: 100%; }

/* Rubriques */
/* Le titre du rayon : un trait de marqueur à la couleur de la famille, comme « Rien oublié ? », sans la fourmi (retour de Fred). */
.family-band { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; margin: 0; padding: 0 2px; font-size: 1.18rem; font-weight: 800; text-align: left; color: var(--color-text-title); background: none; }
.family-mark { --band-mark: var(--band-bg); position: relative; display: inline-block; padding: 0 6px; transform: rotate(-3deg); transform-origin: left bottom; }
/* Le texte penche de 3°, le trait de 1° seulement (retour de Fred). */
.family-mark::before { content: ""; position: absolute; z-index: -1; left: 0; right: 0; bottom: -4px; height: 7px; background: var(--band-mark); border-radius: 4px; transform: rotate(2deg); transform-origin: left center; }
/* Le pastel de la famille, foncé et plus franc : le trait doit se voir d'un coup d'œil sur le crème. */
@supports (color: oklch(from red l c h)) {
  .family-mark { --band-mark: oklch(from var(--band-bg) calc(l - 0.14) calc(c * 3) h); }
}
/* Rayon terminé : plus de barré épais sur les lettres. Un trait fin et long traverse la ligne, comme une rature sur papier. */
.family-band.is-done { position: relative; }
.family-band.is-done .family-mark { color: var(--color-text-secondary); }
.family-band.is-done::after { content: ""; position: absolute; left: 0; right: 28px; top: 50%; height: 2px; background: var(--color-text-secondary); border-radius: 1px; transform: rotate(-.6deg); pointer-events: none; }
.family-band.is-done .due-tag { position: relative; z-index: 1; }
.family-band-text { flex: 1; min-width: 0; white-space: nowrap; padding: 4px 0 6px; }
.family-band svg { flex: none; }
.chrono { display: flex; align-items: center; gap: 6px; font-size: .765rem; font-weight: 600; color: var(--color-text-secondary); }

/* Lignes */
.rows { background: var(--color-background-surface); border-radius: 16px; overflow: hidden; }
.swipe-row { position: relative; overflow: hidden; touch-action: pan-y; }
.swipe-row + .swipe-row { border-top: 1px solid var(--color-separator-line); }
.row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 2px 8px;
  background: var(--color-background-surface);
  touch-action: pan-y;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.is-settling .row { transition: transform .22s cubic-bezier(.2,.8,.2,1); }
.row-check { display: flex; align-items: center; justify-content: center; flex: none; width: 44px; height: 44px; color: var(--color-accent-default); }
.row.is-readonly .row-check { color: var(--color-text-secondary); }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { overflow-wrap: anywhere; }
.row-title.is-checked { text-decoration: line-through; color: var(--color-text-secondary); }
.row-quantity { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--color-text-title); }
.swipe-leading {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  gap: 8px;
  padding-left: 16px;
  font-size: .882rem;
  font-weight: 700;
  color: var(--color-text-on-accent);
  background: var(--color-accent-default);
  opacity: .75;
}
.shows-leading .swipe-leading { display: flex; }
.is-past .swipe-leading { opacity: 1; }
.is-past .swipe-leading svg { transform: scale(1.25); }
.swipe-leading svg { transition: transform .15s; }
.swipe-leading svg circle[fill="currentColor"] + path { stroke: var(--color-accent-default); }
.swipe-trailing { position: absolute; top: 0; bottom: 0; right: 0; display: none; width: min(60%, 176px); }
.shows-trailing .swipe-trailing { display: flex; }
.swipe-action { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: .706rem; font-weight: 700; }
.swipe-action.is-edit { background: var(--color-background-brand); color: var(--color-text-on-brand); }
.swipe-action.is-remove { background: var(--color-state-error-text); color: var(--color-state-error-background); }

/* Proposition « À prévoir » : une ligne, pas encore un article */
.row.is-due .row-check { color: var(--color-text-secondary); }
.row.is-due .row-title { color: var(--color-text-secondary); }
.due-tag { flex: none; padding: 2px 8px; font-size: .765rem; font-weight: 400; letter-spacing: 0; color: var(--color-text-secondary); background: var(--color-background-sunken); border-radius: 999px; }

.due-tag { max-width: 45%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* État vide */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px 0; text-align: center; }
.empty-title { font-size: 1.18rem; font-weight: 700; color: var(--color-text-title); }
.mascot img { display: block; }

/* Bandeaux */
.state-banner { display: flex; gap: 8px; padding: 12px; font-size: .882rem; border-radius: 12px; }
.state-banner svg { flex: none; }
.state-banner.is-success { color: var(--color-state-success-text); background: var(--color-state-success-background); }
.state-banner.is-warning { color: var(--color-state-warning-text); background: var(--color-state-warning-background); }
.state-banner.is-error { color: var(--color-state-error-text); background: var(--color-state-error-background); }
.bars { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; flex-direction: column; overflow: hidden; pointer-events: none; }
.bars.is-top { top: 0; bottom: auto; }
.bars > * { pointer-events: auto; margin: 0 16px 8px; }
.bar { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 16px; color: var(--color-text-on-brand); border-radius: 16px; width: auto; }
.bar-brand { background: var(--color-background-brand); }
.undo-bar { font-size: .882rem; }
.undo-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bar-question { display: flex; align-items: center; min-height: 44px; font-size: .882rem; font-weight: 700; text-decoration: underline; color: inherit; }
.undo-button { flex: none; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; font-size: 1rem; font-weight: 600; color: inherit; }
.store-proposal { text-align: left; }

/* Feuilles */
#overlays { position: fixed; top: 0; left: 0; right: 0; height: 100%; z-index: 20; pointer-events: none; }
.overlay { position: absolute; inset: 0; pointer-events: auto; }
.overlay.is-sheet { background: rgba(0,0,0,.35); display: flex; align-items: flex-end; }
.sheet { width: 100%; height: calc(100% - 44px - env(safe-area-inset-top)); background: var(--color-background-canvas); border-radius: 16px 16px 0 0; overflow: hidden; display: flex; flex-direction: column; animation: sheet-in .28s cubic-bezier(.2,.8,.2,1); }
@keyframes sheet-in { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } .is-settling .row { transition: none; } }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-footer { flex: none; }
.sheet-footer:empty { display: none; }
.sheet-footer > * { margin: 8px 16px calc(8px + env(safe-area-inset-bottom)); }
.sheet-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; min-height: 52px; padding: 0 16px; background: var(--color-background-canvas); }
.sheet-bar-side { flex: 1; display: flex; }
.sheet-bar-side.is-right { justify-content: flex-end; }
.sheet-bar-title { font-weight: 600; text-align: center; }
.sheet-content { display: flex; flex-direction: column; gap: 8px; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 4px 20px; background: var(--color-background-canvas); }
.sheet-head-title { font-size: 1.18rem; font-weight: 700; color: var(--color-text-title); }
.store-hint { display: flex; gap: 8px; padding: 4px 8px; font-size: .824rem; }
.sheet-empty { display: flex; flex-direction: column; gap: 16px; padding: 24px; }
.form-section { display: flex; flex-direction: column; background: var(--color-background-surface); border-radius: 16px; overflow: hidden; }
.form-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 6px 16px; }
.form-row + .form-row { border-top: 1px solid var(--color-separator-line); }
.form-grow { flex: 1; min-width: 0; }
.form-value { color: var(--color-text-secondary); font-size: .882rem; text-align: right; }
.form-row.is-link svg { color: var(--color-accent-default); flex: none; }
.form-row.is-action { color: var(--color-accent-default); font-weight: 600; }
.hint.is-plain { font-weight: 400; }
.form-row.is-destructive { color: var(--color-state-error-text); }
.form-footer { padding: 0 4px 4px; font-size: .765rem; color: var(--color-text-secondary); }
.form-header { padding: 12px 16px 4px; font-size: .765rem; font-weight: 600; text-transform: uppercase; color: var(--color-text-secondary); }
.form-header.is-plain { padding: 8px 4px 0; font-size: .824rem; font-weight: 500; text-transform: none; }
.form-date, .form-select { font-size: max(16px, 1rem); color: var(--color-accent-default); background: transparent; border: 0; text-align: right; }
.title-editor { flex-direction: column; align-items: stretch; }
.title-field { width: 100%; min-height: 44px; border: 0; outline: none; background: transparent; font-size: 1.3rem; font-weight: 700; color: var(--color-text-title); }
.choice-text { display: flex; flex-direction: column; gap: 2px; }
.detail-title { font-size: 1.3rem; font-weight: 700; color: var(--color-text-title); overflow-wrap: anywhere; }
.round-button { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none; color: var(--color-accent-default); background: var(--color-background-sunken); border-radius: 50%; }
.round-button:disabled { color: var(--color-text-disabled); }
.switch { width: 51px; height: 31px; flex: none; margin: 0; -webkit-appearance: none; appearance: none; border-radius: 16px; background: var(--color-separator-line); position: relative; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch:checked { background: var(--color-accent-default); }
.switch:checked::after { transform: translateX(20px); }
.bench-note { font-size: .882rem; color: var(--color-text-secondary); }

/* Alertes */
.overlay.is-dialog { display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(0,0,0,.35); }
.dialog { width: 100%; max-width: 300px; padding: 20px 16px 8px; background: var(--color-background-surface); border-radius: 16px; text-align: center; }
.dialog-title { font-size: 1rem; font-weight: 700; color: var(--color-text-title); }
.dialog-message { margin-top: 6px; font-size: .882rem; }
.dialog-buttons { display: flex; flex-direction: column; margin-top: 12px; }
.dialog-button { min-height: 44px; text-align: center; font-weight: 600; color: var(--color-accent-default); border-top: 1px solid var(--color-separator-line); }
.dialog-button.is-cancel { font-weight: 500; }

/* Menus */
.overlay.is-menu { background: transparent; }
.menu { position: absolute; left: 16px; right: 16px; max-width: 320px; max-height: 70vh; overflow-y: auto; background: var(--color-background-surface); border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.28); }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 6px 14px 6px 8px; }
.menu-note { padding: 10px 14px; font-size: .765rem; color: var(--color-text-secondary); border-bottom: 1px solid var(--color-separator-line); }
.menu-item + .menu-item { border-top: 1px solid var(--color-separator-line); }
.menu-item.is-destructive { color: var(--color-state-error-text); }
.menu-check { width: 18px; flex: none; color: var(--color-accent-default); }
.menu-label { flex: 1; }
