:root {
  --b-bg: #f3f2ee;
  --b-surface: #fff;
  --b-ink: #17171a;
  --b-muted: #66666c;
  --b-line: #e3e1db;
  --b-line-strong: #c9c6bd;
  --b-accent: #116962;
  --b-accent-soft: #e2efed;
  --b-bar-h: 64px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--b-bg);
  color: var(--b-ink);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid #7aa7ff; outline-offset: 2px; }

#app { display: grid; grid-template-rows: auto 1fr auto; min-height: 100dvh; }

/* Barre du haut */
.bar {
  position: sticky; top: 0; z-index: 20; height: var(--b-bar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 20px; background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--b-line);
}
.bar-brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.bar-brand img { width: 38px; height: 38px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px var(--b-line); padding: 4px; object-fit: contain; flex: none; }
.bar-brand strong { display: block; font-size: 15px; }
.bar-brand span { display: block; font-size: 12.5px; color: var(--b-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-actions { display: flex; gap: 8px; flex: none; }

.btn-b {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--b-line); background: var(--b-surface);
  font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn-b:hover { border-color: var(--b-line-strong); }
.btn-b.primary { background: var(--b-ink); border-color: var(--b-ink); color: #fff; }
.btn-b.primary:hover { background: #000; }
.btn-b.accent { background: var(--b-accent); border-color: var(--b-accent); color: #fff; }
.btn-b.accent:hover { background: #0c524c; }
.btn-b:disabled { opacity: .35; cursor: default; }
.btn-b.big { height: 52px; font-size: 16px; border-radius: 12px; }

/* Mise en page */
.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.steps {
  position: sticky; top: var(--b-bar-h); align-self: start;
  height: calc(100dvh - var(--b-bar-h) - 65px); overflow-y: auto;
  padding: 18px 12px; border-right: 1px solid var(--b-line);
}
.step-link {
  display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; width: 100%;
  padding: 9px 10px; border: 0; background: none; border-radius: 10px; text-align: left;
}
.step-link:hover { background: rgba(0, 0, 0, .04); }
.step-link.on { background: var(--b-surface); box-shadow: 0 0 0 1px var(--b-line), 0 4px 14px -8px rgba(0, 0, 0, .2); }
.step-num { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #e7e5df; font-size: 11.5px; font-weight: 700; }
.step-link.on .step-num { background: var(--b-ink); color: #fff; }
.step-link b { display: block; font-size: 13.5px; font-weight: 600; }
.step-link small { display: block; font-size: 12px; color: var(--b-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-link small.off { text-decoration: line-through; }

.main { padding: 28px clamp(16px, 3vw, 40px) 48px; min-width: 0; }
.step-head { max-width: 760px; }
.step-count { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--b-accent); margin: 0 0 6px; }
.step-head h1 { font-size: clamp(22px, 3vw, 30px); line-height: 1.15; margin: 0 0 6px; letter-spacing: -.02em; }
.step-head p { margin: 0; color: var(--b-muted); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 20px 0; }
.toolbar[hidden] { display: none; }
.hint { font-size: 13px; color: var(--b-muted); }

.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: #e7e5df; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--b-muted); white-space: nowrap; }
.seg button.on { background: #fff; color: var(--b-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* Cartes de modèles */
.grid { display: grid; gap: 22px; align-items: start; }
.grid.desktop { grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); }
.grid.phone { grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.card {
  position: relative; background: var(--b-surface); border-radius: 14px; overflow: hidden; cursor: pointer;
  box-shadow: 0 0 0 1px var(--b-line); transition: box-shadow .2s;
}
.card:hover { box-shadow: 0 0 0 1px var(--b-line-strong), 0 14px 30px -18px rgba(0, 0, 0, .3); }
.card.sel { box-shadow: 0 0 0 3px var(--b-accent), 0 14px 30px -18px rgba(0, 0, 0, .3); }
.sel-tag {
  position: absolute; top: 10px; left: 10px; z-index: 2; display: none;
  background: var(--b-accent); color: #fff; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
}
.card.sel .sel-tag { display: block; }
.pv { position: relative; overflow: hidden; background: #fff; border-bottom: 1px solid var(--b-line); height: 260px; }
.pv iframe { position: absolute; top: 0; left: 0; border: 0; transform-origin: 0 0; pointer-events: none; background: #fff; }
.pv.loading::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, #f3f2ee 30%, #fbfaf7 50%, #f3f2ee 70%); background-size: 300% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { to { background-position: -300% 0; } }
.none-pv {
  display: grid; place-items: center; text-align: center; height: 200px; padding: 20px; color: var(--b-muted); font-size: 14px;
  background: repeating-linear-gradient(-45deg, #faf9f6 0 10px, #f3f2ee 10px 20px); border-bottom: 1px solid var(--b-line);
}
.meta { display: grid; grid-template-columns: 22px 1fr auto; gap: 12px; align-items: start; padding: 14px 16px; }
.radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--b-line-strong); margin-top: 1px; display: grid; place-items: center; }
.card.sel .radio { border-color: var(--b-accent); background: var(--b-accent); }
.card.sel .radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.meta strong { display: block; font-size: 15px; }
.meta .d { display: block; font-size: 13px; color: var(--b-muted); margin-top: 2px; }
.zoom-btn { width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--b-line); background: #fff; display: grid; place-items: center; font-size: 17px; }
.zoom-btn:hover { border-color: var(--b-line-strong); }
.swatches { display: flex; gap: 5px; margin-top: 9px; }
.swatches i { width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.ref-tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: #fbf0d9; color: #7a5716; font-size: 11px; font-weight: 700; vertical-align: 2px; }

/* Récapitulatif */
.sum { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; margin-top: 22px; }
.sum-list { background: #fff; border-radius: 14px; box-shadow: 0 0 0 1px var(--b-line); overflow: hidden; }
.sum-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--b-line); }
.sum-row:first-child { border-top: 0; }
.sum-row.off .sum-txt { opacity: .5; }
.sum-row .step-num { background: var(--b-accent-soft); color: var(--b-accent); }
.sum-txt b { display: block; font-size: 14px; }
.sum-txt small { color: var(--b-muted); font-size: 12.5px; }
.sum-actions { display: flex; gap: 6px; }
.icon-b { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--b-line); background: #fff; display: grid; place-items: center; font-size: 14px; }
.icon-b:disabled { opacity: .25; cursor: default; }
.icon-b.txt { width: auto; padding: 0 12px; font-weight: 600; font-size: 13px; }
.sum-side { position: sticky; top: calc(var(--b-bar-h) + 20px); background: #fff; border-radius: 14px; box-shadow: 0 0 0 1px var(--b-line); padding: 20px; display: grid; gap: 14px; }
.sum-side h2 { font-size: 17px; margin: 0; }
.sum-side p { margin: 0; color: var(--b-muted); font-size: 13.5px; }
.sum-style { display: grid; gap: 4px; font-size: 14px; }

/* Barre du bas */
.nav-bottom {
  position: sticky; bottom: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--b-line);
}
.progress { flex: 1; max-width: 460px; height: 5px; border-radius: 5px; background: #e7e5df; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--b-accent); transition: width .3s; }

/* Résultat */
#result { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-rows: auto minmax(0, 1fr); background: #2a2a2e; }
#result[hidden] { display: none; }
.rbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: #17171a; color: #fff; }
.rbar .btn-b { background: #2c2c31; border-color: #3a3a40; color: #fff; }
.rbar .btn-b:hover { border-color: #5a5a62; }
.rbar .btn-b.on { background: #fff; color: #17171a; border-color: #fff; }
.rbar .spacer { flex: 1; }
.rbar .seg { background: #2c2c31; }
.rbar .seg button { color: #b5b5bb; }
.rbar .seg button.on { background: #fff; color: #17171a; }
.stage { display: grid; min-height: 0; overflow: hidden; }
.device { width: 100%; height: 100%; background: #fff; }
.device iframe { width: 100%; height: 100%; border: 0; display: block; }
.stage.phone { place-items: center; padding: 22px; }
.stage.phone .device { width: 390px; height: min(844px, 100%); border-radius: 38px; overflow: hidden; box-shadow: 0 0 0 10px #0c0c0e, 0 30px 80px rgba(0, 0, 0, .5); }

/* Agrandissement */
#zoom { width: min(1240px, 96vw); height: 92dvh; max-height: none; max-width: none; padding: 0; border: 0; border-radius: 16px; overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, .4); }
#zoom::backdrop { background: rgba(20, 20, 22, .6); }
#zoom[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.zoom-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--b-line); background: #fff; }
.zoom-bar strong { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zoom-body { position: relative; overflow: hidden; background: #e9e8e4; }
.zoom-body iframe { position: absolute; top: 0; border: 0; transform-origin: 0 0; background: #fff; }

#toast {
  position: fixed; left: 50%; bottom: 90px; z-index: 100; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 12px; background: #17171a; color: #fff; font-size: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .3); transition: opacity .25s, transform .25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Téléphone */
@media (max-width: 900px) {
  :root { --b-bar-h: 58px; }
  .bar { padding: 0 12px; }
  .bar-brand span, .lbl { display: none; }
  .layout { grid-template-columns: 1fr; }
  .steps {
    position: sticky; top: var(--b-bar-h); z-index: 15; height: auto; display: flex; gap: 6px; overflow-x: auto;
    padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--b-line); background: var(--b-bg); scrollbar-width: none;
  }
  .steps::-webkit-scrollbar { display: none; }
  .step-link { display: block; width: auto; flex: none; padding: 7px 13px; border-radius: 999px; background: #fff; box-shadow: 0 0 0 1px var(--b-line); white-space: nowrap; }
  .step-link .step-num, .step-link small { display: none; }
  .step-link b { font-size: 13px; }
  .step-link.on { background: var(--b-ink); color: #fff; box-shadow: none; }
  .main { padding: 20px 16px 32px; }
  .hint { display: none; }
  .sum { grid-template-columns: 1fr; }
  .sum-side { position: static; order: -1; }
  .nav-bottom { padding-inline: 12px; }
  .progress { display: none; }
  .nav-bottom .btn-b { flex: 1; height: 46px; }
  .rbar { padding: 8px 10px; gap: 6px; }
  .rbar .seg { display: none; }
  .rbar .btn-b { padding: 0 12px; }
  #zoom { width: 100vw; height: 100dvh; border-radius: 0; }
}

/* Écran de mot de passe */
html.is-locked, html.is-locked body { overflow: hidden; }
#gate {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at 30% 20%, #e2efed, transparent 60%), var(--b-bg);
}
.gate-card {
  width: min(100%, 380px); display: grid; gap: 10px; padding: 32px 28px; background: #fff;
  border-radius: 18px; box-shadow: 0 0 0 1px var(--b-line), 0 30px 60px -30px rgba(0, 0, 0, .3);
}
.gate-card img { width: 56px; height: 56px; border-radius: 50%; padding: 6px; box-shadow: 0 0 0 1px var(--b-line); object-fit: contain; justify-self: center; }
.gate-card h1 { margin: 6px 0 0; font-size: 22px; text-align: center; letter-spacing: -.02em; }
.gate-card > p { margin: 0 0 8px; color: var(--b-muted); font-size: 14px; text-align: center; }
.gate-card label { font-size: 13px; font-weight: 600; }
.gate-card input { font: inherit; font-size: 16px; height: 48px; padding: 0 14px; border: 1px solid var(--b-line-strong); border-radius: 10px; width: 100%; }
.gate-card input:focus { outline: 2px solid var(--b-accent); outline-offset: 1px; border-color: var(--b-accent); }
.gate-card .gate-error { margin: 0; min-height: 20px; color: #b42318; font-size: 13px; text-align: left; }
