:root {
  --cream: #FBF5F0;
  --paper: #FFFDFB;
  --blush: #F8DDE4;
  --pink: #EBA9BC;
  --pink-deep: #C8718B;
  --gold: #C49A3A;
  --gold-soft: #E9D08E;
  --ink: #1A1414;
  --muted: #7C6A6C;
  --line: #EEDFD8;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(120, 70, 60, .10);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: 'Outfit', system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(120% 60% at 100% 0%, #FBE3EA 0%, transparent 60%), var(--cream);
  min-height: 100dvh;
}
body.tracing { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
.muted { color: var(--muted); }
.app { max-width: 520px; margin: 0 auto; padding: 0 16px 110px; }

/* Header */
.top { display: flex; align-items: center; gap: 8px; padding: 14px 0 10px; padding-top: max(14px, env(safe-area-inset-top)); }
.logo { width: 44px; height: 44px; border-radius: 50%; box-shadow: 0 2px 10px rgba(196, 154, 58, .35); }
.brand { flex: 1; min-width: 0; }
.brand h1 { font-family: 'Rye', serif; font-weight: 400; font-size: clamp(19px, 5.4vw, 23px); white-space: nowrap; margin: 0; line-height: 1; letter-spacing: .5px; }
.brand p { margin: 3px 0 0; font-size: 11px; letter-spacing: 2px; white-space: nowrap; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.icon-btn {
  min-width: 38px; height: 38px; padding: 0 8px; border-radius: 12px;
  background: var(--paper); border: 1px solid var(--line); font-weight: 600; font-size: 14px;
  display: inline-grid; place-items: center;
}
.icon-btn:active { transform: scale(.96); }

/* Escenario */
.stage-wrap { position: relative; margin-top: 6px; }
.stage {
  height: min(46dvh, 420px); min-height: 280px; border-radius: 24px; overflow: hidden;
  display: grid; place-items: center; touch-action: none; user-select: none;
  background-color: #fff;
  background-image:
    linear-gradient(to right, #F2E9E4 1px, transparent 1px),
    linear-gradient(to bottom, #F2E9E4 1px, transparent 1px);
  background-position: center center;
  border: 1.5px solid var(--gold-soft);
  box-shadow: var(--shadow), inset 0 0 0 6px #fff;
}
.stage svg { display: block; flex: none; }
.stage-chip {
  position: absolute; left: 14px; top: 14px; pointer-events: none;
  background: rgba(255, 255, 255, .92); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 11px; font-size: 12px; font-weight: 600; color: var(--muted);
}
.lock-btn {
  position: absolute; right: 12px; top: 12px; display: inline-flex; gap: 6px; align-items: center;
  background: rgba(255, 255, 255, .92); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 11px; font-size: 12px; font-weight: 600; color: var(--muted);
}
.lock-btn.on { background: var(--ink); color: var(--gold-soft); border-color: var(--ink); }
.lock-btn.pulse { animation: pulse .5s; }
@keyframes pulse { 30% { transform: scale(1.12); } }
.stage-hint { text-align: center; font-size: 12px; color: var(--muted); margin: 8px 0 0; }

/* Tabs */
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin: 14px 0 12px; }
.tab { padding: 10px 0; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--muted); }
.tab.active { background: var(--blush); color: var(--ink); }
.panel { display: none; }
.panel.active { display: block; animation: fade .2s; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; margin: 16px 0 8px; font-weight: 700; }
.panel h3:first-child { margin-top: 4px; }
.panel h3 small { text-transform: none; letter-spacing: 0; font-weight: 500; }

/* Diseños */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile {
  position: relative; aspect-ratio: 3 / 4; border-radius: 16px; background: var(--paper);
  border: 1.5px solid var(--line); display: grid; place-items: center; overflow: hidden; padding: 10px 10px 26px;
}
.tile svg, .tile img { width: 100%; height: 100%; object-fit: contain; }
.tile.sel { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(196, 154, 58, .22); }
.tile.locked svg { opacity: .35; }
.tile .name { position: absolute; bottom: 7px; left: 0; right: 0; font-size: 12px; font-weight: 600; text-align: center; }
.tile .badge { position: absolute; top: 7px; left: 7px; font-size: 10px; font-weight: 700; background: var(--ink); color: var(--gold-soft); padding: 2px 7px; border-radius: 99px; }
.tile .del { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 50%; background: rgba(26, 20, 20, .75); color: #fff; font-size: 15px; line-height: 21px; }
.tile.upload { background: linear-gradient(160deg, var(--blush), #fff); border-style: dashed; border-color: var(--pink); gap: 4px; align-content: center; padding: 10px; color: var(--pink-deep); font-weight: 600; font-size: 13px; }
.tile.upload .plus { font-size: 30px; line-height: 1; }

/* Uña */
.shapes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.shape { background: var(--paper); border: 1.5px solid var(--line); border-radius: 14px; padding: 8px 4px 6px; display: grid; justify-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.shape svg { width: 26px; height: 38px; }
.shape.active { border-color: var(--gold); color: var(--ink); background: #FFF8EA; }
.sizes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.size { background: var(--paper); border: 1.5px solid var(--line); border-radius: 12px; padding: 7px 0 5px; display: grid; line-height: 1.1; }
.size b { font-size: 17px; }
.size small { font-size: 10px; color: var(--muted); }
.size.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.size.active small { color: var(--gold-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 16px; border-radius: 999px; background: var(--paper); border: 1.5px solid var(--line); font-weight: 600; font-size: 14px; color: var(--muted); }
.chip.active { background: var(--blush); border-color: var(--pink); color: var(--ink); }

/* Sliders y toggles */
.slider { display: block; margin: 14px 0 4px; }
.slider span { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.slider em { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--pink-deep); height: 28px; }
.toggles { display: grid; gap: 8px; margin: 16px 0; }
.toggle { display: flex; align-items: center; gap: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; font-size: 14px; font-weight: 500; }
.toggle input { width: 20px; height: 20px; accent-color: var(--pink-deep); }
.row { display: flex; gap: 10px; margin-top: 14px; }
.row .btn { flex: 1; }

/* Botones */
.btn { padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 15px; }
.btn.primary { background: linear-gradient(135deg, #2A1F1F, var(--ink)); color: #fff; box-shadow: 0 6px 18px rgba(26, 20, 20, .25); }
.btn.primary span { color: #fff; }
.btn.ghost { background: var(--paper); border: 1.5px solid var(--line); }
.btn.big { width: 100%; padding: 16px; font-size: 17px; }
.btn:active { transform: scale(.98); }
.link { text-decoration: underline; color: var(--muted); font-size: 14px; padding: 8px; }
.cta-bar {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--cream) 70%, transparent);
}
.cta-bar .btn { max-width: 488px; margin: 0 auto; display: block; }
.cta-bar .btn::first-letter { color: var(--gold-soft); }

/* Modo calco */
.trace {
  position: fixed; inset: 0; z-index: 50; background: #fff; touch-action: none; user-select: none; -webkit-user-select: none;
  display: grid; grid-template-rows: auto 1fr auto;
}
.trace[hidden] { display: none; }
.trace-top { display: flex; justify-content: space-between; gap: 10px; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); font-size: 11px; color: #b5b5b5; }
.trace-canvas { display: grid; place-items: center; overflow: hidden; }
.trace-bottom { display: flex; align-items: center; gap: 12px; padding: 14px 16px; padding-bottom: max(14px, env(safe-area-inset-bottom)); color: #b5b5b5; font-size: 12px; }
.trace-bottom p { margin: 0; }
.unlock { position: relative; width: 52px; height: 52px; border-radius: 50%; background: #f5f5f5; color: #999; display: grid; place-items: center; flex: none; }
.unlock .ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.unlock .ring circle { fill: none; stroke: var(--pink-deep); stroke-width: 3; stroke-dasharray: 126; stroke-dashoffset: 126; }
.unlock.holding .ring circle { stroke-dashoffset: 0; transition: stroke-dashoffset 1.2s linear; }

/* Hojas modales */
.sheet { position: fixed; inset: 0; z-index: 60; background: rgba(26, 20, 20, .45); display: grid; align-items: end; justify-items: center; overflow-y: auto; overflow-x: hidden; }
.sheet[hidden] { display: none; }
.sheet-card {
  width: 100%; max-width: 520px; background: var(--cream); border-radius: 26px 26px 0 0; padding: 22px 18px;
  padding-bottom: max(22px, env(safe-area-inset-bottom)); animation: up .25s ease-out;
}
.sheet-card.center { text-align: center; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-card h2 { font-family: 'Rye', serif; font-weight: 400; margin: 0 0 6px; font-size: 22px; }
.sheet-card p { margin: 0 0 12px; font-size: 14px; line-height: 1.45; }
.card-area { display: grid; place-items: center; padding: 8px 0; overflow: hidden; }
.card-rect {
  border: 2px dashed var(--gold); background: linear-gradient(160deg, #FFF8EA, var(--blush));
  display: grid; place-items: center; color: var(--gold); font-weight: 700; letter-spacing: 1px; font-size: 13px; flex: none;
}
.ruler-wrap { display: grid; justify-items: center; gap: 4px; margin: 8px 0; color: var(--muted); }
.ruler {
  height: 16px; border-left: 1.5px solid var(--ink); border-right: 1.5px solid var(--ink);
  background-image:
    linear-gradient(to right, var(--ink) 1px, transparent 1px),
    linear-gradient(to right, var(--ink) 1.5px, transparent 1.5px),
    linear-gradient(to right, var(--ink) 1.5px, transparent 1.5px);
  background-repeat: repeat-x; background-position: 0 0;
}
.calib-ctl { display: flex; align-items: center; gap: 10px; }
.calib-ctl input { flex: 1; }
.photo-preview { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: grid; place-items: center; height: 240px; margin-bottom: 12px; }
.photo-preview canvas { max-width: 100%; max-height: 214px; width: auto; height: auto; }
.pro-logo { width: 88px; height: 88px; border-radius: 50%; margin: 0 auto 8px; display: block; }
.price { font-size: 22px !important; font-weight: 700; color: var(--pink-deep); }
.sheet-card.center .btn { margin-top: 8px; width: 100%; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); opacity: 0; z-index: 80;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; transition: .25s; pointer-events: none;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 560px) { .sizes { grid-template-columns: repeat(12, 1fr); } }

/* Texto */
.small { font-size: 12px; margin: 8px 0 10px; }
.text-add { display: flex; gap: 8px; }
.text-add input, .text-edit-in {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink);
}
.text-add input:focus, .text-edit-in:focus { outline: none; border-color: var(--pink); }
.text-edit-in { width: 100%; margin-top: 12px; }
.fonts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.font { background: var(--paper); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 4px; font-size: 20px; line-height: 1.2; white-space: nowrap; overflow: hidden; }
.font.active { border-color: var(--gold); background: #FFF8EA; }

/* Ajustar a mi tip */
.fit-open { width: 100%; background: linear-gradient(135deg, #FFF8EA, var(--blush)); border: 1.5px solid var(--gold-soft); color: var(--ink); margin-bottom: 4px; }
.fit .trace-top { color: var(--pink-deep); font-size: 14px; justify-content: center; }
.fit-panel { background: var(--cream); border-radius: 22px 22px 0 0; padding: 14px 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(0, 0, 0, .06); }
.fit-panel p { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.fit-panel .slider { margin: 8px 0; }
.fit-panel .btn { margin-top: 6px; }

/* Categorías */
.cats { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 2px 16px 4px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cats .chip { flex: none; padding: 7px 14px; font-size: 13px; }
.tile.upload .badge { top: 7px; left: 7px; }
