.custom-card-page {
  margin: 0;
  color: #f8f3f6;
  background: #020d29;
}

.custom-card-page *,
.custom-card-page *::before,
.custom-card-page *::after {
  box-sizing: border-box;
}

.builder-main {
  min-height: 100vh;
  padding: 112px 0 90px;
  background:
    radial-gradient(circle at 10% 12%, rgba(117, 60, 127, .19), transparent 31%),
    radial-gradient(circle at 87% 41%, rgba(47, 73, 143, .2), transparent 34%),
    #020d29;
}

.builder-shell {
  width: min(1520px, calc(100% - 64px));
  margin: 0 auto;
}

.builder-intro {
  max-width: 1080px;
  margin: 0 0 38px;
}

.builder-eyebrow,
.builder-section-label {
  color: #f3c976;
  font: 700 13px/1.4 var(--police-texte, sans-serif);
  letter-spacing: .15em;
}

.builder-eyebrow span {
  margin-left: 12px;
  color: #fc81c6;
}

.builder-intro h1 {
  margin: 10px 0 10px;
  color: #fff9f1;
  font: 500 clamp(38px, 4.1vw, 66px)/1.08 var(--police-titres, Georgia, serif);
  letter-spacing: -.03em;
}

.builder-intro h1 em {
  color: #f58cc8;
  font-weight: 500;
}

/* La typographie de l’atelier garde sa hiérarchie face aux règles globales. */
html body main.builder-main .builder-intro h1 {
  margin: 10px 0 !important;
  font-size: clamp(38px, 4.1vw, 66px) !important;
  font-weight: 500 !important;
  line-height: 1.08 !important;
}

html body main.builder-main .builder-intro h1 em {
  color: #f58cc8 !important;
}

html body main.builder-main .builder-preview h2 {
  font-size: clamp(24px, 2vw, 34px) !important;
  font-weight: 500 !important;
  line-height: 1.15 !important;
}

html body main.builder-main .builder-step-heading h2 {
  font-size: 24px !important;
  font-weight: 500 !important;
  line-height: 1.16 !important;
}

.builder-intro > p:last-child {
  margin: 0;
  color: #d1d9e9;
  font-size: 18px;
  line-height: 1.55;
}

.builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.26fr) minmax(340px, .82fr);
  gap: clamp(20px, 2.5vw, 40px);
  align-items: start;
}

.builder-preview,
.builder-panel {
  min-width: 0;
  border: 1px solid rgba(227, 188, 113, .5);
  border-radius: 24px;
  background: linear-gradient(155deg, #111e43, #0c1839 68%, #151537);
  box-shadow: 0 28px 72px rgba(0, 0, 0, .22);
}

.builder-preview {
  position: sticky;
  top: 96px;
  padding: clamp(18px, 2.1vw, 32px);
}

.builder-preview-top {
  display: flex;
  margin-bottom: 18px;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.builder-preview h2 {
  margin: 4px 0 0;
  color: #fff9f1;
  font: 500 clamp(24px, 2vw, 34px)/1.15 var(--police-titres, Georgia, serif);
}

.builder-format {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid rgba(229, 189, 116, .42);
  border-radius: 30px;
  color: #f5d39b;
  font-size: 13px;
  letter-spacing: .02em;
}

.builder-canvas-frame {
  overflow: hidden;
  padding: clamp(7px, 1vw, 12px);
  border: 1px solid #bd955c;
  border-radius: 18px;
  background: linear-gradient(130deg, #f3d9a1, #815f34 27%, #e3bd78 63%, #906636);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .32);
}

#card-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3/2;
  border-radius: 8px;
  touch-action: pan-y;
}

#card-canvas.can-drag {
  cursor: grab;
  touch-action: none;
}

#card-canvas.is-dragging {
  cursor: grabbing;
}

.builder-drag-hint,
.builder-note {
  margin: 12px 0 0;
  color: #cad4e5;
  font-size: 14px;
  line-height: 1.45;
}

.builder-actions {
  display: grid;
  margin-top: 22px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.builder-action,
.builder-photo-button {
  display: inline-flex;
  min-height: 48px;
  padding: 10px 18px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font: 700 15px/1.2 var(--police-texte, sans-serif);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform .2s ease, filter .2s ease, border-color .2s ease;
}

.builder-action:hover,
.builder-photo-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.09);
}

