/* ---------- Mise en page de l'outil ---------- */
.tool {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 460px);
  gap: 24px 32px;
  align-items: start;
  padding-bottom: clamp(64px, 9vw, 112px);
}
.steps { display: grid; gap: 16px; min-width: 0; }
.preview { position: sticky; top: 96px; grid-row: span 3; }
.direct, .privacy, .cta { grid-column: 1; }
@media (max-width: 960px) {
  .tool { grid-template-columns: 1fr; }
  .preview { position: static; grid-row: auto; }
}

.step { display: grid; gap: 20px; }
.step h2, .direct h2 { font-size: 1.375rem; display: flex; align-items: center; gap: 12px; }
.step h2 .n {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--sky-soft); color: var(--sky-deep); font-family: var(--mono); font-size: var(--fs-small); font-weight: 500;
}

.status { margin: 0; font-size: var(--fs-small); min-height: 1.4em; }
.status:empty { display: none; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--butter-ink); background: var(--butter); border-radius: 8px; padding: 8px 12px; }
.status.err { color: var(--err); }
.status a { color: inherit; font-weight: 600; }

.help { border-top: 1px solid var(--line); padding-top: 16px; font-size: var(--fs-ui); color: var(--ink-2); }
.help summary { cursor: pointer; font-weight: 600; color: var(--sky-deep); }
.help ol { margin: 12px 0; padding-left: 20px; display: grid; gap: 4px; }
.help p { margin: 0; }
.help code { font-family: var(--mono); font-size: 0.85em; background: var(--raised); padding: 2px 6px; border-radius: 4px; }

