/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #eef2fb;
  --surface: #ffffff;
  --surface-2: #e2e9f7;
  --text: #0e1526;
  --text-dim: #55627e;
  --border: #cdd8ef;
  --accent: #2f5fe4;
  --accent-2: #17c3e0;
  --accent-ink: #ffffff;
  --ok: #147a52;
  --warn: #c23c1f;
  --radius: 10px;
  --radius-sm: 6px;
  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  --display: var(--mono);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --container: 1180px;
  --plate-cut: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0f1c;
    --surface: #10182a;
    --surface-2: #172236;
    --text: #eef2fb;
    --text-dim: #95a2c4;
    --border: #253156;
    --accent: #5b85ff;
    --accent-2: #2ee0ff;
    --ok: #35c98d;
    --warn: #ff7355;
  }
}

/* Manual theme toggle wins over the OS setting in both directions. */
:root[data-theme="dark"] {
  --bg: #0a0f1c;
  --surface: #10182a;
  --surface-2: #172236;
  --text: #eef2fb;
  --text-dim: #95a2c4;
  --border: #253156;
  --accent: #5b85ff;
  --accent-2: #2ee0ff;
  --ok: #35c98d;
  --warn: #ff7355;
}
:root[data-theme="light"] {
  --bg: #eef2fb;
  --surface: #ffffff;
  --surface-2: #e2e9f7;
  --text: #0e1526;
  --text-dim: #55627e;
  --border: #cdd8ef;
  --accent: #2f5fe4;
  --accent-2: #17c3e0;
  --ok: #147a52;
  --warn: #c23c1f;
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; overflow-x: clip; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -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; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.18; letter-spacing: -0.015em; font-family: var(--display); font-weight: 700; }
input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; border-radius: 4px; }

/* Ambient background: soft, slow-breathing aurora blobs */
.aurora-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora-blob {
  position: absolute; border-radius: 50%; filter: blur(70px);
  will-change: transform;
}
.aurora-blob--a {
  width: 60vw; height: 60vw; max-width: 720px; max-height: 720px;
  top: -18vw; left: -12vw;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 55%, transparent) 0%, transparent 72%);
  animation: aurora-drift-a 52s ease-in-out infinite alternate;
}
.aurora-blob--b {
  width: 54vw; height: 54vw; max-width: 620px; max-height: 620px;
  top: 8vw; right: -16vw;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent-2) 50%, transparent) 0%, transparent 72%);
  animation: aurora-drift-b 64s ease-in-out infinite alternate;
}
.aurora-blob--c {
  width: 46vw; height: 46vw; max-width: 560px; max-height: 560px;
  bottom: -16vw; left: 18vw;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 40%, transparent) 0%, transparent 72%);
  animation: aurora-drift-c 70s ease-in-out infinite alternate;
}
@keyframes aurora-drift-a { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(6vw, 5vw) scale(1.12); } }
@keyframes aurora-drift-b { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(-5vw, 6vw) scale(1.08); } }
@keyframes aurora-drift-c { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(4vw, -6vw) scale(1.1); } }
@media (prefers-reduced-motion: reduce) {
  .aurora-blob { animation: none; }
}
@media (max-width: 720px) {
  .aurora-blob { filter: blur(46px); opacity: .8; }
}

/* Corner-bracket "viewfinder" mark — reused on the tool frames */
.blueprint-corners { position: relative; }
.blueprint-corners::before, .blueprint-corners::after {
  content: ""; position: absolute; width: 16px; height: 16px; pointer-events: none; z-index: 2;
}
.blueprint-corners::before { top: -1px; left: -1px; border-top: 2px solid var(--accent-2); border-left: 2px solid var(--accent-2); border-top-left-radius: 4px; }
.blueprint-corners::after { bottom: -1px; right: -1px; border-bottom: 2px solid var(--accent-2); border-right: 2px solid var(--accent-2); border-bottom-right-radius: 4px; }

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 1.25rem; }

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

/* =============================================================
   3. Header / footer
   ============================================================= */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 40; }
.header-row { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: .5rem; }
.brand { display: flex; align-items: center; gap: .5rem; font-family: var(--display); font-weight: 800; font-size: 1.15rem; flex-shrink: 0; }
.brand-mark { display: flex; border-radius: 7px; overflow: hidden; box-shadow: 0 0 0 1px var(--border); }
.brand-mark img { display: block; width: 28px; height: 28px; }
.header-nav { display: flex; gap: .9rem; font-weight: 600; font-size: .8rem; white-space: nowrap; overflow-x: auto; scrollbar-width: none; }
.header-nav::-webkit-scrollbar { display: none; }
.header-nav a { opacity: .82; transition: opacity .15s var(--ease-out); }
.header-nav a:hover { opacity: 1; }
@media (min-width: 540px) { .header-row { height: 60px; } .header-nav { gap: 1.25rem; font-size: .92rem; } }

