/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f0eee7;
  --ink: #1b1b22;
  --ink-soft: #55555f;
  --line: #e4e1d8;
  --accent: #d9622b;
  --accent-ink: #ffffff;
  --accent-soft: #fdece1;
  --ok: #1c8a5a;
  --warn: #b5750a;
  --danger: #c8422f;

  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --display: "Sora", var(--sans);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 1px 2px rgba(20,18,10,.04), 0 12px 32px -16px rgba(20,18,10,.18);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --surface: #1e1e24;
    --surface-2: #26262e;
    --ink: #f1f0ec;
    --ink-soft: #a8a6b0;
    --line: #34343e;
    --accent-soft: #3a2416;
  }
}

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

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: min(1080px, 100% - 2.5rem); margin-inline: auto; }
.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; }
.field-label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-soft); margin-bottom: .4rem; }

/* =============================================================
   4. Typography
   ============================================================= */
.section-title { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2rem); margin-bottom: 1.5rem; }
.hint-text { font-size: .82rem; color: var(--ink-soft); margin-top: .6rem; }
.block-title { font-size: 1.3rem; margin-bottom: .3rem; }
.block-sub { color: var(--ink-soft); margin-bottom: 1.1rem; font-size: .95rem; }

/* =============================================================
   5. Components
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .8rem 1.4rem; border-radius: 999px; font-weight: 700; font-size: .95rem;
  transition: transform .18s var(--ease-out), background .18s var(--ease-out), box-shadow .18s var(--ease-out);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 20px -8px rgba(217,98,43,.55); }
.btn-primary:hover { box-shadow: 0 10px 26px -8px rgba(217,98,43,.65); }
.btn-secondary { background: var(--surface-2); color: var(--ink); }
.btn-secondary:hover { background: var(--line); }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: .5rem .9rem; font-size: .82rem; }
.btn-lg { padding: 1rem 1.8rem; font-size: 1.02rem; }

/* =============================================================
   6. Header / footer
   ============================================================= */
.site-header { padding: 1.1rem 0; border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; }
.logo { display: flex; align-items: center; gap: .5rem; font-family: var(--display); font-weight: 800; font-size: 1.1rem; color: var(--ink); }
.logo svg { color: var(--accent); }
.header-nav { display: none; gap: 1.6rem; font-weight: 600; font-size: .92rem; color: var(--ink-soft); }
.header-nav a:hover { color: var(--accent); }
@media (min-width: 720px) { .header-nav { display: flex; } }

.site-footer { border-top: 1px solid var(--line); padding: 1.6rem 0; margin-top: 3rem; color: var(--ink-soft); 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(--accent); }

/* =============================================================
   7. Hero + sections
   ============================================================= */
.hero { padding: 2.6rem 0 1.6rem; text-align: center; }
.hero h1 { font-size: clamp(1.8rem, 1.3rem + 2.2vw, 2.7rem); max-width: 24ch; margin-inline: auto; }
.hero-sub { margin-top: .9rem; color: var(--ink-soft); max-width: 52ch; margin-inline: auto; font-size: 1.05rem; }

.section { padding: 3.2rem 0; }
.section-alt { background: var(--surface-2); border-radius: var(--radius-lg); }

/* =============================================================
   8. Tool card
   ============================================================= */
.tool-section { padding-bottom: 1rem; }
.tool-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: clamp(1.1rem, .8rem + 1vw, 1.8rem); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 1.7rem;
}
.tool-block { padding-top: 1.5rem; border-top: 1px solid var(--line); }
.tool-block:first-child { padding-top: 0; border-top: 0; }

