/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #1b1b22;
  --ink-soft: #55555f;
  --border: #e4e1d8;
  --accent: #d3542a;
  --accent-ink: #ffffff;
  --accent-soft: #fbe6dc;
  --good: #1f8a52;
  --bad: #c23b3b;
  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --display: "Sora", var(--sans);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 32px -18px rgba(27,27,34,.28);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --surface: #1f1f26;
    --ink: #f2f1ec;
    --ink-soft: #b7b6c0;
    --border: #33333c;
    --accent: #ef6b3e;
    --accent-soft: #3a271f;
  }
}

/* =============================================================
   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;
  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%; }
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 { font-family: var(--display); text-wrap: balance; line-height: 1.1; letter-spacing: -0.01em; }
::selection { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* =============================================================
   3. Utilities
   ============================================================= */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.is-hidden { display: none !important; }
.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;
  transition: top .2s var(--ease-out);
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   4. Header / footer
   ============================================================= */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.header-inner { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px 20px; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 800; font-size: 1.25rem; }
.brand-mark { color: var(--accent); font-size: 1.4rem; }
.header-tag { color: var(--ink-soft); font-size: .85rem; display: none; }
@media (min-width: 540px) { .header-tag { display: block; } }

.site-footer { border-top: 1px solid var(--border); margin-top: 64px; padding: 28px 0 40px; color: var(--ink-soft); font-size: .9rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; }
.footer-nav { display: flex; gap: 18px; }
.footer-nav a:hover { color: var(--accent); }

/* =============================================================
   5. Hero
   ============================================================= */
.hero { padding: 44px 20px 24px; text-align: center; }
.hero h1 { font-size: clamp(1.7rem, 4.2vw, 2.6rem); max-width: 18ch; margin: 0 auto; }
.hero-sub { color: var(--ink-soft); max-width: 56ch; margin: 14px auto 0; font-size: 1.05rem; }

/* =============================================================
   6. Tool card
   ============================================================= */
.tool-section { padding: 8px 20px 32px; }
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
@media (min-width: 720px) { .tool-card { padding: 28px; } }

.tool-grid { display: grid; gap: 28px; }
@media (min-width: 960px) { .tool-grid { grid-template-columns: 1fr 1fr; gap: 36px; } }

.field-group { margin-bottom: 22px; }
.field-group:last-child { margin-bottom: 0; }
.field-label { display: block; font-weight: 700; font-size: .85rem; margin-bottom: 8px; }
.field-input {
  width: 100%; padding: .7rem .85rem; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg); color: var(--ink);
  transition: border-color .15s var(--ease-out);
}
.field-input:focus { border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 10px; }
.field-hint { font-size: .82rem; color: var(--ink-soft); margin-top: 6px; }
.field-hint[data-bad] { color: var(--bad); font-weight: 600; }
.field-hint[data-good] { color: var(--good); }

.field-color {
  width: 100%; height: 44px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px; background: var(--bg); cursor: pointer;
}

.mode-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.mode-tab {
  padding: .5rem 1rem; border-radius: 999px; border: 1.5px solid var(--border);
  font-weight: 600; font-size: .88rem; color: var(--ink-soft);
}
.mode-tab.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.style-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.style-opt {
  padding: .6rem .7rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-weight: 600; font-size: .85rem; text-align: center; transition: border-color .15s var(--ease-out), background .15s var(--ease-out);
}
.style-opt.is-active { border-color: var(--accent); background: var(--accent-soft); }

.center-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.emoji-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-opt {
  width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  font-size: 1.15rem; display: flex; align-items: center; justify-content: center;
}
.emoji-opt.is-active { border-color: var(--accent); background: var(--accent-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: .75rem 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-primary { background: var(--accent); color: var(--accent-ink); width: 100%; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px -10px rgba(211,84,42,.55); }
.btn-secondary { background: var(--ink); color: var(--bg); }
.btn-secondary:hover { transform: translateY(-1px); }
.btn-ghost { background: transparent; border: 1.5px solid var(--border); }
.btn-sm { padding: .55rem 1rem; font-size: .85rem; }
.btn-link { display: block; text-align: center; margin-top: 10px; font-size: .85rem; font-weight: 600; color: var(--ink-soft); text-decoration: underline; }
.btn-link:hover { color: var(--accent); }
.btn[disabled] { opacity: .55; pointer-events: none; }

.print-warnings { display: flex; flex-direction: column; gap: 8px; }
.warning-item {
  font-size: .82rem; padding: .55rem .75rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); display: flex; gap: 8px; align-items: flex-start;
}
.warning-item.is-bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.warning-item.is-ok { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, transparent); }

