/* VirtualDress V0 — interface mobile d'abord */
:root {
  --fond: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f2ede5;
  --fond-photo: #f4efe7;
  --texte: #2b2a28;
  --texte-doux: #6f6a63;
  --bord: #e4ddd2;
  --accent: #c2603d;
  --accent-fort: #a94f2f;
  --accent-texte: #ffffff;
  --accent-doux: #f6e3da;
  --bulle-moi: #c2603d;
  --bulle-moi-texte: #ffffff;
  --alerte-fond: #fff4e5;
  --alerte-texte: #7a4a00;
  --erreur: #b3261e;
  --succes: #2e7d4f;
  --ombre: 0 1px 2px rgba(43, 42, 40, .06), 0 4px 14px rgba(43, 42, 40, .07);
  --rayon: 14px;
  --rayon-petit: 10px;
  --nav-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #1c1a18;
    --surface: #262320;
    --surface-2: #302c28;
    --fond-photo: #e9e3d9;
    --texte: #f1ece4;
    --texte-doux: #b3aca2;
    --bord: #3d3833;
    --accent: #d9774f;
    --accent-fort: #e88a63;
    --accent-texte: #1c1a18;
    --accent-doux: #43302a;
    --bulle-moi: #b85a39;
    --bulle-moi-texte: #ffffff;
    --alerte-fond: #3a2e1c;
    --alerte-texte: #f3d39b;
    --erreur: #f28b82;
    --succes: #7fcf9f;
    --ombre: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
h1 { font-size: 1.35rem; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0; font-weight: 650; }
[hidden] { display: none !important; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
}

.bandeau {
  background: var(--alerte-fond);
  color: var(--alerte-texte);
  font-size: .85rem;
  padding: 8px 16px;
  text-align: center;
}

.entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0 12px;
}

