/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0eee7;
  --text: #171712;
  --text-muted: #5d5a4f;
  --accent: #14213d;
  --accent-2: #e8b94a;
  --border: #e3e0d5;
  --success: #0f7a4e;
  --warn: #b3720a;
  --error: #c23a2e;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px -14px rgba(20, 33, 61, 0.22);
  --serif: "Manrope", "Inter", sans-serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14140f;
    --surface: #1d1d16;
    --surface-2: #24241b;
    --text: #f3f1e8;
    --text-muted: #b3b09f;
    --border: #35342a;
    --accent: #7f9cd4;
    --accent-2: #e8b94a;
    color-scheme: dark;
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video, canvas { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.12; letter-spacing: -0.015em; font-family: var(--serif); }
::selection { background: var(--accent-2); color: #14140f; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 9999;
  padding: .6rem 1rem; background: var(--text); color: var(--bg);
  border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

.container { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }

/* =============================================================
   3. Header / footer
   ============================================================= */
.site-header { padding: 1.1rem 0; border-bottom: 1px solid var(--border); background: var(--surface); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .55rem; font-family: var(--serif); font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand-mark { color: var(--accent); }
.header-nav { display: flex; gap: 1.4rem; font-size: .92rem; font-weight: 500; }
.header-nav a { color: var(--text-muted); transition: color .2s var(--ease-out); }
.header-nav a:hover { color: var(--text); }
@media (max-width: 719px) { .header-nav { display: none; } }

.site-footer { border-top: 1px solid var(--border); padding: 1.6rem 0; margin-top: 3rem; color: var(--text-muted); font-size: .88rem; }
.footer-row { display: flex; flex-wrap: wrap; gap: .8rem 1.4rem; align-items: center; justify-content: space-between; }
.footer-nav { display: flex; gap: 1.2rem; }
.footer-nav a:hover { color: var(--text); }
.credits-line { color: var(--text-muted); font-size: .78rem; margin-top: 2.4rem; }

/* =============================================================
   4. Hero + tool card
   ============================================================= */
.hero { padding-top: 2.4rem; padding-bottom: 1rem; }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); max-width: 22ch; }
.hero-sub { color: var(--text-muted); font-size: 1.05rem; max-width: 62ch; margin-top: .7rem; margin-bottom: 1.8rem; }

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.6rem;
}
.tool-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 2rem; }
.tool-grid > * { min-width: 0; }
@media (max-width: 959px) { .tool-grid { grid-template-columns: 1fr; } }

.tool-h2 { font-size: 1rem; font-weight: 700; margin-top: 1.5rem; margin-bottom: .6rem; }
.tool-col > .tool-h2:first-child { margin-top: 0; }
.tool-h2-opt { font-weight: 400; color: var(--text-muted); font-size: .85em; }

.field-label { display: block; font-size: .85rem; font-weight: 600; color: var(--text-muted); margin-bottom: .35rem; margin-top: .9rem; }
.field-label:first-of-type { margin-top: 0; }
.text-input {
  width: 100%; padding: .68rem .8rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: .96rem; font-family: inherit;
  transition: border-color .2s var(--ease-out);
}
.text-input:focus { border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; min-width: 0; }
.field-row > * { min-width: 0; }
.field-error { color: var(--error); font-size: .85rem; margin-top: .5rem; }
.check-label { display: flex; align-items: center; gap: .5rem; font-size: .88rem; margin-top: .7rem; color: var(--text-muted); }

