/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e1d8;
  --accent: #b45309;
  --accent-ink: #ffffff;
  --danger: #b91c1c;
  --ok: #15803d;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --container: 1080px;
}

[data-theme="dark"] {
  --bg: #171310;
  --surface: #221c17;
  --ink: #f4ede3;
  --muted: #a89e91;
  --line: #372e26;
  --accent: #f0a24a;
  --accent-ink: #221c17;
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.01em; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* =============================================================
   3. Utilities
   ============================================================= */
.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--ink); color: var(--bg);
  z-index: 9999; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }
.container { max-width: var(--container); margin-inline: auto; padding-inline: 20px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* =============================================================
   4. Typography
   ============================================================= */
h1 { font-size: clamp(1.7rem, 4.4vw, 2.5rem); }
h2 { font-size: clamp(1.3rem, 2.6vw, 1.7rem); margin-bottom: .6em; }
.lead { color: var(--muted); font-size: 1.05rem; max-width: 60ch; }

/* =============================================================
   5. Components
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font-size: 14.5px; font-weight: 600; transition: background .15s var(--ease-out), border-color .15s var(--ease-out);
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(0.94); }
.btn.block { width: 100%; }
.btn.big { padding: 15px 20px; font-size: 16px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .spinner { display: none; }
.btn[data-loading="1"] .spinner { display: inline-block; }

.pill-group { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 13.5px; font-weight: 600; color: var(--muted);
  transition: all .15s var(--ease-out);
}
.pill[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--ok); font-weight: 600;
}
.badge svg { width: 15px; height: 15px; flex: none; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field input[type=text], .field input[type=password], .field textarea {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 14.5px; font-family: inherit; background: var(--surface); color: var(--ink);
}
.field input[type=color] { width: 52px; height: 38px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row span { font-size: 13px; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }

/* =============================================================
   6. Sections
   ============================================================= */

/* header */
.site-header {
  padding: 14px 0; border-bottom: 1px solid var(--line); background: var(--surface);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; }
.brand svg { width: 22px; height: 22px; color: var(--accent); }
.header-links { display: flex; align-items: center; gap: 16px; font-size: 13.5px; color: var(--muted); }
.header-links a:hover { color: var(--ink); }

/* hero + tool */
.hero { padding: 34px 0 10px; }
.hero .kicker { color: var(--accent); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.hero h1 { max-width: 20ch; }
.hero .lead { margin-top: 10px; }

.tool-section { padding: 26px 0 8px; }
.tool-card {
  padding: 20px;
  display: grid; gap: 22px;
  grid-template-columns: 1fr;
}
@media (min-width: 960px) {
  .tool-card { grid-template-columns: 1.05fr 0.95fr; padding: 28px; }
}

.tool-controls > .field:first-child { margin-top: 0; }

.mode-tabs { display: flex; gap: 6px; margin-bottom: 16px; background: var(--bg); padding: 4px; border-radius: 10px; border: 1px solid var(--line); }
.mode-tab { flex: 1; padding: 8px 10px; border-radius: 7px; font-size: 13.5px; font-weight: 700; color: var(--muted); }
.mode-tab[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.style-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 4px; }
.style-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 4px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface);
  font-size: 11.5px; font-weight: 600; color: var(--muted);
}
.style-opt[aria-pressed="true"] { border-color: var(--accent); color: var(--ink); }
.style-opt .dot { width: 20px; height: 20px; border-radius: 4px; background: var(--ink); }
.style-opt[data-style="redondeado"] .dot { border-radius: 8px; }
.style-opt[data-style="puntos"] .dot { border-radius: 50%; }
.style-opt[data-style="elegante"] .dot { border-radius: 6px 2px; }

.emoji-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 10px; }
.emoji-opt {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; border: 1.5px solid var(--line); border-radius: 9px; background: var(--surface);
}
.emoji-opt[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }

.upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.upload-row .btn { padding: 8px 14px; font-size: 13px; }
.logo-preview { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; display: none; }
.logo-preview.show { display: block; }

