:root {
  --navy: #13285a; --coral: #fc4f52; --yellow: #fcb305; --teal: #23c3b2; --purple: #ac5fcb; --pink: #f08aa0;
  --coral-soft: #ffe4e2; --yellow-soft: #fff1cc; --teal-soft: #d8f5f1; --purple-soft: #f1e3f7;
  --bg: #fffaf3; --surface: #fff; --ink: #13285a; --ink-soft: #4a5679; --line: #ece4d8;
  --radius: 24px; --shadow: 0 18px 40px -22px rgba(19, 40, 90, .35); --shadow-sm: 0 8px 20px -14px rgba(19, 40, 90, .4);
  --display: "Fredoka", "Nunito", system-ui, sans-serif; --body: "Nunito", system-ui, sans-serif;
  --bar-h: 76px;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
/* Sin zoom por doble toque (la app no necesita zoom: la prenda ya se ve a pantalla completa) */
html { overflow-x: clip; -webkit-text-size-adjust: 100%; touch-action: manipulation; }
body { margin: 0; font-family: var(--body); font-size: 16px; line-height: 1.55; color: var(--ink); background: var(--bg); padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom)); }
img, svg { display: block; max-width: 100%; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.12; margin: 0 0 .5em; }
h1 { font-size: clamp(1.8rem, 4.5vw, 2.7rem); }
p { margin: 0 0 1em; }
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; border-radius: 8px; }
.center { text-align: center; }