.theme-toggle {
  flex-shrink: 0; font-family: var(--mono); font-size: .68rem; font-weight: 700; letter-spacing: .06em;
  border: 1px solid var(--border); border-radius: 999px; padding: .32rem .7rem; color: var(--text-dim);
  background: var(--surface-2); transition: border-color .15s var(--ease-out), color .15s var(--ease-out);
}
.theme-toggle:hover { border-color: var(--accent-2); color: var(--text); }
.theme-toggle[data-mode="light"], .theme-toggle[data-mode="dark"] { color: var(--accent); border-color: var(--accent); }

.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; padding-block: 1.5rem; background: var(--surface); }
.footer-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; color: var(--text-dim); font-size: .9rem; }
.footer-row nav { display: flex; gap: 1.1rem; }
.credits-row { margin-top: .75rem; color: var(--text-dim); font-size: .78rem; }

/* =============================================================
   4. Hero
   ============================================================= */
.hero { padding-block: 2.6rem 1.6rem; text-align: center; }
.hero h1 { font-size: clamp(1.5rem, 3.2vw, 2.35rem); max-width: 24ch; margin-inline: auto; }
.hero-sub { margin-top: .9rem; color: var(--text-dim); font-size: 1.05rem; max-width: 62ch; margin-inline: auto; }

@media (min-width: 720px) { .container { padding-inline: 2rem; } }

/* =============================================================
   5. Tool card
   ============================================================= */
.tool-section { padding-block: 1rem 2rem; }
.tool-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.tool-noscript { background: var(--surface-2); border-radius: var(--radius-sm); padding: .9rem 1rem; margin-bottom: 1rem; font-size: .92rem; }

.tool-grid { display: grid; gap: 1.4rem; }
@media (min-width: 960px) { .tool-grid { grid-template-columns: 1.05fr 1fr; align-items: start; } }

.tool-controls { display: flex; flex-direction: column; gap: .9rem; }
.field-row { display: flex; flex-direction: column; gap: .35rem; }
.field-row label { font-family: var(--mono); font-weight: 700; font-size: .74rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.field-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.field-row input[type="text"], .field-row input[type="email"], .field-row input[type="tel"],
.field-row textarea, .field-row select {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .7rem;
  background: var(--bg); font-size: .95rem; width: 100%;
}
.field-row input[type="color"] { width: 100%; height: 42px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; background: var(--bg); }
.field-row input[type="file"] { font-size: .85rem; }
.check-row { display: flex; align-items: center; gap: .5rem; font-size: .88rem; color: var(--text-dim); }
.content-panel { display: flex; flex-direction: column; gap: .5rem; border-top: 1px dashed var(--border); padding-top: .8rem; }
.content-panel[hidden] { display: none; }

.style-grid, .format-3d-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
@media (min-width: 540px) { .style-grid { grid-template-columns: repeat(4, 1fr); } }
.style-option, .format-3d-option {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .55rem .5rem;
  font-size: .85rem; font-weight: 600; text-align: center; background: var(--bg);
  transition: border-color .15s var(--ease-out), background .15s var(--ease-out), transform .12s var(--ease-out);
}
.style-option:hover, .format-3d-option:hover { border-color: var(--accent); }
.style-option.is-active, .format-3d-option.is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.style-option:active, .format-3d-option:active { transform: scale(.97); }
.format-3d-hint { font-size: .82rem; color: var(--text-dim); margin-top: .3rem; }

.emoji-grid { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.emoji-btn {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg);
}
.emoji-btn.is-active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--bg)); }
.emoji-btn--remove { width: auto; padding-inline: .6rem; font-size: .75rem; font-weight: 700; }

/* Preview */
.tool-preview { display: flex; flex-direction: column; gap: .9rem; }
.preview-frame {
  position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius-sm);
  background:
    linear-gradient(45deg, var(--surface-2) 25%, transparent 25%) -8px 0/16px 16px,
    linear-gradient(-45deg, var(--surface-2) 25%, transparent 25%) -8px 0/16px 16px,
    linear-gradient(45deg, transparent 75%, var(--surface-2) 75%) 0 0/16px 16px,
    linear-gradient(-45deg, transparent 75%, var(--surface-2) 75%) 0 0/16px 16px,
    var(--bg);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.preview-frame canvas { width: 88%; height: 88%; object-fit: contain; display: none; }