.mode-tabs { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.mode-tab {
  padding: .6rem 1.1rem; border-radius: 999px; background: var(--surface-2); font-weight: 700; font-size: .9rem;
  transition: background .15s var(--ease-out), color .15s var(--ease-out);
}
.mode-tab.is-active { background: var(--ink); color: var(--bg); }
.mode-panel { display: none; }
.mode-panel.is-active { display: block; }

.text-input {
  width: 100%; padding: .8rem 1rem; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-size: .98rem;
  transition: border-color .15s var(--ease-out);
}
.text-input:focus { border-color: var(--accent); }
.select-input { appearance: auto; }
.field-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; margin-bottom: 1rem; }
@media (min-width: 540px) { .field-grid { grid-template-columns: 1fr 1fr; } }

.style-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin-bottom: 1.2rem; }
.style-opt {
  display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .8rem .4rem;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); font-size: .78rem; font-weight: 600; color: var(--ink-soft);
  transition: border-color .15s var(--ease-out), background .15s var(--ease-out), color .15s var(--ease-out);
}
.style-opt svg { fill: currentColor; }
.style-opt.is-active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.color-row { display: flex; gap: 1.6rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.color-field { display: flex; flex-direction: column; gap: .4rem; }
.color-field input[type=color] { width: 56px; height: 40px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 3px; background: var(--surface); cursor: pointer; }

.logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.emoji-picker { display: flex; flex-wrap: wrap; gap: .4rem; }
.emoji-opt {
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; font-size: 1.15rem;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color .15s var(--ease-out), background .15s var(--ease-out);
}
.emoji-opt.is-active { border-color: var(--accent); background: var(--accent-soft); }
.logo-upload { display: flex; gap: .5rem; flex-wrap: wrap; }

.preview-block { display: grid; gap: 1.6rem; grid-template-columns: 1fr; align-items: center; }
@media (min-width: 720px) { .preview-block { grid-template-columns: minmax(220px, 300px) 1fr; } }
.qr-preview-wrap { display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.qr-preview {
  width: 100%; max-width: 260px; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden;
  display: flex; align-items: center; justify-content: center; background: var(--surface-2); border: 1px solid var(--line);
}
.qr-preview canvas, .qr-preview img, .qr-preview svg { width: 100%; height: 100%; }
.preview-caption { font-size: .8rem; color: var(--ink-soft); }
.download-col { display: flex; flex-direction: column; gap: .8rem; }
.download-row { display: flex; gap: .7rem; flex-wrap: wrap; }
.privacy-badge { font-size: .82rem; color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); padding: .55rem .8rem; border-radius: var(--radius-sm); }

.format-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin-bottom: 1.2rem; }
.format-opt {
  display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: 1rem .5rem;
  border: 1.5px solid var(--line); border-radius: var(--radius); color: var(--ink-soft);
  transition: border-color .15s var(--ease-out), background .15s var(--ease-out), color .15s var(--ease-out);
}
.format-opt span { font-weight: 700; font-size: .92rem; color: var(--ink); }
.format-opt small { font-size: .74rem; }
.format-opt.is-active { border-color: var(--accent); background: var(--accent-soft); }
.format-opt.is-active span { color: var(--accent); }

.warn-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.2rem; }
.warn-list:empty { display: none; }
.warn-list li { padding: .6rem .9rem; border-radius: var(--radius-sm); font-size: .86rem; font-weight: 600; }
.warn-list li.is-ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.warn-list li.is-warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.warn-list li.is-danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

.viewer3d-wrap { margin-bottom: 1.2rem; }
.viewer3d {
  position: relative; width: 100%; aspect-ratio: 4/3; max-height: 420px; border-radius: var(--radius);
  background: linear-gradient(160deg, var(--surface-2), var(--surface)); border: 1px solid var(--line); overflow: hidden;
  touch-action: none;
}
.viewer3d canvas { width: 100%; height: 100%; cursor: grab; }
.viewer3d canvas:active { cursor: grabbing; }
.viewer3d-hint {
  position: absolute; left: .8rem; bottom: .8rem; font-size: .76rem; font-weight: 600; color: var(--ink-soft);
  background: color-mix(in srgb, var(--surface) 75%, transparent); padding: .3rem .6rem; border-radius: 999px; pointer-events: none;
}
.viewer3d-status {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 1rem;
  font-size: .88rem; color: var(--ink-soft); background: var(--surface-2);
}
.viewer3d-status[hidden] { display: none; }
.download-row-3d { margin-bottom: 0; }