/* ---------- Encabezado y pasos ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; max-width: 1240px; margin: 0 auto; }
.top__brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.top__brand img { height: 48px; width: auto; }
.top__name { font-family: var(--display); font-weight: 600; font-size: 1.2rem; }
.top__name em { font-style: normal; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; background: var(--purple-soft); color: #7a3597; padding: 3px 8px; border-radius: 99px; vertical-align: 3px; margin-left: 4px; }
.link-btn { background: none; border: 0; font-weight: 700; color: var(--ink-soft); text-decoration: underline; cursor: pointer; padding: 8px; }

.stepper { position: sticky; top: 0; z-index: 20; background: rgba(255, 250, 243, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.stepper ol { list-style: none; margin: 0 auto; padding: 10px 16px; max-width: 760px; display: flex; justify-content: space-between; gap: 6px; }
.stepper li { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .9rem; color: #9aa1b5; flex: 1; position: relative; }
.stepper li:not(:last-child)::after { content: ""; flex: 1; height: 3px; border-radius: 3px; background: var(--line); margin-left: 4px; }
.stepper b { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--line); color: #fff; font-family: var(--display); }
.stepper li.is-done { color: var(--ink); cursor: pointer; }
.stepper li.is-done b { background: var(--teal); }
.stepper li.is-done::after { background: var(--teal); }
.stepper li.is-current { color: var(--ink); }
.stepper li.is-current b { background: var(--navy); box-shadow: 0 0 0 4px var(--purple-soft); }
@media (max-width: 640px) { .stepper li span { display: none; } .stepper li.is-current span { display: inline; } }

/* ---------- Pasos ---------- */
.step { padding: 28px 16px 40px; animation: in .35s ease; }
@keyframes in { from { opacity: 0; transform: translateY(10px); } }
.wrap { max-width: 760px; margin: 0 auto; }
.wrap--wide { max-width: 1100px; }
.kicker { font-family: var(--display); font-weight: 600; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--coral); margin-bottom: 10px; }
.lead { font-size: 1.08rem; color: var(--ink-soft); max-width: 60ch; }
.center .lead { margin-inline: auto; }
.q { font-size: 1.3rem; margin-top: 28px; }
.hint { color: var(--ink-soft); font-size: .93rem; margin-bottom: 12px; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.choice { border: 2px solid var(--line); background: var(--surface); border-radius: 18px; padding: 16px 14px; text-align: left; font-weight: 800; cursor: pointer; transition: all .15s; }
.choice:hover { border-color: var(--navy); }
.choice[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip { border: 2px solid var(--line); background: var(--surface); border-radius: 99px; padding: 8px 15px; font-weight: 700; font-size: .92rem; cursor: pointer; transition: all .15s; }
.chip:hover { border-color: var(--navy); }
.chip[aria-pressed="true"] { background: var(--purple); border-color: var(--purple); color: #fff; }
.chip--add::before { content: "+ "; }

.field { display: grid; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > span { font-weight: 700; font-size: .93rem; }
.field input, .field select, .field textarea, .add-text input, #sello-nombre, .selbar input, .selbar select {
  width: 100%; background: var(--surface); border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; font-size: 16px;
}
.field input:focus, .field select:focus, .field textarea:focus, .add-text input:focus, #sello-nombre:focus, .selbar input:focus, .selbar select:focus { outline: none; border-color: var(--purple); }
.field.is-invalid input, .field.is-invalid select { border-color: var(--coral); }

/* ---------- Piezas ---------- */
.piece-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
@media (max-width: 520px) { .piece-grid { grid-template-columns: repeat(2, 1fr); } }
.piece-card { background: var(--surface); border: 2px solid var(--line); border-radius: 20px; padding: 12px 10px 14px; cursor: pointer; text-align: center; font-weight: 800; transition: all .15s; }
.piece-card svg { width: 100%; height: auto; aspect-ratio: 400 / 440; margin-bottom: 8px; background: var(--bg); border-radius: 14px; padding: 6px; }
.piece-card:hover { border-color: var(--navy); transform: translateY(-2px); }
.piece-card[aria-pressed="true"] { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(19, 40, 90, .18); cursor: pointer; position: relative; padding: 0; }
.swatches--lg .swatch { width: 52px; height: 52px; }
.swatches--sm .swatch { width: 32px; height: 32px; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--navy); }
.swatch-label { display: block; margin-top: 10px; font-weight: 700; color: var(--ink-soft); }

/* ---------- Editor ---------- */
.step--editor { padding: 12px 12px 24px; }
.editor {
  max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px 20px; align-items: start;
  grid-template-areas: "stage sel" "stage panel"; grid-template-rows: auto 1fr;
}
.stage { grid-area: stage; }
.selbar { grid-area: sel; }
.panel { grid-area: panel; }
@media (max-width: 900px) { .editor { grid-template-columns: minmax(0, 1fr); gap: 12px; } }
.editor > * { min-width: 0; }
.stage { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 12px; }
.stage__bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stage__tools { display: flex; gap: 6px; }
.seg[hidden] { display: none; }
.seg { display: inline-flex; background: var(--bg); border-radius: 99px; padding: 4px; }
.seg button { border: 0; background: none; padding: 8px 16px; border-radius: 99px; font-weight: 800; cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--navy); color: #fff; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--bg); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:disabled { opacity: .35; cursor: default; }

.canvas-wrap { position: relative; max-width: 560px; margin: 4px auto 0; }
#canvas { width: 100%; height: auto; overflow: visible; touch-action: none; user-select: none; -webkit-user-select: none; }
.canvas-empty { text-align: center; color: var(--ink-soft); font-weight: 700; font-size: .88rem; margin: 6px 0 2px; }
#canvas .el { cursor: grab; }
#canvas .el:active { cursor: grabbing; }
#canvas .h { cursor: pointer; }

.selbar { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 14px; display: grid; gap: 12px; align-content: start; }
.selbar__foot { display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.selbar__hint { margin: 0; flex: 1; font-size: .82rem; color: var(--ink-soft); line-height: 1.35; }
.selbar__hint b { color: var(--purple); }
.selbar__row { display: grid; grid-template-columns: minmax(0, 1fr) 130px; gap: 8px; }
.selbar__row[hidden], .swatches[hidden] { display: none; }
.selbar input, .selbar select { padding: 9px 12px; }
.selbar__actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-btn { border: 2px solid var(--line); background: var(--surface); border-radius: 99px; padding: 7px 14px; font-weight: 700; font-size: .88rem; cursor: pointer; }
.pill-btn:hover { border-color: var(--navy); }
.pill-btn--danger { color: #b8272a; }
.pill-btn--danger:hover { border-color: var(--coral); background: var(--coral-soft); }

.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 12px; align-self: start; }
@media (max-width: 900px) { .panel { position: static; } }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg); border-radius: 16px; padding: 4px; margin-bottom: 12px; }
.tabs button { border: 0; background: none; padding: 10px 6px; border-radius: 12px; font-weight: 800; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); box-shadow: var(--shadow-sm); }
.tab-body { padding: 4px; }
.cats {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 6px; scrollbar-width: none;
  /* desvanecido a la derecha: indica que hay más categorías */
  -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent);
}
.cats button:last-child { margin-right: 24px; }
.cats::-webkit-scrollbar { display: none; }
.cats button { flex: none; border: 0; background: var(--bg); border-radius: 99px; padding: 7px 13px; font-weight: 700; font-size: .88rem; cursor: pointer; }
.cats button[aria-pressed="true"] { background: var(--teal-soft); color: #0b6d63; }
/* Escritorio: todos los elementos visibles, sin barra de desplazamiento interna */
.lib { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 900px) { .lib { grid-template-columns: repeat(5, 1fr); max-height: none; } }
@media (max-width: 420px) { .lib { grid-template-columns: repeat(4, 1fr); } }
.lib button { aspect-ratio: 1; border: 2px solid transparent; background: var(--bg); border-radius: 16px; padding: 10px; cursor: pointer; transition: border-color .12s, background .12s; min-width: 0; }
.lib button:focus-visible { outline: 3px solid var(--purple); outline-offset: -3px; }
.lib button:active { background: var(--teal-soft); }
/* Resaltado solo con mouse (en celular el "hover" se queda pegado) y sin cambiar tamaño */
@media (hover: hover) { .lib button:hover { border-color: var(--teal); background: #fff; } }
.lib svg { width: 100%; height: 100%; }
.add-text { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 6px 0 10px; }
.mini-h { font-size: 1.05rem; margin: 8px 0 10px; }
#sello-wrap { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 12px; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 10px; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--navy); }

/* ---------- Revisión ---------- */
.review { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; align-items: start; margin-top: 18px; }
@media (max-width: 860px) { .review { grid-template-columns: 1fr; } }
.review__previews { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.preview { background: var(--surface); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm); text-align: center; font-weight: 800; }
.preview svg { width: 100%; height: auto; }
.form { background: var(--surface); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary { background: var(--bg); border-radius: 16px; padding: 14px 16px; margin-bottom: 16px; font-size: .95rem; }
.summary dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.summary dt { font-weight: 800; }
.summary dd { margin: 0; color: var(--ink-soft); }
.form-error { color: #b8272a; font-weight: 700; background: var(--coral-soft); padding: 10px 14px; border-radius: 12px; }
.fine { font-size: .85rem; color: var(--ink-soft); text-align: center; margin: 12px 0 0; }
.form .btn + .btn { margin-top: 10px; }

/* ---------- Confirmación ---------- */
.done-badge { width: 96px; margin: 10px auto 18px; animation: spin 1.2s ease; }
@keyframes spin { from { transform: rotate(-200deg) scale(.4); opacity: 0; } }
.share-box { background: var(--yellow-soft); border-radius: var(--radius); padding: 20px; margin: 22px auto; max-width: 560px; }
.share-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.next-steps { list-style: none; padding: 0; margin: 26px auto; max-width: 480px; text-align: left; display: grid; gap: 12px; }
.next-steps li { display: flex; gap: 12px; align-items: center; font-weight: 600; }
.next-steps b { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--teal-soft); color: #0b6d63; display: grid; place-items: center; font-family: var(--display); }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--display); font-weight: 600; font-size: 1.02rem; padding: 13px 24px; border-radius: 999px; border: 2px solid transparent; text-decoration: none; cursor: pointer; transition: transform .15s, background .15s; line-height: 1.2; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--navy); color: #fff; }
.btn--ghost { background: transparent; color: var(--navy); border-color: var(--navy); }
.btn--yellow { background: var(--yellow); color: var(--navy); }
.btn--sm { padding: 10px 16px; font-size: .95rem; }
.btn--block { width: 100%; }

.nav-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .95); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.nav-bar .btn { min-width: 130px; }
.nav-bar #next { flex: 0 1 260px; margin-left: auto; }
.nav-bar[hidden] { display: none; }
body.no-bar { padding-bottom: 0; }

.toast { position: fixed; left: 50%; bottom: calc(var(--bar-h) + 16px); transform: translate(-50%, 20px); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 99px; font-weight: 700; opacity: 0; pointer-events: none; transition: all .25s; z-index: 40; max-width: calc(100% - 32px); text-align: center; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

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

#intencion, #color-wrap { scroll-margin-top: 70px; scroll-margin-bottom: calc(var(--bar-h) + 20px); }

/* =========================================================
   Celular: editor tipo app (prenda arriba, herramientas abajo)
   ========================================================= */
@media (max-width: 900px) {
  .top { padding: 6px 14px; }
  .top__brand img { height: 40px; }
  body.is-editor .top { display: none; }

  .step--editor { padding: 8px 8px 0; }
  .editor {
    display: flex; flex-direction: column; align-items: stretch; gap: 8px;
    height: calc(100vh - 52px - var(--bar-h) - 8px);
    height: calc(100dvh - 52px - var(--bar-h) - env(safe-area-inset-bottom) - 8px);
  }
  .stage { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 8px; }
  .stage__bar { flex: none; }
  .seg button { padding: 6px 14px; }
  .icon-btn { width: 36px; height: 36px; }
  .canvas-wrap { flex: 1 1 auto; min-height: 0; width: 100%; max-width: none; margin: 4px 0 0; display: flex; align-items: center; justify-content: center; }
  #canvas { width: auto; height: 100%; max-width: 100%; }
  .canvas-empty { flex: none; font-size: .82rem; margin: 2px 0 0; }

  .panel { flex: 0 0 44%; min-height: 0; display: flex; flex-direction: column; padding: 8px; position: static; align-self: stretch; }
  .tabs { flex: none; margin-bottom: 8px; }
  .tabs button { padding: 8px 6px; }
  .tab-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: stable; scrollbar-width: thin; }
  .tab-body[hidden] { display: none !important; }
  .lib { max-height: none; grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .lib button { padding: 8px; border-radius: 14px; }

  .selbar { flex: 0 0 auto; max-height: 46%; overflow-y: auto; padding: 12px; gap: 10px; }
  .editor.has-sel .panel { display: none; }
  .swatches--sm .swatch { width: 34px; height: 34px; }
}
@media (max-width: 380px) { .lib { grid-template-columns: repeat(4, 1fr); } }

/* =========================================================
   Pedido con varias piezas: carrito, datos y pago
   ========================================================= */
.piece-card__price { display: block; font-weight: 700; color: var(--ink-soft); font-size: .85rem; margin-top: 2px; }

.checkout { display: grid; grid-template-columns: 1.25fr 1fr; gap: 24px; align-items: start; margin-top: 18px; }
@media (max-width: 860px) { .checkout { grid-template-columns: minmax(0, 1fr); gap: 18px; } }

.cart { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 12px; }
.cart-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; background: var(--surface); border-radius: 20px; padding: 12px; box-shadow: var(--shadow-sm); border: 2px solid transparent; }
.cart-item.is-invalid { border-color: var(--coral); }
.cart-item__thumbs { display: flex; gap: 6px; align-items: flex-start; }
.thumb { width: 104px; padding: 4px; border: 0; border-radius: 14px; background: var(--bg); cursor: pointer; }
.thumb--sm { width: 56px; }
.thumb svg { width: 100%; height: auto; }
.cart-item__name { font-family: var(--display); font-weight: 600; font-size: 1.08rem; margin: 2px 0 0; }
.cart-item__meta { color: var(--ink-soft); font-size: .9rem; margin: 0 0 8px; }
.cart-item__opts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.mini-select { font-weight: 700; border: 2px solid var(--line); border-radius: 12px; padding: 7px 10px; background: var(--surface); font-size: 16px; }
.cart-item.is-invalid .mini-select { border-color: var(--coral); background: var(--coral-soft); }
.tag { font-size: .85rem; font-weight: 700; color: var(--ink-soft); background: var(--bg); padding: 6px 10px; border-radius: 10px; }
.stepper-qty { display: inline-flex; align-items: center; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; }
.stepper-qty button { width: 38px; height: 36px; border: 0; background: var(--surface); font-size: 1.2rem; font-weight: 800; cursor: pointer; }
.stepper-qty button:active { background: var(--bg); }
.stepper-qty span { min-width: 30px; text-align: center; font-weight: 800; }
.cart-item__foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 10px; }
.price { font-family: var(--display); font-weight: 600; font-size: 1.1rem; }
.price small { display: block; font-family: var(--body); font-weight: 600; font-size: .78rem; color: var(--ink-soft); }
.cart-item__acts { display: flex; gap: 2px; }
.cart-item__acts .link-btn { padding: 6px; font-size: .88rem; }
.link-btn--danger { color: #b8272a; }
@media (max-width: 420px) { .thumb { width: 84px; } .thumb--sm { width: 44px; } .cart-item { gap: 10px; } }

.add-piece {
  width: 100%; border: 2.5px dashed var(--purple); background: var(--purple-soft); color: #7a3597; border-radius: 20px;
  padding: 16px; font-family: var(--display); font-weight: 600; font-size: 1.08rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px;
}
.add-piece span { width: 30px; height: 30px; border-radius: 50%; background: var(--purple); color: #fff; display: grid; place-items: center; font-size: 1.3rem; line-height: 1; }
@media (hover: hover) { .add-piece:hover { background: #ead6f3; } }

.form__title { font-size: 1.25rem; margin-bottom: 14px; }
.entrega { border: 0; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
.radio { display: flex; align-items: center; gap: 10px; border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer; font-weight: 700; }
.radio input { width: 20px; height: 20px; accent-color: var(--navy); flex: none; }
.radio small { font-weight: 600; color: var(--ink-soft); }
.radio:has(input:checked) { border-color: var(--navy); background: var(--bg); }
.radio[hidden] { display: none; }

.totals { margin: 16px 0 10px; display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 14px; }
.totals div { display: flex; justify-content: space-between; }
.totals dt { color: var(--ink-soft); font-weight: 600; }
.totals dd { margin: 0; font-weight: 700; }
.totals__total { font-family: var(--display); font-size: 1.3rem; border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 4px; }
.totals__total dt, .totals__total dd { color: var(--ink); font-weight: 600; }

.status-box { max-width: 520px; margin: 22px auto; border-radius: var(--radius); padding: 20px; background: var(--bg); text-align: center; }
.status-box p { margin: 0 0 8px; }
.status-box .btn { margin-top: 8px; }
.status-box__t { font-family: var(--display); font-weight: 600; font-size: 1.3rem; }
.status-box--ok { background: var(--teal-soft); }
.status-box--warn { background: var(--yellow-soft); }
.status-box--bad { background: var(--coral-soft); }

.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(19, 40, 90, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; }
.overlay[hidden] { display: none; }
.overlay__box { background: var(--surface); border-radius: var(--radius); padding: 28px 24px; width: min(340px, 100%); text-align: center; box-shadow: var(--shadow); }
.overlay__box p { font-family: var(--display); font-weight: 600; font-size: 1.1rem; margin: 14px 0; }
.spinner { width: 54px; height: 54px; margin: 0 auto; border-radius: 50%; border: 6px solid var(--yellow-soft); border-top-color: var(--yellow); animation: girar .9s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
.progress { height: 8px; border-radius: 99px; background: var(--bg); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--coral), var(--yellow), var(--teal)); transition: width .3s; }
@media (prefers-reduced-motion: reduce) { .spinner { animation: girar 2s linear infinite !important; } }
.lib img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Computador: todas las categorías a la vista (con mouse no es obvio deslizar un carrusel) */
@media (min-width: 901px) {
  .cats { flex-wrap: wrap; overflow: visible; -webkit-mask-image: none; mask-image: none; padding-bottom: 4px; margin-bottom: 10px; }
  .cats button:last-child { margin-right: 0; }
}

/* Estampado cargando: miniatura borrosa + indicador; luego la imagen buena */
.el .ph-img, .el .ph-spin { display: none; }
.el.cargando .ph-img { display: inline; filter: blur(1.5px); opacity: .85; }
.el.cargando .ph-spin { display: inline; }
.el.cargando .full { opacity: 0; }
.el .full { transition: opacity .25s; }

/* =========================================================
   Guía de Diseña
   ========================================================= */
.guia { position: fixed; inset: 0; z-index: 90; }
.guia[hidden] { display: none; }
.guia__hueco {
  position: fixed; border-radius: 16px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(19, 40, 90, .62), 0 0 0 3px var(--yellow) inset;
  transition: left .35s ease, top .35s ease, width .35s ease, height .35s ease, border-radius .35s;
}
.guia__card {
  position: fixed; background: var(--surface); border-radius: 22px; padding: 18px 18px 14px;
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, .35); transition: top .35s ease, left .35s ease;
  animation: in .3s ease;
}
.guia__card h2 { font-size: 1.2rem; margin: 6px 0 6px; }
.guia__card p { margin: 0 0 14px; color: var(--ink-soft); font-size: .97rem; }
.guia__pasos { display: flex; gap: 5px; }
.guia__pasos i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: all .2s; }
.guia__pasos i.on { width: 20px; border-radius: 99px; background: var(--purple); }
.guia__acciones { display: flex; justify-content: space-between; align-items: center; }
#ver-guia { font-family: var(--display); font-weight: 700; font-size: 1.05rem; color: var(--purple); }
#guia-sig { margin-left: auto; }

/* Manito del ejemplo en vivo */
.mano { position: fixed; left: 0; top: 0; z-index: 95; width: 44px; height: 44px; margin: -6px 0 0 -14px; pointer-events: none;
  opacity: 0; transition-property: transform, opacity; transition-timing-function: cubic-bezier(.4, 0, .2, 1); }
.mano.on { opacity: 1; }
.mano svg { width: 100%; height: 100%; filter: drop-shadow(0 4px 6px rgba(19, 40, 90, .35)); transition: transform .15s; transform-origin: 30% 10%; }
.mano.presiona svg { transform: scale(.86); }
.mano__onda { position: absolute; left: 6px; top: -4px; width: 28px; height: 28px; border-radius: 50%; background: rgba(252, 179, 5, .55); transform: scale(0); opacity: 0; }
.mano.presiona .mano__onda { animation: onda .5s ease-out; }
@keyframes onda { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.8); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .mano { transition-duration: 0ms !important; } }
.mano { margin: -3px 0 0 -21px; }

/* Colores de la pieza elegida, debajo de su fila */
.color-inline {
  grid-column: 1 / -1; position: relative; background: var(--surface); border: 2px solid var(--teal);
  border-radius: 20px; padding: 14px 16px 16px; margin-top: 4px; animation: in .25s ease;
  scroll-margin-bottom: calc(var(--bar-h) + 20px);
}
.color-inline::before {
  content: ""; position: absolute; top: -10px; left: var(--flecha); width: 18px; height: 18px; margin-left: -9px;
  background: var(--surface); border-left: 2px solid var(--teal); border-top: 2px solid var(--teal); transform: rotate(45deg);
}
.color-inline__t { margin: 0 0 10px; font-weight: 700; }
.color-inline__t b { color: var(--purple); }

/* Franja de colores del paso Imagina: fija encima de la barra de abajo */
.color-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--bar-h) + env(safe-area-inset-bottom)); z-index: 29;
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  animation: subirBarra .2s ease;
}
.color-bar[hidden] { display: none; }
@keyframes subirBarra { from { transform: translateY(100%); opacity: 0; } }
.color-bar__t { flex: none; font-weight: 700; font-size: .9rem; min-width: 96px; }
.color-bar__t b { display: block; color: var(--purple); }
.color-bar__list { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 4px; margin: -4px; }
.color-bar__list::-webkit-scrollbar { display: none; }
.color-bar .swatch { width: 36px; height: 36px; flex: none; }
body.con-colores { padding-bottom: calc(var(--bar-h) + 64px + env(safe-area-inset-bottom)); }
@media (min-width: 901px) { .color-bar { justify-content: center; } }
.piece-card__img { display: block; }
/* Círculos más pequeños y con aire para que el anillo del elegido no se recorte */
.color-bar__list { gap: 10px; padding: 8px; margin: -8px -8px -8px 0; }
.color-bar .swatch { width: 30px; height: 30px; }
.color-bar .swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--navy); }
.piece-card rect.tinte { transition: fill .25s ease; }

