:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e3e6ef;
  --text: #0f172a;
  --muted: #5b6478;
  --primary: #4f46e5;
  --primary-2: #06b6d4;
  --primary-soft: rgba(79, 70, 229, 0.1);
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 32px -16px rgba(15, 23, 42, 0.18);
  --radius: 18px;
}
[data-theme="dark"] {
  --bg: #0b0e17;
  --surface: #121725;
  --surface-2: #1a2032;
  --border: #252c40;
  --text: #e6e9f2;
  --muted: #98a1b6;
  --primary: #818cf8;
  --primary-2: #22d3ee;
  --primary-soft: rgba(129, 140, 248, 0.14);
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -20px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(900px 500px at 15% -10%, var(--primary-soft), transparent 60%),
    radial-gradient(700px 400px at 95% 0%, rgba(6, 182, 212, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s, color .3s;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1120px; margin: 0 auto; padding: 14px 24px;
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.top-actions { display: flex; align-items: center; gap: 20px; font-size: .92rem; }
.top-actions a { color: var(--muted); }
.top-actions a:hover { color: var(--text); text-decoration: none; }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; transition: transform .3s, border-color .2s; }
.icon-btn:hover { transform: rotate(20deg); border-color: var(--primary); }
[data-theme="light"] .i-sun, [data-theme="dark"] .i-moon { display: none; }

main { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* Hero */
.hero { text-align: center; padding: 48px 0 28px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.1; letter-spacing: -0.03em; font-weight: 800; }
.grad { background: linear-gradient(120deg, var(--primary), var(--primary-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { max-width: 640px; margin: 16px auto 0; color: var(--muted); font-size: 1.05rem; }

/* Tabs */
.tabs { display: flex; gap: 6px; width: max-content; margin: 8px auto 26px; padding: 6px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.tab { display: flex; align-items: center; gap: 8px; padding: 10px 22px; border: 0; border-radius: 999px; background: transparent;
  color: var(--muted); font-weight: 600; cursor: pointer; transition: background .25s, color .25s; }
.tab:hover { color: var(--text); }
.tab.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }

/* Layout */
.panel { animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.studio { display: grid; grid-template-columns: 1.25fr 1fr; gap: 22px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; }

/* Form */
.form-card { display: flex; flex-direction: column; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: .85rem; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; }
.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.type { padding: 11px 8px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer;
  font-weight: 600; font-size: .92rem; transition: border-color .2s, background .2s, transform .15s; }
.type:hover { border-color: var(--primary); }
.type:active { transform: scale(.97); }
.type.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
#dynamic-fields { display: flex; flex-direction: column; gap: 14px; }
#dynamic-fields .field { animation: fade .3s ease; }
input[type="text"], input[type="url"], input[type="email"], input[type="tel"], input[type="password"], select, textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2);
  transition: border-color .2s, box-shadow .2s; outline: none;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); }

.customise { border-top: 1px dashed var(--border); padding-top: 16px; }
.customise summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px; }
.customise summary::before { content: "›"; display: inline-block; transition: transform .2s; color: var(--primary); font-size: 1.2rem; }
.customise[open] summary::before { transform: rotate(90deg); }
.customise summary::-webkit-details-marker { display: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.color { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.color input { width: 34px; height: 30px; border: 0; background: none; cursor: pointer; padding: 0; }
.color code { font-size: .85rem; color: var(--muted); }
input[type="range"] { accent-color: var(--primary); width: 100%; margin-top: 8px; }
.hint { margin-top: 12px; font-size: .85rem; color: #b45309; }

/* Preview */
.preview-card { position: sticky; top: 84px; text-align: center; }
.preview { position: relative; display: grid; place-items: center; aspect-ratio: 1; border-radius: 14px;
  background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 22px 22px; border: 1px solid var(--border); overflow: hidden; }
.preview img { width: 82%; height: auto; border-radius: 8px; box-shadow: 0 10px 30px -12px rgba(15, 23, 42, .35); animation: pop .35s cubic-bezier(.2,.8,.2,1.2); image-rendering: pixelated; }
@keyframes pop { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
.placeholder { color: var(--muted); padding: 24px; display: grid; justify-items: center; gap: 10px; font-size: .95rem; }
.placeholder.small { justify-items: start; padding: 6px 0; }
.spinner { position: absolute; width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--primary-soft); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.payload { margin-top: 14px; font-size: .8rem; color: var(--muted); word-break: break-all; font-family: ui-monospace, Consolas, monospace; }
.downloads { display: flex; gap: 10px; margin-top: 18px; }
.downloads .btn.primary { flex: 1; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer; transition: transform .15s, box-shadow .2s, opacity .2s, border-color .2s; text-decoration: none !important; }
.btn.primary { color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.btn.primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 24px -10px var(--primary); }
.btn.ghost { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn.ghost:hover:not(:disabled) { border-color: var(--primary); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Scanner */
.scanner { position: relative; aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; background: var(--surface-2); border: 2px dashed var(--border); transition: border-color .2s, background .2s; }
.scanner.drag { border-color: var(--primary); background: var(--primary-soft); }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.dropzone { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px; text-align: center; color: var(--muted); padding: 20px; }
.dropzone strong { color: var(--text); }
.muted { font-size: .82rem; }
.scan-frame { position: absolute; inset: 14%; border-radius: 16px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35); }
.scan-frame::before { content: ""; position: absolute; inset: 0; border-radius: 16px; border: 3px solid rgba(255, 255, 255, .9); }
.scan-frame span { position: absolute; left: 6%; right: 6%; height: 2px; background: var(--primary-2); box-shadow: 0 0 12px var(--primary-2); animation: sweep 2s ease-in-out infinite; }
@keyframes sweep { 0%, 100% { top: 8%; } 50% { top: 92%; } }
.scan-actions { display: flex; gap: 10px; margin-top: 16px; }
.scan-actions .btn.primary { flex: 1; }
.result-card h3 { margin-bottom: 12px; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--primary-soft); color: var(--primary); }
#result pre { margin-top: 12px; padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border);
  white-space: pre-wrap; word-break: break-word; font-size: .9rem; max-height: 260px; overflow: auto; }
.error { margin-top: 12px; color: var(--danger); font-size: .9rem; }

/* Info sections */
.info { padding: 72px 0 0; }
.info h2 { text-align: center; font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -0.02em; margin-bottom: 28px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.step { padding: 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.step b { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #fff; margin-bottom: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.step h3, .features h3 { font-size: 1.02rem; margin-bottom: 4px; }
.step p, .features p { color: var(--muted); font-size: .92rem; }
.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-top: 18px; }
.features > div { padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.features span { font-size: 1.5rem; display: block; margin-bottom: 8px; }
.faq { max-width: 780px; margin: 0 auto; display: grid; gap: 10px; }
.faq details { border-radius: 14px; background: var(--surface); border: 1px solid var(--border); padding: 4px 20px; transition: border-color .2s; }
.faq details[open] { border-color: var(--primary); }
.faq summary { cursor: pointer; padding: 14px 0; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--primary); font-size: 1.3rem; line-height: 1; transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq p { color: var(--muted); padding: 0 0 16px; }

.footer { text-align: center; padding: 60px 24px 36px; color: var(--muted); font-size: .9rem; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); padding: 12px 20px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: .9rem; box-shadow: var(--shadow); animation: fade .25s ease; z-index: 50; }

/* Responsive */
@media (max-width: 880px) {
  .studio { grid-template-columns: 1fr; }
  .preview-card { position: static; }
  .steps, .features { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .top-actions a { display: none; }
  .types { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .steps, .features { grid-template-columns: 1fr; }
  .card { padding: 20px; }
  .hero { padding-top: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
