:root {
  --bg: #f6f2ec;
  --surface: #fffdf9;
  --surface-2: #efe9e0;
  --text: #2a2420;
  --muted: #776c62;
  --line: #e2d9cc;
  --accent: #8a4b2a;
  --accent-text: #fff;
  --focus: #2b55a6;
  --sil-stroke: rgba(40, 30, 20, 0.28);
  --hair: #4a3426;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.06), 0 6px 20px rgba(60, 40, 20, 0.06);
  --radius: 16px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1917;
    --surface: #25221f;
    --surface-2: #302c28;
    --text: #f1ebe3;
    --muted: #a99d91;
    --line: #3b3631;
    --accent: #e0a37a;
    --accent-text: #1b1917;
    --focus: #9ec0ff;
    --sil-stroke: rgba(255, 245, 235, 0.35);
    --hair: #2a1d15;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  min-height: 100vh;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.1rem; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.container { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-family: var(--serif); font-size: 1.25rem; font-weight: 600; }
.brand em { color: var(--accent); font-style: italic; }
.top-actions { display: flex; gap: 8px; }
.btn { border: 0; border-radius: 999px; padding: 8px 16px; background: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* Étapes */
.stepper { display: flex; gap: 6px; list-style: none; padding: 0; margin: 20px 0 24px; flex-wrap: wrap; font-size: .9rem; }
.stepper li { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.stepper li + li::before { content: ""; width: 18px; height: 1px; background: var(--line); margin-right: 2px; }
.stepper b { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); font-size: .8rem; }
.stepper .is-current { color: var(--text); font-weight: 600; }
.stepper .is-current b { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.stepper .is-done b { background: var(--surface-2); }
.stepper button { background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

.step { padding-bottom: 32px; }
.lead { color: var(--muted); margin: 0 0 20px; }
.step h3 { margin-top: 20px; font-family: var(--sans); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.gender-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 16px; }
.big-choice, .piece {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 20px 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
  font-weight: 600; transition: transform .15s, border-color .15s;
}
.big-choice:hover, .piece:hover { border-color: var(--accent); transform: translateY(-2px); }
.big-choice { font-size: 1.15rem; padding: 28px 12px; }
.big-choice .piece-icon { width: 64px; height: 64px; }
.piece-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.piece-icon { width: 44px; height: 44px; fill: var(--surface-2); stroke: var(--text); stroke-width: 1.6; stroke-linejoin: round; }

/* Nuancier */
.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.swatch-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-size: .85rem; text-align: center;
}
.swatch-btn:hover { border-color: var(--accent); }
.swatch-btn .swatch { width: 48px; height: 48px; }
.swatch-btn .badge { position: absolute; top: 6px; right: 6px; }
.swatch {
  display: inline-block; flex: none; width: 36px; height: 36px; border-radius: 50%;
  background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14);
}
.swatch.lg { width: 64px; height: 64px; }
.swatch.sm { width: 18px; height: 18px; vertical-align: -3px; margin-right: 6px; }
.swatch.xs { width: 14px; height: 14px; vertical-align: -2px; margin-right: 5px; }
.swatch.metal { background: linear-gradient(135deg, #fff8 0%, var(--c) 45%, #0002 100%); }
.badge { display: inline-block; padding: 1px 6px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: .68rem; font-weight: 700; letter-spacing: .02em; vertical-align: 1px; }
.custom-color { display: flex; align-items: center; gap: 12px; margin-top: 24px; padding: 12px; border: 1px dashed var(--line); border-radius: 12px; cursor: pointer; }
.custom-color input { width: 48px; height: 48px; border: 0; padding: 0; background: none; cursor: pointer; }

/* Résultats */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.summary { display: flex; align-items: center; gap: 16px; }
.summary p { margin: 0; font-size: .85rem; }
.summary h2 { margin: 0; }
.summary h2::first-letter { text-transform: uppercase; }
.summary-actions { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 4px; font-size: .9rem; }
.style-chips { display: flex; gap: 8px; overflow-x: auto; padding: 16px 0; scrollbar-width: thin; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: .88rem; }
.chip.is-on { background: var(--text); color: var(--bg); border-color: var(--text); }

.results { display: grid; gap: 16px; padding-bottom: 32px; }
@media (min-width: 900px) {
  .results { grid-template-columns: 380px 1fr; align-items: start; }
  .wheel-card { position: sticky; top: 76px; }
}

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.tabs button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 4px 10px; font-size: .82rem; }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tabs button:disabled { opacity: .45; cursor: default; }
.wheel-wrap { max-width: 340px; margin: 0 auto; }
.wheel { width: 100%; height: auto; display: block; }
.wheel .seg { stroke: var(--surface); stroke-width: 1.5; }
.wheel-inner { fill: var(--surface-2); }
.target-wedge { fill: none; stroke: var(--text); stroke-width: 2.5; stroke-dasharray: 4 3; }
.axis { stroke: var(--text); stroke-width: 1.2; stroke-dasharray: 3 3; opacity: .6; }
.base-axis { stroke-dasharray: none; stroke-width: 2; opacity: .9; }
.harmony-shape { fill: color-mix(in srgb, var(--text) 6%, transparent); stroke: var(--text); stroke-width: 1; opacity: .5; }
.dot { stroke: var(--sil-stroke); stroke-width: 1; cursor: pointer; opacity: .45; transition: opacity .15s; }
.dot:hover, .dot:focus { opacity: 1; outline: none; stroke: var(--text); stroke-width: 2; }
.dot.is-match { opacity: 1; stroke: var(--text); stroke-width: 1.5; }
.dot.is-base { opacity: 1; stroke: var(--text); stroke-width: 3; }
.dot.is-selected { opacity: 1; stroke: var(--focus); stroke-width: 3; }
.dot-info { min-height: 3em; margin: 8px 0; font-size: .92rem; }
.match-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .85rem; }
.match-list .chip { padding: 3px 10px; font-size: .82rem; }
.legend { font-size: .78rem; margin: 10px 0 0; }

.outfits { display: grid; gap: 16px; }
@media (min-width: 1200px) { .outfits { grid-template-columns: 1fr; } }
.outfit header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 8px; }
.outfit header h3 { margin: 0; font-size: 1.3rem; }
.outfit header p { margin: 0; font-size: .88rem; }
.outfit-body { display: grid; grid-template-columns: 110px 1fr; gap: 16px; align-items: start; }
@media (min-width: 600px) { .outfit-body { grid-template-columns: 150px 1fr; } }
.silhouette { width: 100%; height: auto; }
.silhouette path, .silhouette rect, .silhouette circle { stroke: var(--sil-stroke); stroke-width: .8; }
.silhouette .hair { fill: var(--hair); }
.silhouette .sil-line { fill: none; }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 700px) { .items { grid-template-columns: 1fr 1fr; } }
.items li { display: flex; gap: 10px; align-items: flex-start; }
.item-text { display: flex; flex-direction: column; min-width: 0; font-size: .92rem; }
.item-slot { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.item-text small { color: var(--muted); font-size: .8rem; line-height: 1.35; }
.alts { display: flex; gap: 6px; margin-top: 4px; }
.alt { width: 22px; height: 22px; border-radius: 50%; border: 0; padding: 0; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18); }
.alt:hover { transform: scale(1.15); }
.reset { justify-self: start; }

