:root {
  --pink: #ff6fa5;
  --purple: #8b5cf6;
  --teal: #14b8a6;
  --bg: #fbf7fb;
  --card: #ffffff;
  --text: #2a2438;
  --muted: #7a7288;
  --border: #ece4f2;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
}
button { font-family: inherit; }

/* --- PIN --- */
#pin-screen {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; padding: 24px;
  background: linear-gradient(145deg, var(--pink), var(--purple));
}
#pin-screen h1 { color: #fff; margin: 0; font-size: 1.6rem; }
#pin-screen .sub { color: #fff; opacity: .9; margin-top: -10px; font-size: 0.9rem; text-align: center; }
#pin-form {
  background: #fff; border-radius: 18px; padding: 28px; display: flex;
  flex-direction: column; gap: 14px; width: 100%; max-width: 300px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}
#pin-input {
  font-size: 1.8rem; text-align: center; letter-spacing: 0.3em;
  padding: 12px; border: 2px solid var(--border); border-radius: 12px; width: 100%;
}
#pin-form button {
  background: var(--purple); color: #fff; border: none; border-radius: 12px;
  padding: 13px; font-size: 1rem; font-weight: 700; cursor: pointer;
}
#pin-error { color: #e3457a; font-size: 0.85rem; text-align: center; min-height: 1.1em; }

/* --- App --- */
#app { display: none; max-width: 640px; margin: 0 auto; padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
#app.visible { display: block; }
.app-header {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: #fff; padding: 22px 20px 18px; border-radius: 0 0 24px 24px;
}
.app-header h1 { margin: 0; font-size: 1.4rem; }
.app-header .sub { opacity: .9; font-size: 0.85rem; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
  border-top: 1px solid var(--border); display: flex; max-width: 640px;
  margin: 0 auto; box-shadow: 0 -4px 14px rgba(0,0,0,0.06);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5;
}
.tabs button {
  flex: 1; background: none; border: none; padding: 12px 4px; font-size: 0.78rem;
  color: var(--muted); cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 2px;
}
.tabs button .icon { font-size: 1.3rem; }
.tabs button.active { color: var(--purple); font-weight: 700; }

.view { display: none; padding: 18px 16px; }
.view.active { display: block; }

