/* ============================================================================
   Dressing — feuille de style.
   Design minimaliste, taillé mobile, mode clair/sombre soigné.
   Couleurs pilotées par des variables ; un attribut data-theme sur <html>
   force clair/sombre, sinon on suit le réglage du système.
   ============================================================================ */

:root {
  --fond: #faf7f2;
  --fond-2: #ffffff;
  --fond-3: #f1ece3;
  --texte: #1d1b19;
  --texte-doux: #6f6a63;
  --bordure: #e7e0d5;
  --accent: #b5835a;         /* terracotta/camel doux, esprit mode */
  --accent-contraste: #ffffff;
  --danger: #c0493b;
  --ombre: 0 6px 24px rgba(40, 33, 24, 0.10);
  --rayon: 18px;
  --rayon-sm: 12px;
  --nav-h: 68px;
}

:root[data-theme="dark"],
html:not([data-theme="light"]) {
  /* valeurs par défaut en sombre si le système est sombre */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #0f0f12;
    --fond-2: #17171c;
    --fond-3: #1f1f26;
    --texte: #f3f1ee;
    --texte-doux: #a09aa8;
    --bordure: #2a2a33;
    --accent: #cf9c74;
    --accent-contraste: #1a1208;
    --ombre: 0 6px 24px rgba(0, 0, 0, 0.45);
  }
}
:root[data-theme="dark"] {
  --fond: #0f0f12;
  --fond-2: #17171c;
  --fond-3: #1f1f26;
  --texte: #f3f1ee;
  --texte-doux: #a09aa8;
  --bordure: #2a2a33;
  --accent: #cf9c74;
  --accent-contraste: #1a1208;
  --ombre: 0 6px 24px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--fond);
  color: var(--texte);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--texte-doux); font-size: 0.86rem; line-height: 1.45; }
.erreur { color: var(--danger); font-size: 0.86rem; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

/* ---------- Boutons ---------- */
.btn {
  border: none; border-radius: 999px; padding: 13px 18px; font-size: 0.98rem;
  font-weight: 600; cursor: pointer; width: 100%; transition: transform .06s ease, opacity .2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-plein { background: var(--accent); color: var(--accent-contraste); }
.btn-ligne { background: var(--fond-3); color: var(--texte); border: 1px solid var(--bordure); }
.btn-texte { background: none; color: var(--texte-doux); }
.btn-texte.accent { color: var(--accent); font-weight: 700; }
.btn-danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); margin-top: 8px; }
.btn-icone {
  background: var(--fond-3); border: 1px solid var(--bordure); color: var(--texte);
  width: 42px; height: 42px; border-radius: 50%; font-size: 1.1rem; cursor: pointer; display: grid; place-items: center;
}
.ligne-boutons { display: flex; gap: 10px; }
.ligne-boutons .btn { width: auto; flex: 1; }

