/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #ffffff;
  --bg-alt: #f6f5f2;
  --ink: #17171c;
  --ink-soft: #55555f;
  --line: #e4e2dc;
  --accent: #2f6fed;
  --accent-ink: #0c3fac;
  --accent-soft: #eaf1ff;
  --warn: #b45309;
  --warn-bg: #fef3e2;
  --bad: #c62828;
  --bad-bg: #fdecea;
  --ok: #1a7f4b;
  --ok-bg: #e9f8ef;
  --card: #ffffff;
  --radius: 16px;
  --radius-sm: 10px;
  --sans: "Manrope", system-ui, sans-serif;
  --display: "Sora", var(--sans);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: 0 1px 2px rgba(20,20,30,.04), 0 8px 24px -12px rgba(20,20,30,.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121216;
    --bg-alt: #1a1a20;
    --ink: #f3f3f6;
    --ink-soft: #a6a6b3;
    --line: #2b2b33;
    --accent: #5a8dff;
    --accent-ink: #cfe0ff;
    --accent-soft: #1c2b4d;
    --card: #191921;
    --warn-bg: #3a2a12;
    --bad-bg: #3a1a1a;
    --ok-bg: #10301f;
  }
}

/* =============================================================
   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: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -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; }
a { color: inherit; text-decoration: none; }
input, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; line-height: 1.1; letter-spacing: -0.01em; }
p { text-wrap: pretty; }
::selection { background: var(--accent); color: #fff; }
: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(--ink); color: var(--bg);
  border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

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

/* =============================================================
   3. Utilities
   ============================================================= */
.wrap { max-width: 1180px; margin-inline: auto; padding-inline: 1.25rem; }
.wrap-narrow { max-width: 760px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .8rem 1.3rem; border-radius: 999px; font-weight: 700; font-size: .95rem;
  transition: transform .15s var(--ease-out), box-shadow .15s var(--ease-out), background .15s var(--ease-out);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 16px -6px rgba(47,111,237,.55); }
.btn-primary:hover { background: var(--accent-ink); }
.btn-secondary { background: var(--bg-alt); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--line); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink-soft); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: .5rem .9rem; font-size: .85rem; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* =============================================================
   4. Header / footer
   ============================================================= */
.site-header { border-bottom: 1px solid var(--line); padding-block: .9rem; }
.site-header .wrap { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-family: var(--display); font-weight: 800; font-size: 1.25rem; }
.brand em { font-style: normal; color: var(--accent); }
.brand-logo { width: 34px; height: 34px; display: block; }
.brand-mark { display: inline-block; width: 1.6rem; height: 1.6rem; border-radius: 6px; background: var(--ink); color: var(--bg); text-align: center; line-height: 1.6rem; font-size: 1rem; }
.header-tag { color: var(--ink-soft); font-size: .85rem; }

.site-footer { border-top: 1px solid var(--line); padding-block: 2rem; margin-top: 2rem; color: var(--ink-soft); font-size: .9rem; }
.site-footer .wrap { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .75rem; }
.footer-nav { display: flex; gap: 1.2rem; }
.footer-nav a:hover { color: var(--accent); }

/* =============================================================
   5. Hero
   ============================================================= */
.hero { padding-block: clamp(2rem, 5vw, 3.4rem) 1.4rem; text-align: center; }
.hero h1 { font-size: clamp(1.9rem, 4.6vw, 3rem); max-width: 18ch; margin-inline: auto; }
.hero-sub { color: var(--ink-soft); max-width: 56ch; margin: .9rem auto 0; font-size: 1.05rem; }

/* =============================================================
   6. Tool card
   ============================================================= */
.tool { padding-block: .6rem 2rem; }
.tool-wrap { display: grid; grid-template-columns: 1fr; gap: 1.1rem; }
.tool-wrap > .panel { min-width: 0; }
@media (min-width: 960px) {
  .tool-wrap { grid-template-columns: 360px 1fr; align-items: start; }
}