/* =========================================================
   Movimiento: que el recorrido se sienta suave y continuo
   ========================================================= */
:root { --suave: cubic-bezier(.22, .8, .24, 1); --rebote: cubic-bezier(.3, 1.45, .5, 1); }

/* Cambio de paso: el actual sale y el nuevo entra desde donde vas (arriba y abajo quedan quietos) */
.step { animation: none; }
@keyframes salir-adelante { to { opacity: 0; transform: translateX(-32px); } }
@keyframes entrar-adelante { from { opacity: 0; transform: translateX(40px); } }
@keyframes salir-atras { to { opacity: 0; transform: translateX(32px); } }
@keyframes entrar-atras { from { opacity: 0; transform: translateX(-40px); } }
.step.sale-adelante { animation: salir-adelante .17s ease-in both; }
.step.sale-atras { animation: salir-atras .17s ease-in both; }
.step.entra-adelante { animation: entrar-adelante .4s var(--suave) both; }
.step.entra-atras { animation: entrar-atras .4s var(--suave) both; }
body { overflow-x: hidden; }

/* Barra de progreso de arriba */
.stepper b, .stepper li::after, .stepper li { transition: background-color .45s var(--suave), color .3s, box-shadow .35s; }

/* Tocar y elegir */
.choice, .chip, .piece-card, .swatch, .btn, .cats button, .lib button, .tabs button, .seg button, .pill-btn, .icon-btn, .thumb, .add-piece, .radio {
  transition: transform .18s var(--suave), background-color .22s, border-color .22s, color .22s, box-shadow .22s, opacity .2s;
}
.choice:active, .chip:active, .piece-card:active, .swatch:active, .btn:active:not(:disabled), .lib button:active,
.cats button:active, .pill-btn:active, .icon-btn:active, .add-piece:active, .thumb:active { transform: scale(.95); }
.choice[aria-pressed="true"], .chip[aria-pressed="true"], .piece-card[aria-pressed="true"], .swatch[aria-pressed="true"] { animation: elegir .38s var(--rebote); }
@keyframes elegir { 45% { transform: scale(1.06); } }