/* --- Météo --- */
.weather-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  padding: 16px; margin-bottom: 16px; font-size: 0.9rem; color: var(--muted);
}
.w-main { display: flex; align-items: center; gap: 14px; color: var(--text); }
.w-icon { font-size: 2.6rem; line-height: 1; }
.w-temp { font-size: 1.8rem; font-weight: 800; }
.w-desc { color: var(--muted); font-size: 0.88rem; }
.w-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin-top: 14px; }
.w-grid div { background: #f7f3fb; border-radius: 10px; padding: 8px 10px; color: var(--text); font-weight: 700; font-size: 0.9rem; }
.w-grid span { display: block; font-weight: 400; font-size: 0.72rem; color: var(--muted); }
.w-tips { margin: 12px 0 0; padding-left: 18px; color: var(--text); }
.w-tips li { margin: 3px 0; }

/* --- Options --- */
.options { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 14px 16px; margin-bottom: 16px; }
.opt-title { font-size: 0.8rem; font-weight: 700; color: var(--muted); margin: 6px 0; text-transform: uppercase; letter-spacing: .03em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  border: 1px solid var(--border); background: #fff; color: var(--text); border-radius: 999px;
  padding: 7px 13px; font-size: 0.85rem; cursor: pointer;
}
.chip.on { background: var(--purple); color: #fff; border-color: var(--purple); font-weight: 700; }
.chip small { opacity: .7; }
.chips.small .chip { padding: 5px 10px; font-size: 0.78rem; }
.chips.filter { margin-bottom: 4px; }

.btn-main {
  width: 100%; background: linear-gradient(135deg, var(--pink), var(--purple)); color: #fff;
  border: none; border-radius: 14px; padding: 14px; font-size: 1rem; font-weight: 700;
  cursor: pointer; margin-top: 8px;
}
.btn-main.small { padding: 10px; font-size: 0.9rem; }
.btn-danger { width: 100%; background: #fdecef; color: #c0356b; border: none; border-radius: 14px; padding: 12px; font-weight: 700; cursor: pointer; margin-top: 8px; }
.btn-link { background: none; border: none; color: var(--muted); width: 100%; padding: 10px; cursor: pointer; }

/* --- Tenue --- */
.outfit-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 10px 0 18px; }
.outfit-item { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 10px; width: 46%; max-width: 150px; text-align: center; }
.outfit-item img { width: 100%; height: 130px; object-fit: contain; }
.outfit-item .label { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.outfit-actions { display: flex; gap: 12px; justify-content: center; }
.outfit-actions button { border: none; border-radius: 14px; padding: 14px 18px; font-size: 0.95rem; font-weight: 700; cursor: pointer; flex: 1; }
.btn-like { background: #e4fbf3; color: #0d9668; }
.btn-dislike { background: #fdecef; color: #c0356b; }
.btn-shuffle { background: #efe9fd; color: var(--purple); width: 100%; border: none; border-radius: 14px; padding: 13px; font-weight: 700; cursor: pointer; margin-top: 10px; }
.note { background: #fff6e0; border: 1px solid #ecd9a0; color: #6b5215; border-radius: 12px; padding: 10px 12px; font-size: 0.82rem; margin-bottom: 10px; }
.empty-note { text-align: center; color: var(--muted); padding: 26px 16px; font-size: 0.92rem; }

/* --- Garde-robe --- */
.wardrobe-group h3 { font-size: 0.95rem; color: var(--purple); margin: 16px 0 8px; }
.wardrobe-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.wardrobe-item {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 8px 6px; cursor: pointer; text-align: center;
}
.wardrobe-item img { width: 100%; height: 90px; object-fit: contain; }
.wardrobe-item .label { font-size: 0.74rem; margin-top: 4px; color: var(--text); }
.wardrobe-item .style-tag { font-size: 0.66rem; color: var(--muted); }
.hint { text-align: center; color: var(--muted); font-size: 0.78rem; margin-top: 16px; }

/* --- Ajout --- */
.upload-zone { border: 2px dashed var(--purple); border-radius: 18px; padding: 24px 18px; text-align: center; background: #faf7ff; }
.upload-zone input { display: none; }
.upload-title { font-weight: 800; font-size: 1.05rem; }
.upload-hint { font-size: 0.8rem; color: var(--muted); margin: 6px 0 14px; }
.btn-upload {
  display: block; background: var(--purple); color: #fff; font-weight: 700;
  padding: 14px; border-radius: 14px; cursor: pointer; margin-top: 10px;
}
.btn-upload.secondary { background: #fff; color: var(--purple); border: 2px solid var(--purple); }

.result-card {
  display: flex; gap: 12px; background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 12px; margin-top: 12px; align-items: flex-start;
}
.result-card img { width: 90px; height: 110px; object-fit: contain; flex-shrink: 0; background: repeating-conic-gradient(#f3eef7 0 25%, #fff 0 50%) 50% / 14px 14px; border-radius: 10px; }
.result-body { flex: 1; font-size: 0.88rem; min-width: 0; }
.result-title { margin-bottom: 6px; }
.result-body select { width: 100%; padding: 9px; border: 1px solid var(--border); border-radius: 10px; margin-top: 6px; font-size: 0.88rem; background: #fff; }
.result-card.pending { align-items: center; color: var(--muted); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--purple); animation: spin 0.9s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Fenêtre d'édition --- */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet.hidden { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(30,20,40,0.45); }
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto;
  background: #fff; border-radius: 22px 22px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
}
.sheet-body img { display: block; margin: 0 auto 12px; max-height: 200px; max-width: 100%; object-fit: contain; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 0.8rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.field select { width: 100%; padding: 11px; border: 1px solid var(--border); border-radius: 12px; font-size: 0.95rem; background: #fff; }
.sheet-actions { display: flex; flex-direction: column; }

.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: #2a2438; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 0.88rem; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 30;
}
.toast.show { opacity: 1; }

/* --- Tenues enregistrées --- */
.btn-save {
  width: 100%; background: #fff7e0; color: #a86b00; border: 2px solid #f5c542;
  border-radius: 14px; padding: 13px; font-weight: 700; font-size: 0.95rem;
  cursor: pointer; margin-bottom: 10px;
}
.btn-save:disabled { opacity: .75; cursor: default; }
.fav-card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 14px; margin-bottom: 14px; }
.fav-name { font-weight: 800; font-size: 1rem; }
.fav-meta { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.fav-items { display: flex; gap: 8px; overflow-x: auto; margin: 12px 0; padding-bottom: 4px; }
.fav-item { flex: 0 0 auto; width: 84px; text-align: center; font-size: 0.7rem; color: var(--muted); }
.fav-item img { width: 84px; height: 84px; object-fit: contain; background: #faf7fd; border-radius: 12px; }
.fav-actions { display: flex; gap: 8px; }
.fav-actions button { flex: 1; border: none; border-radius: 12px; padding: 10px; font-weight: 700; cursor: pointer; background: #efe9fd; color: var(--purple); }
.fav-actions button.danger { background: #fdecef; color: #c0356b; }
.tabs button { font-size: 0.72rem; }
