/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #FAF8F4;
  --surface: #FFFFFF;
  --surface-2: #F1EEE7;
  --text: #1B1B22;
  --text-muted: #5B5A63;
  --border: #E4E0D7;
  --accent: #1B4F72;
  --accent-2: #F2C14E;
  --danger: #B3261E;
  --danger-bg: #FBEAEA;
  --ok: #1E7A46;
  --ok-bg: #EAF6EE;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20,18,10,.04), 0 8px 24px rgba(20,18,10,.06);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --display: "Manrope", var(--sans);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}
[data-theme="dark"] {
  --bg: #14131A;
  --surface: #1C1B24;
  --surface-2: #24232E;
  --text: #F2EFE8;
  --text-muted: #A6A3AF;
  --border: #34333F;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14131A;
    --surface: #1C1B24;
    --surface-2: #24232E;
    --text: #F2EFE8;
    --text-muted: #A6A3AF;
    --border: #34333F;
  }
}

/* =============================================================
   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;
  -moz-osx-font-smoothing: grayscale;
  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 { font-family: var(--display); text-wrap: balance; line-height: 1.08; letter-spacing: -0.01em; font-weight: 800; }
::selection { background: var(--accent-2); color: #1B1B22; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.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. Utilities
   ============================================================= */
.container { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: 1.25rem; }
.container-prose { max-width: 760px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.is-hidden { display: none !important; }

/* =============================================================
   4. Typography
   ============================================================= */
h1 { font-size: clamp(1.9rem, 4.6vw, 3.1rem); max-width: 20ch; margin-inline: auto; text-align: center; }
h2 { font-size: clamp(1.4rem, 2.6vw, 2rem); margin-bottom: 1.2rem; }
.subtitle {
  text-align: center; max-width: 56ch; margin: .9rem auto 1.8rem;
  color: var(--text-muted); font-size: 1.05rem;
}
.section-kicker { font-size: 1.1rem; margin-bottom: 1rem; }

/* =============================================================
   5. Components
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .8rem 1.4rem; border-radius: 999px; font-weight: 600; font-size: .95rem;
  transition: transform .18s var(--ease-out), background .18s var(--ease-out), box-shadow .18s var(--ease-out);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: #163f5c; }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-ghost { background: transparent; color: var(--text-muted); text-decoration: underline; }
.btn-large { padding: 1rem 1.8rem; font-size: 1.05rem; width: 100%; }
.btn-small { padding: .5rem .9rem; font-size: .85rem; }

.field-label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-muted); margin-bottom: .45rem; }
.text-input, .select-input {
  width: 100%; padding: .75rem .9rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit;
  transition: border-color .18s var(--ease-out);
}
.text-input:focus, .select-input:focus { border-color: var(--accent); }
.field-grid { display: grid; gap: .8rem; grid-template-columns: 1fr 1fr; }
.field-grid > label:has(input[type="checkbox"]) { grid-column: 1 / -1; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--text-muted); }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: .25rem; gap: .25rem; }
.segmented-btn { padding: .5rem 1.1rem; border-radius: 999px; font-weight: 600; font-size: .88rem; color: var(--text-muted); }
.segmented-btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.pill-group { display: flex; flex-wrap: wrap; gap: .5rem; }
.pill {
  display: flex; align-items: center; gap: .4rem; padding: .55rem .9rem; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface); font-size: .85rem; font-weight: 600;
  transition: border-color .18s var(--ease-out), background .18s var(--ease-out);
}
.pill:hover { border-color: var(--accent); }
.pill.is-active { border-color: var(--accent); background: var(--accent); color: #fff; }
.pill-format { flex-direction: column; align-items: flex-start; text-align: left; padding: .8rem 1rem; gap: .15rem; min-width: 150px; }
.pill-format .pill-icon { font-size: 1.3rem; }
.pill-format .pill-hint { font-weight: 400; font-size: .76rem; opacity: .8; }

.color-controls { display: flex; gap: 1rem; align-items: center; }
.color-field { display: flex; flex-direction: column; gap: .3rem; font-size: .78rem; color: var(--text-muted); font-weight: 600; }
.color-field input[type="color"] { width: 44px; height: 34px; border: 1.5px solid var(--border); border-radius: 8px; padding: 2px; background: var(--surface); }
.color-presets { display: flex; gap: .4rem; margin-top: .6rem; flex-wrap: wrap; }
.color-preset-btn {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border);
  background: linear-gradient(135deg, var(--pb) 50%, var(--pc) 50%);
}
.color-preset-btn:hover { border-color: var(--accent); }

.emoji-grid { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .6rem; }
.emoji-btn {
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface);
}
.emoji-btn.is-active { border-color: var(--accent); background: var(--surface-2); }
.logo-upload-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

/* =============================================================
   6. Sections / tool card
   ============================================================= */
.site-header { padding-block: 1rem; border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: .5rem; font-family: var(--display); font-weight: 800; font-size: 1.15rem; }
.header-tagline { color: var(--text-muted); font-size: .85rem; margin-left: auto; }
@media (max-width: 539px) { .header-tagline { display: none; } }

.hero-tool { padding-block: 2.4rem 1.5rem; }

.tool-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.25rem;
  display: flex; flex-direction: column; gap: 1.4rem;
}
.tool-card-3d { gap: 1.1rem; }
.tool-row { display: flex; flex-direction: column; gap: 1rem; }
.design-row, .format-row { flex-direction: row; flex-wrap: wrap; gap: 1.5rem; }
.design-col { flex: 1 1 220px; min-width: 200px; }
.result-row { flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 1.5rem; }
.qr-preview-wrap { flex: 0 0 auto; }
.qr-preview {
  width: 220px; height: 220px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.qr-preview canvas, .qr-preview img { width: 100%; height: 100%; object-fit: contain; }
.result-actions { flex: 1 1 220px; display: flex; flex-direction: column; gap: .6rem; align-items: flex-start; }
.tool-error {
  color: var(--danger); background: var(--danger-bg); padding: .5rem .8rem; border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 600;
}
.privacy-badge { font-size: .85rem; color: var(--ok); background: var(--ok-bg); padding: .55rem .9rem; border-radius: var(--radius-sm); width: fit-content; }
.tool-limits { font-size: .8rem; color: var(--text-muted); }

.preview3d-row { flex-direction: row; flex-wrap: wrap; gap: 1.5rem; align-items: stretch; }
.preview3d-wrap {
  position: relative; flex: 1 1 320px; min-height: 300px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.preview3d-wrap canvas { width: 100% !important; height: 100% !important; }
.preview3d-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 1rem; color: var(--text-muted); font-size: .9rem; }
.preview3d-hint { position: absolute; bottom: .6rem; left: 50%; transform: translateX(-50%); font-size: .75rem; color: var(--text-muted); background: var(--surface); padding: .25rem .6rem; border-radius: 999px; }
.warnings-col { flex: 1 1 240px; display: flex; flex-direction: column; gap: .5rem; }
.warning-item { padding: .6rem .8rem; border-radius: var(--radius-sm); font-size: .83rem; font-weight: 600; display: flex; gap: .5rem; }
.warning-item.ok { background: var(--ok-bg); color: var(--ok); }
.warning-item.bad { background: var(--danger-bg); color: var(--danger); }
.download3d-row { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .8rem; }
.download3d-row .btn-large { flex: 1 1 260px; }

/* Ad slots — placeholders only */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: .78rem; letter-spacing: .08em; font-weight: 700;
  background: var(--surface-2);
}
.ad-leaderboard { min-height: 90px; margin: 1.5rem auto; max-width: 1120px; margin-inline: auto; }
.ad-incontent { min-height: 250px; max-width: 700px; margin: 2rem auto; }
.ad-popup { min-height: 200px; width: 300px; margin-bottom: .8rem; }
.ad-corner { min-height: 90px; width: 260px; }
.ad-label { opacity: .7; }