.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem;
}
.controls { display: flex; flex-direction: column; gap: 1.1rem; }
.ctrl-group { display: flex; flex-direction: column; gap: .55rem; }
.ctrl-label { font-weight: 700; font-size: .88rem; }

.tabbar { display: flex; gap: .4rem; background: var(--bg-alt); padding: .3rem; border-radius: 999px; }
.tab { flex: 1; padding: .55rem .6rem; border-radius: 999px; font-weight: 700; font-size: .85rem; color: var(--ink-soft); transition: background .15s, color .15s; }
.tab.is-active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.content-pane { display: none; flex-direction: column; gap: .6rem; margin-top: .6rem; }
.content-pane.is-active { display: flex; }

.field { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.field input[type="text"], .field select {
  padding: .7rem .85rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--ink); font-weight: 500; font-size: .95rem;
}
.field input:focus-visible, .field select:focus-visible { border-color: var(--accent); }
.field-hint { font-size: .78rem; color: var(--ink-soft); }

.style-grid, .format-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.style-btn, .format-btn {
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  padding: .7rem .5rem; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  font-size: .78rem; font-weight: 700; text-align: center; transition: border-color .15s, background .15s;
}
.style-btn .swatch { width: 34px; height: 34px; }
.style-btn.is-active, .format-btn.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.format-btn { grid-column: span 1; }
.format-grid { grid-template-columns: 1fr; }
.format-btn { flex-direction: row; text-align: left; align-items: center; gap: .7rem; padding: .7rem .8rem; }
.format-btn .ficon { font-size: 1.4rem; }
.format-btn .flabel { display: flex; flex-direction: column; gap: .15rem; }
.format-btn .fdesc { font-weight: 500; color: var(--ink-soft); font-size: .74rem; }

.color-row { display: flex; gap: .8rem; }
.color-field { display: flex; flex-direction: column; gap: .35rem; font-size: .8rem; font-weight: 600; color: var(--ink-soft); flex: 1; }
.color-field input[type="color"] { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; background: var(--bg); }

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: .3rem; max-height: 132px; overflow-y: auto; padding: .4rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.emoji-btn { font-size: 1.15rem; padding: .3rem; border-radius: 8px; transition: background .15s; }
.emoji-btn:hover { background: var(--bg-alt); }
.emoji-btn.is-active { background: var(--accent-soft); outline: 2px solid var(--accent); }
.logo-row { display: flex; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }

.print-warnings { display: flex; flex-direction: column; gap: .5rem; }
.warning { padding: .6rem .8rem; border-radius: var(--radius-sm); font-size: .82rem; font-weight: 600; display: flex; gap: .5rem; align-items: flex-start; }
.warning.ok { background: var(--ok-bg); color: var(--ok); }
.warning.warn { background: var(--warn-bg); color: var(--warn); }
.warning.bad { background: var(--bad-bg); color: var(--bad); }

/* =============================================================
   7. Preview
   ============================================================= */
.preview { display: flex; flex-direction: column; gap: 1.4rem; }
.preview-block { display: flex; flex-direction: column; gap: .7rem; }
.preview-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.preview-head h2 { font-size: 1.05rem; }
.drag-hint { font-size: .78rem; font-weight: 500; color: var(--ink-soft); }

.qr-2d-wrap { display: flex; justify-content: center; padding: 1rem; background: var(--bg-alt); border-radius: var(--radius-sm); min-height: 260px; align-items: center; }
.qr-2d { line-height: 0; }
.qr-2d canvas, .qr-2d img, .qr-2d svg { max-width: 240px; max-height: 240px; width: auto; height: auto; border-radius: 8px; }

.qr-3d-wrap { position: relative; background: var(--bg-alt); border-radius: var(--radius-sm); min-height: 320px; overflow: hidden; }
.qr-3d-wrap canvas { width: 100%; height: 320px; touch-action: none; cursor: grab; }
.qr-3d-wrap:active canvas { cursor: grabbing; }
.viewer3d-status {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); font-size: .9rem; font-weight: 600; text-align: center; padding: 1rem;
  background: var(--bg-alt); pointer-events: none;
}
.qr-3d-wrap[data-state="ready"] .viewer3d-status { display: none; }