/* Lo que aparece de pronto entra con un fundido */
@keyframes fundido { from { opacity: 0; transform: translateY(8px); } }
#intencion:not([hidden]), .tab-body:not([hidden]), .status-box, .form-error:not([hidden]), .canvas-empty:not([hidden]) { animation: fundido .32s var(--suave); }
.selbar:not([hidden]) { animation: fundido .26s var(--suave); }
.lib.lib--cambio button { animation: fundido .3s var(--suave) both; }
.lib.lib--cambio button:nth-child(2) { animation-delay: .02s; } .lib.lib--cambio button:nth-child(3) { animation-delay: .04s; }
.lib.lib--cambio button:nth-child(4) { animation-delay: .06s; } .lib.lib--cambio button:nth-child(5) { animation-delay: .08s; }
.lib.lib--cambio button:nth-child(6) { animation-delay: .1s; } .lib.lib--cambio button:nth-child(7) { animation-delay: .12s; }
.lib.lib--cambio button:nth-child(8) { animation-delay: .14s; } .lib.lib--cambio button:nth-child(n+9) { animation-delay: .16s; }

/* Dibujos en la prenda: aparecen con rebote y se desvanecen al quitarlos */
.el__in { transform-box: fill-box; transform-origin: center; }
.el.aparece .el__in { animation: aparecer .45s var(--rebote); }
@keyframes aparecer { from { transform: scale(.4); opacity: 0; } }
.el.sale .el__in { animation: desaparecer .18s ease-in forwards; }
@keyframes desaparecer { to { transform: scale(.6); opacity: 0; } }