.preview-idle, .preview-error { text-align: center; padding: 1.2rem; color: var(--text-dim); font-size: .92rem; display: none; }
.preview-error { color: var(--warn); font-weight: 600; }

.tool-card[data-state="idle"] .preview-idle { display: block; }
.tool-card[data-state="working"] .preview-frame canvas,
.tool-card[data-state="done"] .preview-frame canvas { display: block; }
.tool-card[data-state="working"] .preview-frame { opacity: .6; }
.tool-card[data-state="error"] .preview-error { display: block; }

/* Scan-sweep: a one-shot light sweep across the code when it finishes rendering */
.scan-sweep {
  position: absolute; left: 6%; right: 6%; top: 0; height: 34%;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--accent-2) 55%, transparent), transparent);
  opacity: 0; pointer-events: none;
}
.scan-sweep.is-active { animation: scan-sweep-run .9s var(--ease-out); }
@keyframes scan-sweep-run {
  0% { opacity: 0; transform: translateY(-10%); }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translateY(230%); }
}
@media (prefers-reduced-motion: reduce) { .scan-sweep.is-active { animation: none; } }

/* Progress stepper: código listo → objeto 3D */
.progress-steps {
  display: flex; align-items: center; gap: .5rem; margin-top: 1rem;
  font-family: var(--mono); font-size: .74rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--text-dim);
}
.progress-step { display: inline-flex; align-items: center; gap: .4rem; }
.progress-step-num {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
  border-radius: 50%; border: 1px solid var(--border); font-size: .68rem; color: var(--text-dim);
}
.progress-step-arrow { color: var(--border); }
.progress-step.is-done { color: var(--ok); }
.progress-step.is-done .progress-step-num { border-color: var(--ok); color: var(--ok); }
.progress-step.is-invite { color: var(--accent); animation: progress-pulse 1.6s ease-in-out infinite; }
.progress-step.is-invite .progress-step-num { border-color: var(--accent); color: var(--accent); }
@keyframes progress-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .progress-step.is-invite { animation: none; } }

/* Scan-test dialog (camera) */
.scan-test-dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; max-width: 420px; width: calc(100% - 2rem); background: var(--surface); color: var(--text); }
.scan-test-dialog::backdrop { background: rgba(0,0,0,.6); }
.scan-test-inner { padding: 1.4rem; position: relative; display: flex; flex-direction: column; gap: .7rem; }
.scan-test-inner h3 { font-size: 1.05rem; padding-right: 1.5rem; }
.scan-test-hint { color: var(--text-dim); font-size: .88rem; }
.scan-test-video-frame { position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius-sm); overflow: hidden; background: #000; border: 1px solid var(--border); }
.scan-test-video-frame video { width: 100%; height: 100%; object-fit: cover; }
.scan-test-result { font-size: .92rem; font-weight: 700; min-height: 1.4em; }
.scan-test-result.ok { color: var(--ok); }
.scan-test-result.warn { color: var(--warn); }

.download-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .75rem 1.25rem; font-weight: 700; font-size: .95rem;
  font-family: var(--mono); letter-spacing: .01em;
  clip-path: polygon(var(--plate-cut) 0, 100% 0, 100% calc(100% - var(--plate-cut)), calc(100% - var(--plate-cut)) 100%, 0 100%, 0 var(--plate-cut));
  transition: transform .12s var(--ease-out), filter .15s var(--ease-out), background .15s var(--ease-out);
}
.btn[hidden] { display: none; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent-2); }
.btn-secondary:disabled { opacity: .45; cursor: not-allowed; }
.btn-3d { background: var(--text); color: var(--bg); width: 100%; }
@media (min-width: 540px) { .btn-3d { width: auto; } }

.privacy-badge { font-size: .82rem; color: var(--text-dim); }