.mode-tabs { display: flex; gap: .4rem; background: var(--surface-2); padding: .3rem; border-radius: 999px; width: fit-content; }
.mode-tab { padding: .45rem 1rem; border-radius: 999px; font-size: .86rem; font-weight: 600; color: var(--text-muted); background: transparent; }
.mode-tab.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.style-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .55rem; }
.style-grid > * { min-width: 0; }
.style-btn {
  display: flex; flex-direction: column; align-items: center; gap: .4rem;
  min-width: 0; width: 100%;
  padding: .7rem .3rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: .7rem; font-weight: 600; color: var(--text-muted);
  white-space: normal; overflow-wrap: break-word; text-align: center;
  transition: border-color .2s var(--ease-out), color .2s var(--ease-out);
}
.style-btn:hover { border-color: var(--accent); }
.style-btn.is-active { border-color: var(--accent); color: var(--text); background: var(--surface-2); }
.style-preview { width: 30px; height: 30px; display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(3,1fr); gap: 2px; }
.style-preview span { background: currentColor; }
.style-preview::before, .style-preview::after { content: ""; }
.style-preview--clasico { background-image: repeating-linear-gradient(currentColor 0 8px, transparent 8px 10px), repeating-linear-gradient(90deg, currentColor 0 8px, transparent 8px 10px); }
.style-preview--redondeado { border-radius: 40%; background: currentColor; }
.style-preview--puntos { border-radius: 50%; background: currentColor; }
.style-preview--elegante { border-radius: 40% 10% 40% 10%; background: currentColor; }
.style-btn .style-preview { color: var(--accent); }

.color-row { display: flex; gap: .8rem; margin-top: .9rem; min-width: 0; }
.color-field {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: .55rem; position: relative;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem .6rem;
  font-size: .82rem; font-weight: 600; color: var(--text-muted); cursor: pointer;
}
.color-field span:not(.color-swatch) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.color-swatch { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); flex-shrink: 0; }
.color-field input[type="color"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.preset-row { display: flex; gap: .5rem; margin-top: .6rem; }
.preset-swatch { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); }

.emoji-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.emoji-btn {
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 1.05rem;
}
.emoji-btn.is-active { border-color: var(--accent); background: var(--surface-2); }
.logo-row { display: flex; align-items: center; gap: .9rem; margin-top: .7rem; }
.upload-btn {
  display: inline-block; padding: .55rem 1rem; border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 600; color: var(--text-muted); cursor: pointer;
}
.upload-btn:hover { border-color: var(--accent); color: var(--text); }
.text-link-btn { font-size: .85rem; font-weight: 600; color: var(--error); text-decoration: underline; }

.module-info { font-size: .78rem; color: var(--text-muted); margin-top: 1rem; }

.qr-preview-wrap {
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 1.2rem; min-height: 220px;
}
.qr-canvas { width: 100%; max-width: 300px; height: auto; border-radius: 6px; }
.download-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.btn {
  padding: .7rem 1.2rem; border-radius: 999px; font-weight: 700; font-size: .9rem;
  border: 1.5px solid transparent; transition: transform .15s var(--ease-out), opacity .15s var(--ease-out);
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: .92; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.btn.is-loading { opacity: .6; pointer-events: none; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.privacy-badge { font-size: .78rem; color: var(--text-muted); margin-top: .9rem; }

/* =============================================================
   5. Painel 3D
   ============================================================= */
.panel3d { border-top: 1px solid var(--border); margin-top: 1.8rem; padding-top: 1.6rem; }
.panel3d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: .8rem; }
.panel3d-grid > * { min-width: 0; }
@media (max-width: 959px) { .panel3d-grid { grid-template-columns: 1fr; } }

.format-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; }
.format-grid > * { min-width: 0; }
.format-btn {
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  min-width: 0; width: 100%;
  padding: .8rem .3rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: .7rem; font-weight: 600; color: var(--text-muted);
  white-space: normal; overflow-wrap: break-word; text-align: center;
}
.format-btn svg { width: 30px; height: 30px; }
.format-btn.is-active { border-color: var(--accent); color: var(--text); background: var(--surface-2); }

.size-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: .3rem; }
.size-grid > * { min-width: 0; }
.size-btn {
  min-width: 0; width: 100%;
  padding: .5rem .3rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: .78rem; font-weight: 600; color: var(--text-muted); display: flex; flex-direction: column; gap: .1rem; background: var(--surface);
}
.size-btn span { font-size: .68rem; font-weight: 400; color: var(--text-muted); }
.size-btn.is-active { border-color: var(--accent); color: var(--text); background: var(--surface-2); }

