:root {
  --paper: #fffdf8;
  --paper-2: #f6efe2;
  --ink: #2b2622;
  --ink-2: #6f6559;
  --ink-3: #a3978a;
  --line: #e6dcc9;
  --accent: #b5462e;
  --accent-2: #d8674d;
  --ok: #2f7a4f;
  --shadow: 0 30px 60px -20px rgba(60, 40, 20, .35), 0 10px 20px -10px rgba(60, 40, 20, .2);
  --radius: 22px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: #e9dfcf;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow-x: hidden;
}

/* ---------- fondo ---------- */
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: linear-gradient(135deg, #f3ebdd 0%, #e5d6bf 45%, #d7bfa1 100%); }
.bg-blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; }
.b1 { width: 55vmax; height: 55vmax; right: -15vmax; top: -20vmax; background: #f5c9a8; }
.b2 { width: 45vmax; height: 45vmax; left: -10vmax; bottom: -20vmax; background: #c9a985; }

.bg-envelope { position: absolute; right: 8vw; top: 50%; transform: translateY(-50%) rotate(-8deg); perspective: 1200px; }
.mini-env { position: relative; width: 420px; height: 280px; animation: float 7s ease-in-out infinite; }
.mini-back, .mini-pocket, .mini-flap, .mini-letter { position: absolute; }
.mini-back { inset: 0; background: var(--pv-inside, #e3cfae); border-radius: 10px; box-shadow: var(--shadow); }
.mini-env { transition: filter .3s; }
.mini-letter { left: 8%; right: 8%; top: -22%; height: 80%; background: var(--paper); border-radius: 6px; box-shadow: 0 8px 20px rgba(0,0,0,.12);
  background-image: repeating-linear-gradient(transparent 0 26px, #eadfc9 26px 27px); background-position: 0 28px; }
.mini-pocket { inset: 0; background: var(--pv-env, #ecdbbd); border-radius: 10px; clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 100%, 0 100%); transition: background .3s; }
.mini-flap { left: 0; right: 0; top: 0; height: 56%; background: var(--pv-dark, #d9c4a1); clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top; transform: rotateX(160deg); border-radius: 10px 10px 0 0; transition: background .3s; }
.mini-seal {
  position: absolute; left: 50%; top: 62%; width: 56px; height: 56px; transform: translate(-50%, -50%); border-radius: 50%;
  display: grid; place-items: center; color: #f7e3da; font: 600 24px var(--serif); text-transform: uppercase;
  background: radial-gradient(circle at 35% 30%, var(--pv-wax-light, #d45a4c), var(--pv-wax, #a8352a) 55%, var(--pv-wax-dark, #7d231b));
  box-shadow: inset 0 2px 6px rgba(255,255,255,.25), inset 0 -3px 6px rgba(0,0,0,.35), 0 6px 14px rgba(0,0,0,.3);
}
@keyframes float { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-14px) } }

@media (max-width: 1000px) { .bg-envelope { display: none; } }

/* ---------- cabecera ---------- */
.top { position: relative; z-index: 2; display: flex; align-items: baseline; gap: 18px; padding: 22px 32px; }
.brand { font-family: var(--serif); font-size: 22px; font-weight: 600; color: var(--ink); text-decoration: none; }
.tagline { color: var(--ink-2); font-size: 14px; }
@media (max-width: 640px) { .tagline { display: none; } .top { padding: 18px 20px; } }

/* ---------- tarjeta ---------- */
.card {
  position: relative; z-index: 2;
  width: min(440px, calc(100% - 32px));
  margin: 8px 0 40px 32px;
  align-self: start;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
@media (max-width: 640px) { .card { margin: 0 auto 32px; padding: 22px; } }

h1 { font-family: var(--serif); font-weight: 500; font-size: 30px; margin: 0 0 18px; letter-spacing: -.01em; }
.lead { color: var(--ink-2); line-height: 1.5; margin: 0 0 18px; }
.fine { color: var(--ink-3); font-size: 12.5px; line-height: 1.45; margin: 12px 0 0; }

/* ---------- dropzone ---------- */
.dropzone {
  display: flex; align-items: center; gap: 14px;
  border: 1.5px dashed #cdbfa6; border-radius: 16px;
  padding: 14px 16px; cursor: pointer; transition: background .15s, border-color .15s;
  background: var(--paper-2);
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag { border-color: var(--accent); background: #fbf1e8; outline: none; }
.dz-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: #fff; font-size: 26px; line-height: 1; flex: none; }
.dz-text { display: flex; flex-direction: column; gap: 2px; }
.dz-text strong { font-weight: 600; font-size: 15px; }
.dz-text span { color: var(--ink-3); font-size: 13px; }

.file-list { list-style: none; margin: 10px 0 6px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list:empty { margin: 0; }
.file-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--paper-2); font-size: 13.5px; }
.file-thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; background: #e8dcc6; flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--ink-2); overflow: hidden; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--ink-3); font-size: 12px; flex: none; }
.file-remove { border: 0; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px; border-radius: 6px; }
.file-remove:hover { color: var(--accent); background: #fff; }

/* ---------- campos ---------- */
.field { display: block; margin-top: 14px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: .04em; text-transform: uppercase; margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 13px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(43,38,34,.08); }
.field input.invalid { border-color: var(--accent); }

.field > span em { font-style: normal; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-3); margin-left: 4px; }
.row { display: grid; grid-template-columns: 1.15fr 1fr; gap: 10px; }
@media (max-width: 480px) { .row { grid-template-columns: 1fr; } }

/* ---------- editor de mensaje ---------- */
.editor { border: 1.5px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.editor:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(43,38,34,.08); }
.toolbar { display: flex; align-items: center; gap: 2px; padding: 6px 8px; border-bottom: 1px solid #efe6d6; background: var(--paper-2); flex-wrap: wrap; }
.toolbar button {
  width: 30px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-2);
  font: 600 14px var(--sans); cursor: pointer; display: grid; place-items: center;
}
.toolbar button:hover { background: #fff; color: var(--ink); }
.toolbar button.on { background: var(--ink); color: #fff; }
.toolbar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }
.font-pick { display: flex; align-items: center; gap: 6px; margin-left: auto; font: 600 13px var(--serif); color: var(--ink-2); }
.font-pick select { font: 500 13px var(--sans); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; background: #fff; }
.editor-body {
  min-height: 130px; max-height: 320px; overflow-y: auto; padding: 12px 14px;
  font-size: 24px; line-height: 1.3; color: #3b2f26; outline: none;
  background-image: repeating-linear-gradient(transparent 0 31px, rgba(120, 95, 60, .12) 31px 32px);
  background-position: 0 6px;
}
.editor-body:empty::before { content: attr(data-placeholder); color: var(--ink-3); pointer-events: none; }

/* ---------- caducidad ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--paper-2); border: 1.5px solid var(--line); }
.seg button { font: 600 13px var(--sans); color: var(--ink-2); background: transparent; border: 0; border-radius: 9px; padding: 8px 6px; cursor: pointer; transition: background .15s, color .15s; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--ink); color: #fff; }
.expiry .fine { margin-top: 8px; }

/* ---------- extras: sello y colores ---------- */
.extras { margin-top: 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; }
.extras summary {
  cursor: pointer; padding: 11px 13px; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: .04em; text-transform: uppercase;
}
.extras summary::-webkit-details-marker { display: none; }
.extras summary .hint { flex: 1; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-3); font-size: 12.5px; }
.extras summary::after { content: "+"; font-size: 18px; line-height: 1; color: var(--ink-3); }
.extras[open] summary::after { content: "–"; }
.extras-body { padding: 2px 13px 14px; border-top: 1px solid #efe6d6; }
.opt-label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 12px 0 7px; }
.seal-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.seal-opt {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0;
  display: grid; place-items: center; color: #f7e3da; font: 600 19px var(--serif); text-transform: uppercase;
  background: radial-gradient(circle at 35% 30%, var(--wax-light), var(--wax) 55%, var(--wax-dark));
  box-shadow: inset 0 2px 5px rgba(255,255,255,.25), inset 0 -3px 5px rgba(0,0,0,.35), 0 3px 8px rgba(0,0,0,.25);
  transition: transform .12s;
}
.seal-opt:hover { transform: translateY(-2px); }
.seal-opt.on { border-color: var(--ink); box-shadow: inset 0 2px 5px rgba(255,255,255,.25), inset 0 -3px 5px rgba(0,0,0,.35), 0 0 0 2px #fff, 0 0 0 3.5px var(--ink); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; padding: 0; transition: transform .12s; }
.swatch:hover { transform: scale(1.1); }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.extras-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 14px; font-size: 12.5px; color: var(--ink-3); }

.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-size: 13px; }

/* ---------- botones ---------- */
.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 15px;
  border: 0; border-radius: 999px; padding: 13px 22px; cursor: pointer; text-decoration: none;
  transition: transform .12s, background .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { width: 100%; margin-top: 18px; background: var(--ink); color: #fff; }
.btn.primary:hover { background: #3f3730; }
.btn.primary[disabled] { opacity: .6; cursor: progress; }
.btn.ghost { background: var(--paper-2); color: var(--ink); }
.btn.small { padding: 9px 14px; font-size: 13px; background: var(--ink); color: #fff; flex: none; }
.btn-label { position: relative; z-index: 1; }
.btn-progress { position: absolute; inset: 0; width: 0; background: var(--accent); transition: width .2s; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link[disabled] { color: var(--ink-3); cursor: default; text-decoration: none; }
.link.back { margin-top: 18px; color: var(--ink-2); font-size: 13.5px; }

.scan-ok { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 9px 12px; border-radius: 10px; background: #e9f3ec; color: var(--ok); font-size: 13px; line-height: 1.35; }
.scan-ok::before { content: "🛡️"; font-size: 15px; }
.error { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: #fbe9e4; color: #8f2f1c; font-size: 13.5px; line-height: 1.4; }
.warn { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: #fcf1d8; color: #7a5410; font-size: 13.5px; line-height: 1.4; }

/* ---------- código ---------- */
.dev-code { margin: 0 0 14px; padding: 9px 12px; border-radius: 10px; background: #e9f3ec; color: var(--ok); font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dev-code code { font-size: 16px; letter-spacing: .2em; font-weight: 700; }
.otp { display: flex; gap: 8px; justify-content: space-between; }
.otp input {
  width: 100%; aspect-ratio: 3 / 4; max-width: 56px; text-align: center; font: 600 26px var(--sans);
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.otp input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(43,38,34,.08); }
.otp.shake { animation: shake .4s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-6px)} 40%,80%{transform:translateX(6px)} }
.resend { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; font-size: 13.5px; color: var(--ink-3); }

/* ---------- enviado ---------- */
.done-mark { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: #e3f1e7; color: var(--ok); font-size: 30px; font-weight: 700; margin-bottom: 16px; animation: pop .5s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.4); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.done-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.done-actions .btn { flex: 1; margin-top: 0; }

.turnstile:empty { display: none; }
.turnstile { margin-top: 14px; }
.cta-box { margin-top: 18px; padding: 14px 16px; border-radius: 14px; background: var(--paper-2); display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; color: var(--ink-2); }
.cta-box strong { color: var(--ink); }
.cta-box a { margin-top: 6px; align-self: flex-start; font-weight: 600; color: var(--accent); }

.site-foot { position: relative; z-index: 2; padding: 0 32px 22px; font-size: 12.5px; color: var(--ink-3); }
.site-foot a { color: var(--ink-2); text-decoration: none; }
.site-foot a:hover { text-decoration: underline; }
@media (max-width: 640px) { .site-foot { padding: 0 20px 20px; text-align: center; } }

/* ---------- transiciones entre pasos ---------- */
.step { animation: stepin .35s ease-out; }
@keyframes stepin { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
