:root {
  --bg: #faf6f2;
  --surface: #ffffff;
  --ink: #3b3135;
  --muted: #8b7d81;
  --rose: #b97a86;
  --rose-dark: #9d6370;
  --blush: #f5e7e7;
  --sand: #ece1d8;
  --line: #eadfd8;
  --ok: #6f8f7a;
  --danger: #b5535c;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(91, 62, 70, .07);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Jost', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-weight: 400; line-height: 1.55; font-size: 16px;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0 0 .4em; line-height: 1.15; letter-spacing: .01em; }
h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); }
h2 { font-size: 1.9rem; }
h3 { font-size: 1.35rem; }
p { margin: 0 0 .8em; }
a { color: var(--rose-dark); }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.hidden { display: none !important; }

/* ---------- boutons & champs ---------- */
button, .btn {
  font: inherit; cursor: pointer; border: 1px solid transparent; border-radius: 999px;
  padding: .6em 1.35em; background: var(--rose); color: #fff; font-weight: 500; letter-spacing: .02em;
  transition: background .15s, transform .05s, opacity .15s;
}
button:hover { background: var(--rose-dark); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: default; }
button.ghost { background: transparent; color: var(--rose-dark); border-color: var(--line); }
button.ghost:hover { background: var(--blush); }
button.danger { background: transparent; color: var(--danger); border-color: var(--line); }
button.danger:hover { background: #f8e9ea; }
button.link { background: none; border: 0; padding: 0; color: var(--rose-dark); text-decoration: underline; }
button.big { padding: .85em 2em; font-size: 1.05rem; }
input, textarea, select {
  font: inherit; color: inherit; width: 100%; padding: .65em .9em; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(185, 122, 134, .15); }
textarea { resize: vertical; min-height: 70px; }
label { display: block; font-size: .88rem; color: var(--muted); margin: 0 0 .25em; }
.field { margin-bottom: 1em; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 200px; }
.spacer { flex: 1; }

/* ---------- accueil ---------- */
.landing { min-height: 100vh; display: flex; flex-direction: column; }
.hero {
  flex: 1; display: grid; place-items: center; text-align: center; padding: 3rem 1.25rem;
  background: radial-gradient(1200px 500px at 50% -10%, var(--blush), transparent 70%);
}
.hero-inner { max-width: 640px; }
.logo { font-family: var(--serif); font-style: italic; font-size: 1.6rem; color: var(--rose-dark); letter-spacing: .02em; }
.logo b { font-style: normal; font-weight: 600; }
.logo-hero { display: block; width: min(260px, 60vw); margin: 0 auto .5rem; mix-blend-mode: multiply; }
.logo-nav { display: block; height: 44px; width: auto; mix-blend-mode: multiply; }
.hero h1 { margin: .2em 0 .3em; }
.hero h1 em { color: var(--rose); font-weight: 500; }
.hero p.lead { font-size: 1.15rem; color: var(--muted); max-width: 30em; margin: 0 auto 2rem; }
.login-box { display: grid; gap: .9rem; justify-items: center; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 1rem; max-width: 900px; margin: 3rem auto 0; padding: 0 1.25rem 3rem; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; text-align: left; }
.feature .ico { font-size: 1.5rem; }
.feature h3 { font-size: 1.2rem; margin-top: .3em; }
.feature p { margin: 0; color: var(--muted); font-size: .95rem; }
.dev-login { display: flex; gap: .5rem; max-width: 380px; width: 100%; }

/* ---------- coque appli ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(250, 246, 242, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: .7rem 1.25rem; display: flex; align-items: center; gap: 1.2rem; }
.nav { display: flex; gap: .3rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a {
  text-decoration: none; color: var(--muted); padding: .4em .95em; border-radius: 999px; white-space: nowrap; font-weight: 500;
}
.nav a:hover { color: var(--ink); }
.nav a.active { background: var(--blush); color: var(--rose-dark); }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--sand); display: grid; place-items: center; color: var(--rose-dark); font-weight: 500; flex: none; }
.user-box { display: flex; align-items: center; gap: .6rem; flex: none; }
.user-email { font-size: .85rem; color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.small-btn { padding: .3em .9em; font-size: .85rem; white-space: nowrap; }
.nav-ico { display: none; }
@media (max-width: 860px) { .user-email { display: none; } }

/* Mobile : le menu passe en barre d'onglets fixe en bas de l'écran */
@media (max-width: 760px) {
  .topbar { backdrop-filter: none; background: var(--bg); } /* sinon le menu fixe se cale sur la barre du haut */
  .topbar-inner { justify-content: space-between; }
  .user-box { margin-left: auto; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; flex: none; gap: 0; overflow: visible;
    background: rgba(255, 255, 255, .97); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
    padding: .35rem .4rem calc(.35rem + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 18px rgba(91, 62, 70, .06);
  }
  .nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem;
    padding: .35rem .2rem; border-radius: 12px; font-size: .72rem; line-height: 1.15; text-align: center;
  }
  .nav-ico { display: block; font-size: 1.3rem; line-height: 1; filter: grayscale(.5); }
  .nav a.active .nav-ico { filter: none; }
  .nav a.active { background: var(--blush); }
  main { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  #toasts { bottom: calc(5rem + env(safe-area-inset-bottom)); }
}
main { max-width: 1080px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
.page-head { display: flex; align-items: end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h2 { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }

/* ---------- composer ---------- */
.composer-box { display: grid; gap: 1rem; }
.occasion-input { font-size: 1.15rem; padding: .85em 1.1em; border-radius: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chips .chip { flex: 1 1 auto; text-align: center; } /* chaque ligne de puces remplit toute la largeur */
.chip {
  background: #fff; color: var(--ink); border: 1px solid var(--line); padding: .35em .95em; font-weight: 400; font-size: .92rem;
}
.chip:hover { background: var(--blush); }
.chip.on { background: var(--rose); color: #fff; border-color: var(--rose); }
.seg { display: inline-flex; background: var(--sand); border-radius: 999px; padding: 3px; }
.seg button { background: transparent; color: var(--muted); padding: .35em 1.1em; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.weather { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; background: var(--blush); border-radius: 14px; padding: .8rem 1.1rem; }
.weather .w-ico { font-size: 2rem; line-height: 1; }
.weather .w-temp { font-family: var(--serif); font-size: 1.6rem; }

.outfit { margin-top: 1.5rem; }
.outfit h3 { font-size: 1.8rem; }
.outfit .summary { color: var(--muted); font-size: 1.02rem; max-width: 46em; }
.pieces { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .9rem; margin: 1.1rem 0; }
.piece { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.piece .ph { aspect-ratio: 3 / 4; background: var(--sand); display: grid; place-items: center; color: var(--muted); font-size: 2rem; }
.piece .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.piece .pb { padding: .55rem .7rem .7rem; }
.piece .cat { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--rose-dark); }
.piece .nm { font-weight: 500; line-height: 1.25; }
.piece .tip { font-size: .83rem; color: var(--muted); margin-top: .2rem; }
.piece.missing .ph { border-bottom: 1px dashed var(--line); }
.extras { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .8rem; }
.extra { background: var(--bg); border-radius: 14px; padding: .8rem 1rem; border: 1px solid var(--line); }
.extra h4 { margin: 0 0 .2em; font-family: var(--serif); font-size: 1.2rem; font-weight: 600; color: var(--rose-dark); }
.extra p { margin: 0; font-size: .95rem; }
.feedback { margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--line); display: grid; gap: .8rem; }
.stars { display: inline-flex; gap: 2px; }
.stars button { background: none; color: #d8ccc8; font-size: 1.6rem; padding: 0 .1em; line-height: 1; border: 0; }
.stars button.on { color: #d9a441; }
.stars button:hover { background: none; color: #d9a441; }
.stars.ro button { cursor: default; font-size: 1.1rem; pointer-events: none; }

.spinner { width: 22px; height: 22px; border: 3px solid var(--sand); border-top-color: var(--rose); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: .8rem; padding: 1.5rem 0; color: var(--muted); }

/* ---------- dressing ---------- */
.tabs { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .4rem; margin-bottom: 1rem; scrollbar-width: thin; }
.tab { background: #fff; color: var(--ink); border: 1px solid var(--line); white-space: nowrap; padding: .4em 1em; font-weight: 400; }
.tab:hover { background: var(--blush); }
.tab.on { background: var(--rose); border-color: var(--rose); color: #fff; }
.tab .n { opacity: .7; margin-left: .35em; font-size: .85em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 1rem; }
.item { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; transition: box-shadow .15s, transform .15s; }
.item:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.item .ph { aspect-ratio: 3 / 4; background: var(--sand); }
.item .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item .ib { padding: .55rem .75rem .7rem; }
.item .nm { font-weight: 500; line-height: 1.25; }
.item .cl { font-size: .83rem; color: var(--muted); }
.item .x {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; padding: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .92); color: var(--danger); border: 1px solid var(--line); font-size: 1.1rem; line-height: 1;
  opacity: 0; transition: opacity .15s;
}
.item:hover .x, .item .x:focus { opacity: 1; }
@media (hover: none) { .item .x { opacity: 1; } }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); background: rgba(255, 255, 255, .5); }
.help { background: var(--blush); border-radius: 12px; padding: .7rem 1rem; margin-bottom: 1rem; color: var(--rose-dark); font-size: .95rem; }

/* ---------- tenues ---------- */
.olist { display: grid; gap: 1rem; }
.ocard .head { display: flex; gap: .8rem; align-items: baseline; flex-wrap: wrap; }
.ocard h3 { margin: 0; font-size: 1.4rem; }
.badge { font-size: .75rem; background: var(--sand); border-radius: 999px; padding: .15em .7em; color: var(--muted); }
.badge.ok { background: #e3eee7; color: var(--ok); }
.thumbs { display: flex; gap: .5rem; flex-wrap: wrap; margin: .8rem 0; }
.thumb { width: 56px; height: 72px; border-radius: 10px; background: var(--sand); overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: .7rem; text-align: center; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- modale ---------- */
.overlay { position: fixed; inset: 0; background: rgba(59, 49, 53, .45); display: grid; place-items: center; z-index: 50; padding: 1rem; overflow-y: auto; }
.modal { background: var(--bg); border-radius: 20px; width: min(640px, 100%); max-height: calc(100vh - 2rem); overflow-y: auto; padding: 1.5rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal h3 { font-size: 1.7rem; }
.modal .actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1rem; }
.detail-photo { width: 100%; max-height: 360px; object-fit: contain; background: var(--sand); border-radius: 14px; margin-bottom: 1rem; }
.checks { display: flex; gap: .5rem; flex-wrap: wrap; }
.checks label { display: inline-flex; align-items: center; gap: .35em; margin: 0; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: .25em .8em; cursor: pointer; }
.checks input { width: auto; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: .5rem; }
.pick { border: 2px solid transparent; border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--sand); position: relative; }
.pick img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; }
.pick.on { border-color: var(--rose); }
.pick.on::after { content: '✓'; position: absolute; top: 3px; right: 3px; background: var(--rose); color: #fff; border-radius: 50%; width: 20px; height: 20px; font-size: .8rem; display: grid; place-items: center; }
.pick small { display: block; padding: 2px 4px; font-size: .68rem; line-height: 1.15; background: #fff; }
.progress-list { display: grid; gap: .4rem; margin-top: .8rem; font-size: .92rem; }
.progress-list div { display: flex; gap: .6rem; align-items: center; }
.loc-results { display: grid; gap: .3rem; margin-top: .5rem; }
.loc-results button { text-align: left; border-radius: 10px; background: #fff; color: var(--ink); border: 1px solid var(--line); }
.loc-results button:hover { background: var(--blush); }

.taste-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.pill-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.pill { background: var(--blush); color: var(--rose-dark); padding: .2em .8em; border-radius: 999px; font-size: .9rem; }
.pill.neg { background: #f1e6e0; color: #8a5b49; }

#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: .5rem; width: min(440px, calc(100% - 2rem)); }
.toast { background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 12px; box-shadow: var(--shadow); font-size: .95rem; }
.toast.err { background: var(--danger); }

@media (max-width: 640px) {
  .topbar-inner { gap: .6rem; padding: .6rem .8rem; }
  .logo { font-size: 1.3rem; }
  main { padding: 1.25rem .9rem 3rem; }
  .pieces { grid-template-columns: repeat(2, 1fr); }
}