.warn-list { list-style: none; margin-top: 1rem; display: flex; flex-direction: column; gap: .4rem; }
.warn-list li { font-size: .82rem; padding: .55rem .7rem; border-radius: var(--radius-sm); border: 1px solid; }
.warn-error { color: var(--error); border-color: color-mix(in srgb, var(--error) 40%, transparent); background: color-mix(in srgb, var(--error) 8%, transparent); }
.warn-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.warn-info { color: var(--text-muted); border-color: var(--border); background: var(--surface-2); }

.hint-text { font-size: .78rem; color: var(--text-muted); margin-top: .8rem; }

.viewer3d-wrap { background: var(--surface-2); border-radius: var(--radius-sm); overflow: hidden; }
.viewer3d-canvas { width: 100%; aspect-ratio: 4/3; touch-action: none; cursor: grab; }
.viewer3d-canvas:active { cursor: grabbing; }

/* =============================================================
   6. Ad slots (placeholders only)
   ============================================================= */
.ad-slot {
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: .8rem; font-weight: 600; letter-spacing: .08em;
  background: var(--surface-2);
}
.ad-label { opacity: .7; }
.ad-slot--banner { min-height: 90px; margin: 2rem auto; }
.ad-slot--incontent { min-height: 250px; margin: 2.4rem auto; max-width: 728px; }
.ad-slot--popup { min-height: 220px; margin-bottom: 1rem; }

.ad-dialog { border: none; border-radius: var(--radius); padding: 1.4rem; max-width: min(420px, 90vw); box-shadow: var(--shadow); background: var(--surface); color: var(--text); }
.ad-dialog::backdrop { background: rgba(10, 10, 8, .5); }
.ad-dialog-close { position: absolute; top: .7rem; right: .7rem; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); }
.ad-dialog-btn { width: 100%; }

.corner-toast {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 40; width: 240px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: .8rem; opacity: 0; transform: translateY(12px);
  transition: opacity .3s var(--ease-out), transform .3s var(--ease-out);
}
.corner-toast.is-in { opacity: 1; transform: translateY(0); }
.corner-toast .ad-slot { min-height: 90px; border-style: solid; }
.corner-toast-close { position: absolute; top: .4rem; right: .4rem; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); font-size: .7rem; }
@media (max-width: 539px) { .corner-toast { right: .6rem; bottom: .6rem; width: 200px; } }

/* =============================================================
   7. Sections: steps, usos, seo copy, faq
   ============================================================= */
.section { padding-block: 2.6rem; }
.section--tint { background: var(--surface-2); }
.section-title { font-size: clamp(1.3rem, 2.6vw, 1.7rem); margin-bottom: 1.5rem; }

.steps-list { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; counter-reset: step; }
@media (max-width: 719px) { .steps-list { grid-template-columns: 1fr; } }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; margin-bottom: .8rem; font-size: .95rem;
}
.step h3 { font-size: 1.02rem; margin-bottom: .4rem; }
.step p { color: var(--text-muted); font-size: .92rem; }

.usos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
@media (max-width: 719px) { .usos-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 539px) { .usos-grid { grid-template-columns: 1fr; } }
.uso-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; }
.uso-emoji { font-size: 1.6rem; display: block; margin-bottom: .6rem; }
.uso-card h3 { font-size: .98rem; margin-bottom: .35rem; }
.uso-card p { color: var(--text-muted); font-size: .88rem; }

.seo-copy p { color: var(--text-muted); max-width: 74ch; margin-bottom: 1rem; font-size: .96rem; }
.seo-copy p:last-child { margin-bottom: 0; }

.faq-list { display: flex; flex-direction: column; gap: .6rem; max-width: 78ch; }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .95rem 1.1rem; }
.faq-item summary { font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-weight: 400; color: var(--text-muted); flex-shrink: 0; }
.faq-item[open] summary::after { content: "−"; }
.faq-item p { color: var(--text-muted); margin-top: .7rem; font-size: .92rem; }

/* =============================================================
   8. No-JS fallback
   ============================================================= */
.no-js-note { display: none; font-size: .85rem; color: var(--text-muted); padding: .8rem; border: 1px dashed var(--border); border-radius: var(--radius-sm); }
html:not(.is-ready) .no-js-note { display: block; }
html:not(.is-ready) .qr-canvas,
html:not(.is-ready) .viewer3d-canvas { display: none; }
