/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #ffffff;
  --surface: #f7f7f8;
  --border: #e6e6e9;
  --text: #16171a;
  --text-muted: #62636b;
  --accent: #1a56ff;
  --accent-contrast: #ffffff;
  --ok: #157f3c;
  --ok-bg: #e9f8ee;
  --warn: #9a5b00;
  --warn-bg: #fff4e0;
  --error: #b3261e;
  --error-bg: #fdecea;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow: 0 1px 2px rgba(20,20,30,.04), 0 8px 24px -12px rgba(20,20,30,.12);
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe 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%; tab-size: 2; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  font-family: var(--sans);
  font-size: 16px; line-height: 1.55; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.01em; }
input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem;
  background: var(--text); color: #fff; z-index: 9999; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

.container { max-width: 1180px; margin-inline: auto; padding-inline: 1.25rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

/* =============================================================
   3. Header / footer
   ============================================================= */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.05rem; }
.brand svg { width: 26px; height: 26px; }
.header-nav { display: flex; gap: 1.25rem; font-size: .92rem; font-weight: 600; }
.header-nav a { text-decoration: none; opacity: .8; }
.header-nav a:hover { opacity: 1; }

.site-footer { border-top: 1px solid var(--border); padding: 2.5rem 0 3rem; margin-top: 3rem; background: var(--surface); }
.footer-grid { display: flex; flex-wrap: wrap; gap: 2rem; justify-content: space-between; }
.footer-links { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; font-size: .9rem; }
.footer-links a { text-decoration: none; color: var(--text-muted); }
.footer-links a:hover { color: var(--text); }
.footer-note { font-size: .82rem; color: var(--text-muted); max-width: 60ch; margin-top: 1rem; }

/* =============================================================
   4. Hero
   ============================================================= */
.hero { padding: 2.2rem 0 1rem; text-align: center; }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); max-width: 24ch; margin-inline: auto; }
.hero p { color: var(--text-muted); max-width: 56ch; margin: .75rem auto 0; font-size: 1.05rem; }

/* =============================================================
   5. Tool layout
   ============================================================= */
.tool-section { padding-bottom: 2rem; }
.tool-layout { display: grid; grid-template-columns: 1fr; gap: 1.5rem; align-items: start; }
@media (min-width: 960px) {
  .tool-layout { grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 2rem; }
  .preview-col { position: sticky; top: 1.25rem; }
}

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.field-group { margin-bottom: 1.25rem; }
.field-group:last-child { margin-bottom: 0; }
.field-label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: .4rem; }
.field-hint { font-size: .8rem; color: var(--text-muted); margin-top: .35rem; }
.text-input, .select-input, textarea.text-input {
  width: 100%; padding: .7rem .85rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; font-size: .95rem;
}
textarea.text-input { resize: vertical; min-height: 3.2rem; }
.input-row { display: flex; gap: .6rem; flex-wrap: wrap; }

.help-toggle { background: none; border: none; padding: 0; font-size: .82rem; font-weight: 600; color: var(--accent); text-decoration: underline; margin-top: .4rem; }
.help-box { margin-top: .6rem; padding: .8rem .9rem; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .86rem; color: var(--text-muted); }
.help-box ol { padding-left: 1.1rem; margin-top: .3rem; }