.download-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.download-row .btn { flex: 1; min-width: 160px; }

/* =============================================================
   8. Ad slots
   ============================================================= */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(45deg, var(--bg-alt), var(--bg-alt) 10px, var(--line) 10px, var(--line) 20px);
  border: 1px dashed var(--ink-soft);
  border-radius: var(--radius-sm);
  color: var(--ink-soft); font-weight: 800; letter-spacing: .12em; font-size: .8rem;
}
.ad-banner { min-height: 90px; margin-block: 1.6rem; }
.ad-incontent { min-height: 250px; max-width: 728px; margin: 2rem auto; }
.ad-popup { min-height: 200px; margin-block: .8rem; }

.ad-corner {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 400;
  width: 220px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: .6rem;
}
.ad-corner-close { position: absolute; top: .3rem; right: .4rem; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--bg-alt); font-size: .8rem; }
.ad-corner-body {
  margin-top: 1rem; min-height: 90px; display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(45deg, var(--bg-alt), var(--bg-alt) 8px, var(--line) 8px, var(--line) 16px);
  border: 1px dashed var(--ink-soft); border-radius: 8px; font-weight: 800; letter-spacing: .1em; font-size: .72rem; color: var(--ink-soft);
}

.download-dialog {
  border: none; border-radius: var(--radius); padding: 1.4rem; max-width: 380px; width: calc(100% - 2rem);
  box-shadow: 0 20px 60px -20px rgba(0,0,0,.4); color: var(--ink); background: var(--card);
}
.download-dialog::backdrop { background: rgba(10,10,15,.55); }
.dialog-close { position: absolute; top: .8rem; right: .8rem; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--bg-alt); }
.dialog-kicker { font-weight: 700; margin-bottom: .8rem; padding-right: 1.6rem; }
.download-dialog .btn { width: 100%; margin-top: .9rem; }

/* =============================================================
   9. How it works / usos / faq
   ============================================================= */
section > .wrap > h2 { text-align: center; font-size: clamp(1.5rem, 3.4vw, 2.1rem); margin-bottom: 1.6rem; }

.how-it-works, .usos { padding-block: 2.4rem; }
.steps-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .steps-grid { grid-template-columns: repeat(3, 1fr); } }
.steps-grid > div { background: var(--bg-alt); border-radius: var(--radius); padding: 1.3rem; }
.steps-grid h3 { font-size: 1.02rem; margin-bottom: .4rem; }
.steps-grid p { color: var(--ink-soft); font-size: .92rem; }

.seo-copy { padding-block: 1.2rem; }
.seo-copy h2 { font-size: clamp(1.3rem, 2.8vw, 1.7rem); margin-bottom: 1rem; }
.seo-copy p { color: var(--ink-soft); margin-bottom: 1rem; }
.seo-copy strong { color: var(--ink); }

.usos-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .usos-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .usos-grid { grid-template-columns: repeat(3, 1fr); } }
.uso-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; display: flex; gap: .8rem; }
.uso-card .icon { font-size: 1.6rem; }
.uso-card h3 { font-size: .98rem; margin-bottom: .3rem; }
.uso-card p { color: var(--ink-soft); font-size: .86rem; }

.faq { padding-block: 2rem 3rem; }
.faq-item { border-bottom: 1px solid var(--line); padding-block: .9rem; }
.faq-item summary { font-weight: 700; 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-size: 1.3rem; color: var(--accent); flex-shrink: 0; }
.faq-item[open] summary::after { content: "–"; }
.faq-item p { color: var(--ink-soft); margin-top: .6rem; font-size: .92rem; }

/* =============================================================
   10. Responsive fine-tuning
   ============================================================= */
@media (max-width: 539px) {
  .download-row .btn { min-width: 0; flex-basis: 100%; }
  .ad-corner { width: calc(100% - 2rem); right: 1rem; left: 1rem; }
}