.limit-note { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* preview panel */
.preview-panel { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.qr-stage {
  width: 100%; max-width: 300px; aspect-ratio: 1/1;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  position: relative;
}
.qr-stage canvas, .qr-stage img { max-width: 100%; max-height: 100%; border-radius: 4px; }
.qr-stage[data-state="error"] { padding: 24px; text-align: center; font-size: 13px; color: var(--danger); }
.qr-stage[data-state="idle"]::after {
  content: "Escribe un enlace para ver tu QR"; font-size: 13px; color: var(--muted); text-align: center; padding: 0 20px;
}

.download-row { display: flex; gap: 10px; width: 100%; }
.download-row .btn { flex: 1; }

.scan-hint { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.scan-hint svg { width: 16px; height: 16px; flex: none; }

.privacy-badge {
  display: flex; align-items: flex-start; gap: 10px; margin-top: 18px;
  padding: 12px 14px; border-radius: 10px; background: color-mix(in srgb, var(--ok) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--ok) 25%, var(--line));
  font-size: 13px; color: var(--ink);
}
.privacy-badge svg { width: 18px; height: 18px; flex: none; color: var(--ok); margin-top: 1px; }

/* 3D print panel */
.tool-3d-section { padding: 22px 0 8px; }
.tool-3d-card { padding: 24px; }
.tool-3d-grid { display: grid; gap: 22px; grid-template-columns: 1fr; margin-top: 4px; }
@media (min-width: 960px) { .tool-3d-grid { grid-template-columns: 1.05fr 0.95fr; } }
.tool-3d-controls > .field:first-child { margin-top: 0; }

.print-warnings { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 14px; }
.print-warning { font-size: 12.5px; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--ok) 10%, var(--surface)); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 25%, var(--line)); }
.print-warning.bad { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, var(--line)); }

.viewer-3d-stage {
  width: 100%; max-width: 340px; aspect-ratio: 1/1;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden;
}
.viewer-3d-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.viewer-3d-msg { font-size: 13px; color: var(--muted); text-align: center; padding: 0 24px; }
.viewer-3d-stage[data-state="error"] .viewer-3d-msg[data-msg-error] { color: var(--danger); }

/* ad slots */
.ad-slot {
  margin: 30px auto; max-width: 728px; min-height: 90px;
  border: 1px dashed var(--line); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px; letter-spacing: .05em; text-transform: uppercase;
}

/* usos */
.usos { padding: 36px 0 6px; }
.usos-grid { display: grid; gap: 14px; grid-template-columns: 1fr; margin-top: 18px; }
@media (min-width: 720px) { .usos-grid { grid-template-columns: repeat(2, 1fr); } }
.uso-card { padding: 18px; }
.uso-card h3 { font-size: 15.5px; margin-bottom: 6px; }
.uso-card p { font-size: 13.5px; color: var(--muted); }

/* seo text */
.seo-text { padding: 30px 0; max-width: 74ch; }
.seo-text h2 { margin-top: 1.4em; }
.seo-text p { margin-bottom: 1em; color: var(--ink); }
.seo-text p:first-of-type { margin-top: 0; }

/* how it works */
.steps { padding: 30px 0; }
.steps-grid { display: grid; gap: 16px; grid-template-columns: 1fr; margin-top: 18px; }
@media (min-width: 720px) { .steps-grid { grid-template-columns: repeat(3, 1fr); } }
.step-card { padding: 18px; }
.step-num {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; margin-bottom: 10px;
}
.step-card h3 { font-size: 15px; margin-bottom: 5px; }
.step-card p { font-size: 13.5px; color: var(--muted); }

/* FAQ */
.faq { padding: 30px 0; }
.faq-list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.faq-item { padding: 4px 4px; }
.faq-item summary {
  cursor: pointer; font-weight: 700; font-size: 14.5px; padding: 14px 16px;
  list-style: none; display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 20px; color: var(--muted); flex: none; }
.faq-item[open] summary::after { content: "–"; }
.faq-item p { padding: 0 16px 16px; color: var(--muted); font-size: 13.5px; }

/* more tools placeholder */
.more-tools { padding: 30px 0 10px; }
.more-tools-grid { display: grid; gap: 12px; grid-template-columns: 1fr; margin-top: 16px; }
@media (min-width: 720px) { .more-tools-grid { grid-template-columns: repeat(3, 1fr); } }
.more-tool-card { padding: 16px; opacity: .6; }
.more-tool-card span { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.more-tool-card h3 { font-size: 14px; margin-top: 4px; }

/* footer */
.site-footer { border-top: 1px solid var(--line); padding: 26px 0 40px; margin-top: 30px; }
.footer-grid { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; font-size: 12.5px; color: var(--muted); }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-links a:hover { color: var(--ink); }

/* =============================================================
   7. Effects
   ============================================================= */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s var(--ease-out), transform .5s var(--ease-out); }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* =============================================================
   8. Responsive (mobile-first, already inline above per component)
   ============================================================= */
@media (min-width: 540px) { }
@media (min-width: 720px) { }
@media (min-width: 960px) { }
@media (min-width: 1280px) { }

/* =============================================================
   9. Reduced motion (only intrusive)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* no-js fallback */
.no-js .js-only { display: none !important; }
