/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --ink: #15201e;
  --muted: #5b6764;
  --line: #e2e6e3;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3f0;
  --warn: #b45309;
  --warn-soft: #fff4e0;
  --bad: #b91c1c;
  --bad-soft: #fde8e8;
  --ok: #15803d;
  --radius: 16px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: 0 1px 2px rgba(16,24,22,.05), 0 8px 28px rgba(16,24,22,.07);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--sans); font-size: 16px; line-height: 1.6;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; overflow-x: clip;
}
img, svg, video, canvas { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.12; letter-spacing: -0.02em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.skip-link { position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem; background: var(--ink); color: #fff; z-index: 9999; border-radius: 8px; }
.skip-link:focus { top: 1rem; }

/* =============================================================
   4. Header / hero
   ============================================================= */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.logo { display: flex; align-items: center; gap: .5rem; color: var(--accent); text-decoration: none; font-weight: 800; font-size: 1.15rem; }
.logo span { color: var(--ink); }
.logo b { color: var(--accent); }
.header-nav { display: none; gap: 1.4rem; }
.header-nav a { color: var(--muted); text-decoration: none; font-size: .95rem; font-weight: 500; }
.header-nav a:hover { color: var(--ink); }

.hero { padding-top: 22px; padding-bottom: 14px; }
.hero h1 { font-size: clamp(1.6rem, 5.2vw, 2.6rem); font-weight: 800; }
.subtitle { color: var(--muted); margin-top: .4rem; max-width: 760px; font-size: clamp(.95rem, 2.4vw, 1.08rem); }

/* =============================================================
   5. Tool card
   ============================================================= */
.tool-card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); padding: 12px; }
.noscript { padding: 1rem; color: var(--bad); font-weight: 600; }
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.panel-title { font-size: 1.02rem; font-weight: 700; display: flex; align-items: center; gap: .55rem; margin-bottom: .8rem; }
.step { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-size: .85rem; flex: none; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: .8rem; }
.tab { padding: .42rem .7rem; border-radius: 999px; border: 1px solid var(--line); font-size: .88rem; font-weight: 500; background: var(--bg); transition: background .2s var(--ease-out), border-color .2s; }
.tab:hover { border-color: #c9d2ce; }
.tab.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .8rem; min-width: 0; }
.field-label { font-size: .86rem; font-weight: 600; color: var(--ink); display: flex; justify-content: space-between; gap: .5rem; }
.field-label small { font-weight: 400; color: var(--muted); }
.field input[type=url], .field input[type=text], .field select {
  width: 100%; padding: .68rem .8rem; border: 1px solid #cfd6d3; border-radius: 10px; background: #fff; font-size: 1rem;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-prefix { display: flex; align-items: stretch; border: 1px solid #cfd6d3; border-radius: 10px; overflow: hidden; background: #fff; }
.input-prefix span { padding: .68rem .2rem .68rem .8rem; color: var(--muted); background: var(--bg); font-size: .95rem; white-space: nowrap; }
.input-prefix input { border: 0 !important; border-radius: 0 !important; box-shadow: none !important; min-width: 0; }
.row-2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .92rem; margin-bottom: .8rem; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.hint { font-size: .82rem; color: var(--muted); }

.styles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.style-opt { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border: 1px solid var(--line); border-radius: 12px; font-size: .76rem; font-weight: 500; }
.style-opt svg { width: 30px; height: 30px; fill: var(--ink); }
.style-opt.is-active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

.colors { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(0,0,0,.18); position: relative; }
.swatch.is-active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.swatch-custom { width: 30px; height: 30px; border-radius: 50%; overflow: hidden; border: 1px dashed #9aa6a2; position: relative; display: grid; place-items: center; font-size: .9rem; color: var(--muted); }
.swatch-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.swatch-custom.is-active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); border-style: solid; }

.emoji-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.emoji-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); font-size: 1.25rem; line-height: 1; display: grid; place-items: center; }
.emoji-btn.is-active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }

.formats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: .9rem; }
.format-opt { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 10px 6px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); }
.format-opt svg { width: 48px; height: 36px; color: var(--accent); margin-bottom: 2px; }
.format-opt b { font-size: .86rem; line-height: 1.2; }
.format-opt small { font-size: .72rem; color: var(--muted); line-height: 1.25; }
.format-opt.is-active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

