/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --ink: #16161d;
  --ink-2: #3b3b46;
  --muted: #6b6b78;
  --line: #e4e2dc;
  --bg: #faf9f6;
  --card: #ffffff;
  --alt: #f2f0ea;
  --accent: #ff6a13;
  --accent-ink: #c94a00;
  --ok: #1f8a4c;
  --warn: #b26a00;
  --bad: #c62828;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(22,22,29,.04), 0 8px 28px rgba(22,22,29,.07);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --display: "Bricolage Grotesque", "Inter", 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, 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 { font-family: var(--display); line-height: 1.08; letter-spacing: -0.02em; text-wrap: balance; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: 1180px; margin-inline: auto; padding-inline: 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: 400; }
.center { text-align: center; }
.noscript { padding: 1rem; background: #fff3e0; border-radius: var(--radius-sm); margin-bottom: 1rem; }

/* =============================================================
   4. Header / hero
   ============================================================= */
.site-header { border-bottom: 1px solid var(--line); background: rgba(250,249,246,.92); position: sticky; top: 0; z-index: 50; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.logo { display: flex; align-items: center; gap: .55rem; text-decoration: none; font-family: var(--display); font-weight: 800; font-size: 1.3rem; letter-spacing: -.02em; }
.logo b { color: var(--accent); }
.header-nav { display: none; gap: 1.6rem; font-size: .93rem; color: var(--ink-2); }
.header-nav a { text-decoration: none; }
.header-nav a:hover { color: var(--accent-ink); }

.hero { padding-top: 22px; padding-bottom: 14px; }
.hero h1 { font-size: clamp(1.7rem, 5.2vw, 3rem); font-weight: 800; }
.hero-sub { margin-top: .5rem; color: var(--ink-2); max-width: 760px; font-size: clamp(.95rem, 2.2vw, 1.08rem); }

/* =============================================================
   5. Tool card
   ============================================================= */
.tool { display: grid; gap: 18px; }
.tool-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; scroll-margin-top: 70px; }
.tool-grid { display: grid; gap: 18px; }
.panel { min-width: 0; }
.step-title { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.05rem; margin: 4px 0 12px; }
.panel > .step-title:not(:first-child) { margin-top: 22px; }
.step-n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; font-size: .85rem; flex: none; }
.field-label { display: block; font-size: .86rem; font-weight: 600; color: var(--ink-2); margin: 12px 0 6px; }
.hint { font-size: .82rem; color: var(--muted); margin-top: 6px; }
.input { width: 100%; border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: .62rem .8rem; background: #fff; transition: border-color .2s; min-width: 0; }
.input:focus { outline: none; border-color: var(--ink); }
.input-big { font-size: 1.05rem; padding: .8rem .95rem; }
.row-2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; align-items: end; }
.check { display: flex; gap: .5rem; align-items: center; font-size: .9rem; padding: .7rem 0; }

