:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --bg: #f5f7fb;
  --card: #ffffff;
  --primary: #4f46e5;
  --primary-2: #4338ca;
  --primary-soft: #eef2ff;
  --accent: #06b6d4;
  --danger: #dc2626;
  --radius: 14px;
  --radius-s: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.container { width: min(1180px, 100% - 32px); margin-inline: auto; }
.container.narrow { width: min(760px, 100% - 32px); }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 18px; }
.brand-mark {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: var(--primary); color: #fff;
}
.site-nav { display: flex; gap: 22px; }
.site-nav a { text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: 14px; }
.site-nav a:hover { color: var(--primary); }

/* Hero */
.hero { padding: 40px 0 26px; text-align: center; }
.hero h1 { font-size: clamp(30px, 4.6vw, 44px); font-weight: 800; }
.hero p { max-width: 720px; margin: 12px auto 0; color: var(--ink-2); font-size: 16px; }

/* App layout */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  align-items: start;
  padding-bottom: 56px;
}
.builder { display: grid; gap: 16px; min-width: 0; }
.preview-col { position: sticky; top: 76px; display: grid; gap: 16px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.panel-head { display: flex; align-items: center; gap: 12px; }
summary.panel-head { cursor: pointer; list-style: none; user-select: none; }
summary.panel-head::-webkit-details-marker { display: none; }
.panel-head h2 { font-size: 17px; font-weight: 700; flex: 1; }
.panel-head .chev {
  width: 10px; height: 10px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .15s; margin-right: 4px;
}
details[open] > .panel-head .chev { transform: rotate(-135deg); }
.panel-body { padding-top: 16px; }
.panel-body h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 10px; }
.panel-body h3:first-child { margin-top: 0; }
.step {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 13px; flex: none;
}

/* Type grid */
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-top: 14px; }
.type-btn {
  display: grid; justify-items: center; gap: 6px; padding: 12px 6px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff; cursor: pointer;
  font-weight: 600; font-size: 12.5px; color: var(--ink-2); transition: border-color .12s, background .12s, color .12s;
}
.type-btn svg { width: 24px; height: 24px; }
.type-btn:hover { border-color: var(--line-2); background: #fafbff; }
.type-btn.is-active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-2); box-shadow: inset 0 0 0 1px var(--primary); }

/* Fields */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin-top: 14px; }
.fields .field.full { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); min-width: 0; }
.field > span { display: flex; justify-content: space-between; gap: 8px; }
.field output { font-weight: 500; color: var(--muted); }
.field input[type="text"], .field input[type="url"], .field input[type="email"], .field input[type="tel"],
.field input[type="number"], .field input[type="password"], .field input[type="datetime-local"], .field input[type="date"],
.field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-s); background: #fff;
  font-weight: 400; font-size: 14px; color: var(--ink); outline: none; transition: border-color .12s, box-shadow .12s;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.field input[type="range"] { width: 100%; accent-color: var(--primary); margin: 8px 0 4px; }
.hint { margin-top: 10px; color: var(--muted); font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; align-self: end; padding: 8px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 14px; margin-top: 14px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.color-wrap {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); border-radius: var(--radius-s); padding: 4px 6px 4px 4px; background: #fff;
}
.color-wrap input[type="color"] {
  width: 34px; height: 30px; padding: 0; border: none; border-radius: 6px; background: none; cursor: pointer;
}
.color-wrap input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-wrap input[type="color"]::-webkit-color-swatch { border: 1px solid var(--line); border-radius: 6px; }
.color-wrap input[type="color"]::-moz-color-swatch { border: 1px solid var(--line); border-radius: 6px; }
.color-wrap .hex { border: none !important; padding: 4px 2px !important; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px !important; box-shadow: none !important; width: 100%; }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: #eef1f6; gap: 2px; }
.seg-btn { border: none; background: transparent; padding: 7px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.seg-btn.is-active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }

/* Shape pickers */
.shape-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.shape-grid.small { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); }
.shape-btn {
  display: grid; gap: 4px; justify-items: center; padding: 8px 4px 6px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: #fff; cursor: pointer; font-size: 11px; font-weight: 600; color: var(--muted); line-height: 1.1;
}
.shape-btn .thumb { width: 52px; height: 52px; display: grid; place-items: center; }
.shape-btn .thumb svg { width: 100%; height: 100%; }
.shape-btn:hover { border-color: var(--line-2); }
.shape-btn.is-active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-2); box-shadow: inset 0 0 0 1px var(--primary); }

/* Frames */
.frame-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.frame-btn {
  display: grid; justify-items: center; gap: 6px; padding: 10px 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: #fff; cursor: pointer; font-size: 11px; font-weight: 600; color: var(--muted);
}
.frame-btn .thumb { width: 60px; height: 72px; display: grid; place-items: center; }
.frame-btn .thumb svg { width: 100%; height: 100%; }
.frame-btn:hover { border-color: var(--line-2); }
.frame-btn.is-active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-2); box-shadow: inset 0 0 0 1px var(--primary); }

/* Presets */
.preset-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 8px; }
.preset-btn {
  display: grid; justify-items: center; gap: 5px; padding: 8px 4px 6px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: #fff; cursor: pointer; font-size: 11px; font-weight: 600; color: var(--muted);
}
.preset-btn .thumb { width: 48px; height: 48px; border-radius: 8px; overflow: hidden; }
.preset-btn .thumb svg { width: 100%; height: 100%; display: block; }
.preset-btn:hover { border-color: var(--primary); }

