/* Editor "Crea tu invitación". */
:root { --ivory: #faf6f0; --paper: #fffdf9; --night: #1f1a1a; --muted: #75696a; --line: #e9ded4; --gold: #b08d57; --rose: #9a4a56; --sans: 'Jost', 'Helvetica Neue', Arial, sans-serif; --serif: 'Playfair Display', Georgia, serif; --gutter: clamp(16px, 3vw, 40px); }
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--ivory); color: var(--night); font: 400 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }

.ed-top { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 64px; padding: 0 var(--gutter); background: var(--ivory); border-bottom: 1px solid var(--line); }
.ed-top__back { font-size: .9rem; color: var(--muted); text-decoration: none; }
.ed-top__brand { font-family: var(--serif); font-size: 1.6rem; letter-spacing: .16em; text-transform: uppercase; text-decoration: none; color: inherit; padding-left: .16em; }
.ed-top__hint { justify-self: end; font-size: .82rem; color: var(--muted); }

.ed-steps { position: sticky; top: 64px; z-index: 19; display: flex; justify-content: center; gap: 4px; padding: 10px var(--gutter); background: var(--ivory); border-bottom: 1px solid var(--line); overflow-x: auto; }
.ed-step { display: inline-flex; align-items: center; gap: 8px; padding: .5em 1em; border: 0; background: none; color: var(--muted); cursor: pointer; white-space: nowrap; border-radius: 99px; }
.ed-step b { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1px solid currentColor; font-weight: 400; font-size: .78rem; }
.ed-step[aria-current="step"] { color: var(--night); background: #fff; box-shadow: 0 0 0 1px var(--line); }
.ed-step[aria-current="step"] b { background: var(--night); border-color: var(--night); color: #fff; }

.ed-layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: clamp(24px, 4vw, 64px); max-width: 1240px; margin: 0 auto; padding: 32px var(--gutter) 96px; align-items: start; }
.ed-panel { min-width: 0; scroll-margin-top: 130px; }
.ed-panel h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(1.8rem, 3vw, 2.4rem); margin: 0 0 6px; }
.ed-lead { color: var(--muted); margin: 0 0 24px; }