.section { padding-block: 2.6rem; }
.how-it-works { background: var(--surface-2); }
.steps-grid { display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.step-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem; }
.step-card h3 { font-family: var(--display); font-size: 1.05rem; margin-bottom: .5rem; }
.step-card p { color: var(--text-muted); font-size: .92rem; }

.seo-text p { margin-bottom: 1.1rem; color: var(--text-muted); }
.seo-text p:last-child { margin-bottom: 0; }

.ideas-grid { display: grid; gap: 1.2rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.idea-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; }
.idea-card h3 { font-size: 1rem; margin-bottom: .4rem; }
.idea-card p { color: var(--text-muted); font-size: .9rem; }

.faq details { border-bottom: 1px solid var(--border); padding-block: .9rem; }
.faq summary { font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.3rem; color: var(--text-muted); flex-shrink: 0; }
.faq details[open] summary::after { content: "−"; }
.faq p { margin-top: .7rem; color: var(--text-muted); font-size: .93rem; }

.site-footer { border-top: 1px solid var(--border); padding-block: 1.6rem; margin-top: 1rem; }
.footer-inner { display: flex; flex-direction: column; gap: .6rem; font-size: .85rem; color: var(--text-muted); }
.footer-nav { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.footer-nav a { text-decoration: underline; }
.footer-cookies-note { font-size: .78rem; opacity: .8; }

/* Download interstitial dialog */
.download-dialog {
  border: none; border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow);
  background: var(--surface); color: var(--text); max-width: 340px;
}
.download-dialog::backdrop { background: rgba(20,18,10,.45); }
.dialog-close {
  position: absolute; top: .6rem; right: .6rem; width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-2); font-size: 1.1rem; line-height: 1;
}
.dialog-continue { display: block; margin-inline: auto; }

/* Corner toast */
.corner-toast { position: fixed; bottom: 1rem; right: 1rem; z-index: 40; }
.corner-toast-close {
  position: absolute; top: -.6rem; right: -.6rem; width: 26px; height: 26px; border-radius: 50%;
  background: var(--text); color: var(--bg); font-size: 1rem;
}

/* =============================================================
   7. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .tool-card { padding: 2rem; }
}
@media (min-width: 720px) {
  .container { padding-inline: 2rem; }
}
@media (max-width: 719px) {
  .design-row, .format-row, .preview3d-row, .result-row { flex-direction: column; }
  .qr-preview { width: 100%; max-width: 260px; margin-inline: auto; }
}
@media (max-width: 539px) {
  .corner-toast { left: 1rem; right: 1rem; }
  .ad-corner { width: 100%; }
}

/* =============================================================
   8. Reduced motion — only intrusive effects
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .preview3d-wrap[data-spin="auto"] { animation: none; }
}

/* Works-without-JS fallback message (paired with <noscript> in the HTML) */
.no-js-note { padding: 1rem; background: var(--danger-bg); color: var(--danger); border-radius: var(--radius-sm); text-align: center; margin-bottom: 1.25rem; }