/* 3D panel */
.three-toggle-row { margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; }
.three-toggle-hint { font-size: .85rem; color: var(--text-dim); }
.panel-3d { margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 1rem; }
.panel-3d[hidden] { display: none; }
.preview-3d-frame { position: relative; }
.preview-3d { width: 100%; aspect-ratio: 4 / 3; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); touch-action: none; }
.preview-3d canvas { border-radius: var(--radius-sm); }
.preview-3d-error { padding: 1rem; font-size: .88rem; color: var(--warn); }
.warnings-3d { list-style: none; display: flex; flex-direction: column; gap: .4rem; font-size: .88rem; }
.warnings-3d li { padding: .5rem .7rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.warnings-3d li.ok { color: var(--ok); }
.warnings-3d li.warn { color: var(--warn); font-weight: 600; }

/* =============================================================
   6. Ad slots (placeholders)
   ============================================================= */
.ad-slot {
  min-height: 90px; display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  margin-block: 1.6rem; color: var(--text-dim); position: relative;
  background: repeating-linear-gradient(135deg, var(--surface-2), var(--surface-2) 10px, var(--bg) 10px, var(--bg) 20px);
}
.ad-label { font-size: .72rem; font-weight: 800; letter-spacing: .08em; color: var(--text-dim); background: var(--surface); padding: .2rem .55rem; border-radius: 999px; border: 1px solid var(--border); }
.ad-incontent { min-height: 250px; }

.ad-popup { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; max-width: 380px; width: calc(100% - 2rem); background: var(--surface); color: var(--text); }
.ad-popup::backdrop { background: rgba(0,0,0,.5); }
.ad-popup-inner { padding: 1.5rem; display: flex; flex-direction: column; align-items: center; gap: .8rem; text-align: center; position: relative; }
.ad-popup-close { position: absolute; top: .6rem; right: .6rem; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); }
.ad-popup-cta { color: var(--text-dim); font-size: .9rem; min-height: 60px; display: flex; align-items: center; justify-content: center; }

.ad-corner-toast {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 60;
  display: flex; align-items: center; gap: .6rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: .5rem .6rem .5rem 1rem; box-shadow: 0 6px 24px rgba(0,0,0,.15);
  transform: translateY(140%); transition: transform .35s var(--ease-out);
}
.ad-corner-toast.is-visible { transform: translateY(0); }
.ad-corner-toast button { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); font-size: .75rem; }
@media (prefers-reduced-motion: reduce) { .ad-corner-toast { transition: none; } }

/* =============================================================
   7. Steps / use cases / SEO text / FAQ / future
   ============================================================= */
section h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); margin-bottom: .3rem; }
.section-sub { color: var(--text-dim); margin-bottom: 1.2rem; }
.steps-section, .usecases-section, .seo-text-section, .faq-section, .future-section { padding-block: 2rem; }

.steps-grid { list-style: none; display: grid; gap: 1rem; margin-top: 1.2rem; }
@media (min-width: 720px) { .steps-grid { grid-template-columns: repeat(3, 1fr); } }
.step-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; margin-bottom: .7rem;
}
.step-card h3 { font-size: 1.05rem; margin-bottom: .35rem; }
.step-card p { color: var(--text-dim); font-size: .92rem; }

.usecases-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .usecases-grid { grid-template-columns: repeat(3, 1fr); } }
.usecase-card {
  text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem; display: flex; flex-direction: column; gap: .4rem;
  transition: border-color .15s var(--ease-out), transform .12s var(--ease-out);
}
.usecase-card:hover { border-color: var(--accent); }
.usecase-card:active { transform: scale(.98); }
.usecase-card h3 { font-size: 1rem; }
.usecase-card p { color: var(--text-dim); font-size: .88rem; }

.seo-text-section { max-width: 78ch; margin-inline: auto; }
.seo-text-section p { margin-top: .9rem; color: var(--text-dim); }
.seo-text-section p:first-of-type { margin-top: 1rem; }

.faq-item { border-bottom: 1px solid var(--border); padding-block: .9rem; }
.faq-item summary { font-weight: 700; cursor: pointer; list-style: none; position: relative; padding-right: 1.5rem; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; position: absolute; right: 0; top: 0; font-size: 1.2rem; color: var(--accent); }
.faq-item[open] summary::after { content: "–"; }
.faq-item p { margin-top: .6rem; color: var(--text-dim); font-size: .95rem; }

.future-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .future-grid { grid-template-columns: repeat(3, 1fr); } }
.future-card { background: var(--surface-2); border-radius: var(--radius); padding: 1rem; opacity: .85; }
.future-card h3 { font-size: .92rem; margin-bottom: .3rem; }
.future-card p { font-size: .84rem; color: var(--text-dim); }

/* =============================================================
   8. Reduced motion — only truly intrusive effects
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .ad-corner-toast { transition: none; }
}
