:root {
  --bg: #f5f4f1;
  --surface: #ffffff;
  --surface-2: #ecebe7;
  --photo: #efeeea;
  --text: #111111;
  --muted: #6d6b66;
  --line: #e2e0db;
  --accent: #111111;
  --accent-ink: #ffffff;
  --ok: #1f7a4d;
  --warn: #a15c07;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
  --radius: 18px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e0f;
    --surface: #18181a;
    --surface-2: #232326;
    --photo: #efeeea;
    --text: #f4f3f0;
    --muted: #9c9a95;
    --line: #2b2b2f;
    --accent: #f4f3f0;
    --accent-ink: #111111;
    --ok: #4cc38a;
    --warn: #f0a33a;
    --danger: #f97066;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--sans);
  min-height: 100vh;
}
h1, h2, h3 { line-height: 1.15; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }
a { color: inherit; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
main {
  outline: none; max-width: 720px; margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }

.wordmark { font-size: 14px; font-weight: 700; letter-spacing: .42em; text-align: center; margin: 2px 0 14px; padding-left: .42em; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn svg { width: 18px; height: 18px; flex: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--text); flex: none;
}
.icon-btn svg { width: 20px; height: 20px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; }

/* ---------- Puces ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"], .chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.event { cursor: default; background: var(--surface-2); border-color: transparent; }
.chip.add { border-style: dashed; color: var(--muted); }
.chip svg { width: 14px; height: 14px; }
.chip .count { opacity: .6; font-weight: 400; }

/* ---------- Cartes ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 22px 0 10px; }
.section-title h2 { font-size: 17px; }

/* ---------- Accueil ---------- */
.hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 0 16px; }
.hello h1 { font-size: 26px; }
.hello .date { color: var(--muted); font-size: 14px; margin-top: 2px; }
.hello .date::first-letter { text-transform: uppercase; }
.weather-now { display: flex; align-items: center; gap: 8px; text-align: right; }
.weather-now svg { width: 30px; height: 30px; }
.weather-now b { font-size: 22px; display: block; line-height: 1; }
.weather-now span { font-size: 12px; color: var(--muted); }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 0 -4px; }
.day {
  display: grid; justify-items: center; gap: 3px; padding: 8px 0 9px; border-radius: 14px;
  border: 0; background: none; cursor: pointer; color: var(--text);
}
.day .dn { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.day .dd { font-size: 17px; font-weight: 700; }
.day .dt { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 1px; }
.day .dt svg { width: 13px; height: 13px; }
.day .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0; }
.day.has .dot { opacity: .9; }
.day.worn .dot { background: var(--ok); }
.day[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.day[aria-pressed="true"] .dn, .day[aria-pressed="true"] .dt { color: inherit; opacity: .75; }

.program { margin-top: 18px; }
.program .chips { margin-top: 8px; }

.outfit { margin-top: 16px; padding: 18px 16px 16px; }
.outfit-head { display: flex; align-items: flex-start; gap: 10px; }
.outfit-head h2 { font-size: 22px; flex: 1; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; letter-spacing: .03em;
  padding: 4px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.ok { color: var(--ok); }
.outfit-why { color: var(--muted); margin-top: 6px; font-size: 15px; }
.outfit-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }
.outfit-grid.n3 > :first-child, .outfit-grid.n5 > :first-child { grid-column: span 2; }
.outfit-grid.n3 > :first-child .ph, .outfit-grid.n5 > :first-child .ph { aspect-ratio: 2 / 1.15; }
.piece { border: 0; padding: 0; background: none; text-align: left; cursor: pointer; color: var(--text); min-width: 0; }
.piece .ph { aspect-ratio: 1; border-radius: 14px; background: var(--photo); overflow: hidden; display: grid; place-items: center; }
.piece .ph img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.piece .nm { font-size: 13px; font-weight: 600; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.piece .ct { font-size: 12px; color: var(--muted); }
.outfit-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }

.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 14px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
  animation: shimmer 1.4s infinite;
}
@media (prefers-color-scheme: dark) { .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent); } }
@keyframes shimmer { to { transform: translateX(100%); } }
.thinking { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 15px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--text); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 34px 18px; }
.empty svg { width: 54px; height: 54px; margin: 0 auto 12px; opacity: .8; }
.empty h2 { margin-bottom: 6px; }
.empty p { color: var(--muted); margin-bottom: 18px; }

.banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); font-size: 14px; margin-top: 14px; }
.banner svg { width: 20px; height: 20px; flex: none; }
.banner .btn { margin-left: auto; }