/* Logo */
.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.logo-btn {
  display: grid; place-items: center; aspect-ratio: 1; border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff; cursor: pointer;
  color: var(--ink-2); font-size: 11px; font-weight: 600; position: relative; overflow: hidden;
}
.logo-btn svg { width: 30px; height: 30px; }
.logo-btn img { width: 44px; height: 44px; object-fit: contain; }
.logo-btn.upload { border-style: dashed; color: var(--primary); }
.logo-btn.upload svg { width: 22px; height: 22px; }
.logo-btn .lbl { font-size: 10px; margin-top: 2px; }
.logo-btn:hover { border-color: var(--line-2); }
.logo-btn.is-active { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; border-radius: 10px;
  border: 1px solid var(--line-2); background: #fff; font-weight: 600; font-size: 14px; cursor: pointer; transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: #f8fafc; border-color: #b6c2d3; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: #eef1f6; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Preview */
.preview-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.preview-stage {
  display: grid; place-items: center; aspect-ratio: 1; width: 100%; border-radius: 12px; padding: 12px;
  background:
    linear-gradient(45deg, #eef1f6 25%, transparent 25%, transparent 75%, #eef1f6 75%),
    linear-gradient(45deg, #eef1f6 25%, transparent 25%, transparent 75%, #eef1f6 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px; background-color: #fff;
}
.preview-stage svg { max-width: 100%; max-height: 100%; width: auto; height: auto; display: block; filter: drop-shadow(0 6px 14px rgba(15, 23, 42, .12)); }
.preview-stage.is-placeholder svg { opacity: .28; filter: none; }
.preview-note { margin-top: 12px; font-size: 13px; color: var(--muted); text-align: center; min-height: 20px; }
.dl-row { margin-top: 12px; }
.dl-buttons { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; margin-top: 12px; }
.dl-buttons.secondary { grid-template-columns: 1fr 1fr; margin-top: 8px; }
.preview-meta { margin-top: 12px; font-size: 12px; color: var(--muted); text-align: center; }
.tips { background: var(--primary-soft); border: 1px solid #dfe3ff; border-radius: var(--radius); padding: 14px 16px; font-size: 13px; color: var(--ink-2); }
.tips ul { margin: 6px 0 0; padding-left: 18px; }
.tips li + li { margin-top: 3px; }

/* Marketing sections */
.section { padding: 56px 0; }
.section.alt { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section h2 { font-size: 28px; font-weight: 800; text-align: center; margin-bottom: 28px; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.step-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.step-card h3 { font-size: 16px; margin: 12px 0 6px; }
.step-card p { color: var(--ink-2); font-size: 14px; }
.type-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.type-card { display: flex; gap: 12px; align-items: flex-start; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; }
.type-card:hover { border-color: var(--primary); }
.type-card svg { width: 26px; height: 26px; flex: none; color: var(--primary); }
.type-card h3 { font-size: 15px; margin-bottom: 4px; }
.type-card p { font-size: 13px; color: var(--ink-2); }
.faq { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 14px 18px; margin-bottom: 10px; }
.faq summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-weight: 500; color: var(--muted); font-size: 18px; }
.faq[open] summary::after { content: "–"; }
.faq p { margin-top: 10px; color: var(--ink-2); font-size: 14px; }
.site-footer { padding: 26px 0 40px; text-align: center; color: var(--muted); font-size: 13px; }

/* Passcode gate */
.gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg); padding: 20px; }
.gate[hidden] { display: none; }
.gate-card { width: min(380px, 100%); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 24px; display: grid; gap: 12px; justify-items: center; text-align: center; }
.gate-card h1 { font-size: 22px; font-weight: 800; }
.gate-card p { color: var(--muted); font-size: 14px; }
.gate-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-s); font-size: 15px; text-align: center; letter-spacing: .08em; outline: none; }
.gate-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.gate-card .btn { width: 100%; }
.gate-error { color: var(--danger) !important; font-weight: 600; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 500;
  transition: transform .2s, opacity .2s; pointer-events: none; z-index: 50;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* Responsive */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .preview-col { position: static; order: -1; }
  .preview-card { display: grid; grid-template-columns: 200px 1fr; gap: 0 18px; align-items: center; }
  .preview-stage { grid-row: 1 / span 5; }
  .preview-note { text-align: left; margin-top: 0; }
  .preview-meta { text-align: left; }
  .tips { display: none; }
  .steps { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .site-nav { display: none; }
  .hero { padding: 26px 0 18px; }
  .panel { padding: 14px; }
  .fields { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .preview-card { grid-template-columns: 1fr; }
  .preview-stage { grid-row: auto; max-width: 260px; margin: 0 auto; }
  .preview-note, .preview-meta { text-align: center; margin-top: 10px; }
  .steps { grid-template-columns: 1fr; }
}
@media print {
  body * { visibility: hidden; }
  #preview, #preview * { visibility: visible; }
  #preview { position: fixed; inset: 0; margin: auto; width: 80vmin; height: 80vmin; background: none; padding: 0; }
  #preview svg { filter: none; }
}
