:root {
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-grad: linear-gradient(135deg, #6366f1, #8b5cf6);
  --bg: #f8fafc;
  --card: #ffffff;
  --card-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #94a3b8;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

[data-theme='dark'] {
  --bg: #0b1120;
  --card: #111827;
  --card-2: #0f172a;
  --border: #1f2937;
  --text: #e2e8f0;
  --text-2: #94a3b8;
  --muted: #64748b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
}

/* No-JS fallback: honor the OS theme until the app sets data-theme explicitly. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0b1120;
    --card: #111827;
    --card-2: #0f172a;
    --border: #1f2937;
    --text: #e2e8f0;
    --text-2: #94a3b8;
    --muted: #64748b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.mono { font-family: var(--mono); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.8rem; }

.icon { display: inline-flex; width: 1.05em; height: 1.05em; flex: none; }
.icon svg { width: 100%; height: 100%; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: var(--accent-grad);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}
.glyph { width: 24px; height: 24px; fill: #fff; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; }
.brand-name .mono { color: var(--accent); font-weight: 600; font-size: 0.95em; }
.brand-tagline { font-size: 0.78rem; color: var(--text-2); }
@media (max-width: 560px) { .brand-tagline { display: none; } }

/* ---------- Layout ---------- */
.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 4vw, 2.5rem);
}
@media (min-width: 1024px) {
  .workspace { grid-template-columns: 1.4fr 1fr; align-items: start; }
}

.controls { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.form-card { padding: 1.1rem; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.3rem;
  scrollbar-width: thin;
}
.tab {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-2);
  border-radius: 999px;
  font: inherit; font-size: 0.85rem; font-weight: 500;
  white-space: nowrap; cursor: pointer;
  transition: all 0.15s;
}
.tab:hover { border-color: var(--accent); color: var(--text); }
.tab.active {
  background: var(--accent-grad);
  border-color: transparent; color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.tab .icon { width: 1rem; height: 1rem; }

/* ---------- Fields ---------- */
.field { margin-bottom: 0.8rem; }
.field:last-child { margin-bottom: 0; }
.field label, .color-input label, .slider-row label, .row-label {
  display: block;
  font-size: 0.8rem; font-weight: 600;
  color: var(--text-2);
  margin-bottom: 0.35rem;
}
.row-label { margin-top: 0.6rem; }
input[type='text'], input[type='tel'], input[type='datetime-local'], textarea, select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-2);
  color: var(--text);
  font: inherit; font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
textarea { resize: vertical; }
.checkbox-row {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.85rem; color: var(--text); cursor: pointer;
  margin: 0.5rem 0;
}
.checkbox-row input { width: auto; accent-color: var(--accent); }
.privacy-hint {
  display: flex; align-items: center; gap: 0.4rem;
  margin: 0.9rem 0 0; padding-top: 0.8rem;
  border-top: 1px dashed var(--border);
  font-size: 0.75rem; color: var(--muted);
}
.privacy-hint .icon { color: var(--accent); }

/* ---------- Accordion ---------- */
.accordion summary {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.9rem 1.1rem;
  font-weight: 600; cursor: pointer;
  list-style: none;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary .icon { color: var(--accent); }
.accordion summary span:nth-child(2) { flex: 1; }
.chev { transition: transform 0.2s; color: var(--muted); }
.accordion[open] .chev { transform: rotate(180deg); }
.accordion-body { padding: 0 1.1rem 1.1rem; }
hr { border: none; border-top: 1px solid var(--border); margin: 0.9rem 0; }

/* ---------- Segmented control ---------- */
.seg {
  display: inline-flex;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.seg.small { margin: 0.5rem 0; }
.seg button {
  border: none; background: none; font: inherit; font-size: 0.82rem; font-weight: 500;
  padding: 0.35rem 0.7rem; border-radius: 7px; cursor: pointer; color: var(--text-2);
  transition: all 0.15s;
}
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

/* ---------- Color input ---------- */
.color-input { margin: 0.6rem 0; }
.color-control { display: flex; gap: 0.5rem; align-items: center; }
input[type='color'] {
  width: 44px; height: 38px; padding: 2px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-2); cursor: pointer;
}
.hex { max-width: 110px; text-transform: uppercase; font-family: var(--mono); font-size: 0.82rem; }
.grad-bar { height: 28px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 0.5rem; }

/* ---------- Sliders ---------- */
.slider-row { margin: 0.7rem 0; }
.slider-row label { display: flex; justify-content: space-between; align-items: center; }
.slider-val { font-family: var(--mono); color: var(--accent); font-weight: 600; }
input[type='range'] {
  width: 100%; accent-color: var(--accent); cursor: pointer;
}

/* ---------- Shape swatches ---------- */
.swatch-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-bottom: 0.4rem; }
.swatch {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  padding: 0.6rem 0.3rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-2); cursor: pointer; font: inherit; transition: all 0.15s;
}
.swatch:hover { border-color: var(--accent); }
.swatch.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.swatch-label { font-size: 0.68rem; color: var(--text-2); }
.swatch-vis { width: 26px; height: 26px; }
/* dots body */
.vis-dotsType-square { background: var(--text); border-radius: 2px; }
.vis-dotsType-dots { background: var(--text); border-radius: 50%; }
.vis-dotsType-rounded { background: var(--text); border-radius: 6px; }
.vis-dotsType-extra-rounded { background: var(--text); border-radius: 10px; }
.vis-dotsType-classy { background: var(--text); border-radius: 10px 2px 10px 2px; }
.vis-dotsType-classy-rounded { background: var(--text); border-radius: 12px 4px 12px 4px; }
/* corner frame — ring */
[class*='vis-cornersSquareType'] { background: none; border: 4px solid var(--text); }
.vis-cornersSquareType-square { border-radius: 2px; }
.vis-cornersSquareType-dot { border-radius: 50%; }
.vis-cornersSquareType-extra-rounded { border-radius: 9px; }
/* corner ball — filled */
[class*='vis-cornersDotType'] { background: var(--text); }
.vis-cornersDotType-square { border-radius: 2px; }
.vis-cornersDotType-dot { border-radius: 50%; }