/* ---------- Connexion ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--fond); padding: 24px; z-index: 50; }
.login-carte { width: 100%; max-width: 340px; text-align: center; display: flex; flex-direction: column; gap: 14px; }
.login-logo { font-size: 3rem; }
.login-carte input { padding: 14px 16px; border-radius: var(--rayon-sm); border: 1px solid var(--bordure); background: var(--fond-2); color: var(--texte); font-size: 1rem; }

/* ---------- Structure ---------- */
.app { max-width: 720px; margin: 0 auto; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
.entete {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 12px; background: color-mix(in srgb, var(--fond) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.entete h1 { font-size: 1.5rem; }
.entete-actions { display: flex; align-items: center; gap: 10px; }
.meteo { font-size: 0.9rem; color: var(--texte-doux); background: var(--fond-3); border: 1px solid var(--bordure); padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.vue { padding: 6px 16px 20px; }

/* ---------- Filtres ---------- */
.filtres { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 10px; scrollbar-width: none; }
.filtres::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--bordure); background: var(--fond-2); color: var(--texte);
  padding: 8px 14px; border-radius: 999px; font-size: 0.9rem; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.chip.actif { background: var(--texte); color: var(--fond); border-color: var(--texte); }
.chip-toggle.actif { background: var(--accent); color: var(--accent-contraste); border-color: var(--accent); }
.sous-filtres { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.select-mini {
  border: 1px solid var(--bordure); background: var(--fond-2); color: var(--texte);
  padding: 8px 12px; border-radius: 999px; font-size: 0.88rem; font-weight: 550;
}

/* ---------- Grille dressing ---------- */
.grille { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 380px) { .grille { grid-template-columns: repeat(2, 1fr); } }
.carte-vet {
  position: relative; aspect-ratio: 3/4; border-radius: var(--rayon-sm); overflow: hidden;
  background: var(--fond-3); border: 1px solid var(--bordure); cursor: pointer;
  display: grid; place-items: center;
}
.carte-vet img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.carte-vet .fav { position: absolute; top: 7px; right: 8px; font-size: 0.95rem; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.carte-vet .nom { position: absolute; left: 0; right: 0; bottom: 0; font-size: 0.72rem; padding: 14px 8px 6px; color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,.55), transparent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Écrans vides ---------- */
.vide { text-align: center; padding: 60px 20px; }
.vide-emoji { font-size: 3.2rem; margin-bottom: 10px; }

/* ---------- Tenues ---------- */
.tenue-controles { display: flex; gap: 10px; margin-bottom: 10px; }
.tenue-controles .btn { width: auto; flex: 1; }
.explication { min-height: 1.1em; margin: 2px 4px 8px; }
.scene {
  background: radial-gradient(120% 90% at 50% 10%, var(--fond-2), var(--fond-3));
  border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 18px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 240px; justify-content: center;
}
.scene-mini { min-height: 150px; padding: 10px; }
.scene .piece { width: 46%; max-width: 180px; }
.scene .piece img { width: 100%; object-fit: contain; filter: drop-shadow(0 8px 14px rgba(0,0,0,.18)); }
.scene .piece.chaussures { width: 38%; }
.scene .vide-msg { color: var(--texte-doux); text-align: center; }
.section-titre { font-size: 1.1rem; margin: 22px 4px 12px; }
.grille-tenues { grid-template-columns: repeat(2, 1fr); }
.carte-tenue {
  background: var(--fond-2); border: 1px solid var(--bordure); border-radius: var(--rayon-sm);
  padding: 8px; cursor: pointer; aspect-ratio: 3/4; display: flex; flex-direction: column; gap: 4px; position: relative;
}
.carte-tenue .mini { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; overflow: hidden; }
.carte-tenue .mini img { width: 100%; height: 100%; object-fit: contain; background: var(--fond-3); border-radius: 6px; }
.carte-tenue .supp { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.45); color:#fff; border:none; border-radius:50%; width:26px; height:26px; cursor:pointer; }

/* ---------- Calendrier ---------- */
.cal-entete { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 14px; }
.cal-entete h2 { font-size: 1.15rem; text-transform: capitalize; }
.cal-jours-sem { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; color: var(--texte-doux); font-size: 0.72rem; margin-bottom: 6px; }
.cal-grille { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-jour {
  aspect-ratio: 1; border-radius: 10px; background: var(--fond-2); border: 1px solid var(--bordure);
  position: relative; cursor: pointer; display: flex; flex-direction: column; padding: 4px; overflow: hidden;
}
.cal-jour.vide-cell { background: none; border: none; cursor: default; }
.cal-jour .num { font-size: 0.72rem; color: var(--texte-doux); }
.cal-jour.aujourdhui { border-color: var(--accent); }
.cal-jour.aujourdhui .num { color: var(--accent); font-weight: 700; }
.cal-jour .vignette-jour { position: absolute; inset: 18px 3px 3px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.cal-jour .vignette-jour img { width: 100%; height: 100%; object-fit: contain; }
.cal-jour .point { position: absolute; bottom: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* ---------- Cartes réglages ---------- */
.carte { background: var(--fond-2); border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 16px; margin-bottom: 14px; }
.carte h2 { font-size: 1.05rem; margin-bottom: 8px; }
.champ { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.champ > span { font-size: 0.82rem; color: var(--texte-doux); font-weight: 600; }
.champ input[type="text"], .champ input[type="password"], .champ select {
  padding: 12px 14px; border-radius: var(--rayon-sm); border: 1px solid var(--bordure);
  background: var(--fond); color: var(--texte); font-size: 1rem;
}
.champ-ligne { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0; }
.version { text-align: center; margin-top: 18px; }

/* interrupteur */
.switch { appearance: none; width: 48px; height: 28px; background: var(--bordure); border-radius: 999px; position: relative; cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; transition: left .2s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { left: 23px; }

/* ---------- Saisons & couleurs (éditeur) ---------- */
.saisons-toggle { display: flex; gap: 6px; flex-wrap: wrap; }
.saisons-toggle button { flex: 1; min-width: 70px; border: 1px solid var(--bordure); background: var(--fond); color: var(--texte); padding: 9px; border-radius: 10px; font-size: 0.82rem; cursor: pointer; }
.saisons-toggle button.actif { background: var(--accent); color: var(--accent-contraste); border-color: var(--accent); }
.couleurs-liste { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pastille-couleur { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--bordure); position: relative; overflow: hidden; }
.pastille-couleur input { position: absolute; inset: -6px; width: 150%; height: 150%; border: none; padding: 0; cursor: pointer; }
.ajouter-couleur { width: 34px; height: 34px; border-radius: 50%; border: 1px dashed var(--bordure); background: none; color: var(--texte-doux); font-size: 1.1rem; cursor: pointer; }

/* ---------- Barre de navigation ---------- */
.barre-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--fond-2) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--bordure); display: flex; align-items: center; justify-content: space-around; z-index: 30;
  max-width: 720px; margin: 0 auto;
}
.nav-item { background: none; border: none; color: var(--texte-doux); font-size: 0.68rem; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; flex: 1; padding: 6px 0; }
.nav-item span { font-size: 1.3rem; }
.nav-item.actif { color: var(--accent); }
.fab {
  width: 56px; height: 56px; min-width: 56px; border-radius: 50%; border: none; background: var(--accent); color: var(--accent-contraste);
  font-size: 1.9rem; line-height: 1; cursor: pointer; box-shadow: var(--ombre); margin-top: -18px; transition: transform .08s;
}
.fab:active { transform: scale(0.92); }

/* ---------- Feuilles (bottom sheets) ---------- */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-fond { position: absolute; inset: 0; background: rgba(0,0,0,.42); }
.sheet-contenu {
  position: relative; width: 100%; max-width: 720px; background: var(--fond-2); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px;
  animation: monter .22s ease; max-height: 86vh; overflow-y: auto;
}
.sheet-contenu h3 { text-align: center; margin: 6px 0 8px; }
.sheet-poignee { width: 40px; height: 4px; background: var(--bordure); border-radius: 999px; margin: 4px auto 6px; }
@keyframes monter { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ---------- Modal éditeur ---------- */
.modal { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; }
.modal-fond { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.modal-contenu {
  position: relative; width: 100%; max-width: 560px; height: 100%; max-height: 100%; background: var(--fond);
  overflow-y: auto; padding: 0 18px calc(28px + env(safe-area-inset-bottom)); animation: monter .22s ease;
}
@media (min-width: 560px) { .modal-contenu { height: auto; max-height: 92vh; border-radius: var(--rayon); } }
.modal-entete {
  position: sticky; top: 0; background: color-mix(in srgb, var(--fond) 88%, transparent); backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top) + 12px) 0 12px; z-index: 5;
}
.apercu-zone { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 8px; }
.apercu-vignette { width: 200px; height: 240px; border-radius: var(--rayon-sm); background: var(--fond-3); border: 1px solid var(--bordure); display: grid; place-items: center; overflow: hidden; }
.apercu-vignette img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.apercu-actions { display: flex; gap: 8px; }
.progression { width: 100%; display: flex; align-items: center; gap: 10px; }
.progression .barre { flex: 1; height: 6px; background: var(--fond-3); border-radius: 999px; overflow: hidden; }
.progression .barre::after { content: ""; display: block; height: 100%; width: var(--p, 20%); background: var(--accent); transition: width .2s; }
.progression span { font-size: 0.78rem; color: var(--texte-doux); white-space: nowrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px); transform: translateX(-50%);
  background: var(--texte); color: var(--fond); padding: 11px 18px; border-radius: 999px; font-size: 0.9rem;
  z-index: 90; box-shadow: var(--ombre); max-width: 90%; text-align: center; animation: apparait .2s ease;
}
@keyframes apparait { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.btn-charge { opacity: .7; pointer-events: none; }

/* ---------- Ajouts : compo, étiquette, stats, valise, associations ---------- */
.deux-colonnes { display: flex; gap: 10px; }
.deux-colonnes .champ { flex: 1; }

.entretien-liste { display: flex; flex-wrap: wrap; gap: 6px; }
.entretien-liste .tag {
  background: var(--fond-3); border: 1px solid var(--bordure); color: var(--texte);
  padding: 6px 10px; border-radius: 999px; font-size: 0.8rem;
}

/* Stats */
#stats-contenu { display: flex; flex-direction: column; gap: 16px; }
.stat-ligne { display: flex; justify-content: space-between; align-items: baseline; }
.stat-ligne .valeur { font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.stat-grille { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-case { background: var(--fond-3); border: 1px solid var(--bordure); border-radius: var(--rayon-sm); padding: 12px; text-align: center; }
.stat-case .n { font-size: 1.5rem; font-weight: 700; }
.stat-case .l { font-size: 0.72rem; color: var(--texte-doux); }
.stats-sous-titre { font-size: 0.82rem; color: var(--texte-doux); font-weight: 600; margin-bottom: 8px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--bordure); }
.rangee-vignettes { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.rangee-vignettes::-webkit-scrollbar { display: none; }
.rangee-vignettes img { width: 62px; height: 78px; object-fit: contain; background: var(--fond-3); border: 1px solid var(--bordure); border-radius: 10px; flex: none; }
.mini-nom { font-size: 0.64rem; color: var(--texte-doux); text-align: center; max-width: 62px; }

/* Valise */
#valise-resultat { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.valise-jour { border: 1px solid var(--bordure); border-radius: var(--rayon-sm); padding: 10px; }
.valise-jour h4 { margin: 0 0 8px; font-size: 0.9rem; }
.valise-packing { background: var(--fond-3); border: 1px solid var(--bordure); border-radius: var(--rayon-sm); padding: 12px; }
.valise-packing label { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 0.92rem; }
.valise-packing img { width: 34px; height: 42px; object-fit: contain; }

/* Le panneau "Avec quoi ça va ?" s'ouvre depuis l'éditeur : au-dessus de lui. */
#sheet-assort { z-index: 80; }