.tool-previews { display: flex; flex-direction: column; gap: 20px; }
.preview-box {
  border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.preview-label { font-size: .82rem; font-weight: 700; color: var(--ink-soft); align-self: flex-start; }
.qr-canvas-wrap { display: flex; align-items: center; justify-content: center; min-height: 220px; width: 100%; }
.qr-canvas-wrap canvas, .qr-canvas-wrap img { max-width: 240px; width: 100%; height: auto; border-radius: 8px; }
.download-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; width: 100%; }

.viewer-3d {
  width: 100%; aspect-ratio: 4/3; border-radius: var(--radius-sm); overflow: hidden;
  background: linear-gradient(160deg, #e9e7de, #f7f6f1); position: relative; touch-action: none;
}
@media (prefers-color-scheme: dark) { .viewer-3d { background: linear-gradient(160deg, #23232b, #17171b); } }
.viewer-3d canvas { width: 100% !important; height: 100% !important; display: block; }
.viewer-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); font-size: .85rem; text-align: center; padding: 12px;
}

.privacy-badge { margin-top: 22px; font-size: .88rem; color: var(--ink-soft); text-align: center; }
.limits-note { margin-top: 6px; font-size: .8rem; color: var(--ink-soft); text-align: center; opacity: .8; }

/* =============================================================
   7. Ad slots
   ============================================================= */
.ad-slot {
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); font-weight: 700; letter-spacing: .08em; font-size: .8rem;
  background: color-mix(in srgb, var(--ink) 3%, transparent);
  margin: 28px 0;
}
.ad-slot--banner { min-height: 90px; }
.ad-slot--incontent { min-height: 250px; max-width: 728px; margin-inline: auto; }
.ad-slot--popup { min-height: 200px; width: 100%; margin: 16px 0; }
.ad-slot--corner { min-height: 100px; width: 260px; margin: 0; }

/* =============================================================
   8. Sections
   ============================================================= */
section.wrap { padding: 40px 20px; }
section h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); margin-bottom: 22px; text-align: center; }

.steps-grid { list-style: none; display: grid; gap: 18px; }
@media (min-width: 720px) { .steps-grid { grid-template-columns: repeat(3, 1fr); } }
.steps-grid li {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; position: relative;
}
.step-num {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; margin-bottom: 12px;
}
.steps-grid h3 { font-size: 1.05rem; margin-bottom: 6px; }
.steps-grid p { color: var(--ink-soft); font-size: .92rem; }

.usos-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .usos-grid { grid-template-columns: repeat(3, 1fr); } }
.uso-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; text-align: center;
}
.uso-emoji { font-size: 1.7rem; display: block; margin-bottom: 8px; }
.uso-card h3 { font-size: .95rem; margin-bottom: 4px; }
.uso-card p { font-size: .82rem; color: var(--ink-soft); }

.seo-copy { max-width: 780px; }
.seo-copy h2 { text-align: left; }
.seo-copy p { color: var(--ink-soft); margin-bottom: 14px; }
.seo-copy p:last-child { margin-bottom: 0; }
.seo-copy strong { color: var(--ink); }

.faq-list { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 18px; background: var(--surface); }
.faq-item summary { padding: 14px 0; font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--accent); font-size: 1.3rem; line-height: 1; flex-shrink: 0; }
.faq-item[open] summary::after { content: "–"; }
.faq-item p { padding-bottom: 16px; color: var(--ink-soft); }

/* =============================================================
   9. Download popup + corner toast
   ============================================================= */
.download-dialog { border: 0; border-radius: var(--radius); padding: 0; max-width: 380px; width: calc(100% - 40px); box-shadow: var(--shadow); }
.download-dialog::backdrop { background: rgba(20,20,24,.55); }
.download-dialog-inner { padding: 22px; position: relative; text-align: center; }
.dialog-eyebrow { font-weight: 700; margin-bottom: 12px; }
.dialog-close {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 8%, transparent); font-size: 1.1rem;
}

.corner-toast {
  position: fixed; bottom: 16px; right: 16px; z-index: 500;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 10px; max-width: 280px;
}
.corner-toast-close {
  position: absolute; top: -10px; right: -10px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); color: var(--bg); font-size: 1rem;
}

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

/* =============================================================
   11. Responsive fine-tuning
   ============================================================= */
@media (max-width: 539px) {
  .field-row { grid-template-columns: 1fr; }
  .style-grid { grid-template-columns: repeat(2, 1fr); }
}