.footer { padding-top: 8px; padding-bottom: max(24px, env(safe-area-inset-bottom)); font-size: .78rem; }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: .9rem; z-index: 20; box-shadow: 0 6px 24px rgba(0, 0, 0, .2);
}

@media (max-width: 420px) {
  h2 { font-size: 1.3rem; }
  .brand span { font-size: 1.1rem; }
  .gender-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stepper { gap: 4px; font-size: .82rem; }
  .stepper li + li::before { width: 8px; }
  .summary-actions { gap: 4px 16px; }
  .swatch-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
}

/* Type de tenue */
.season-bar { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
@media (min-width: 640px) { .season-bar { grid-template-columns: repeat(4, 1fr); } }
.season { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 14px; text-align: left; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.season small { color: var(--muted); font-size: .76rem; line-height: 1.25; }
.season.is-on { background: var(--text); color: var(--bg); border-color: var(--text); }
.season.is-on small { color: color-mix(in srgb, var(--bg) 75%, transparent); }

/* Coupe & proportions */
.fit-card summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; cursor: pointer; list-style: none; }
.fit-card summary::-webkit-details-marker { display: none; }
.fit-card summary h2 { margin: 0; font-size: 1.3rem; }
.fit-card summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform .15s; }
.fit-card[open] summary::after { transform: rotate(180deg); }
.fit-q { margin: 14px 0 8px; font-weight: 600; }
.fit-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fit-hint { margin: 12px 0 0; font-size: .9rem; }
.fit-intro { margin: 14px 0 0; }
.fit-card h4 { margin: 16px 0 4px; font-family: var(--sans); font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.fit-why { margin: 0 0 10px; font-size: .92rem; }
.fit-pairs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fit-pairs figure { margin: 0; padding: 8px 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); text-align: center; }
.fit-pairs figure.is-best { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.fit-pairs .silhouette { width: 78%; max-height: 190px; }
.fit-pairs figcaption { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .78rem; line-height: 1.2; margin-top: 4px; }
.fit-more { margin: 8px 0 0; font-size: .85rem; }
.fit-rules { margin: 14px 0 0; display: grid; gap: 8px; }
.fit-rules div { display: grid; grid-template-columns: 96px 1fr; gap: 10px; font-size: .9rem; }
.fit-rules dt { font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; }
.fit-rules dd { margin: 0; }
.fit-rules .is-avoid dd { color: #b4412b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fit-rules .is-avoid dd { color: #f0a08c; } }

.fit-photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 4px; }
@media (min-width: 640px) { .fit-photos { grid-template-columns: repeat(4, 1fr); } }
.fit-photo { margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-2); display: flex; flex-direction: column; }
.fit-photo.is-own { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.fit-photo img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: center top; background: var(--surface-2); }
.fit-photo figcaption { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 6px 8px 8px; font-size: .78rem; line-height: 1.25; }
.fit-photo figcaption a { color: var(--muted); font-size: .7rem; text-decoration: none; }
.fit-photo figcaption a:hover { text-decoration: underline; }

.silhouette .sil-detail { fill: none; stroke: var(--sil-stroke); stroke-width: 1; stroke-linecap: round; }
