/* ---------------------------------------------------------------
   Listou — design system (identite visuelle v2)
   Trois familles : vert d'action, accent chaud, neutres papier/encre.
   --lime et les degrades sont DECORATIFS : jamais sous du texte.
   Typo : Nunito embarquee (aucune requete reseau), 3 graisses.
   Theme : clair par defaut, sombre auto (reglage du telephone),
   choix manuel via [data-theme] qui prime sur l'automatique.
   --------------------------------------------------------------- */

/* Police embarquee dans l'appli : aucune requete reseau, aucun CDN.
   Nunito, licence SIL OFL 1.1 — voir fonts/OFL.txt et fonts/POLICE.md. */
@font-face {
  font-family: "Nunito";
  src: url("fonts/nunito-var-latin.woff2") format("woff2-variations");
  font-weight: 400 800;
  font-display: swap;   /* le texte s'affiche tout de suite en police systeme */
  font-style: normal;
}

:root {
  --paper: #f6f3ec;
  --surface: #ffffff;
  --ink: #22302a;
  --muted: #5d6b63;
  --line: #e6e1d5;
  --green: #00874a;
  --green-deep: #00693a;
  --green-soft: #e2f4e8;
  --green-line: #b8dfc9;
  --lime: #12b76a;
  --terra: #c4551f;
  --terra-deep: #9c3f24;
  --terra-soft: #fdeee4;
  --on-green: #ffffff;
  --on-terra: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(34, 48, 42, 0.08);
}

:root[data-theme="dark"] {
  --paper: #161b18;
  --surface: #1f2622;
  --ink: #ece9e1;
  --muted: #9aa8a0;
  --line: #2c342f;
  --green: #46c98a;
  --green-deep: #8ee0b4;
  --green-soft: #1d3328;
  --green-line: #35564a;
  --lime: #6ee0a6;
  --terra: #f08a63;
  --terra-deep: #f6a988;
  --terra-soft: #33231c;
  --on-green: #10231a;
  --on-terra: #2a1a12;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #161b18;
    --surface: #1f2622;
    --ink: #ece9e1;
    --muted: #9aa8a0;
    --line: #2c342f;
    --green: #46c98a;
    --green-deep: #8ee0b4;
    --green-soft: #1d3328;
    --green-line: #35564a;
    --lime: #6ee0a6;
    --terra: #f08a63;
    --terra-deep: #f6a988;
    --terra-soft: #33231c;
    --on-green: #10231a;
    --on-terra: #2a1a12;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  }
}

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

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

body {
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.45;
  min-height: 100dvh;
}

.screen {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 20px 130px;
}

a { color: inherit; text-decoration: none; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ---- Bandeau hors connexion + toast ---- */

#bandeau {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--terra);
  color: var(--on-terra);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  padding: 8px 16px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  z-index: 40;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  white-space: nowrap;
}

/* ---- En-tetes ---- */

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 4px;
}

.app-header img { width: 44px; height: 44px; border-radius: 11px; }

.app-header h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  flex: 1;
  color: var(--green-deep);
}

.tagline { color: var(--muted); margin: 2px 0 18px; font-size: 15px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0 16px;
}

.topbar .back {
  font-size: 26px;
  line-height: 1;
  padding: 6px 12px 8px 0;
  color: var(--green);
}

.topbar h1 {
  font-size: 21px;
  font-weight: 800;
  flex: 1;
  letter-spacing: -0.2px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.share-btn {
  background: var(--green-soft);
  color: var(--green-deep);
  font-size: 14px;
  font-weight: 800;
  border-radius: 999px;
  padding: 8px 14px;
  flex-shrink: 0;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-content: center;
  color: var(--green-deep);
  background: var(--green-soft);
  flex-shrink: 0;
}

.icon-btn.lang-btn { font-size: 13px; font-weight: 700; letter-spacing: 0.5px; }

/* ---- Promesse ---- */

.promise {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.promise span {
  background: var(--green-soft);
  color: var(--green-deep);
  font-size: 13px;
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 999px;
}

/* Un badge chaud sur trois : la palette respire sans devenir criarde. */
.promise span:nth-child(2) {
  background: var(--terra-soft);
  color: var(--terra-deep);
}

/* ---- Cartes de listes ---- */

.list-card {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 56px 16px 16px;
  margin-bottom: 12px;
}

.list-card:active { transform: scale(0.985); }

.list-card h2 { font-size: 18px; font-weight: 800; margin-bottom: 4px; overflow-wrap: anywhere; }

.list-card .meta { color: var(--muted); font-size: 14px; }

.progress {
  height: 5px;
  background: var(--green-soft);
  border-radius: 999px;
  margin-top: 12px;
  overflow: hidden;
}

.progress i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--lime));
  border-radius: 999px;
}