/* ---------- Dressing ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 14px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.tile { border: 0; padding: 0; background: none; cursor: pointer; text-align: left; color: var(--text); min-width: 0; }
.tile .ph { aspect-ratio: 3 / 4; border-radius: 14px; background: var(--photo); overflow: hidden; }
.tile .ph img { width: 100%; height: 100%; object-fit: cover; }
.tile .nm { font-size: 12px; font-weight: 500; margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .15); vertical-align: -1px; margin-right: 4px; }

.fab {
  position: fixed; right: max(16px, calc(50% - 344px)); bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 15;
  display: inline-flex; align-items: center; gap: 8px; height: 52px; padding: 0 20px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); cursor: pointer; text-decoration: none;
}
.fab svg { width: 20px; height: 20px; }

/* ---------- Import ---------- */
.switch-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 12px; background: var(--surface); border-radius: 14px; cursor: pointer; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.switch-row span { display: grid; gap: 2px; }
.switch-row small { color: var(--muted); font-size: 13px; }
.pickers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.picker {
  display: grid; justify-items: center; gap: 8px; padding: 20px 10px; border-radius: var(--radius);
  border: 1.5px dashed var(--line); background: var(--surface); cursor: pointer; font-weight: 600; text-align: center;
}
.picker svg { width: 28px; height: 28px; }
.picker small { font-weight: 400; color: var(--muted); font-size: 12px; }
.picker input { display: none; }
.queue { display: grid; gap: 10px; margin-top: 16px; }
.qitem { display: flex; gap: 12px; align-items: center; background: var(--surface); border-radius: 16px; padding: 10px; box-shadow: var(--shadow); }
.qthumb { flex: none; }
.qitem img, .qitem .qph { width: 64px; height: 80px; border-radius: 10px; object-fit: cover; background: var(--photo); flex: none; }
.qitem .qbody { flex: 1; min-width: 0; display: grid; gap: 4px; }
.qitem input, .qitem select { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 6px 10px; font-size: 14px; }
.qitem input:focus, .qitem select:focus { outline: none; border-color: var(--text); }
.qitem .qstate { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.qitem .qstate.err { color: var(--warn); }
.sticky-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); z-index: 15;
  padding: 12px 16px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.sticky-bar > div { max-width: 688px; margin: 0 auto; display: flex; gap: 10px; }

/* ---------- Formulaires ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, .field input:not([type="range"]):not([type="color"]), .field select, .field textarea, textarea.input {
  width: 100%; min-height: 46px; padding: 11px 14px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); font-size: 16px; outline: none;
}
.field textarea, textarea.input { resize: vertical; min-height: 96px; line-height: 1.4; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--text); }
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.range-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input[type="color"] { width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 4px; background: var(--surface); flex: none; }
.error-msg { color: var(--danger); font-size: 14px; min-height: 1em; }

/* ---------- Connexion ---------- */
.auth { min-height: calc(100vh - 140px); display: grid; align-content: center; gap: 22px; max-width: 400px; margin: 0 auto; }
.auth .logo { width: 72px; height: 72px; margin: 0 auto; }
.auth h1 { text-align: center; font-size: 15px; letter-spacing: .42em; padding-left: .42em; }
.auth .tagline { text-align: center; color: var(--muted); margin-top: -12px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.seg button { border: 0; background: none; border-radius: 999px; min-height: 38px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Tenue pour… ---------- */
.ask textarea { min-height: 84px; }
.history { display: grid; gap: 10px; }
.hist { display: flex; gap: 12px; align-items: center; padding: 10px 12px; background: var(--surface); border-radius: 16px; border: 0; width: 100%; text-align: left; cursor: pointer; box-shadow: var(--shadow); color: var(--text); }
.hist .mini { display: flex; flex: none; }
.hist .mini img { width: 40px; height: 48px; object-fit: cover; border-radius: 8px; background: var(--photo); border: 2px solid var(--surface); margin-left: -12px; }
.hist .mini img:first-child { margin-left: 0; }
.hist .txt { min-width: 0; flex: 1; }
.hist .txt b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.hist .txt span { font-size: 13px; color: var(--muted); }

/* ---------- Réglages ---------- */
.settings-group { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.settings-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 56px; border: 0; background: none; width: 100%; text-align: left; color: var(--text); cursor: pointer; font-size: 16px; }
.settings-row + .settings-row { border-top: 1px solid var(--line); }
.settings-row svg { width: 20px; height: 20px; flex: none; }
.settings-row .val { margin-left: auto; color: var(--muted); font-size: 14px; text-align: right; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; margin-right: 6px; }
.status-dot.on { background: var(--ok); }
.status-dot.off { background: var(--danger); }
.results { display: grid; gap: 6px; }
.result { text-align: left; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--text); }
.result small { display: block; color: var(--muted); }
.help { font-size: 14px; color: var(--muted); background: var(--surface-2); padding: 12px 14px; border-radius: 12px; }
.help ol { margin: 6px 0 0; padding-left: 20px; }

/* ---------- Barre d'onglets ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: grid; justify-items: center; gap: 2px; padding: 6px 0; text-decoration: none; color: var(--muted);
  font-size: 11px; font-weight: 600;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--text); }

/* ---------- Feuille du bas ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); opacity: 0; transition: opacity .25s; }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 88vh; overflow-y: auto; overscroll-behavior: contain;
  max-width: 720px; margin: 0 auto; background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}
.sheet.open { transform: none; }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.photos { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
.photos::-webkit-scrollbar { display: none; }
.photo { position: relative; flex: 0 0 72%; max-width: 320px; margin: 0; scroll-snap-align: center; }
.photo img { width: 100%; aspect-ratio: 4 / 5; object-fit: contain; border-radius: 16px; background: var(--photo); }
.photo-del { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; }
.photo.add {
  flex-basis: 40%; display: grid; place-content: center; justify-items: center; gap: 6px; padding: 12px; aspect-ratio: auto;
  border: 1.5px dashed var(--line); border-radius: 16px; background: var(--surface); cursor: pointer; text-align: center; font-weight: 600; font-size: 14px;
}
.photo.add svg { width: 26px; height: 26px; }
.photo.add small { font-weight: 400; color: var(--muted); font-size: 12px; }
.alts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; max-width: calc(100% - 32px);
  background: var(--accent); color: var(--accent-ink); padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  transition: opacity .2s, transform .2s; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