/* Diseños */
.ed-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.ed-chip { padding: .45em 1.1em; border-radius: 99px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.ed-chip[aria-selected="true"] { background: var(--night); border-color: var(--night); color: #fff; }
.ed-tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; }
.ed-tpl { display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.ed-tpl__name { font-weight: 500; margin-top: 8px; }
.ed-tpl__desc { font-size: .84rem; color: var(--muted); line-height: 1.35; }
.ed-tpl.is-on .ed-mini { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--gold); }

.ed-mini { position: relative; display: grid; place-items: center; aspect-ratio: 3 / 4.4; overflow: hidden; border-radius: 10px; background: var(--m-bg); color: var(--m-ink); box-shadow: 0 0 0 1px var(--line); transition: box-shadow .2s; }
.ed-mini__names { position: relative; z-index: 2; padding: 0 10px; text-align: center; font-family: var(--m-script); font-size: 1.5rem; line-height: 1.1; }
.ed-mini--envelope { color: #fff; }
.ed-mini__flap { position: absolute; inset: 0 0 auto; height: 55%; background: rgba(0, 0, 0, .1); clip-path: polygon(0 0, 100% 0, 50% 100%); }
.ed-mini--envelope .ed-mini__names { margin-bottom: 40%; }
.ed-mini__bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ed-mini--photo { color: #fff; }
.ed-mini--photo::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 40%, rgba(0, 0, 0, .55)); }
.ed-mini--photo .ed-mini__names { align-self: end; padding-bottom: 14px; font-family: var(--m-display); font-size: .95rem; letter-spacing: .14em; text-transform: uppercase; }
.ed-mini__pic { position: absolute; top: 10%; left: 50%; translate: -50% 0; width: 62%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 999px 999px 4px 4px; }
.ed-mini--clouds .ed-mini__pic { width: 46%; aspect-ratio: 1; border-radius: 50%; top: 18%; }
.ed-mini--arch .ed-mini__names, .ed-mini--clouds .ed-mini__names { align-self: end; padding-bottom: 14%; color: var(--m-accent); }
.ed-mini--botanical .ed-mini__names, .ed-mini--deco .ed-mini__names { font-family: var(--m-display); font-size: 1rem; letter-spacing: .14em; text-transform: uppercase; }
.ed-mini--deco .ed-mini__names { color: var(--m-accent); }
.ed-mini__frame { position: absolute; inset: 8px; border: 1px solid var(--m-accent); outline: 1px solid var(--m-accent); outline-offset: -5px; }

/* Formulario */
.ed-group { margin: 0 0 22px; padding: 22px; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; }
.ed-group legend { padding: 0 6px; font-family: var(--serif); font-size: 1.15rem; }
.ed-group__note { margin: 0 0 12px; font-size: .88rem; color: var(--muted); }
.ed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.ed-field { display: grid; gap: 5px; align-content: start; }
.ed-field--wide { grid-column: 1 / -1; }
.ed-field label { font-size: .82rem; color: var(--muted); }
.ed-field input, .ed-field textarea, .ed-row input, .ed-row select { width: 100%; padding: .7em .8em; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.ed-field textarea { resize: vertical; }
.ed-field input:focus, .ed-field textarea:focus, .ed-row input:focus, .ed-row select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176, 141, 87, .18); }
.ed-field [aria-invalid="true"] { border-color: #b3261e; }
.ed-field small { font-size: .78rem; color: var(--muted); }
.ed-field__error { min-height: 0; font-size: .78rem; color: #b3261e; }
.ed-row { display: grid; grid-template-columns: 110px 1fr 120px 36px; gap: 8px; margin-bottom: 8px; }
.ed-icon-btn { border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-size: 1.1rem; }
.ed-link { margin-top: 6px; padding: 0; border: 0; background: none; color: var(--rose); cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.ed-link:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.ed-palette { display: flex; gap: 8px; flex-wrap: wrap; }
.ed-palette input { width: 44px; height: 44px; padding: 2px; border: 1px solid var(--line); border-radius: 50%; background: #fff; cursor: pointer; }

/* Fotos */
.ed-photos { margin-bottom: 22px; padding: 18px 22px; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; }
.ed-photos__label { margin: 0 0 10px; font-family: var(--serif); font-size: 1.1rem; }
.ed-photos__row { display: flex; flex-wrap: wrap; gap: 10px; }
.ed-thumb { position: relative; margin: 0; width: 92px; height: 92px; border-radius: 8px; overflow: hidden; }
.ed-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ed-thumb__x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer; line-height: 1; }
.ed-upload { position: relative; display: grid; place-items: center; width: 92px; height: 92px; padding: 8px; border: 1.5px dashed #cbb9a6; border-radius: 8px; text-align: center; font-size: .78rem; color: var(--muted); cursor: pointer; }
.ed-upload:hover, .ed-upload:focus-within { border-color: var(--gold); color: var(--night); }
.ed-file { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Niveles y final */
.ed-tiers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.ed-tier { display: grid; gap: 4px; padding: 16px; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.ed-tier.is-on { border-color: var(--night); box-shadow: 0 0 0 1px var(--night); }
.ed-tier__name { font-family: var(--serif); font-size: 1.2rem; }
.ed-tier__price { font-weight: 500; }
.ed-tier__sum { font-size: .8rem; color: var(--muted); line-height: 1.35; }
.ed-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.ed-toggle { display: flex; gap: 10px; align-items: center; font-size: .92rem; cursor: pointer; }
.ed-toggle input { width: 18px; height: 18px; accent-color: var(--night); }
.ed-summary { list-style: none; margin: 0 0 18px; padding: 0; border-top: 1px solid var(--line); }
.ed-summary li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.ed-total { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 22px; font-size: 1.1rem; }
.ed-total strong { font-family: var(--serif); font-weight: 400; font-size: 2rem; }
.ed-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }

.ed-btn { display: inline-flex; align-items: center; justify-content: center; padding: .9em 1.8em; border: 1px solid var(--night); border-radius: 99px; background: var(--night); color: #fff; font-size: .82rem; letter-spacing: .14em; text-transform: uppercase; text-decoration: none; cursor: pointer; }
.ed-btn--ghost { background: transparent; color: var(--night); }
.ed-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }

/* Vista previa */
.ed-preview { position: sticky; top: 140px; display: grid; justify-items: center; gap: 10px; }
.ed-preview__note { margin: 0; font-size: .8rem; color: var(--muted); }
.ed-notice { position: fixed; left: 50%; bottom: 20px; translate: -50% 0; z-index: 40; max-width: min(92vw, 520px); margin: 0; padding: 12px 18px; border-radius: 10px; background: var(--night); color: #fff; font-size: .9rem; }
.ed-preview-toggle { display: none; }

@media (max-width: 1080px) {
  .ed-tiers { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .ed-layout { grid-template-columns: 1fr; padding-bottom: 120px; }
  .ed-preview { position: fixed; inset: 0; z-index: 30; display: none; place-content: center; background: rgba(31, 26, 26, .85); }
  .is-previewing .ed-preview { display: grid; }
  .ed-phone { --w: min(330px, 80vw); }
  .ed-preview__note { color: #fff; }
  .ed-preview-toggle { display: block; position: fixed; z-index: 35; left: 50%; bottom: 18px; translate: -50% 0; padding: .95em 1.8em; border: 0; border-radius: 99px; background: var(--night); color: #fff; font-size: .82rem; letter-spacing: .14em; text-transform: uppercase; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .5); }
  .ed-top__hint { display: none; }
  .ed-steps { justify-content: flex-start; }
}
@media (max-width: 560px) {
  .ed-grid, .ed-toggles { grid-template-columns: 1fr; }
  .ed-row { grid-template-columns: 90px 1fr 36px; }
  .ed-row select { grid-column: 1 / 3; }
  .ed-group { padding: 16px; }
  .ed-tpls { grid-template-columns: 1fr 1fr; }
}
.ed-field--pay { margin-bottom: 18px; max-width: 420px; }
.ed-btn--pay { background: #009ee3; border-color: #009ee3; }
.ed-btn--pay:hover { background: #0089c6; }
.ed-btn:disabled { opacity: .6; cursor: progress; }
/* Miniaturas con textura */
.ed-mini--texture { color: #fff; }
.ed-mini__tint { position: absolute; inset: 0; background: var(--m-tint); mix-blend-mode: multiply; }
.ed-mini__tint.is-light { mix-blend-mode: normal; }
.ed-mini--texture:has(.is-light) { color: var(--m-ink); }
.ed-mini--texture .ed-mini__names { font-family: var(--m-display); font-size: .95rem; letter-spacing: .14em; text-transform: uppercase; }
.ed-mini--editorial, .ed-mini--numeral { color: #fff; }
.ed-mini--editorial::after, .ed-mini--numeral::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 40%, rgba(0, 0, 0, .6)); }
.ed-mini--editorial .ed-mini__names, .ed-mini--numeral .ed-mini__names { align-self: end; padding-bottom: 14px; }
.ed-mini--phototop .ed-mini__pic { top: 0; width: 100%; aspect-ratio: auto; height: 56%; border-radius: 0; }
.ed-mini--inset .ed-mini__pic { top: 9%; width: 70%; aspect-ratio: 4 / 5; border-radius: 0; border: 4px solid #fbf8f3; transform: translateX(-50%) rotate(-2deg); translate: none; left: 50%; }
.ed-mini--phototop .ed-mini__names, .ed-mini--inset .ed-mini__names { align-self: end; padding-bottom: 12%; color: var(--m-accent); }

/* Teléfono de vista previa con aspecto de iPhone: marco de titanio, botones, isla dinámica y barra de estado. */
.ed-phone { --w: min(340px, calc((100vh - 200px) * .485)); position: relative; width: var(--w); aspect-ratio: 71.5 / 147; padding: 3px; border-radius: calc(var(--w) * .165); background: linear-gradient(140deg, #a7a39d 0%, #57544f 9%, #2a2927 22%, #1d1d1e 50%, #2a2927 78%, #57544f 91%, #a7a39d 100%); box-shadow: 0 50px 80px -40px rgba(31, 26, 26, .65), 0 0 0 1px rgba(0, 0, 0, .35); }
.ed-phone__screen { position: relative; height: 100%; padding: calc(var(--w) * .03); border-radius: calc(var(--w) * .155); background: #050505; overflow: hidden; }
/* La invitación se dibuja a tamaño de iPhone real (390×844) y se escala para caber en la pantalla. */
.ed-phone__view { position: relative; height: 100%; overflow: hidden; border-radius: calc(var(--w) * .125); background: #fff; }
.ed-phone iframe { position: absolute; top: 0; left: 0; width: 390px; height: 844px; border: 0; transform-origin: 0 0; transform: scale(var(--s, .78)); }
.ed-phone__island { position: absolute; z-index: 3; top: calc(var(--w) * .052); left: 50%; translate: -50% 0; width: calc(var(--w) * .3); height: calc(var(--w) * .088); border-radius: 99px; background: #000; }
.ed-phone__status { position: absolute; z-index: 2; top: calc(var(--w) * .055); left: calc(var(--w) * .1); right: calc(var(--w) * .085); display: flex; justify-content: space-between; align-items: center; color: #fff; font: 600 calc(var(--w) * .045) -apple-system, 'SF Pro Text', 'Helvetica Neue', sans-serif; letter-spacing: .01em; text-shadow: 0 0 6px rgba(0, 0, 0, .45); pointer-events: none; }
.ed-phone__status svg { width: calc(var(--w) * .2); filter: drop-shadow(0 0 3px rgba(0, 0, 0, .45)); }
.ed-phone__home { position: absolute; z-index: 2; bottom: calc(var(--w) * .035); left: 50%; translate: -50% 0; width: 36%; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, .85); box-shadow: 0 0 6px rgba(0, 0, 0, .35); pointer-events: none; }
.ed-phone__btn { position: absolute; width: 4px; border-radius: 2px; background: linear-gradient(90deg, #6c6964, #2c2b29); }
.ed-phone__btn--action { left: -3px; top: 17%; height: 4.5%; }
.ed-phone__btn--vol-up { left: -3px; top: 25%; height: 8.5%; }
.ed-phone__btn--vol-down { left: -3px; top: 35.5%; height: 8.5%; }
.ed-phone__btn--power { right: -3px; top: 28%; height: 13%; background: linear-gradient(270deg, #6c6964, #2c2b29); }
.ed-phone.is-dark-status .ed-phone__status { color: #111; text-shadow: none; }
.ed-phone.is-dark-status .ed-phone__status svg { filter: none; }
.ed-phone.is-dark-status .ed-phone__home { background: rgba(0, 0, 0, .75); box-shadow: none; }

/* ===== Flujo: barra fija de navegación, pantalla de éxito y versión celular ===== */
.ed-bar { position: sticky; bottom: 0; z-index: 25; display: flex; align-items: center; gap: 12px; padding: 14px var(--gutter); background: rgba(250, 246, 240, .94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.ed-bar[hidden] { display: none; }
.ed-nav__next { margin-left: auto; min-width: 220px; }
.ed-subtitle { margin: 34px 0 4px; font-family: var(--serif); font-weight: 400; font-size: 1.6rem; }
.ed-swipe-hint { display: none; }

.ed-success { text-align: center; padding: 6px 0 26px; }
.ed-success h2 { margin-bottom: 8px; }
.ed-success p { color: var(--muted); max-width: 30em; margin: 0 auto; }
.ed-success__check { position: relative; display: inline-grid; place-items: center; width: 64px; height: 64px; margin-bottom: 14px; border-radius: 50%; background: #e6efe3; }
.ed-success__check::after { content: ''; width: 18px; height: 30px; margin-top: -6px; border-right: 3px solid #3d6a3a; border-bottom: 3px solid #3d6a3a; transform: rotate(45deg); }
@media (prefers-reduced-motion: no-preference) {
  .ed-success__check { animation: pop .5s cubic-bezier(.3, 1.6, .5, 1); }
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

@media (max-width: 900px) {
  .ed-layout { gap: 18px; padding: 18px var(--gutter) 24px; }
  .ed-panel h2 { font-size: 1.7rem; }
  .ed-lead { margin-bottom: 16px; font-size: .95rem; }
  .ed-steps { gap: 2px; padding: 8px var(--gutter); }
  .ed-step { padding: .45em .7em; font-size: .88rem; }

  /* Diseño y Paquete: el iPhone siempre visible arriba. */
  body.step-diseno .ed-preview, body.step-nivel .ed-preview, body.step-listo .ed-preview { position: static; display: grid; order: -1; padding: 0; background: none; inset: auto; }
  body.step-diseno .ed-phone, body.step-nivel .ed-phone, body.step-listo .ed-phone { --w: min(232px, 58vw); }
  body.step-diseno .ed-preview__note, body.step-nivel .ed-preview__note, body.step-listo .ed-preview__note { display: none; }
  body.step-diseno .ed-preview-toggle, body.step-nivel .ed-preview-toggle, body.step-listo .ed-preview-toggle { display: none; }

  /* Diseños en tira deslizable con el dedo. */
  .ed-chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(var(--gutter) * -1) 14px; padding: 0 var(--gutter); scrollbar-width: none; }
  .ed-chips::-webkit-scrollbar, .ed-tpls::-webkit-scrollbar { display: none; }
  .ed-chip { flex: none; }
  .ed-tpls { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 calc(var(--gutter) * -1); padding: 4px var(--gutter) 6px; scrollbar-width: none; }
  .ed-tpl { flex: 0 0 112px; scroll-snap-align: center; }
  .ed-tpl__desc { display: none; }
  .ed-tpl__name { margin-top: 6px; font-size: .9rem; }
  .ed-swipe-hint { display: block; margin: 8px 0 0; font-size: .8rem; color: var(--muted); }

  /* Paquetes en 2 columnas compactas. */
  .ed-tiers { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ed-tier { padding: 12px; }

  /* Barra fija y botón de vista previa por encima de ella. */
  .ed-bar { position: fixed; left: 0; right: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .ed-nav__next { flex: 1; min-width: 0; }
  .ed-panel { padding-bottom: 90px; }
  .ed-preview-toggle { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .ed-notice { bottom: calc(90px + env(safe-area-inset-bottom)); }
}

/* Celular: diseño y paquete caben en una sola pantalla (teléfono + tira de diseños + botón). */
@media (max-width: 900px) {
  body.step-diseno .ed-phone, body.step-nivel .ed-phone { --w: clamp(150px, calc((100svh - 480px) * .486), 220px); }
  body.step-diseno .ed-layout, body.step-nivel .ed-layout { padding-top: 10px; gap: 10px; }
  body.step-diseno .ed-panel h2, body.step-nivel .ed-panel h2 { font-size: 1.35rem; margin-bottom: 2px; }
  body.step-diseno .ed-lead, body.step-nivel .ed-lead { display: none; }
  body.step-diseno .ed-chips { margin-top: 8px; margin-bottom: 10px; }
  body.step-diseno .ed-tpl { flex-basis: 96px; }
  body.step-diseno .ed-mini__names { font-size: 1.05rem; }
  body.step-diseno .ed-swipe-hint { margin-top: 4px; }
}
@media (max-width: 900px) {
  body.step-diseno .ed-tpl { flex-basis: 82px; }
  body.step-diseno .ed-mini { border-radius: 8px; }
  body.step-diseno .ed-mini__names { font-size: .9rem; }
  body.step-diseno .ed-mini--texture .ed-mini__names, body.step-diseno .ed-mini--photo .ed-mini__names { font-size: .62rem; }
  body.step-diseno .ed-tpl__name { font-size: .8rem; margin-top: 4px; }
  body.step-diseno .ed-swipe-hint { display: none; }
}