.star {
  position: absolute;
  top: 10px;
  right: 8px;
  width: 42px;
  height: 42px;
  display: grid;
  place-content: center;
  color: var(--muted);
}

.star svg path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }

.star.actif { color: var(--terra); }

.star.actif svg path { fill: currentColor; }

.card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.btn-small {
  background: var(--green-soft);
  color: var(--green-deep);
  font-size: 14px;
  font-weight: 800;
  border-radius: 999px;
  padding: 8px 14px;
}

/* ---- Etat vide + liens discrets ---- */

.empty {
  text-align: center;
  color: var(--muted);
  padding: 36px 12px;
  font-size: 15px;
}

/* Premiere ouverture : on accueille, on ne se contente pas d'une ligne grise. */
.accueil-vide {
  text-align: center;
  padding: 14px 12px 8px;
}

.accueil-vide img {
  display: block;
  width: 100%;
  max-width: 240px;
  height: auto;
  margin: 0 auto 18px;
}

.accueil-vide .titre {
  font-size: 19px;
  font-weight: 800;
  color: var(--green-deep);
  margin-bottom: 6px;
}

.accueil-vide .hint { color: var(--muted); font-size: 15px; }

.link-muted {
  display: block;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 14px;
  width: 100%;
}

.link-muted:active { color: var(--ink); }

/* ---- Articles ---- */

.section-label {
  color: var(--green-deep);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 22px 4px 8px;
}

.items {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 6px 9px 16px;
  border-bottom: 1px solid var(--line);
}

.item:last-child, .item-actions:last-child { border-bottom: 0; }

.item.dragging {
  opacity: 0.85;
  background: var(--green-soft);
  position: relative;
  z-index: 10;
}

.item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border: 2px solid var(--green-line);
  border-radius: 8px;
  flex-shrink: 0;
  display: grid;
  place-content: center;
  cursor: pointer;
}

.item input[type="checkbox"]:checked { background: var(--green); border-color: var(--green); }

.item input[type="checkbox"]:checked::before {
  content: "";
  width: 12px;
  height: 7px;
  border-left: 2.5px solid var(--on-green);
  border-bottom: 2.5px solid var(--on-green);
  transform: translateY(-2px) rotate(-45deg);
}

/* ---- Icones d'aliments ---------------------------------------------------
   Chaque categorie a sa teinte naturelle (pain dore, tomate rouge, lait
   bleute...) posee sur une pastille de la meme teinte, tres claire. Une seule
   saturation pour toutes : la liste reste calme.
   Les teintes sont ici, et nulle part ailleurs : le dessin (icones.js) ne
   connait que sa categorie, la couleur appartient au style. */

.ico-slot {
  width: 24px;
  flex-shrink: 0;
  display: grid;
  place-content: center;
}

/* Les Twemoji portent leurs propres couleurs : on ne les recolore pas.
   Une pastille neutre, la meme pour tous, empeche les emoji clairs (oeuf,
   lait, sel, glacon) de se fondre sur le fond, surtout en mode nuit. */
.ico {
  width: 22px;
  height: 22px;
  display: block;
  padding: 2px;
  border-radius: 50%;
  background: rgba(34, 48, 42, 0.06);
}

:root[data-theme="dark"] .ico { background: rgba(255, 255, 255, 0.13); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ico { background: rgba(255, 255, 255, 0.13); }
}

/* Aucune icone : une puce neutre, volontairement discrete. */
.ico-slot .puce {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
}

.item.coche .ico { filter: grayscale(0.85); opacity: 0.55; }

.liste-progress { margin: 0 4px 18px; }

.item .texte {
  flex: 1;
  padding: 4px 0;
  min-width: 0;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.item.coche .texte { color: var(--muted); text-decoration: line-through; }

.item .handle {
  color: var(--muted);
  padding: 10px 12px;
  flex-shrink: 0;
  touch-action: none;
  cursor: grab;
}

.texte-input {
  flex: 1;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--green);
  border-radius: 8px;
  padding: 6px 10px;
  min-width: 0;
}

.item-actions {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--green-soft);
}

.item-actions .danger { color: var(--terra); }