/* =============================================================
   9. Steps / ideas / FAQ
   ============================================================= */
.steps-grid { display: grid; gap: 1.2rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .steps-grid { grid-template-columns: repeat(3, 1fr); } }
.step-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; }
.step-card h3 { font-size: 1.05rem; margin-bottom: .5rem; }
.step-card p { color: var(--ink-soft); font-size: .94rem; }

.seo-copy { max-width: 74ch; display: flex; flex-direction: column; gap: 1rem; color: var(--ink-soft); }
.seo-copy strong { color: var(--ink); }

.ideas-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; padding: 1px 0 2.4rem; }
@media (min-width: 620px) { .ideas-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .ideas-grid { grid-template-columns: repeat(3, 1fr); } }
.idea-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; display: flex; flex-direction: column; gap: .5rem; }
.idea-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.idea-card h3 { font-size: 1rem; }
.idea-card p { color: var(--ink-soft); font-size: .9rem; }
.section-alt .idea-card, .section-alt .ideas-grid { }
.section-alt { padding: 3rem clamp(1rem, 2vw, 2rem); }

.faq-list { display: flex; flex-direction: column; gap: .7rem; max-width: 74ch; }
.faq-item { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.faq-item summary { padding: 1rem 1.2rem; font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.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 { padding: 0 1.2rem 1.1rem; color: var(--ink-soft); font-size: .94rem; }

/* =============================================================
   10. Ad placeholders
   ============================================================= */
.ad-slot {
  display: flex; align-items: center; justify-content: center; min-height: 90px; margin-top: 1.4rem;
  border: 1.5px dashed var(--line); border-radius: var(--radius); color: var(--ink-soft);
  font-size: .8rem; font-weight: 700; letter-spacing: .08em; background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}
.ad-leaderboard { min-height: 90px; }
.ad-incontent { min-height: 250px; max-width: 336px; margin-inline: auto; }

.ad-corner {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 60; width: 220px; min-height: 90px;
  background: var(--surface); border: 1.5px dashed var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: .9rem 1rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem;
}
.ad-corner-close { position: absolute; top: .3rem; right: .5rem; font-size: .9rem; color: var(--ink-soft); width: 24px; height: 24px; }
.ad-corner-label { font-size: .75rem; font-weight: 700; color: var(--ink-soft); letter-spacing: .08em; }

.ad-dialog { border: 0; border-radius: var(--radius-lg); padding: 1.6rem; width: min(420px, 92vw); box-shadow: var(--shadow); background: var(--surface); color: var(--ink); }
.ad-dialog::backdrop { background: rgba(10,10,12,.55); }
.ad-dialog-close { position: absolute; top: .8rem; right: .9rem; font-size: 1rem; color: var(--ink-soft); width: 30px; height: 30px; border-radius: 50%; }
.ad-dialog-close:hover { background: var(--surface-2); }
.ad-dialog-label { font-size: .74rem; font-weight: 700; color: var(--ink-soft); letter-spacing: .1em; margin-bottom: .6rem; }
.ad-dialog-slot { min-height: 200px; display: flex; align-items: center; justify-content: center; border: 1.5px dashed var(--line); border-radius: var(--radius); color: var(--ink-soft); font-weight: 700; font-size: .85rem; margin-bottom: 1.1rem; }

/* =============================================================
   11. Responsive tweaks
   ============================================================= */
@media (max-width: 539px) {
  .style-grid { grid-template-columns: repeat(2, 1fr); }
  .format-grid { grid-template-columns: 1fr; }
  .download-row { flex-direction: column; }
  .download-row .btn { width: 100%; }
}

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