/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --border: #e4e1d8;
  --text: #1c1b18;
  --text-dim: #5c584f;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: #e2eafc;
  --accent2: #c2410c;
  --accent2-ink: #ffffff;
  --accent2-soft: #fce8dc;
  --warn: #b45309;
  --warn-soft: #fdf1e0;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --cream: #f2f1ec;

  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --shadow-sm: 0 1px 2px rgba(20, 20, 15, 0.06), 0 1px 1px rgba(20,20,15,.04);
  --shadow-md: 0 10px 30px -12px rgba(20, 20, 15, 0.18);

  --gutter: 1.25rem;
  --container-w: 1180px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --ease-soft: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14130f;
    --surface: #1b1a15;
    --surface-2: #211f19;
    --border: #34322a;
    --text: #f2efe6;
    --text-dim: #b6b2a5;
    --accent: #5b8def;
    --accent-ink: #0b1220;
    --accent-soft: #16233d;
    --accent2: #fb923c;
    --accent2-ink: #2a1405;
    --accent2-soft: #3a2313;
    --warn: #f2b866;
    --warn-soft: #2c2113;
    --danger: #ef7b72;
    --danger-soft: #2c1614;
    --cream: #26241d;
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; overflow-x: clip; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
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.08; letter-spacing: -0.015em; font-weight: 800; }
::selection { background: var(--accent); color: var(--accent-ink); }
input, select, textarea { font: inherit; color: inherit; }

: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: var(--container-w); margin-inline: auto; padding-inline: var(--gutter); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

/* =============================================================
   4. Typography
   ============================================================= */
.section-title { font-size: clamp(1.5rem, 3.2vw, 2.1rem); margin-bottom: .5rem; }
.section-sub { color: var(--text-dim); max-width: 62ch; margin-bottom: 1.75rem; }

/* =============================================================
   5. Components
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .8rem 1.3rem; border-radius: var(--radius-sm);
  font-weight: 700; font-size: .95rem;
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), background .18s var(--ease-out);
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--cream); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }
.btn-small { padding: .5rem .9rem; font-size: .85rem; }
.btn-3d { width: 100%; }
.file-btn { position: relative; }

.field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.field > span, .field legend { font-size: .82rem; font-weight: 700; color: var(--text-dim); padding: 0; }
.field input[type="text"], .field select {
  padding: .75rem .9rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: .98rem;
  transition: border-color .15s var(--ease-out);
}
.field input[type="text"]:focus, .field select:focus { border-color: var(--accent); }
.field fieldset { border: 0; padding: 0; margin-bottom: 1rem; }
.field-row { display: grid; gap: .75rem; grid-template-columns: 1fr; }
.field-inline { max-width: 260px; }

/* =============================================================
   6. Sections — header
   ============================================================= */
.site-header { padding-block: 1rem; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 40; }
.header-inner { display: flex; align-items: center; justify-content: space-between; }
.logo { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.15rem; color: var(--text); }
.logo svg { color: var(--accent); }
.header-nav { display: none; gap: 1.5rem; font-weight: 600; font-size: .92rem; color: var(--text-dim); }
.header-nav a:hover { color: var(--accent); }
@media (min-width: 720px) { .header-nav { display: flex; } }

/* hero */
.hero { padding-block: 2.25rem 1.5rem; text-align: center; }
.hero h1 { font-size: clamp(1.9rem, 4.6vw, 3rem); max-width: 20ch; margin-inline: auto; }
.hero-sub { margin: 1rem auto 0; max-width: 56ch; color: var(--text-dim); font-size: 1.05rem; }

/* tool section */
.tool-section { padding-block: .5rem 2rem; }
.tool-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.25rem; box-shadow: var(--shadow-md);
}
@media (min-width: 720px) { .tool-card { padding: 2rem; } }

.tool-block { padding-block: 1.1rem; border-bottom: 1px dashed var(--border); }
.tool-block:first-of-type { padding-top: 0; }
.tool-block:last-of-type { border-bottom: 0; }
.tool-block-head { display: flex; align-items: center; gap: .65rem; margin-bottom: 1rem; }
.tool-block-head h2 { font-size: 1.1rem; }
.step-badge {
  width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--accent2); color: var(--accent2-ink);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .85rem; flex: none;
}