.range input[type=range] { width: 100%; accent-color: var(--accent); }
.range output { font-weight: 600; color: var(--accent); }
.row-text { grid-template-columns: 1fr 110px !important; }
.module-info { font-size: .86rem; color: var(--muted); }
.module-info b { color: var(--ink); }
.module-info .bad { color: var(--bad); }

/* Preview */
.panel-preview { background: linear-gradient(180deg, #fbfcfb, #f3f6f4); }
.preview-stack { display: grid; grid-template-columns: 1fr 1.25fr; gap: 10px; }
.preview-stack figure { min-width: 0; }
.preview-stack figcaption { font-size: .76rem; color: var(--muted); text-align: center; margin-top: 4px; }
.qr2d { aspect-ratio: 1; background: #fff; border-radius: 12px; border: 1px solid var(--line); padding: 8px; display: grid; place-items: center; overflow: hidden; }
.qr2d canvas, .qr2d svg { width: 100% !important; height: auto !important; }
.viewer3d { aspect-ratio: 1 / .8; border-radius: 12px; border: 1px solid var(--line); background: radial-gradient(circle at 50% 35%, #ffffff, #dfe5e2); position: relative; overflow: hidden; touch-action: none; cursor: grab; }
.viewer3d:active { cursor: grabbing; }
.viewer3d canvas { width: 100% !important; height: 100% !important; }
.viewer-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 1rem; font-size: .85rem; color: var(--muted); }

.warnings { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.warnings li { font-size: .84rem; padding: .5rem .7rem; border-radius: 10px; background: var(--warn-soft); color: #7a3e07; line-height: 1.4; }
.warnings li.bad { background: var(--bad-soft); color: #8a1515; }
.warnings li.ok { background: #e7f6ec; color: #14532d; }

.downloads { margin-top: 12px; display: grid; gap: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .7rem 1rem; border-radius: 12px; font-weight: 600; transition: transform .15s var(--ease-out), background .2s, box-shadow .2s; text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px rgba(15,118,110,.28); }
.btn-primary:hover { background: #0d665f; }
.btn-big { padding: .95rem 1rem; font-size: 1.08rem; width: 100%; }
.btn-big small { font-weight: 500; opacity: .85; }
.btn-ghost { background: #fff; border: 1px solid #cfd6d3; color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: .45rem .75rem; font-size: .86rem; border-radius: 10px; cursor: pointer; }
.btn[disabled] { opacity: .6; pointer-events: none; }
.dl-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.link-btn { font-size: .84rem; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; padding: .2rem; }
.link-btn:hover { color: var(--accent); }
.dl-status { font-size: .84rem; min-height: 1.2em; text-align: center; color: var(--ok); }
.dl-status.err { color: var(--bad); }

.privacy-badge { margin-top: 12px; font-size: .9rem; color: var(--ink); background: var(--accent-soft); border-radius: 12px; padding: .6rem .9rem; }
.limits { font-size: .82rem; color: var(--muted); margin-top: .5rem; }

/* =============================================================
   6. Ads (placeholders)
   ============================================================= */
.ad-slot { display: grid; place-items: center; border: 2px dashed #c3ccc8; border-radius: 12px; background: repeating-linear-gradient(45deg, #f1f3f2, #f1f3f2 10px, #eceeed 10px, #eceeed 20px); color: #8a9592; font-weight: 700; letter-spacing: .18em; font-size: .8rem; }
.ad-leaderboard { min-height: 100px; margin: 28px auto 0; max-width: 970px; }
.ad-incontent { min-height: 250px; margin: 8px auto 0; max-width: 728px; }
.ad-popup { width: 300px; max-width: 100%; height: 250px; margin: 0 auto; }
.ad-corner { width: 100%; height: 100px; }

.ad-dialog { margin: auto; border: 0; border-radius: 18px; padding: 22px 18px 16px; width: min(360px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.3); text-align: center; }
.ad-dialog::backdrop { background: rgba(15,24,22,.55); }
.ad-dialog[open] { display: grid; gap: 12px; animation: pop .25s var(--ease-out); }
.ad-dialog-title { font-weight: 700; font-size: 1rem; padding: 0 20px; }
.ad-close { position: absolute; top: 8px; right: 10px; width: 34px; height: 34px; border-radius: 50%; font-size: 1.5rem; line-height: 1; color: var(--muted); background: var(--bg); }
.ad-close:hover { color: var(--ink); background: var(--line); }
.ad-close-sm { width: 24px; height: 24px; font-size: 1.1rem; top: -10px; right: -10px; background: #fff; border: 1px solid var(--line); z-index: 2; }
.ad-toast { position: fixed; right: 16px; bottom: 16px; width: min(300px, calc(100vw - 32px)); background: #fff; border-radius: 14px; padding: 8px; box-shadow: 0 12px 36px rgba(0,0,0,.18); z-index: 50; animation: slideUp .35s var(--ease-out); }
@keyframes pop { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: none; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* =============================================================
   7. Content sections
   ============================================================= */
.section { padding-top: 48px; }
.section > h2 { font-size: clamp(1.35rem, 3.6vw, 1.9rem); margin-bottom: 1.1rem; }
.steps { list-style: none; padding: 0; display: grid; gap: 14px; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.step-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: .7rem; }
.step-icon svg { width: 24px; height: 24px; fill: currentColor; }
.steps h3 { font-size: 1.08rem; margin-bottom: .3rem; }
.steps p { color: var(--muted); font-size: .95rem; }

.prose { max-width: 820px; }
.prose h3 { font-size: 1.15rem; margin: 1.4rem 0 .4rem; }
.prose p, .prose li { color: #2f3b38; }
.prose p + p { margin-top: .8rem; }
.prose ul { padding-left: 1.2rem; display: grid; gap: .4rem; }

.ideas { display: grid; grid-template-columns: 1fr; gap: 12px; }
.idea { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.idea-emoji { font-size: 1.8rem; display: block; margin-bottom: .4rem; }
.idea h3 { font-size: 1.05rem; margin-bottom: .25rem; }
.idea p { color: var(--muted); font-size: .93rem; }

.faq { display: grid; gap: 8px; max-width: 860px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 16px; }
.faq summary { cursor: pointer; font-weight: 600; padding: 14px 0; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-size: 1.3rem; line-height: 1; }
.faq details[open] summary::after { content: "–"; }
.faq details p { padding-bottom: 14px; color: var(--muted); }

.site-footer { margin-top: 64px; background: var(--surface); border-top: 1px solid var(--line); padding: 22px 0; font-size: .88rem; color: var(--muted); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .6rem; }
.site-footer a { color: var(--muted); }

.legal { max-width: 760px; padding-top: 32px; }
.legal h1 { font-size: 1.8rem; margin-bottom: 1rem; }
.legal h2 { font-size: 1.2rem; margin: 1.4rem 0 .4rem; }
.legal p { color: #2f3b38; }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (max-width: 539px) {
  .preview-stack { grid-template-columns: 1fr 1.3fr; gap: 8px; }
  .format-opt small { display: none; }
  .tool-card { padding: 8px; border-radius: 18px; }
  .panel { padding: 12px; }
}
@media (min-width: 540px) {
  .row-2 { grid-template-columns: 1fr 1fr; }
  .colors { grid-template-columns: 1fr 1fr; }
  .ideas { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 720px) {
  .header-nav { display: flex; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .tool-card { padding: 16px; }
}
@media (min-width: 960px) {
  .tool-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: start; }
  #panel-contenido { grid-column: 1; grid-row: 1; }
  #panel-diseno { grid-column: 1; grid-row: 2; }
  #panel-objeto { grid-column: 1; grid-row: 3; }
  .panel-preview { grid-column: 2; grid-row: 1 / span 3; position: sticky; top: 12px; }
  .preview-stack { grid-template-columns: 1fr; }
  .preview-2d { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: center; }
  .preview-2d figcaption { text-align: left; }
  .preview-3d { order: -1; }
  .viewer3d { aspect-ratio: 1 / .78; }
  .ideas { grid-template-columns: repeat(3, 1fr); }
}

/* =============================================================
   9. Reduced motion (only intrusive effects)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .ad-toast, .ad-dialog[open] { animation: none; }
}
