/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #F6F5F1;
  --surface: #FFFFFF;
  --surface-2: #F1F0EB;
  --ink: #15171E;
  --ink-2: #2A2D37;
  --muted: #5E6370;
  --line: #E3E1DA;
  --accent: #F25C05;
  --accent-ink: #FFFFFF;
  --ok: #17804F;
  --warn: #9A6200;
  --err: #C0262D;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(21,23,30,.05), 0 12px 40px -12px rgba(21,23,30,.14);
  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; 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;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}
img, svg, video, canvas { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select { font: inherit; color: inherit; }
a { color: inherit; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.1; letter-spacing: -0.02em; }
fieldset { border: 0; padding: 0; min-width: 0; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.skip-link { position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem; background: var(--ink); color: #fff; z-index: 9999; border-radius: 8px; }
.skip-link:focus { top: 1rem; }
.muted { color: var(--muted); font-weight: 500; }
.opt { color: var(--muted); font-weight: 500; }

/* =============================================================
   4. Header / hero
   ============================================================= */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 1.2rem; letter-spacing: -0.02em; }
.brand b { color: var(--accent); font-weight: 800; }
.brand-mark { width: 32px; height: 32px; }
.header-nav { display: none; gap: 24px; font-weight: 600; font-size: .95rem; }
.header-nav a { text-decoration: none; color: var(--muted); }
.header-nav a:hover { color: var(--ink); }

.hero { padding-top: 22px; padding-bottom: 14px; }
.hero h1 { font-size: clamp(1.7rem, 4.6vw, 2.8rem); font-weight: 800; }
.hero-sub { margin-top: 8px; color: var(--muted); font-size: clamp(.98rem, 1.6vw, 1.12rem); max-width: 760px; }
.hero-sub strong { color: var(--ink-2); }

/* =============================================================
   5. Tool card
   ============================================================= */
.tool-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.noscript { padding: 14px; background: #FFF4E5; border-radius: var(--radius-sm); margin-bottom: 12px; }

.tool-grid { display: flex; flex-direction: column; gap: 18px; }
.controls-col, .preview-col { display: contents; }
#step-content { order: 1; }
#preview-2d   { order: 2; }
#step-design  { order: 3; }
#step-3d      { order: 4; }
#preview-3d   { order: 5; }

.step { display: flex; flex-direction: column; gap: 10px; }
.step + .step { }
.step legend { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.08rem; margin-bottom: 10px; padding: 0; }
.step-n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; font-size: .85rem; }

.field-label { display: block; font-weight: 700; font-size: .88rem; color: var(--ink-2); margin-bottom: 6px; }
.field-label output { color: var(--accent); }
.hint { font-size: .84rem; color: var(--muted); line-height: 1.45; }

.input {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 1rem;
  transition: border-color .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(21,23,30,.08); }
.input-lg { padding: 14px 14px; font-size: 1.05rem; font-weight: 600; }
.input.is-shake { animation: shake .4s; border-color: var(--accent); }
select.input { appearance: auto; }

.row-2 { display: grid; grid-template-columns: 1fr; gap: 12px; align-items: end; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .92rem; padding: 10px 0; }

.seg { display: inline-flex; background: var(--surface-2); padding: 4px; border-radius: 999px; align-self: flex-start; }
.seg-btn { padding: 7px 18px; border-radius: 999px; font-weight: 700; font-size: .92rem; color: var(--muted); }
.seg-btn.is-on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.mode-panel { display: flex; flex-direction: column; gap: 10px; }
.mode-panel[hidden], [hidden] { display: none !important; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .85rem; font-weight: 600; transition: background .2s, border-color .2s; }
.chip:hover { border-color: var(--ink); }
.chip.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }

.styles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.style-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); font-size: .8rem; font-weight: 700; background: var(--surface); transition: border-color .2s; }
.style-opt svg { width: 30px; height: 30px; fill: var(--ink); }
.style-opt:hover { border-color: #b9b6ad; }
.style-opt.is-on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

.colors { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px rgba(0,0,0,.18); position: relative; transition: transform .15s var(--ease-out); }
.sw:hover { transform: scale(1.1); }
.sw.is-on { box-shadow: 0 0 0 2px var(--ink); }
.sw-custom { width: 30px; height: 30px; border-radius: 50%; overflow: hidden; position: relative; box-shadow: 0 0 0 1px rgba(0,0,0,.18); background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.sw-custom input { position: absolute; inset: -6px; width: 44px; height: 44px; opacity: 0; cursor: pointer; }
.sw-custom.is-on { box-shadow: 0 0 0 2px var(--ink); }
.link-btn { align-self: flex-start; font-weight: 700; font-size: .86rem; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; padding: 2px 0; }
.link-btn:hover { color: var(--accent); }
.link-btn.center { align-self: center; }

.center-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.emo-btn { width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); font-size: 1.3rem; line-height: 1; display: grid; place-items: center; color: var(--muted); transition: border-color .2s; }
.center-pick.small .emo-btn { width: 36px; height: 36px; font-size: 1.15rem; }
.emo-btn:hover { border-color: #b9b6ad; }
.emo-btn.is-on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.logo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.formats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.format-opt { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 3px; padding: 12px 6px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); transition: border-color .2s; }
.format-opt svg { width: 46px; height: 38px; color: var(--ink); margin-bottom: 4px; }
.format-opt b { font-size: .86rem; line-height: 1.2; }
.format-opt small { font-size: .74rem; color: var(--muted); line-height: 1.25; }
.format-opt:hover { border-color: #b9b6ad; }
.format-opt.is-on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #FFF7F2; }
.format-opt.is-on svg { color: var(--accent); }

.range { width: 100%; accent-color: var(--accent); height: 28px; }
.adv { border-top: 1px dashed var(--line); padding-top: 10px; }
.adv summary { cursor: pointer; font-weight: 700; font-size: .9rem; color: var(--ink-2); margin-bottom: 8px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 18px; border-radius: 12px; font-weight: 800; font-size: .95rem; text-decoration: none; cursor: pointer; transition: transform .15s var(--ease-out), background .2s, box-shadow .2s; }
.btn:active { transform: translateY(1px); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #2C303C; }
.btn-ghost { background: var(--surface); border: 1.5px solid var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-sm { padding: 8px 14px; font-size: .88rem; }
.btn-accent { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 24px -8px rgba(242,92,5,.6); }
.btn-accent:hover { background: #DB5204; }
.btn-xl { width: 100%; padding: 16px 20px; font-size: 1.08rem; }
.btn-xl small { font-weight: 600; opacity: .9; }
.btn[aria-busy="true"] { opacity: .7; pointer-events: none; }

/* Previews */
.preview { background: var(--surface-2); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 800; font-size: .92rem; }
.badge { font-size: .74rem; font-weight: 700; background: #FFE9DB; color: #A33D00; padding: 3px 9px; border-radius: 999px; }
.badge[hidden] { display: none; }
.dims { font-size: .78rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.qr-frame { background: var(--surface); border-radius: 14px; padding: 14px; display: grid; place-items: center; }
.qr2d { width: 100%; max-width: 260px; aspect-ratio: 1; }
.qr2d svg, .qr2d canvas { width: 100% !important; height: auto !important; display: block; }
.dl-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.viewer { position: relative; width: 100%; aspect-ratio: 4 / 3; min-height: 240px; border-radius: 14px; overflow: hidden; background: radial-gradient(120% 90% at 50% 20%, #FFFFFF 0%, #E6E5E0 100%); touch-action: none; cursor: grab; }
.viewer:active { cursor: grabbing; }
.viewer canvas { width: 100% !important; height: 100% !important; }
.viewer-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; font-weight: 600; font-size: .9rem; color: var(--muted); }
.viewer-msg[hidden] { display: none; }

.warnings { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: .84rem; line-height: 1.4; }
.warnings li { padding: 8px 10px; border-radius: 10px; background: var(--surface); border-left: 3px solid var(--line); }
.warnings li.ok { border-left-color: var(--ok); }
.warnings li.warn { border-left-color: #E0A100; }
.warnings li.err { border-left-color: var(--err); background: #FFF1F1; }
.warnings li b { font-weight: 800; }
.status { min-height: 1.2em; font-size: .84rem; font-weight: 600; color: var(--muted); text-align: center; }
.status.err { color: var(--err); }

.privacy { margin: 14px 4px 0; font-size: .9rem; color: var(--muted); }
.privacy strong { color: var(--ink-2); }

/* =============================================================
   6. Ads (placeholders)
   ============================================================= */
.ad-slot {
  display: grid; place-items: center;
  border: 1.5px dashed #C9C6BD; border-radius: 12px;
  background: repeating-linear-gradient(135deg, #FBFAF7 0 12px, #F3F2EE 12px 24px);
  color: #8D8A82; font-weight: 800; font-size: .8rem; letter-spacing: .22em;
}
.ad-leaderboard { min-height: 100px; margin: 26px auto 0; max-width: 970px; }
.ad-incontent { min-height: 280px; margin: 8px auto; max-width: 728px; }
.ad-box { width: 300px; max-width: 100%; height: 250px; margin: 0 auto; }
.ad-mini { width: 100%; height: 100px; }

.ad-modal { border: 0; border-radius: var(--radius); padding: 22px 20px 20px; width: min(360px, calc(100vw - 32px)); box-shadow: 0 30px 80px -20px rgba(0,0,0,.45); text-align: center; color: var(--ink); }
.ad-modal::backdrop { background: rgba(15,17,22,.55); }
.ad-modal[open] { display: flex; flex-direction: column; gap: 14px; animation: pop .3s var(--ease-out); }
.modal-title { font-weight: 800; color: var(--ok); }
.modal-x, .toast-x { position: absolute; top: 6px; right: 8px; width: 32px; height: 32px; border-radius: 50%; font-size: 1.4rem; line-height: 1; color: var(--muted); display: grid; place-items: center; }
.modal-x:hover, .toast-x:hover { background: var(--surface-2); color: var(--ink); }
.ad-modal .btn { width: 100%; }

.ad-toast { position: fixed; right: 16px; bottom: 16px; z-index: 50; width: min(300px, calc(100vw - 32px)); background: var(--surface); border-radius: 14px; padding: 30px 10px 10px; box-shadow: 0 16px 50px -12px rgba(0,0,0,.35); border: 1px solid var(--line); animation: slideup .4s var(--ease-out); }
.ad-toast[hidden] { display: none; }
@media (max-width: 539px) {
  .ad-toast { right: 10px; bottom: 10px; width: 250px; padding: 26px 8px 8px; }
  .ad-mini { height: 56px; }
}

/* =============================================================
   7. Content sections
   ============================================================= */
.section { padding-top: 56px; }
.section h2 { font-size: clamp(1.45rem, 3vw, 2rem); font-weight: 800; margin-bottom: 22px; }

.steps3 { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr; gap: 14px; }
.steps3 li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.steps3 svg { width: 40px; height: 40px; color: var(--accent); margin-bottom: 12px; }
.steps3 h3 { font-size: 1.1rem; margin-bottom: 6px; }
.steps3 p { color: var(--muted); font-size: .95rem; }

.ideas { display: grid; grid-template-columns: 1fr; gap: 14px; }
.idea { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.idea-ico { display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: var(--surface-2); font-size: 1.5rem; margin-bottom: 10px; }
.idea h3 { font-size: 1.05rem; margin-bottom: 6px; }
.idea p { color: var(--muted); font-size: .94rem; }

.prose { max-width: 800px; }
.prose h3 { font-size: 1.15rem; margin: 24px 0 8px; }
.prose p { color: var(--ink-2); margin-bottom: 10px; }

.faq { display: flex; flex-direction: column; gap: 10px; max-width: 860px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0 18px; }
.faq summary { cursor: pointer; padding: 16px 0; font-weight: 700; list-style: none; position: relative; padding-right: 28px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 0; top: 50%; transform: translateY(-50%); font-size: 1.4rem; font-weight: 500; color: var(--accent); }
.faq details[open] summary::after { content: "–"; }
.faq details p { padding-bottom: 16px; color: var(--muted); }

.site-footer { margin-top: 70px; border-top: 1px solid var(--line); background: var(--surface); padding: 26px 0 90px; font-size: .9rem; color: var(--muted); }
.footer-inner { display: flex; flex-direction: column; gap: 10px; }
.site-footer a { color: var(--ink-2); }

/* Legal pages */
.legal { max-width: 800px; padding-top: 30px; }
.legal h1 { font-size: 2rem; margin-bottom: 16px; }
.legal h2 { font-size: 1.2rem; margin: 22px 0 8px; }
.legal p, .legal li { color: var(--ink-2); margin-bottom: 8px; }
.todo { background: #FFF4D6; padding: 0 4px; border-radius: 4px; }

/* =============================================================
   8. Effects
   ============================================================= */
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes slideup { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

/* =============================================================
   9. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .row-2 { grid-template-columns: 1fr 1fr; }
  .steps3 { grid-template-columns: repeat(3, 1fr); }
  .ideas { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 720px) {
  .header-nav { display: flex; }
  .tool-card { padding: 22px; }
}
@media (min-width: 960px) {
  .tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 28px; align-items: start; }
  .controls-col { display: flex; flex-direction: column; gap: 26px; }
  .preview-col { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 16px; }
  .preview-2d { display: grid; grid-template-columns: 150px 1fr; grid-template-areas: "head head" "qr dl"; align-items: center; column-gap: 14px; }
  .preview-2d .preview-head { grid-area: head; }
  .preview-2d .qr-frame { grid-area: qr; padding: 8px; }
  .preview-2d .dl-row { grid-area: dl; grid-template-columns: 1fr; }
  .ideas { grid-template-columns: repeat(3, 1fr); }
  .hero { padding-top: 34px; padding-bottom: 20px; }
}
@media (min-width: 1280px) {
  .tool-grid { grid-template-columns: minmax(0, 1fr) 460px; }
  .preview-2d { grid-template-columns: 170px 1fr; }
}

/* =============================================================
   10. Reduced motion (only intrusive effects)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .ad-toast { animation: none; }
}