/* Pedido: las piezas entran en cascada y al quitarlas se cierran */
.cart.entra .cart-item { animation: fundido .4s var(--suave) both; }
.cart.entra .cart-item:nth-child(2) { animation-delay: .06s; } .cart.entra .cart-item:nth-child(3) { animation-delay: .12s; }
.cart.entra .cart-item:nth-child(n+4) { animation-delay: .18s; }
.cart-item.sale { overflow: hidden; transition: height .26s var(--suave), opacity .2s, transform .26s var(--suave), padding .26s, margin .26s;
  height: 0 !important; opacity: 0; transform: translateX(-24px); padding-top: 0; padding-bottom: 0; margin-top: -12px; }

/* Precio total: cambia con suavidad */
.totals dd { transition: color .3s; }

/* Biblioteca por páginas */
.lib { max-height: none !important; overflow: visible; touch-action: pan-y; }
.paginador { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 10px 0 2px; font-weight: 700; font-size: .9rem; color: var(--ink-soft); }
.paginador[hidden] { display: none; }
.paginador__btn { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); font-size: 1.35rem; line-height: 1; font-weight: 700; color: var(--navy); cursor: pointer; display: grid; place-items: center; padding-bottom: 3px; }
.paginador__btn:disabled { opacity: .3; cursor: default; }
@media (hover: hover) { .paginador__btn:not(:disabled):hover { border-color: var(--navy); } }
.lib.lib--sig button { animation: pagSig .28s var(--suave) both; }
.lib.lib--ant button { animation: pagAnt .28s var(--suave) both; }
@keyframes pagSig { from { opacity: 0; transform: translateX(26px); } }
@keyframes pagAnt { from { opacity: 0; transform: translateX(-26px); } }
@media (max-width: 900px) { .tab-body[data-body="elementos"] { overflow: hidden; display: flex; flex-direction: column; } .tab-body[data-body="elementos"][hidden] { display: none !important; } .paginador { margin-top: auto; } }