.swatch-grid, .chip-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.swatch {
  padding: .5rem .9rem; border-radius: 999px; border: 2px solid var(--border); font-size: .82rem; font-weight: 700;
  transition: transform .15s var(--ease-out), box-shadow .15s var(--ease-out);
}
.swatch:hover { transform: translateY(-1px); }
.swatch.is-active { box-shadow: 0 0 0 2px var(--text) inset; }
.chip {
  padding: .5rem .85rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: #fff;
  font-size: .82rem; font-weight: 600; color: var(--text-muted);
}
.chip.is-active { background: var(--text); color: #fff; border-color: var(--text); }

.color-row { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.color-field { display: flex; align-items: center; gap: .5rem; font-size: .85rem; font-weight: 600; }
.color-field input[type=color] { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--border); padding: 2px; background: #fff; }

.radio-row { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .88rem; }
.radio-row label { display: flex; align-items: center; gap: .4rem; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; }
.switch { position: relative; width: 42px; height: 24px; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background .15s; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: transform .15s var(--ease-out); box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track + .thumb { transform: translateX(18px); }

.slider-row { display: flex; align-items: center; gap: .8rem; }
input[type=range] { flex: 1; }

.logo-upload-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.logo-preview { width: 48px; height: 48px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 4px; }
.btn-file { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .9rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: #fff; font-weight: 600; font-size: .85rem; }
.btn-file input { display: none; }
.link-btn { background: none; border: none; color: var(--error); font-weight: 600; font-size: .82rem; text-decoration: underline; padding: 0; }

fieldset { border: none; padding: 0; }
legend { padding: 0; }

.section-title { font-weight: 800; font-size: 1rem; margin-bottom: .9rem; padding-top: .5rem; border-top: 1px solid var(--border); }
.panel > .section-title:first-child { border-top: none; padding-top: 0; }

.top-actions { display: flex; justify-content: flex-end; gap: 1rem; margin-bottom: .75rem; font-size: .82rem; }
.top-actions button { background: none; border: none; color: var(--text-muted); text-decoration: underline; font-weight: 600; padding: 0; }

/* =============================================================
   6. Preview
   ============================================================= */
.preview-shell {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.5rem; display: flex; flex-direction: column; align-items: center; gap: 1rem;
}
.canvas-wrap { display: flex; justify-content: center; width: 100%; }
.canvas-wrap canvas { max-width: 100%; height: auto; border-radius: 6px; box-shadow: var(--shadow); background: #fff; }
.empty-state { text-align: center; color: var(--text-muted); padding: 3rem 1rem; font-size: .95rem; }
.empty-state svg { width: 42px; height: 42px; margin: 0 auto .75rem; opacity: .5; }

.qr-status { font-size: .85rem; font-weight: 600; padding: .6rem .85rem; border-radius: var(--radius-sm); width: 100%; text-align: center; }
.qr-status--ok { background: var(--ok-bg); color: var(--ok); }
.qr-status--warning { background: var(--warn-bg); color: var(--warn); }
.qr-status--error { background: var(--error-bg); color: var(--error); }

.download-row { display: flex; flex-wrap: wrap; gap: .6rem; width: 100%; }
.download-notice {
  width: 100%; font-size: .85rem; font-weight: 600; text-align: center;
  padding: .6rem .85rem; border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .8rem 1.1rem; border-radius: var(--radius-sm); font-weight: 700; font-size: .92rem;
  border: 1px solid transparent; transition: transform .12s var(--ease-out), opacity .12s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--text); color: #fff; flex: 1 1 auto; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); flex: 1 1 auto; }
.btn-block { width: 100%; }
.test-qr-btn { background: #fff; border: 1px solid var(--border); color: var(--text); font-weight: 700; padding: .7rem 1rem; border-radius: var(--radius-sm); width: 100%; }

.printsheet-section { margin-top: .5rem; padding-top: 1rem; border-top: 1px dashed var(--border); width: 100%; }

/* =============================================================
   7. Ad placeholders
   ============================================================= */
.ad-slot {
  border: 1px dashed #c7c9d1; border-radius: var(--radius-sm); background: #fbfbfc;
  color: #9799a6; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  display: flex; align-items: center; justify-content: center; text-align: center;
}
.ad-slot--banner { min-height: 90px; margin: 1.5rem auto; max-width: 728px; width: 100%; }
.ad-slot--incontent { min-height: 250px; max-width: 336px; width: 100%; margin: 2rem auto; }
.ad-slot--sidebar { min-height: 600px; }
.sidebar-ad-col { display: none; }
@media (min-width: 1280px) {
  .sidebar-ad-col { display: block; width: 300px; flex-shrink: 0; }
  .layout-with-sidebar { display: flex; gap: 2rem; align-items: flex-start; justify-content: center; }
}

dialog[data-download-ad] { border: none; border-radius: var(--radius-lg); padding: 0; max-width: 420px; width: calc(100% - 2rem); }
dialog[data-download-ad]::backdrop { background: rgba(15,16,20,.5); }
.ad-modal-inner { padding: 1.5rem; text-align: center; }
.ad-modal-inner .ad-slot { min-height: 220px; margin-bottom: 1rem; }
.corner-notice {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 500; width: 260px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow); padding: .9rem;
}
.corner-notice button.close-x { position: absolute; top: .4rem; right: .5rem; background: none; border: none; font-size: 1rem; color: var(--text-muted); }

/* =============================================================
   8. SEO content sections
   ============================================================= */
.content-section { padding: 3rem 0; }
.content-section h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin-bottom: 1rem; }
.content-section > .container > p.lead { color: var(--text-muted); max-width: 68ch; margin-bottom: 1.5rem; }

.steps-grid { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .steps-grid { grid-template-columns: repeat(3, 1fr); } }
.step-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.4rem; }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--text); color: #fff; font-weight: 800; font-size: .9rem; margin-bottom: .8rem; }
.step-card h3 { font-size: 1.05rem; margin-bottom: .4rem; }
.step-card p { color: var(--text-muted); font-size: .92rem; }

.usecase-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .usecase-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .usecase-grid { grid-template-columns: repeat(5, 1fr); } }
.usecase-card { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1rem; background: #fff; }
.usecase-card h3 { font-size: .95rem; margin-bottom: .35rem; }
.usecase-card p { font-size: .82rem; color: var(--text-muted); }

.why-grid { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .why-grid { grid-template-columns: repeat(2, 1fr); } }
.why-card h3 { font-size: 1rem; margin-bottom: .35rem; }
.why-card p { color: var(--text-muted); font-size: .92rem; }

.faq-list { max-width: 78ch; }
.faq-item { border-bottom: 1px solid var(--border); padding: 1rem 0; }
.faq-item summary { cursor: pointer; font-weight: 700; font-size: 1rem; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; font-weight: 400; font-size: 1.3rem; color: var(--text-muted); }
.faq-item[open] summary::after { content: '\2212'; }
.faq-item p { margin-top: .6rem; color: var(--text-muted); font-size: .93rem; }

.related-links { display: flex; flex-wrap: wrap; gap: .6rem; }
.related-links a { padding: .5rem .9rem; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; font-size: .85rem; font-weight: 600; color: var(--text-muted); }

.legal-content { max-width: 72ch; margin: 2.5rem auto; padding-inline: 1.25rem; }
.legal-content h1 { margin-bottom: 1rem; }
.legal-content h2 { margin-top: 1.75rem; margin-bottom: .6rem; font-size: 1.15rem; }
.legal-content p, .legal-content li { color: var(--text-muted); font-size: .95rem; margin-bottom: .8rem; }
.legal-content ul { padding-left: 1.2rem; }