/* Choix du modèle */
.models { display: grid; grid-template-columns: repeat(3, minmax(0, 120px)); gap: 16px; }
.model { display: grid; gap: 8px; justify-items: center; font-weight: 600; font-size: var(--fs-ui); cursor: pointer; }
.model input { position: absolute; opacity: 0; pointer-events: none; }
.thumb {
  --c: var(--sky-deep);
  width: 100%; aspect-ratio: 148 / 210; border-radius: 10px; position: relative; overflow: hidden;
  background: #fff; box-shadow: 0 0 0 1px var(--line); transition: box-shadow 0.15s;
}
.thumb i { position: absolute; left: 22%; right: 22%; top: 34%; aspect-ratio: 1; border-radius: 4px; background: #fff; }
.thumb i svg { width: 100%; height: 100%; }
.thumb i path { fill: var(--ink); }
.thumb b { position: absolute; left: 18%; right: 18%; top: 14%; height: 7%; border-radius: 3px; background: var(--c); }
.t-clair i { box-shadow: 0 0 0 6px #fff, 0 0 0 8px var(--c); }
.t-couleur { background: var(--c); }
.t-couleur i { box-shadow: 0 0 0 7px #fff; }
.t-couleur b { background: #fff; }
.t-bandeau b { left: 0; right: 0; top: 0; height: 22%; border-radius: 0; }
.model input:checked + .thumb { box-shadow: 0 0 0 3px var(--ink); }
.model input:focus-visible + .thumb { outline: 3px solid var(--sky-deep); outline-offset: 4px; }

/* Couleurs */
.colors { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer; padding: 0;
  box-shadow: inset 0 0 0 1px rgba(22, 24, 29, 0.12);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.picker {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: var(--r-ctl);
  box-shadow: inset 0 0 0 1px var(--ctl-line); cursor: pointer; font-family: var(--mono); font-size: var(--fs-meta);
}
.picker input { width: 28px; height: 28px; border: 0; padding: 0; background: none; cursor: pointer; }
.picker input::-webkit-color-swatch-wrapper { padding: 0; }
.picker input::-webkit-color-swatch { border: 0; border-radius: 6px; }
.picker input::-moz-color-swatch { border: 0; border-radius: 6px; }

/* Logo */
.opt { font-weight: 400; color: var(--muted); font-size: var(--fs-small); margin-left: 4px; }
.logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.file { position: relative; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file:focus-within { outline: 3px solid var(--sky-deep); outline-offset: 3px; }
.logo-thumb {
  display: grid; place-items: center; height: 56px; min-width: 56px; max-width: 160px; padding: 8px; border-radius: 8px;
  background: repeating-conic-gradient(#eef1f5 0 25%, #fff 0 50%) 0 0 / 12px 12px; box-shadow: inset 0 0 0 1px var(--line);
}
.logo-thumb[hidden] { display: none; }
.logo-thumb img { max-height: 40px; max-width: 144px; width: auto; height: auto; }
.check { display: flex; align-items: center; gap: 8px; font-size: var(--fs-ui); font-weight: 500; cursor: pointer; margin-top: 4px; }
.check[hidden] { display: none; }
.check input { accent-color: var(--ink); width: 18px; height: 18px; margin: 0; }
.hint.err { color: var(--err); }
.swatch.from-logo { position: relative; }
.swatch.from-logo::after { content: ""; position: absolute; right: -4px; bottom: -4px; width: 14px; height: 14px; border-radius: 50%; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2316181d' stroke-width='3'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center / 8px no-repeat; box-shadow: 0 0 0 1px var(--line); }

/* Aperçu */
.preview .card { display: grid; gap: 16px; }
.tabs { display: flex; gap: 4px; background: var(--raised); padding: 4px; border-radius: 12px; }
.tabs button {
  flex: 1; font: inherit; font-weight: 600; font-size: var(--fs-small); border: 0; background: none; color: var(--muted);
  padding: 8px; border-radius: 8px; cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.tabs button[aria-selected="true"] { background: var(--white); color: var(--ink); box-shadow: 0 1px 3px rgba(22, 24, 29, 0.1); }
.pane { display: grid; gap: 16px; }
.pane[hidden] { display: none; }
.stage { background: var(--raised); border-radius: 12px; padding: 20px; }
.fit { position: relative; margin-inline: auto; }
.fit > .scaler { position: absolute; top: 0; left: 0; transform-origin: 0 0; box-shadow: 0 2px 10px rgba(22, 24, 29, 0.12); }
.stage { position: relative; }
.stage.demo .scaler, .stage.demo svg { opacity: 0.35; filter: grayscale(1); }
.stage.demo::after {
  content: "Aperçu : collez votre lien à l'étape 1"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--ink); color: #fff; font-weight: 600; font-size: var(--fs-small); padding: 8px 16px; border-radius: var(--r-ctl); white-space: nowrap;
}
.qr-stage { display: grid; place-items: center; }
.qr-stage svg { width: min(100%, 260px); height: auto; background: #fff; border-radius: 8px; }
.hint { font-size: var(--fs-small); color: var(--muted); margin: 0; }
.paper { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; font-size: var(--fs-ui); }
.paper legend { font-weight: 600; padding: 0; margin-bottom: 8px; }
.paper label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.paper input { accent-color: var(--ink); width: 18px; height: 18px; margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.row .btn { flex: 1; }
.pdf-tip { margin: 0; font-size: var(--fs-small); color: var(--muted); border-top: 1px solid var(--line); padding-top: 16px; }

/* Lien direct */
.direct { display: grid; gap: 20px; }
.direct .sub { margin: 0; color: var(--muted); max-width: 60ch; }
.copy-grid { display: grid; gap: 12px; }
.copy {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px;
}
.copy .label { grid-column: 1 / -1; font-size: var(--fs-meta); font-weight: 600; color: var(--muted); }
.copy output { font-size: var(--fs-ui); overflow-wrap: anywhere; }
.copy output.mono { font-family: var(--mono); font-size: var(--fs-small); }

.privacy { margin: 0; font-size: var(--fs-small); color: var(--muted); padding-left: 16px; border-left: 2px solid var(--sky); }

.cta {
  display: flex; flex-wrap: wrap; gap: 24px; align-items: center; justify-content: space-between;
  background: var(--ink); color: #fff; border-radius: var(--r-card); padding: clamp(24px, 4vw, 40px);
}
.cta h2 { font-size: 1.5rem; margin-bottom: 8px; }
.cta p { margin: 0; color: #c9d0da; max-width: 52ch; }
.cta .btn-ink { background: #fff; color: var(--ink); }
.cta .btn-ink:hover { background: var(--sky-soft); }

/* Raccourci vers l'aperçu, sur mobile seulement, tant que l'aperçu n'est pas à l'écran */
.jump { display: none; }
@media (max-width: 960px) {
  .preview { scroll-margin-top: 88px; }
  .jump {
    display: flex; position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 40; justify-content: center;
    background: var(--ink); color: #fff; font-weight: 600; text-decoration: none; padding: 12px 20px; min-height: 48px; align-items: center;
    border-radius: var(--r-ctl); box-shadow: 0 8px 24px -8px rgba(22, 24, 29, 0.4);
    transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
  }
  .jump.off { opacity: 0; transform: translateY(8px); pointer-events: none; visibility: hidden; }
  footer.site { padding-bottom: 96px; }
}
/* Cibles tactiles de 44 px sur petit écran */
@media (max-width: 760px) {
  .swatch { width: 44px; height: 44px; }
  .tabs button { min-height: 44px; }
  .btn-sm { min-height: 44px; }
  .picker { min-height: 44px; }
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; font-weight: 600; font-size: var(--fs-ui); padding: 8px 16px; border-radius: var(--r-ctl);
  transition: opacity 0.2s, transform 0.3s var(--ease); z-index: 100;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Feuilles imprimables (dimensions réelles en mm) ---------- */
.sheet {
  --c: #026cb5; --on: #fff; --qr: #16181d; --tc: #026cb5;
  position: relative; overflow: hidden; background: #fff; color: #16181d;
  font-family: var(--body); line-height: 1.25;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.sheet .p-name { font-family: var(--display); font-weight: 800; letter-spacing: -0.02em; font-size: var(--ns, 9mm); line-height: 1.05; color: var(--tc); overflow-wrap: anywhere; }
.sheet .p-title { font-family: var(--display); font-weight: 800; letter-spacing: -0.03em; font-size: var(--ts, 11mm); line-height: 1; }
.sheet .p-msg { font-size: 4.4mm; line-height: 1.35; color: #2e333d; margin: 0; }
.sheet .p-foot { font-family: var(--mono); font-size: 2.7mm; color: #5e6675; overflow-wrap: anywhere; }
.sheet .p-card { background: #fff; border-radius: 6mm; padding: 5mm 6mm 6mm; display: grid; justify-items: center; gap: 3.5mm; }
.sheet .p-stars { display: flex; gap: 1.4mm; }
.sheet .p-stars svg { width: 6mm; height: 6mm; fill: #f4b400; }
.sheet .p-qr { display: block; width: var(--qs, 74mm); height: var(--qs, 74mm); }
.sheet .p-qr path { fill: var(--qr); }

/* Affichette A5 portrait */
.poster { width: 148mm; height: 210mm; padding: 14mm 12mm 10mm; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6mm; }
.poster .p-head { display: grid; justify-items: center; }
.poster .p-msg { max-width: 112mm; font-size: 5.2mm; }
.poster .p-card { --qs: 84mm; }
.poster .p-stars svg { width: 7mm; height: 7mm; }
.poster .p-foot { margin-top: auto; }

/* Face de chevalet (demi A4) */
.panel { width: 210mm; height: 148.5mm; padding: 12mm 14mm; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; column-gap: 10mm; row-gap: 4mm; align-items: center; }
.panel .p-head { grid-column: 1 / -1; }
.panel.no-head { grid-template-rows: 1fr; }
.panel .p-text { display: grid; gap: 5mm; align-content: center; }
.panel .p-card { --qs: 62mm; }
.panel .p-foot { margin-top: 2mm; }

/* Modèle Clair */
.tpl-clair .p-card { box-shadow: inset 0 0 0 1.2mm var(--c); }
/* Modèle Couleur */
.tpl-couleur { background: var(--c); color: var(--on); }
.tpl-couleur .p-name { color: var(--on); }
/* Pleine opacité : le blanc ou l'encre choisi garde au moins 4,5:1 sur toutes les couleurs */
.tpl-couleur .p-msg, .tpl-couleur .p-foot { color: var(--on); }
/* Modèle Bandeau */
.tpl-bandeau .p-head { background: var(--c); align-self: stretch; }
.tpl-bandeau .p-name { color: var(--on); }
.tpl-bandeau .p-card { box-shadow: inset 0 0 0 0.4mm #d5dce4; }
.tpl-bandeau::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3mm; background: var(--c); }
.poster.tpl-bandeau { padding-top: 0; }
.poster.tpl-bandeau .p-head { margin: 0 -12mm; padding: 9mm 12mm 8mm; min-height: 30mm; align-content: center; }
.panel.tpl-bandeau { padding-top: 0; }
.panel.tpl-bandeau .p-head { margin: 0 -14mm; padding: 6mm 14mm; }
.tpl-bandeau .p-foot { padding-bottom: 2mm; }

/* Logo sur les feuilles */
.sheet .p-logo { display: inline-grid; place-items: center; }
.sheet .p-logo img { display: block; width: auto; height: auto; max-width: var(--lw); max-height: var(--lh); }
.tpl-couleur .p-logo, .tpl-bandeau .p-logo { background: #fff; border-radius: 4mm; padding: 3mm 4.5mm; }
.sheet .p-head.has-logo { gap: 3mm; }
.has-logo .p-name { font-size: min(var(--ns), 7mm); }
.poster .p-head { --lw: 84mm; --lh: 30mm; }
.poster .p-head.has-logo.with-name { --lw: 66mm; --lh: 20mm; }
.poster.has-logo { gap: 5mm; }
.poster.has-logo .p-card { --qs: 72mm; }
.poster.tpl-bandeau .p-head.has-logo { padding: 6mm 12mm; }
.panel .p-head { --lw: 60mm; --lh: 18mm; }
.panel .p-head.has-logo { display: flex; align-items: center; gap: 5mm; }
.panel.tpl-bandeau .p-head.has-logo { padding: 4mm 14mm; }

/* Pages à imprimer */
#print { display: none; }
.page { position: relative; overflow: hidden; background: #fff; }
.page-a5 { width: 148mm; height: 209.6mm; }
.page-a4p { width: 210mm; height: 296.6mm; }
.page-a4l { width: 297mm; height: 209.6mm; display: flex; justify-content: center; }
.page-a4l .poster + .poster { border-left: 0.3mm dashed #9aa4b1; }
.page-a4p .panel:first-child { transform: rotate(180deg); }
.fold { position: absolute; left: 0; right: 0; top: 148.5mm; border-top: 0.3mm dashed #9aa4b1; }

@media print {
  html, body { background: #fff; margin: 0; }
  .screen, .toast, .skip { display: none !important; }
  #print { display: block; }
  .page { break-after: page; page-break-after: always; }
  .page:last-child { break-after: auto; page-break-after: auto; }
}