.item-actions button {
  font-size: 14px;
  font-weight: 700;
  color: var(--green-deep);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 14px;
}

/* ---- Suggestions ---- */

.suggestions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 440px;
  margin: 0 auto 10px;
}

.suggestions button {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  border-radius: 999px;
  padding: 7px 13px;
  box-shadow: var(--shadow);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Actions de liste ---- */

.list-tools { margin-top: 18px; display: grid; gap: 4px; }

/* Permanent deletion: red, outlined, clearly distinct from « Archiver ». */
.btn-danger {
  background: none;
  color: var(--terra-deep);
  border: 1.5px solid var(--terra);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 800;
  padding: 12px;
  cursor: pointer;
}

.btn-danger:active { background: var(--terra-soft); }

/* As a chip in the archived-list actions, it stays small and red. */
.btn-small.btn-danger {
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
}

.archived-note {
  background: var(--green-soft);
  color: var(--green-deep);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
}

/* ---- Barres du bas ---- */

.bottom-cta, .add-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 12px 20px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 70%, transparent);
}

.btn-primary {
  display: block;
  max-width: 440px;
  margin: 0 auto;
  background: var(--green);
  color: var(--on-green);
  font-size: 17px;
  font-weight: 800;
  text-align: center;
  border-radius: var(--radius);
  padding: 15px;
  width: 100%;
}

.btn-primary:active { background: var(--green-deep); }

.btn-secondary {
  display: block;
  max-width: 440px;
  margin: 0 auto;
  background: var(--surface);
  color: var(--green-deep);
  border: 1.5px solid var(--green);
  font-size: 17px;
  font-weight: 800;
  text-align: center;
  border-radius: var(--radius);
  padding: 14px;
  width: 100%;
}

.btn-row { display: grid; gap: 10px; margin: 18px 0 22px; }

.add-bar .inner, .inline-form {
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
}

.inline-form { margin-top: 10px; }

.add-bar input, .inline-form input {
  flex: 1;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.add-bar input::placeholder, .inline-form input::placeholder { color: var(--muted); }

.add-bar button, .inline-form button {
  min-width: 52px;
  background: var(--green);
  color: var(--on-green);
  font-size: 17px;
  font-weight: 800;
  border-radius: var(--radius);
  padding: 0 14px;
}

.add-bar .inner-form { flex: 1; display: flex; gap: 10px; min-width: 0; }

.add-bar .inner-form button { font-size: 26px; }

/* « Catégories » : ouvre le catalogue. Pastille compacte, pas le gros bouton +. */
.add-bar .btn-catalogue {
  min-width: 0;
  flex-shrink: 0;
  background: var(--green-soft);
  color: var(--green-deep);
  font-size: 15px;
  font-weight: 800;
  border-radius: var(--radius);
  padding: 0 16px;
  box-shadow: var(--shadow);
}

.add-bar .btn-catalogue:active { background: var(--green-line); }

/* ---- Catalogue (panneau plein ecran, 100 % local) ---- */

.catalogue {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(34, 48, 42, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.cat-panneau {
  background: var(--paper);
  width: 100%;
  max-width: 560px;
  max-height: 85dvh;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cat-tete {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.cat-tete h2 { flex: 1; font-size: 19px; font-weight: 800; letter-spacing: -0.3px; }

.cat-fermer {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green-deep);
  font-size: 24px;
  line-height: 1;
}

.cat-corps {
  overflow-y: auto;
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
}

.cat-rayon { margin-top: 16px; }

.cat-rayon h3 {
  color: var(--green-deep);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px 7px 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.chip:active { background: var(--green-soft); }

.chip .ico-slot { width: 22px; }

/* ---- Partage ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}

.card .lead { font-size: 16px; margin-bottom: 14px; }

.card p + p { margin-top: 8px; }

.card .hint { color: var(--muted); font-size: 13px; }

.apropos { text-align: center; }

.credit { color: var(--muted); font-size: 12px; text-align: center; padding: 4px 12px; }

.apropos img { border-radius: 18px; margin-bottom: 12px; }

.lien { color: var(--green-deep); font-weight: 700; text-decoration: underline; }

.link-box {
  background: var(--green-soft);
  color: var(--green-deep);
  font-weight: 700;
  border-radius: 10px;
  padding: 13px 14px;
  font-size: 15px;
  word-break: break-all;
}

.pledge { list-style: none; }

.pledge li {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  font-size: 15px;
}

.pledge li::before { content: "\2014"; color: var(--terra); font-weight: 700; }