.mode-tabs { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.mode-tab {
  padding: .55rem 1rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  font-weight: 700; font-size: .88rem; color: var(--text-dim); transition: all .15s var(--ease-out);
}
.mode-tab.is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.design-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .design-grid { grid-template-columns: 1.1fr 1fr; align-items: start; } }
.preview-col { position: sticky; top: 5.5rem; }
@media (max-width: 719px) { .preview-col { position: static; } }

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

.color-row { display: flex; gap: 1rem; margin-bottom: .7rem; }
.color-field { display: flex; flex-direction: column; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 700; color: var(--text-dim); }
.color-field input[type="color"] {
  width: 3rem; height: 3rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 2px; background: var(--surface); cursor: pointer;
}
.palette-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.palette-swatch {
  width: 2rem; height: 2rem; border-radius: 50%; border: 2px solid var(--border); cursor: pointer;
  transition: transform .15s var(--ease-out);
  background: conic-gradient(var(--sw-base) 0 50%, var(--sw-code) 50% 100%);
}
.palette-swatch:hover { transform: scale(1.1); }
.contrast-note { font-size: .8rem; color: var(--text-dim); }
.contrast-note.is-warn { color: var(--warn); font-weight: 700; }
.contrast-note.is-bad { color: var(--danger); font-weight: 700; }

.emoji-row { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .6rem; }
.emoji-opt {
  width: 2.3rem; height: 2.3rem; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--surface-2); font-size: 1.15rem; display: flex; align-items: center; justify-content: center;
  transition: all .15s var(--ease-out);
}
.emoji-opt.is-active { border-color: var(--accent); background: var(--accent-soft); }
.center-actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

.qr-preview-wrap { display: flex; justify-content: center; padding: 1rem; background: var(--surface-2); border-radius: var(--radius-md); border: 1px solid var(--border); }
.qr-preview { width: 100%; max-width: 280px; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.qr-preview canvas, .qr-preview svg, .qr-preview img { width: 100%; height: 100%; border-radius: 6px; }
.hint-text { font-size: .8rem; color: var(--text-dim); margin-block: .6rem; }
.hint-text code { font-family: var(--mono); background: var(--surface-2); padding: .1rem .4rem; border-radius: 4px; }
.download-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }
.download-row .btn { flex: 1 1 auto; }

.format-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.format-opt {
  display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: .8rem .4rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
  font-weight: 700; font-size: .78rem; text-align: center; transition: all .15s var(--ease-out);
}
.format-opt.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.format-icon { font-size: 1.4rem; }

.warnings-panel { display: flex; flex-direction: column; gap: .5rem; margin-top: .5rem; }
.warning-item {
  padding: .6rem .8rem; border-radius: var(--radius-sm); font-size: .82rem; font-weight: 600;
  display: flex; gap: .5rem; align-items: flex-start; line-height: 1.4;
}
.warning-item.is-ok { background: var(--accent-soft); color: var(--accent); }
.warning-item.is-warn { background: var(--warn-soft); color: var(--warn); }
.warning-item.is-bad { background: var(--danger-soft); color: var(--danger); }

.viewer3d-wrap {
  position: relative; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  aspect-ratio: 1; overflow: hidden;
}
.viewer3d-canvas { width: 100%; height: 100%; touch-action: none; }
.viewer3d-canvas canvas { width: 100% !important; height: 100% !important; display: block; }
.viewer3d-hint {
  position: absolute; bottom: .6rem; left: 50%; transform: translateX(-50%);
  font-size: .72rem; color: var(--text-dim); background: color-mix(in srgb, var(--surface) 85%, transparent);
  padding: .25rem .6rem; border-radius: 999px; pointer-events: none;
}

.privacy-badge { margin-top: 1.25rem; font-size: .85rem; color: var(--text-dim); text-align: center; }
.limits-note { margin-top: .35rem; font-size: .78rem; color: var(--text-dim); text-align: center; opacity: .8; }