/* ---------- Templates ---------- */
.template-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.6rem; }
@media (max-width: 560px) { .template-grid { grid-template-columns: repeat(3, 1fr); } }
.template {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  padding: 0.5rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-2); cursor: pointer; font: inherit; transition: all 0.15s;
}
.template:hover { border-color: var(--accent); transform: translateY(-2px); }
.template-thumb { width: 48px; height: 48px; border-radius: 6px; overflow: hidden; background: #fff; display: grid; place-items: center; }
.template-thumb svg, .template-thumb canvas { width: 100% !important; height: 100% !important; }
.template-name { font-size: 0.68rem; color: var(--text-2); }
.link-btn { background: none; border: none; color: var(--accent); font: inherit; font-size: 0.8rem; cursor: pointer; padding: 0.6rem 0 0; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Logo upload ---------- */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 1.2rem; text-align: center; cursor: pointer; color: var(--text-2);
  transition: all 0.15s;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.upload-zone .icon { width: 1.6rem; height: 1.6rem; color: var(--accent); }
.upload-zone p { margin: 0.4rem 0 0.2rem; font-size: 0.9rem; }
.upload-zone .link { color: var(--accent); font-weight: 600; }
.upload-zone small { color: var(--muted); }
.logo-row { display: flex; align-items: center; gap: 0.8rem; margin: 0.8rem 0; }
#logo-thumb { width: 52px; height: 52px; object-fit: contain; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-2); padding: 4px; }
.note { display: flex; align-items: flex-start; gap: 0.4rem; font-size: 0.75rem; color: var(--text-2); background: color-mix(in srgb, var(--warn) 10%, transparent); padding: 0.5rem 0.6rem; border-radius: var(--radius-sm); margin-top: 0.8rem; }
.note .icon { color: var(--warn); flex: none; }

/* ---------- Preview ---------- */
.preview-panel { min-width: 0; }
@media (min-width: 1024px) { .preview-panel { position: sticky; top: 88px; } }
.preview-card { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.9rem; }
.qr-stage {
  display: grid; place-items: center;
  padding: 1.25rem; border-radius: var(--radius);
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e9edf3 25%, transparent 25%),
    linear-gradient(-45deg, #e9edf3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e9edf3 75%),
    linear-gradient(-45deg, transparent 75%, #e9edf3 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
#qr-container { display: grid; place-items: center; transition: opacity 0.2s; }
#qr-container svg, #qr-container canvas { max-width: 100%; height: auto; border-radius: 6px; }
.status-line {
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.85rem; font-weight: 500; justify-content: center;
  padding: 0.5rem; border-radius: var(--radius-sm);
}
.status-line.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.status-line.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.status-line.empty { color: var(--muted); }
.format-seg { width: 100%; justify-content: stretch; }
.format-seg button { flex: 1; }
.download-row { display: flex; gap: 0.6rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.7rem 1rem; border-radius: var(--radius-sm); border: none;
  font: inherit; font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.btn.primary { flex: 1; background: var(--accent-grad); color: #fff; box-shadow: 0 6px 16px rgba(99, 102, 241, 0.32); }
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(99, 102, 241, 0.42); }
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px;
  border: 1px solid var(--border); background: var(--card); color: var(--text-2);
  border-radius: var(--radius-sm); cursor: pointer; transition: all 0.15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.filename-field { margin: 0; }
.filename-field input { font-size: 0.85rem; }
.scan-reminder { display: flex; align-items: center; justify-content: center; gap: 0.4rem; margin: 0; font-size: 0.75rem; color: var(--muted); }
.scan-reminder .icon { color: var(--ok); }
.contrast-chip { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; font-weight: 500; margin-top: 0.6rem; padding: 0.3rem 0.6rem; border-radius: 999px; }
.contrast-chip.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.contrast-chip.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }

/* ---------- Debug decoder ---------- */
.preview-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.debug-link { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0; font-size: 0.75rem; color: var(--muted); }
.debug-link:hover { color: var(--accent); }
.debug-link .icon { width: 0.9rem; height: 0.9rem; }
.debug-panel { border-top: 1px dashed var(--border); padding-top: 0.9rem; display: flex; flex-direction: column; gap: 0.7rem; }
.debug-empty, .debug-loading { display: flex; align-items: center; gap: 0.4rem; margin: 0; font-size: 0.82rem; color: var(--text-2); }
.debug-status { display: flex; align-items: flex-start; gap: 0.45rem; font-size: 0.8rem; font-weight: 500; padding: 0.55rem 0.7rem; border-radius: var(--radius-sm); }
.debug-status .icon { flex: none; margin-top: 1px; }
.debug-status.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.debug-status.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.debug-status.err { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.debug-field { display: flex; flex-direction: column; gap: 0.25rem; }
.debug-key { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.debug-field pre {
  margin: 0; padding: 0.6rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-2); color: var(--text); font-family: var(--mono); font-size: 0.78rem;
  white-space: pre-wrap; word-break: break-all; max-height: 180px; overflow: auto;
}
.debug-meta { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 1rem; }
.debug-meta div { display: flex; flex-direction: column; }
.debug-meta dt { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.debug-meta dd { margin: 0; font-size: 0.82rem; font-weight: 500; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 2rem; background: var(--card-2); }
.footer-inner { max-width: 1280px; margin: 0 auto; padding: 2.5rem clamp(1rem, 4vw, 2.5rem); color: var(--text-2); font-size: 0.85rem; }

.footer-menu {
  display: grid; gap: 2rem 1.5rem;
  grid-template-columns: 1.6fr repeat(3, 1fr);
}
@media (max-width: 860px) { .footer-menu { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .footer-menu { grid-template-columns: 1fr; } }
.footer-col h3 {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text); margin: 0 0 0.8rem;
}
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.footer-col a { color: var(--text-2); text-decoration: none; transition: color 0.15s; }
.footer-col a:hover { color: var(--accent); }
.footer-col .footer-all { color: var(--accent); font-weight: 600; }
.footer-brand { max-width: 280px; }
.footer-logo { font-weight: 800; font-size: 1.1rem; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.footer-logo span { color: var(--accent); font-family: var(--mono); font-weight: 600; font-size: 0.95em; }
.footer-brand p { margin: 0.6rem 0 0; line-height: 1.55; }

.footer-bottom {
  margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; align-items: baseline; justify-content: space-between;
}
.footer-bottom .privacy { margin: 0; max-width: 640px; }
.footer-bottom .privacy .icon { color: var(--accent); }
.colophon { color: var(--muted); font-size: 0.8rem; margin: 0; }
.colophon a { color: var(--accent); text-decoration: none; }
.colophon a:hover { text-decoration: underline; }

/* ---------- Static SEO content ---------- */
.seo-content { border-top: 1px solid var(--border); }
.seo-inner {
  max-width: 820px; margin: 0 auto;
  padding: 2.5rem clamp(1rem, 4vw, 2.5rem) 1rem;
  color: var(--text-2);
}
.seo-inner h1 {
  font-size: clamp(1.5rem, 4vw, 2rem); line-height: 1.2; letter-spacing: -0.02em;
  color: var(--text); margin: 0 0 0.8rem;
}
.seo-inner h2 {
  font-size: 1.2rem; color: var(--text); margin: 2rem 0 0.6rem; letter-spacing: -0.01em;
}
.seo-inner h3 { font-size: 0.98rem; color: var(--text); margin: 1.1rem 0 0.3rem; }
.seo-lede { font-size: 1.02rem; line-height: 1.65; color: var(--text-2); margin: 0; }
.seo-inner p { line-height: 1.65; }
.seo-steps, .seo-features { padding-left: 1.2rem; line-height: 1.7; }
.seo-steps li, .seo-features li { margin: 0.3rem 0; }
.seo-steps strong, .seo-faq h3, .seo-lede strong { color: var(--text); }
.seo-faq p { margin: 0.2rem 0 0.9rem; }
.seo-inner a { color: var(--accent); text-decoration: none; }
.seo-inner a:hover { text-decoration: underline; }