/* =========================================================
   Computador: el editor cabe entero en la ventana, sin scroll
   (--alto-editor lo calcula app.js según el espacio libre)
   ========================================================= */
@media (min-width: 901px) {
  body.is-editor { overflow: hidden; }
  .step--editor { padding: 10px 16px 0; }
  .editor { height: var(--alto-editor, calc(100vh - 230px)); grid-template-rows: auto minmax(0, 1fr); align-items: stretch; }
  .stage { display: flex; flex-direction: column; min-height: 0; }
  .stage__bar { flex: none; }
  .canvas-wrap { flex: 1 1 auto; min-height: 0; width: 100%; max-width: none; margin: 4px 0 0; display: flex; align-items: center; justify-content: center; }
  #canvas { width: auto; height: 100%; max-width: 100%; }
  .canvas-empty { flex: none; margin: 4px 0 0; }
  .panel { align-self: stretch; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
  .tabs { flex: none; }
  .tab-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .tab-body[hidden] { display: none !important; }
  .tab-body[data-body="elementos"] { overflow: hidden; display: flex; flex-direction: column; }
  .tab-body[data-body="elementos"] .paginador { margin-top: auto; }
  .selbar { align-self: start; }
}
@media (min-width: 901px) {
  .cats { gap: 5px; margin-bottom: 8px; padding-bottom: 2px; }
  .cats button { padding: 5px 11px; font-size: .8rem; }
  .lib { grid-template-columns: repeat(5, 1fr); gap: 7px; }
  .lib button { padding: 6px; border-radius: 12px; }
  .paginador { padding-top: 6px; }
}