/* Boutons */
.btn {
  appearance: none;
  border: 1px solid var(--bord);
  background: var(--surface);
  color: var(--texte);
  font: inherit;
  font-weight: 550;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  box-shadow: var(--ombre);
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.btn-accent:hover { background: var(--accent-fort); }
.btn-large { width: 100%; min-height: 52px; border-radius: var(--rayon); }
.btn-petit { font-size: .85rem; padding: 8px 12px; }
.btn-icone { width: 44px; padding: 0; box-shadow: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Puces */
.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puces-defil {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 2px 0 10px;
  scrollbar-width: none;
}
.puces-defil::-webkit-scrollbar { display: none; }
/* Grand écran : les puces passent à la ligne au lieu de défiler (barre masquée invisible à la souris) */
@media (min-width: 600px) {
  .puces-defil { flex-wrap: wrap; overflow-x: visible; }
}
.puce {
  appearance: none;
  flex: none;
  border: 1px solid var(--bord);
  background: var(--surface);
  color: var(--texte);
  font: inherit;
  font-size: .9rem;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.puce[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }

/* Grille du dressing */
.grille {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
@media (max-width: 360px) { .grille { grid-template-columns: repeat(2, 1fr); } }
.tuile {
  appearance: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  background: var(--surface);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  overflow: hidden;
  cursor: pointer;
  min-width: 0;
}
.tuile-photo {
  aspect-ratio: 1;
  background: var(--fond-photo);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tuile-photo img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.tuile-nom {
  padding: 8px 10px 2px;
  font-weight: 550;
  font-size: .92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tuile-info { padding: 0 10px 10px; font-size: .8rem; color: var(--texte-doux); }
.statut-badge {
  display: inline-block;
  font-size: .72rem;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-doux);
  color: var(--texte);
  margin-left: 4px;
}
.vide { color: var(--texte-doux); text-align: center; padding: 32px 8px; }

/* Cartes */
.carte {
  background: var(--surface);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 14px 16px;
}
.conseils ul { margin: 6px 0 0; padding-left: 20px; color: var(--texte-doux); font-size: .92rem; }
.choix-photo { display: grid; gap: 10px; margin: 16px 0 10px; }
.webcam { margin: 0 0 12px; display: grid; gap: 10px; }
.webcam-cadre { background: #000; border-radius: var(--rayon-petit); overflow: hidden; }
.webcam-cadre video { display: block; width: 100%; max-height: 60vh; object-fit: contain; }
.webcam-conseil { margin: 0; }
.input-cache { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
label.btn { position: relative; }
.case { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.case input { width: 22px; height: 22px; accent-color: var(--accent); }
.aide { margin: 0 0 12px; font-size: .85rem; color: var(--texte-doux); }

/* Étapes du traitement */
.etapes { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 6px; }
.etapes li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .92rem;
  color: var(--texte-doux);
}
.etapes li::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--bord);
}
.etapes li[data-etat="encours"] { color: var(--texte); }
.etapes li[data-etat="encours"]::before { border-color: var(--accent); border-top-color: transparent; animation: tourne .8s linear infinite; }
.etapes li[data-etat="fait"]::before { background: var(--succes); border-color: var(--succes); }
.etapes li[data-etat="erreur"] { color: var(--erreur); }
.etapes li[data-etat="erreur"]::before { background: var(--erreur); border-color: var(--erreur); }
.etapes li[data-etat="saute"]::before { border-style: dashed; }
@keyframes tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .etapes li[data-etat="encours"]::before { animation: none; } }

.message {
  padding: 10px 14px;
  border-radius: var(--rayon-petit);
  background: var(--alerte-fond);
  color: var(--alerte-texte);
  font-size: .92rem;
}
.message.erreur { color: var(--erreur); }

.apercu {
  background: var(--fond-photo);
  border-radius: var(--rayon);
  margin: 12px 0;
  display: flex;
  justify-content: center;
  /* damier discret pour voir la transparence */
  background-image: linear-gradient(45deg, rgba(0,0,0,.035) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.035) 75%),
                    linear-gradient(45deg, rgba(0,0,0,.035) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.035) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}
.apercu img { max-height: 280px; object-fit: contain; padding: 10px; }

/* Formulaire de fiche */
.formulaire { display: grid; gap: 4px; }
.champ { margin: 10px 0 4px; border: 0; padding: 0; min-width: 0; }
.champ > legend, .champ > label { display: block; font-size: .85rem; font-weight: 600; color: var(--texte-doux); margin-bottom: 6px; padding: 0; }
.champ input[type="text"], .champ input[type="number"], .champ input[type="date"], textarea {
  width: 100%;
  min-height: 44px;
  font: inherit;
  color: var(--texte);
  background: var(--surface);
  border: 1px solid var(--bord);
  border-radius: var(--rayon-petit);
  padding: 10px 12px;
}
.champ .puces .puce { font-size: .85rem; }
.ligne-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ligne-2 .champ { margin-top: 10px; }
.actions { display: flex; gap: 10px; margin-top: 16px; }
.actions .btn { flex: 1; }
.actions-3 { flex-wrap: wrap; }

/* Navigation par onglets */
.onglets {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--bord);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.onglet {
  appearance: none;
  border: 0;
  background: none;
  color: var(--texte-doux);
  font: inherit;
  font-size: .75rem;
  height: var(--nav-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}
.onglet svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.onglet.actif { color: var(--accent); font-weight: 650; }

/* Feuilles (dialog) */
dialog.feuille {
  width: min(640px, 100%);
  max-width: 100%;
  max-height: 92vh;
  margin: auto auto 0;
  padding: 0 16px calc(16px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--fond);
  color: var(--texte);
  overflow-y: auto;
  overflow-x: hidden;
}
@media (min-width: 700px) { dialog.feuille { margin: auto; border-radius: 20px; } }
dialog::backdrop { background: rgba(20, 18, 16, .45); }
.feuille-entete {
  position: sticky;
  top: 0;
  background: var(--fond);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 8px;
  z-index: 1;
}

/* Carte de tenue */
.tenue {
  background: var(--surface);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 14px;
  margin: 10px 0;
  min-width: 0;
}
.tenue-titre { font-weight: 650; margin: 0 0 10px; }
.tenue-pieces { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.tenue-piece { min-width: 0; }
.tenue-piece .tuile-photo { border-radius: var(--rayon-petit); }
.tenue-piece span { display: block; font-size: .78rem; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tenue-explication { margin: 10px 0 0; font-size: .92rem; color: var(--texte-doux); }
.manque { font-size: .88rem; color: var(--texte-doux); }

/* Emma */
.ecran-emma { display: flex; flex-direction: column; min-height: calc(100vh - var(--nav-h) - 40px); }
.entete-emma { align-items: flex-start; }
.meteo { margin: 2px 0 0; font-size: .85rem; color: var(--texte-doux); }
.fil { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 6px 0 12px; }
.bulle {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 18px;
  overflow-wrap: anywhere;
}
.bulle-user { align-self: flex-end; background: var(--bulle-moi); color: var(--bulle-moi-texte); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.bulle-assistant { align-self: flex-start; background: var(--surface); box-shadow: var(--ombre); border-bottom-left-radius: 6px; }
.bulle-erreur { align-self: center; background: var(--alerte-fond); color: var(--alerte-texte); font-size: .9rem; }
.bloc-tenues { align-self: stretch; }
.accueil-emma { color: var(--texte-doux); }
.reflechit { color: var(--texte-doux); font-style: italic; padding: 4px 2px 10px; }
.saisie {
  position: sticky;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--fond);
  padding: 8px 0;
}
.saisie textarea { flex: 1; min-width: 0; resize: none; max-height: 140px; border-radius: 22px; padding: 11px 16px; }

/* --- Connexion (0.3.0) --- */
.ecran-connexion {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.ecran-connexion[hidden] { display: none; }
.connexion { max-width: 380px; width: 100%; text-align: center; }
.connexion h1 { margin: 8px 0 4px; font-size: 1.5rem; }
.connexion p { color: var(--texte-doux); margin: 0 0 20px; }
.connexion-icone { width: 64px; height: 64px; margin: 0 auto; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.compte {
  display: flex; justify-content: flex-end; align-items: center; gap: 8px;
  padding: 6px 16px 0; font-size: .8rem; color: var(--texte-doux);
}
.compte[hidden] { display: none; }
.lien {
  background: none; border: 0; padding: 4px 0; font: inherit; color: var(--accent);
  text-decoration: underline; cursor: pointer;
}
body.non-connecte main, body.non-connecte .onglets, body.non-connecte .bandeau { display: none; }

/* --- Mon style (0.4.0) --- */
.intro-style { margin-top: 0; }
.bloc-style { margin: 0 0 14px; }
.appro .bloc-style { box-shadow: none; padding: 0; margin: 0; background: none; }
.bloc-entete { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.bloc-style .message { margin: 10px 0 0; }
.sous-titre { font-size: .95rem; margin: 18px 0 0; font-weight: 650; }
.mots { display: grid; gap: 0; }
@media (min-width: 520px) { .mots { grid-template-columns: repeat(3, 1fr); gap: 10px; } }
.pastille {
  flex: none;
  font-size: .72rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px dashed var(--bord);
  color: var(--texte-doux);
  white-space: nowrap;
}
.pastille-fait { border: 1px solid var(--succes); color: var(--succes); }

/* Curseur 0 à 10 */
.curseur input[type="range"] { width: 100%; min-height: 44px; accent-color: var(--accent); margin: 0; }
.curseur-bornes { display: flex; justify-content: space-between; font-size: .75rem; color: var(--texte-doux); }
.curseur-valeur { display: block; margin-top: 4px; font-weight: 600; font-size: .92rem; }
.moyenne { margin: 16px 0 4px; padding: 10px 14px; border-radius: var(--rayon-petit); background: var(--accent-doux); }

/* Portrait */
.portrait { margin: 0 0 18px; }
.portrait-mots { font-size: 1.3rem; font-weight: 650; margin: 2px 0 6px; overflow-wrap: anywhere; }
.portrait-barometre { margin: 0 0 6px; }
.portrait-formule { margin: 0 0 6px; font-style: italic; color: var(--texte-doux); }
.portrait-liste { margin: 10px 0 0; display: grid; gap: 6px; }
.portrait-ligne { display: grid; grid-template-columns: 9.5em 1fr; gap: 8px; font-size: .92rem; }
.portrait-ligne dt { color: var(--texte-doux); }
.portrait-ligne dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 380px) { .portrait-ligne { grid-template-columns: 1fr; gap: 0; } }
.portrait-modifier { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 12px; font-size: .88rem; color: var(--texte-doux); }
.portrait-modifier .lien { min-height: 44px; }

/* Approfondissements */
.approfondir .entete { padding-top: 6px; }
.aide-compte { font-size: .85rem; color: var(--texte-doux); }
.appro { margin: 0 0 10px; padding: 0; overflow: hidden; }
.appro > .bloc-style { padding: 0 16px 14px; }
.appro-entete {
  appearance: none; border: 0; background: none; font: inherit; color: inherit; text-align: left;
  width: 100%; min-height: 56px; padding: 12px 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.appro-titres { display: grid; min-width: 0; }
.appro-resume { font-size: .85rem; color: var(--texte-doux); }

/* --- Photo de look envoyée à Emma (0.5.0) --- */
.saisie { flex-wrap: wrap; }
.btn-icone { flex: none; width: 44px; height: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.photo-look-apercu { flex-basis: 100%; display: flex; gap: 10px; align-items: center; min-width: 0; }
.photo-look-apercu[hidden] { display: none; }
.photo-look-apercu .puces { flex: 1; min-width: 0; padding-bottom: 0; }
.photo-look-vignette { position: relative; flex: none; }
.photo-look-vignette img { display: block; width: 64px; height: 84px; object-fit: cover; border-radius: var(--rayon-petit); border: 1px solid var(--bord); }
.photo-look-retirer {
  position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--bord); background: var(--surface); color: var(--texte); font: inherit; font-size: 1.05rem; line-height: 1; cursor: pointer;
}
.photo-look-menu { position: absolute; bottom: calc(100% + 4px); left: 0; display: grid; gap: 8px; padding: 10px; z-index: 5; min-width: 210px; }
.photo-look-menu[hidden] { display: none; }
.voile { position: fixed; inset: 0; background: rgba(30, 26, 22, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.voile[hidden] { display: none; }
.photo-look-info { max-width: 420px; width: 100%; }
.photo-look-info h2 { margin: 0 0 8px; font-size: 1.15rem; }
.photo-look-info p, .photo-look-info li { font-size: .95rem; }
.photo-look-info ul { margin: 6px 0 10px; padding-left: 20px; color: var(--texte-doux); }
.photo-look-plafond { color: var(--texte-doux); font-size: .85rem !important; margin: 0 0 14px; }
.photo-look-info .btn { width: 100%; }
.bulle-photo { display: block; max-width: 160px; max-height: 220px; border-radius: 12px; margin: 0 0 6px auto; object-fit: cover; }
.bulle-photo-absente { display: block; font-size: .85rem; opacity: .85; margin-bottom: 4px; font-style: italic; }