.seg { display: inline-flex; background: var(--alt); border-radius: 999px; padding: 4px; gap: 2px; }
.seg-btn { padding: .42rem 1rem; border-radius: 999px; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.seg-btn.is-on { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.mode-pane { margin-top: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: .8rem; padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; }
.chip:hover, .chip.is-on { border-color: var(--ink); }

.styles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.style-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: .55rem .2rem; border: 1.5px solid var(--line); border-radius: var(--radius-sm); font-size: .76rem; font-weight: 600; background: #fff; }
.style-btn svg { width: 30px; height: 30px; fill: var(--ink); }
.style-btn.is-on { border-color: var(--ink); background: var(--alt); }

.colors-2d { margin-top: 10px; grid-template-columns: 1fr 1fr; }
.color-field { display: flex; align-items: center; gap: .55rem; font-size: .86rem; font-weight: 600; color: var(--ink-2); padding: .4rem 0; cursor: pointer; }
input[type="color"] { -webkit-appearance: none; appearance: none; width: 38px; height: 38px; border: 1.5px solid var(--line); border-radius: 10px; padding: 2px; background: #fff; cursor: pointer; flex: none; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 7px; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 7px; }

.emojis { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; }
.emoji-btn { font-size: 1.35rem; line-height: 1; aspect-ratio: 1; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: #fff; display: grid; place-items: center; font-family: "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif; }
.emoji-btn.is-on { border-color: var(--ink); background: var(--alt); }
.emojis-sm { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; margin-top: 8px; }
.emojis-sm .emoji-btn { font-size: 1.05rem; border-radius: 8px; }
.logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }

.warn { font-size: .84rem; color: var(--warn); background: #fff6e8; border-radius: 8px; padding: .45rem .7rem; margin-top: 6px; }

/* preview */
.panel-preview { display: flex; flex-direction: column; gap: 12px; }
.qr-frame { position: relative; background: var(--alt); border-radius: var(--radius); padding: 18px; display: grid; place-items: center; }
.qr-preview { width: min(100%, 220px); aspect-ratio: 1; }
#card-qr .panel-preview { order: 2; }
#card-qr .panel-design { order: 3; }
.panel-design > .step-title:first-child { margin-top: 4px; }
.qr-preview canvas, .qr-preview svg { width: 100% !important; height: 100% !important; border-radius: 6px; box-shadow: 0 4px 18px rgba(0,0,0,.08); }
.sample-badge { position: absolute; top: 10px; left: 10px; font-size: .74rem; font-weight: 600; background: var(--ink); color: #fff; border-radius: 999px; padding: .2rem .6rem; }
.dl-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.privacy { font-size: .8rem; color: var(--muted); text-align: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .72rem 1.1rem; border-radius: 12px; font-weight: 700; font-size: .95rem; text-decoration: none; transition: transform .15s var(--ease-out), background .2s, box-shadow .2s; cursor: pointer; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:not([disabled]):hover { background: #2b2b36; }
.btn-ghost { background: #fff; border: 1.5px solid var(--line); }
.btn-ghost:not([disabled]):hover { border-color: var(--ink); }
.btn-accent { background: var(--accent); color: #fff; box-shadow: 0 6px 18px rgba(255,106,19,.28); }
.btn-accent:not([disabled]):hover { background: #ff7a2b; }
.btn-block { width: 100%; }
.btn-big { padding: 1rem 1.2rem; font-size: 1.05rem; }
.btn-sm { padding: .45rem .8rem; font-size: .84rem; border-radius: 10px; }
.btn-link { font-size: .86rem; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; padding: .2rem; align-self: center; }
.btn-link[disabled] { opacity: .45; cursor: not-allowed; }

/* 3D card */
.formats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.fmt-btn { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: .7rem .3rem; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: #fff; color: var(--ink-2); }
.fmt-btn svg { width: 46px; height: 38px; margin-bottom: 4px; }
.fmt-btn b { font-size: .84rem; color: var(--ink); line-height: 1.2; }
.fmt-btn small { font-size: .7rem; color: var(--muted); line-height: 1.25; }
.fmt-btn.is-on { border-color: var(--accent); background: #fff4ec; color: var(--accent-ink); }

.filaments { display: grid; grid-template-columns: 1fr; gap: 10px; }
.filament { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; }
.filament-head { display: flex; align-items: center; justify-content: space-between; font-size: .86rem; font-weight: 600; margin-bottom: 6px; }
.filament-head input[type="color"] { width: 32px; height: 32px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.swatch.is-on { box-shadow: 0 0 0 2px var(--ink); }

input[type="range"] { width: 100%; accent-color: var(--accent); }

.checks { list-style: none; padding: 0; margin-top: 14px; display: grid; gap: 6px; }
.checks li { font-size: .84rem; border-radius: 8px; padding: .45rem .7rem; display: flex; gap: .5rem; align-items: flex-start; }
.checks li::before { flex: none; font-weight: 700; }
.checks .ok { background: #ecf7f0; color: #17643a; }
.checks .ok::before { content: "✓"; }
.checks .warning { background: #fff6e8; color: #8a5200; }
.checks .warning::before { content: "!"; }
.checks .bad { background: #fdecec; color: #a11d1d; }
.checks .bad::before { content: "✕"; }
.checks .info { background: var(--alt); color: var(--ink-2); }
.checks .info::before { content: "i"; font-style: italic; font-family: Georgia, serif; }

.viewer { position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: 460px; border-radius: var(--radius); background: radial-gradient(120% 90% at 50% 20%, #ffffff 0%, #ebe8e1 100%); overflow: hidden; 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: 1.5rem; color: var(--muted); font-size: .92rem; }
.viewer-tip { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); font-size: .72rem; color: var(--muted); background: rgba(255,255,255,.85); padding: .15rem .6rem; border-radius: 999px; white-space: nowrap; pointer-events: none; }
.dims { font-size: .84rem; color: var(--ink-2); text-align: center; font-variant-numeric: tabular-nums; }

/* =============================================================
   6. Sections
   ============================================================= */
.section { padding-block: 48px; }
.section h2 { font-size: clamp(1.45rem, 3.6vw, 2.15rem); font-weight: 800; margin-bottom: 22px; }
.section-alt { background: var(--alt); }

.steps { list-style: none; padding: 0; display: grid; gap: 14px; }
.steps li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.step-ico { width: 44px; height: 44px; border-radius: 12px; background: #fff4ec; display: grid; place-items: center; margin-bottom: 12px; }
.step-ico svg { width: 24px; height: 24px; fill: none; stroke: var(--accent-ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.steps h3 { font-size: 1.15rem; margin-bottom: 6px; }
.steps p { color: var(--ink-2); font-size: .95rem; }

.ideas { display: grid; gap: 14px; }
.idea { background: var(--card); border-radius: var(--radius); padding: 20px; border: 1px solid var(--line); }
.idea-emoji { font-size: 1.8rem; display: block; margin-bottom: 8px; }
.idea h3 { font-size: 1.1rem; margin-bottom: 6px; }
.idea p { color: var(--ink-2); font-size: .94rem; }

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

.faq { display: grid; gap: 10px; max-width: 860px; }
.faq details { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 18px; }
.faq summary { cursor: pointer; font-weight: 600; padding: 15px 0; 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; line-height: 1; color: var(--accent-ink); transition: transform .2s var(--ease-out); }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { padding-bottom: 16px; color: var(--ink-2); }

.site-footer { border-top: 1px solid var(--line); padding: 28px 0 90px; font-size: .88rem; color: var(--ink-2); }
.footer-inner { display: grid; gap: 12px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 1.2rem; }

/* =============================================================
   7. Ad placeholders
   ============================================================= */
.ad-slot { display: grid; place-items: center; border: 2px dashed #cfccc3; border-radius: var(--radius-sm); background: repeating-linear-gradient(45deg, #f7f6f2, #f7f6f2 10px, #f1efe9 10px, #f1efe9 20px); color: #9a978d; font-weight: 800; letter-spacing: .2em; font-size: .85rem; }
.ad-leaderboard { min-height: 100px; margin-top: 28px; }
.ad-incontent { min-height: 250px; margin-block: 8px 8px; max-width: 820px; }
.ad-popup { min-height: 250px; width: 100%; margin: 14px 0; }
.ad-corner { min-height: 90px; width: 100%; }

.ad-dialog { border: 0; border-radius: var(--radius); padding: 22px; width: min(92vw, 380px); box-shadow: 0 24px 60px rgba(0,0,0,.25); position: fixed; inset: 0; margin: auto; height: fit-content; max-height: 90vh; overflow: auto; }
.ad-dialog::backdrop { background: rgba(22,22,29,.55); }
.ad-dialog-title { font-weight: 700; padding-right: 28px; }
.ad-close { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%; background: var(--alt); font-size: 1.35rem; line-height: 1; display: grid; place-items: center; }
.ad-close:hover { background: var(--line); }
.ad-close-sm { width: 26px; height: 26px; font-size: 1.05rem; top: 6px; right: 6px; z-index: 1; }

.ad-toast { position: fixed; right: 12px; bottom: 12px; width: min(300px, calc(100vw - 24px)); background: #fff; border-radius: 14px; padding: 10px; box-shadow: 0 12px 34px rgba(0,0,0,.18); z-index: 80; animation: toastIn .45s var(--ease-out); }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px); } }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .row-2 { grid-template-columns: 1fr 1fr; }
  .filaments { grid-template-columns: 1fr 1fr; }
  .tool-card { padding: 22px; }
}
@media (min-width: 720px) {
  .header-nav { display: flex; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .ideas { grid-template-columns: repeat(2, 1fr); }
  .footer-inner { grid-template-columns: 1fr auto; align-items: center; }
}
@media (min-width: 960px) {
  .hero { padding-top: 34px; padding-bottom: 20px; }
  .tool-card { padding: 26px; }
  .tool-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 0 32px; align-items: start; }
  .panel-preview { position: sticky; top: 76px; }
  #card-qr .panel-content { grid-column: 1; grid-row: 1; }
  #card-qr .panel-design { grid-column: 1; grid-row: 2; margin-top: 22px; }
  #card-qr .panel-preview { grid-column: 2; grid-row: 1 / span 2; }
  .qr-preview { width: min(100%, 300px); }
  .ideas { grid-template-columns: repeat(3, 1fr); }
  .section { padding-block: 64px; }
}