.builder-action-primary {
  color: #fff;
  border: 1px solid #ff83bb;
  background: linear-gradient(115deg, #d33a86, #8a4ec5);
}

.builder-action-secondary {
  color: #fff6fa;
  border: 1px solid rgba(232, 147, 210, .62);
  background: rgba(118, 55, 124, .33);
}

.builder-action-text {
  grid-column: 1/-1;
  min-height: 38px;
  color: #f7d5ec;
  border: 0;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.builder-status {
  min-height: 24px;
  margin: 10px 0 0;
  color: #ffe3a7;
  font-size: 14px;
  line-height: 1.4;
}

.builder-save-fallback {
  display: inline-block;
  margin-top: 6px;
  color: #ffe3a7;
  font-size: 14px;
  font-weight: 700;
  text-underline-offset: 3px;
}

.builder-save-fallback[hidden] {
  display: none;
}

.builder-panel {
  padding: 4px clamp(18px, 2vw, 30px);
}

.builder-step {
  padding: 25px 0 27px;
  border-bottom: 1px solid rgba(201, 178, 192, .22);
}

.builder-step:last-child {
  border-bottom: 0;
}

.builder-step-heading {
  display: flex;
  margin-bottom: 17px;
  align-items: start;
  gap: 13px;
}

.builder-step-heading > span {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(239, 197, 113, .66);
  border-radius: 50%;
  color: #f3cf8f;
  font-size: 13px;
  font-weight: 700;
}

.builder-step-heading h2 {
  margin: 1px 0 2px;
  color: #fff8f3;
  font: 500 24px/1.16 var(--police-titres, Georgia, serif);
}

.builder-step-heading p {
  margin: 0;
  color: #c9d3e6;
  font-size: 14px;
}

.builder-models,
.builder-frames {
  display: grid;
  max-height: 355px;
  overflow-y: auto;
  padding: 4px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  scrollbar-color: #aa6baf #111d3e;
}

.builder-frames {
  max-height: 355px;
}

.builder-model-count {
  margin: 9px 0 11px;
  color: #cbd5e7;
  font-size: 14px;
}

.builder-model,
.builder-frame {
  min-width: 0;
  padding: 7px;
  border: 1px solid rgba(207, 184, 209, .35);
  border-radius: 12px;
  color: #f8f1f5;
  background: #152149;
  font: 600 14px/1.2 var(--police-texte, sans-serif);
  cursor: pointer;
}

.builder-model.is-selected,
.builder-frame.is-selected {
  border-color: #ff9ccf;
  box-shadow: 0 0 0 2px rgba(255, 132, 199, .39);
}

.builder-model[hidden],
.builder-frame[hidden] {
  display: none;
}

.builder-model > span:last-child,
.builder-frame > span:last-child {
  display: grid;
  min-height: 33px;
  place-items: center;
}

.builder-model-art {
  display: grid;
  height: 76px;
  margin-bottom: 7px;
  place-items: center;
  position: relative;
  overflow: hidden;
  border-radius: 7px;
  color: #fff;
  font: 44px/1 Georgia, serif;
  background: var(--model-solid);
  text-shadow: 0 2px 7px rgba(24, 15, 49, .18);
}

.builder-model-art::after {
  position: absolute;
  top: 6px;
  right: 9px;
  color: rgba(255, 255, 255, .85);
  content: "✦";
  font: 16px/1 Georgia, serif;
}

.builder-frame-art {
  display: block;
  height: 112px;
  margin-bottom: 7px;
  border-radius: 7px;
  background: #fffdfb center/contain no-repeat;
}

.builder-background-choice {
  display: grid;
  min-width: 0;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.builder-background-choice legend {
  width: 100%;
  margin-bottom: 9px;
  padding: 0;
  color: #f4e9ed;
  font-size: 14px;
  font-weight: 650;
}

.builder-step .builder-background-choice .builder-background-option {
  display: flex;
  min-height: 52px;
  margin: 0;
  padding: 7px 10px;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(220, 184, 205, .45);
  border-radius: 10px;
  background: #18254a;
  cursor: pointer;
}

.builder-step .builder-background-choice .builder-background-option:has(input:checked) {
  border-color: #ff9ccf;
  background: #322452;
  box-shadow: inset 0 0 0 1px rgba(255, 156, 207, .35);
}

.builder-background-option input {
  flex: 0 0 auto;
  margin: 0;
  accent-color: #ed82b9;
}

.builder-background-swatch {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, .65);
  border-radius: 6px;
  background: #52658b;
}

.builder-background-swatch-light {
  background: #fffaf0;
}

.builder-background-option > span:last-child {
  font-size: 13px;
  line-height: 1.2;
}

.builder-step label:not(.builder-photo-button) {
  display: block;
  margin: 0 0 7px;
  color: #f4e9ed;
  font-size: 14px;
  font-weight: 650;
}

.builder-photo-button {
  width: 100%;
  color: #fff;
  border: 1px solid #df89bd;
  background: linear-gradient(115deg, #8c3c89, #6549af);
}

#card-photo {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

#card-photo:focus-visible + .builder-field-help,
.builder-photo-button:has(+ #card-photo:focus-visible) {
  outline: 3px solid #ffb4dc;
  outline-offset: 3px;
}

.builder-field-help {
  margin: 9px 0 0;
  color: #c4cfe2;
  font-size: 13px;
  line-height: 1.45;
}

.builder-zoom-row {
  display: grid;
  margin-top: 17px;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 3px 12px;
}

.builder-zoom-row label {
  grid-column: 1/-1;
}

.builder-zoom-row output {
  margin-left: 6px;
  color: #f3c976;
  font-weight: 600;
}

.builder-zoom-row button {
  padding: 8px 0;
  border: 0;
  color: #f7d69e;
  background: transparent;
  font: 600 14px var(--police-texte, sans-serif);
  cursor: pointer;
}

.builder-zoom-row button:disabled {
  opacity: .48;
  cursor: default;
}

.builder-photo-move {
  display: flex;
  margin-top: 10px;
  align-items: center;
  gap: 7px;
}

.builder-photo-move span {
  margin-right: auto;
  color: #d7deeb;
  font-size: 14px;
}

.builder-photo-move button {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(220, 184, 205, .55);
  border-radius: 8px;
  color: #fff;
  background: #28345c;
  font-size: 20px;
  cursor: pointer;
}

.builder-photo-move button:disabled {
  opacity: .42;
  cursor: default;
}

.builder-step input[type="range"] {
  width: 100%;
  margin: 7px 0;
  accent-color: #f684bd;
}

.builder-step textarea,
.builder-step input[type="text"],
.builder-step input[type="search"],
.builder-step select {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(220, 184, 205, .5);
  border-radius: 9px;
  outline-offset: 2px;
  color: #fff;
  background: #0b1635;
  font: 400 15px/1.45 var(--police-texte, sans-serif);
}

.builder-step textarea {
  min-height: 100px;
  resize: vertical;
}

.builder-step input::placeholder,
.builder-step textarea::placeholder {
  color: #aeb9cf;
  opacity: 1;
}

.builder-form-grid {
  display: grid;
  margin-top: 15px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.builder-form-grid label {
  min-height: 22px;
}

.builder-form-grid output {
  margin-left: 4px;
  color: #f3c976;
  font-weight: 500;
}

.builder-step input[type="color"] {
  display: block;
  width: 100%;
  height: 43px;
  padding: 4px;
  border: 1px solid rgba(220, 184, 205, .5);
  border-radius: 9px;
  background: #0b1635;
  cursor: pointer;
}

.builder-border-choices {
  min-width: 0;
  margin: 0 0 20px;
  padding: 0;
  border: 0;
}

.builder-border-choices legend {
  margin-bottom: 10px;
  color: #fff3e8;
  font-weight: 700;
}

.builder-border-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.builder-border-options label {
  display: flex !important;
  min-height: 83px;
  margin: 0 !important;
  padding: 8px 12px;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(220, 184, 205, .4);
  border-radius: 11px;
  background: #18254a;
  cursor: pointer;
}

.builder-border-options label:has(input:checked) {
  border-color: #e7be74;
  background: #40235d;
  box-shadow: 0 0 0 2px rgba(231, 190, 116, .3);
}

.builder-border-options input {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: #f372c2;
}

.builder-border-swatch {
  position: relative;
  display: grid;
  width: 88px;
  height: 58px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  color: #a66b27;
  background: linear-gradient(135deg, #fff7dd, #f5dfa8);
}

.builder-border-swatch::before {
  position: absolute;
  inset: 5px;
  border: 3px solid currentColor;
  border-radius: 6px;
  content: "";
}

.builder-border-swatch::after {
  position: relative;
  padding: 0 3px;
  background: #fff1c9;
  font: 21px/1 Georgia, serif;
}

.builder-border-swatch--aucun { color: #8793a9; }
.builder-border-swatch--aucun::before { border: 0; }
.builder-border-swatch--aucun::after { content: "—"; }
.builder-border-swatch--dore::after { content: "◇"; }
.builder-border-swatch--coeurs::after { content: "♥"; }
.builder-border-swatch--fleurs::after { content: "✿"; }
.builder-border-swatch--trefles::after { content: "✤"; }
.builder-border-swatch--etoiles::after { content: "✦"; }
.builder-border-swatch--perles::before { border-style: dotted; }
.builder-border-swatch--perles::after { content: "●"; }
.builder-border-swatch--vagues::after { content: "≈"; }
}

.builder-optional {
  color: #b9c6dd;
  font-size: 13px;
  font-weight: 400;
}

.builder-signature-size {
  margin-top: 16px;
}

.builder-signature-size output {
  margin-left: 4px;
  color: #f3c976;
  font-weight: 500;
}

.builder-font-preview {
  display: block;
  max-width: 100%;
  margin-top: 9px;
  overflow: hidden;
  color: #fff0db;
  font-size: 23px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.builder-font-hint {
  display: block;
  margin-top: 5px;
  color: #c8d3e8;
  font-size: 12px;
  line-height: 1.3;
}

.custom-card-page :is(button, input, select, textarea, a):focus-visible {
  outline: 3px solid #ffa4d6;
  outline-offset: 3px;
}

/* Invitation discrète dans la galerie principale. */
.postcards-page .pc-create {
  display: grid;
  grid-template-columns: minmax(150px, 210px) minmax(0, 1fr) auto;
  margin: 0 0 42px;
  padding: clamp(22px, 3vw, 36px);
  align-items: center;
  gap: 24px;
  border: 1px solid rgba(231, 183, 112, .65);
  border-radius: 21px;
  background: linear-gradient(120deg, #15234b, #412250 74%, #542653);
}

.pc-create-image {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
  object-position: center;
  border: 1px solid rgba(241, 203, 129, .75);
  border-radius: 14px;
}

.pc-create-copy { min-width: 0; }
.pc-create span { color: #f1cb81; font-size: 13px; font-weight: 700; letter-spacing: .12em; }
.pc-create h2 { margin: 5px 0 5px; color: #fff; font: 500 clamp(26px, 2.5vw, 36px)/1.15 var(--police-titres, Georgia, serif); }
.pc-create p { margin: 0; color: #dce1ee; font-size: 16px; }
.pc-create a { display: inline-flex; min-height: 48px; padding: 10px 19px; flex: 0 0 auto; align-items: center; border-radius: 12px; color: #fff; background: linear-gradient(110deg, #d33d89, #8748be); font-weight: 700; text-decoration: none; }
.pc-create a:hover { filter: brightness(1.1); }
html body main .pc-create h2 { font-size: clamp(26px, 2.5vw, 36px) !important; font-weight: 500 !important; }

@media (max-width: 1000px) {
  .postcards-page .pc-create { grid-template-columns: minmax(145px, 190px) minmax(0, 1fr); }
  .pc-create a { grid-column: 2; width: fit-content; }
}

@media (max-width: 1100px) {
  .builder-layout { grid-template-columns: minmax(0, 1fr); }
  .builder-preview { position: static; }
}

@media (max-width: 760px) {
  .builder-main { padding: 94px 0 60px; }
  .builder-shell { width: min(100% - 26px, 620px); }
  .builder-intro { margin-bottom: 22px; }
  html body main.builder-main .builder-intro h1 { font-size: clamp(32px, 9vw, 47px) !important; }
  .builder-intro > p:last-child { font-size: 16px; }
  .builder-preview, .builder-panel { border-radius: 17px; }
  .builder-preview-top { align-items: start; }
  .builder-format { font-size: 12px; }
  .builder-actions { grid-template-columns: 1fr; }
  .builder-action-text { grid-column: 1; }
  .builder-models, .builder-frames { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .builder-form-grid { gap: 13px; }
  .postcards-page .pc-create { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .pc-create-image { width: min(100%, 190px); height: 126px; }
  .pc-create a { grid-column: 1; width: fit-content; }
}

@media (max-width: 390px) {
  .builder-models, .builder-frames { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .builder-form-grid { grid-template-columns: 1fr; }
  .builder-background-choice { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .builder-border-options { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .builder-action, .builder-photo-button { transition: none; }
}