/* ad slots */
.ad-slot {
  display: flex; align-items: center; justify-content: center; min-height: 90px;
  border: 1px dashed var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
  margin-block: 1.75rem; position: relative;
}
.ad-label { font-size: .75rem; font-weight: 800; letter-spacing: .12em; color: var(--text-dim); text-transform: uppercase; }
.ad-slot--leaderboard { min-height: 90px; }
.ad-slot--incontent { min-height: 250px; max-width: 336px; margin-inline: auto; }
.ad-slot--popup { min-height: 250px; width: 300px; max-width: 100%; margin-inline: auto; }

/* steps */
.steps-grid { display: grid; gap: 1.25rem; grid-template-columns: 1fr; counter-reset: step; }
@media (min-width: 720px) { .steps-grid { grid-template-columns: repeat(3, 1fr); } }
.step-card { padding: 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.step-card .step-num { display: inline-flex; align-items: center; justify-content: center; width: 2.1rem; height: 2.1rem; border-radius: 50%; background: var(--accent2-soft); color: var(--accent2); font-weight: 800; margin-bottom: .75rem; }
.step-card h3 { font-size: 1.05rem; margin-bottom: .4rem; }
.step-card p { color: var(--text-dim); font-size: .92rem; }

/* SEO copy */
.seo-copy p { margin-bottom: 1rem; max-width: 74ch; color: var(--text-dim); }
.seo-copy p:last-child { margin-bottom: 0; }

/* ideas */
.ideas-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 540px) { .ideas-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .ideas-grid { grid-template-columns: repeat(4, 1fr); } }
.idea-card { padding: 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out); }
.idea-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.idea-icon { font-size: 1.5rem; margin-bottom: .5rem; display: block; }
.idea-card h3 { font-size: .98rem; margin-bottom: .35rem; }
.idea-card p { font-size: .85rem; color: var(--text-dim); }

/* faq */
.faq-list { display: flex; flex-direction: column; gap: .6rem; max-width: 74ch; }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.faq-item summary {
  padding: .95rem 1.1rem; font-weight: 700; cursor: pointer; list-style: none;
  display: flex; align-items: center; 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(--text-dim); transition: transform .2s var(--ease-out); flex: none; }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { padding: 0 1.1rem 1rem; color: var(--text-dim); font-size: .92rem; }

/* footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; background: var(--surface-2); }
.footer-inner { display: flex; flex-direction: column; gap: 1.5rem; padding-block: 2rem 1rem; }
@media (min-width: 720px) { .footer-inner { flex-direction: row; justify-content: space-between; align-items: flex-start; } }
.footer-brand p { color: var(--text-dim); font-size: .85rem; max-width: 40ch; margin-top: .5rem; }
.logo-mini { font-weight: 800; font-size: 1.05rem; }
.footer-links { display: flex; gap: 1.25rem; font-size: .85rem; font-weight: 600; color: var(--text-dim); flex-wrap: wrap; }
.footer-links a:hover { color: var(--accent); }
.footer-bottom { padding-block: 1rem 1.5rem; font-size: .76rem; color: var(--text-dim); }

/* corner toast */
.corner-toast {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 60;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: .8rem 2.2rem .8rem 1rem; box-shadow: var(--shadow-md);
  min-width: 160px; min-height: 60px; display: flex; align-items: center; justify-content: center;
}
.corner-toast-close {
  position: absolute; top: .3rem; right: .3rem; width: 1.4rem; height: 1.4rem;
  border-radius: 50%; background: var(--surface-2); font-size: .75rem; display: flex; align-items: center; justify-content: center;
}

/* download dialog */
.download-dialog {
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.25rem;
  box-shadow: var(--shadow-md); max-width: 340px; width: 90vw; background: var(--surface); color: var(--text);
  position: relative;
}
.download-dialog::backdrop { background: rgba(10, 10, 8, .55); }
.dialog-close { position: absolute; top: .7rem; right: .7rem; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--surface-2); }
.dialog-caption { text-align: center; margin-block: .9rem .7rem; font-size: .9rem; color: var(--text-dim); }
.download-dialog .btn { width: 100%; }

/* =============================================================
   8. Responsive helpers already inlined above (mobile-first)
   ============================================================= */
@media (min-width: 1280px) {
  .hero { padding-block: 3rem 2rem; }
}

/* =============================================================
   9. Reduced-motion — only intrusive effects
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .skip-link { transition: none; }
}
