:root {
  --navy: #0f172a;
  --blue: #2563eb;
  --blue-d: #1d4ed8;
  --bg: #f1f5f9;
  --panel: #ffffff;
  --line: #e2e8f0;
  --muted: #64748b;
  --text: #0f172a;
  --soft: #eff6ff;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Pretendard, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column; font-size: 14px;
}
button, input, select, textarea { font: inherit; color: inherit; }
code, kbd { font-family: "JetBrains Mono", Consolas, monospace; font-size: 12px; }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; color: #1e40af; }
kbd { background: #fff; border: 1px solid var(--line); border-bottom-width: 2px; padding: 0 5px; border-radius: 4px; }
em { font-style: normal; color: var(--muted); font-weight: 400; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #3b82f6, #6366f1); font-weight: 800; font-size: 12px; letter-spacing: .5px;
}
.brand-name { font-weight: 800; font-size: 16px; }
.brand-sub { font-size: 12px; color: #94a3b8; }
.topbar-actions { display: flex; gap: 8px; }
.topbar .btn.ghost { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: #fff; }
.topbar .btn.ghost:hover { background: rgba(255,255,255,.16); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; margin-right: 4px; }
.dot.ok { background: #22c55e; }

/* ---------- Stepper ---------- */
.stepper {
  display: flex; gap: 6px; padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.stepper button {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 150px;
  padding: 8px 12px; border: 1px solid transparent; background: none; border-radius: 10px;
  cursor: pointer; color: var(--muted); font-weight: 600; transition: .2s;
}
.stepper button:hover { background: #f8fafc; }
.stepper .num {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: #e2e8f0; font-size: 12px; flex-shrink: 0; transition: .2s;
}
.stepper button.done .num { background: #dbeafe; color: var(--blue); }
.stepper button.active { background: var(--soft); border-color: #bfdbfe; color: var(--navy); }
.stepper button.active .num { background: var(--blue); color: #fff; }
.stepper .lbl { white-space: nowrap; }

/* ---------- Layout ---------- */
.workspace {
  flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(380px, 460px) 1fr;
  gap: 14px; padding: 14px;
}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.form-scroll { flex: 1; overflow-y: auto; padding: 20px 22px; }
.step { display: none; animation: fade .25s ease; }
.step.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.step h2 { margin: 0 0 10px; font-size: 18px; }
.tip {
  background: var(--soft); border: 1px solid #dbeafe; color: #1e3a8a; padding: 10px 12px;
  border-radius: 10px; font-size: 13px; line-height: 1.55; margin-bottom: 16px;
}
.tip b { display: inline-block; background: var(--blue); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 999px; margin-right: 6px; }
.subhead { font-weight: 700; margin: 18px 0 8px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 12px; font-weight: 600; color: #334155; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: #fff;
  outline: none; transition: border .15s, box-shadow .15s; width: 100%;
}
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; cursor: pointer; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--blue); }

/* ---------- Page type cards & personal box ---------- */
.type-cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 14px;
}
.type-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left;
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  cursor: pointer; transition: .15s; position: relative;
}
.type-card:hover { border-color: #93c5fd; background: #f8fbff; }
.type-card.active { border-color: var(--blue); background: var(--soft); box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.type-card .tc-top { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.type-card .tc-ico { font-size: 16px; }
.type-card .tc-tag { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: #f1f5f9; color: var(--muted); }
.type-card.personal .tc-tag { background: #ede9fe; color: #6d28d9; }
.type-card.mobile-card-featured {
  grid-column: span 3; flex-direction: row; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, #f4f1eb 0%, #e7eadc 100%); border-color: #bec9b6; padding: 10px 14px;
}
.type-card.mobile-card-featured .tc-top { width: auto; gap: 8px; order: 2; }
.type-card.mobile-card-featured .tc-tag { background: #315b46; color: #fffefa; }
.type-card.active .tc-tag { background: var(--blue); color: #fff; }
.type-card b { font-size: 12px; line-height: 1.3; color: var(--text); }
.type-card small { font-size: 11px; color: var(--muted); line-height: 1.3; }
.personal-box {
  background: linear-gradient(135deg, #f5f3ff 0%, #eff6ff 100%);
  border: 1px solid #ddd6fe; border-radius: 11px; padding: 12px; margin-bottom: 12px;
}
.personal-box[hidden] { display: none; }
.personal-head { font-size: 12px; font-weight: 800; color: #5b21b6; margin-bottom: 8px; }
.mc-extras { margin-top: 10px; padding-top: 10px; border-top: 1px dashed #c4b5fd; }
.mc-extras[hidden] { display: none; }
.mc-extras-head { font-size: 11.5px; font-weight: 800; color: #315b46; margin-bottom: 8px; }
.mc-upload { display: flex; align-items: center; gap: 6px; }
.mc-upload input[type=file] { font-size: 11px; padding: 6px; }
.btn.sm { padding: 4px 8px; font-size: 11px; border-radius: 6px; }

/* ---------- Layout style cards ---------- */
.layout-cards {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 14px;
}
.layout-card {
  display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center;
  padding: 8px 6px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  cursor: pointer; transition: .15s;
}
.layout-card:hover { border-color: #93c5fd; background: #f8fbff; }
.layout-card.active { border-color: var(--blue); background: var(--soft); box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.layout-card b { font-size: 11px; color: var(--text); line-height: 1.2; }
.layout-card small { font-size: 9.5px; color: var(--muted); line-height: 1.2; }
.lw-wire {
  width: 100%; height: 34px; border-radius: 5px; background: #f8fafc; border: 1px solid #e2e8f0;
  padding: 4px; display: flex; flex-direction: column; gap: 3px; overflow: hidden;
}
.layout-card.active .lw-wire { border-color: #93c5fd; background: #fff; }
.lw-bar { height: 4px; border-radius: 2px; background: #cbd5e1; width: 100%; }
.lw-split { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; flex: 1; }
.lw-split i, .lw-center i, .lw-bento i, .lw-side i, .lw-mag i { display: block; border-radius: 2px; background: #cbd5e1; }
.lw-split i:last-child, .lw-bento i.acc, .lw-mag i.acc { background: #93c5fd; }
.lw-center { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; }
.lw-center i:first-child { width: 65%; height: 6px; }
.lw-center i:last-child { width: 90%; flex: 1; background: #93c5fd; }
.lw-bento { display: grid; grid-template-columns: 2fr 1fr; gap: 2px; flex: 1; }
.lw-side { display: grid; grid-template-columns: 12px 1fr; gap: 3px; flex: 1; height: 100%; }
.lw-side i:first-child { background: #64748b; }
.lw-mag { display: grid; grid-template-columns: 1fr 1.4fr; gap: 3px; flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 9px;
  cursor: pointer; font-weight: 600; transition: .15s;
}
.btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-d); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37,99,235,.3); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn.big { width: 100%; padding: 14px; font-size: 15px; flex-direction: column; gap: 2px; }
.btn.big small { font-weight: 400; opacity: .8; font-size: 12px; }
.icon-btn { border: 1px solid var(--line); background: #fff; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: #f8fafc; }

/* ---------- Section list ---------- */
.section-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.section-item {
  display: grid; grid-template-columns: 22px 28px 1fr auto; gap: 8px; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; transition: .15s;
}
.section-item.dragging { opacity: .4; }
.section-item.over { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.section-item .handle { cursor: grab; color: #94a3b8; text-align: center; user-select: none; }
.section-item .ico {
  width: 28px; height: 28px; border-radius: 7px; background: var(--soft); color: var(--blue);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.section-item .meta { min-width: 0; }
.section-item .title { font-weight: 700; font-size: 13px; }
.section-item .title .idx { color: var(--blue); margin-right: 4px; }
.section-item input { width: 100%; border: none; border-bottom: 1px dashed transparent; padding: 2px 0; font-size: 12px; color: var(--muted); outline: none; background: transparent; }
.section-item input:focus { border-bottom-color: var(--blue); color: var(--text); }
.section-item .acts { display: flex; gap: 2px; }
.section-item .acts button { border: none; background: none; width: 24px; height: 24px; border-radius: 6px; cursor: pointer; color: #64748b; }
.section-item .acts button:hover { background: #f1f5f9; color: var(--text); }
.section-item .acts button.del:hover { background: #fee2e2; color: #dc2626; }
.add-section { display: flex; gap: 8px; margin-top: 10px; }
.add-section select { flex: 1; border: 1px solid var(--line); border-radius: 9px; padding: 8px; }

/* ---------- Colors ---------- */
.presets { display: flex; flex-wrap: wrap; gap: 8px; }
.preset { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 6px 10px 6px 6px; display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12px; font-weight: 600; transition: .15s; }
.preset:hover { border-color: var(--blue); }
.preset.active { border-color: var(--blue); background: var(--soft); box-shadow: 0 0 0 2px rgba(37,99,235,.15); color: var(--navy); }
.preset .sw { display: flex; border-radius: 6px; overflow: hidden; }
.preset .sw i { width: 14px; height: 22px; display: block; }
.colors { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.color-row { display: grid; grid-template-columns: 40px 110px 1fr 92px; gap: 8px; align-items: center; }
.color-row input[type=color] { width: 40px; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; cursor: pointer; }
.color-row .role { font-weight: 700; font-size: 12px; }
.color-row .role small { display: block; font-weight: 400; color: var(--muted); }
.color-row input[type=text] { border: 1px solid var(--line); border-radius: 8px; padding: 8px; width: 100%; outline: none; }
.color-row input.hex { font-family: Consolas, monospace; text-transform: uppercase; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 12px; font-weight: 600; transition: .15s; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- Breakpoint diagram ---------- */
.bp-diagram { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; margin-top: 8px; }
.bp-box { border: 1px dashed #cbd5e1; border-radius: 10px; padding: 10px; background: #f8fafc; }
.bp-box .cap { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.bp-box .bar { height: 10px; border-radius: 3px; background: #cbd5e1; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; padding: 0 4px; }
.bp-box .bar i { width: 10px; height: 4px; background: #94a3b8; border-radius: 2px; }
.bp-box .hero { height: 34px; border-radius: 4px; background: #e2e8f0; margin-bottom: 6px; display: flex; gap: 4px; padding: 4px; }
.bp-box .hero span { flex: 1; border-radius: 3px; background: #cbd5e1; }
.bp-box .hero.col { flex-direction: column; height: 50px; }
.bp-box .cards { display: grid; gap: 4px; }
.bp-box .cards span { height: 18px; border-radius: 3px; background: #93c5fd; }
.bp-box .cards.scroll { display: flex; overflow: hidden; }
.bp-box .cards.scroll span { min-width: 75%; }

/* ---------- Interactions ---------- */
.ix-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.ix { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: .15s; }
.ix:hover { border-color: #cbd5e1; }
.ix:has(> input:checked) { border-color: #93c5fd; background: #f8fbff; }
.ix > input { margin-top: 2px; }
.ix b { display: block; font-size: 13px; }
.ix small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.inline-num { width: 46px; border: 1px solid var(--line); border-radius: 6px; padding: 1px 4px; }

/* ---------- Step 5 ---------- */
.dropzone {
  border: 2px dashed #cbd5e1; border-radius: 12px; padding: 22px; text-align: center; cursor: pointer;
  background: #f8fafc; transition: .15s; display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.dropzone:hover, .dropzone.drag { border-color: var(--blue); background: var(--soft); }
.dropzone small { color: var(--muted); }
.dz-icon { font-size: 26px; }
.thumbs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 12px 0; }
.thumb { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; position: relative; background: #fff; }
.thumb img { width: 100%; height: 110px; object-fit: cover; object-position: top; display: block; background: #f1f5f9; }
.thumb select { width: 100%; border: none; border-top: 1px solid var(--line); padding: 6px; font-size: 12px; }
.thumb .rm { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; border: none; background: rgba(15,23,42,.75); color: #fff; cursor: pointer; }
.gen-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.gen-actions .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gen-actions .row .btn { font-size: 12px; }
.status { font-size: 12px; color: var(--muted); min-height: 18px; display: flex; align-items: center; gap: 8px; }
.status.err { color: #dc2626; }
.status.ok { color: #16a34a; }
.spinner { width: 14px; height: 14px; border: 2px solid #bfdbfe; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.form-footer { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.progress { flex: 1; height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.progress .bar { height: 100%; background: var(--blue); transition: width .3s; }

/* ---------- Output ---------- */
.out-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.quick-style-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  padding: 7px 12px; background: #f8fafc; border-bottom: 1px solid var(--line);
}
.qsb-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qsb-label { font-size: 11px; font-weight: 700; color: var(--muted); }
.qsb-sep { width: 1px; height: 18px; background: var(--line); }
.qsb-pills { display: flex; gap: 4px; flex-wrap: wrap; }
.qsb-pill {
  border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 4px 8px;
  font-size: 11px; font-weight: 600; color: var(--muted); cursor: pointer; transition: .15s;
}
.qsb-pill:hover { border-color: #93c5fd; color: var(--text); }
.qsb-pill.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.qsb-swatches { display: flex; align-items: center; gap: 5px; }
.qsb-swatch {
  display: inline-flex; padding: 2px; border-radius: 999px; border: 2px solid transparent;
  background: #fff; cursor: pointer; transition: .15s; box-shadow: 0 0 0 1px var(--line);
}
.qsb-swatch:hover { transform: scale(1.08); }
.qsb-swatch.active { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(37,99,235,.2); }
.qsb-swatch span { display: flex; width: 18px; height: 18px; border-radius: 999px; overflow: hidden; }
.qsb-swatch i { flex: 1; height: 100%; display: block; }
.qsb-picker {
  width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 999px;
  padding: 1px; background: #fff; cursor: pointer;
}
.tabs, .devices { display: flex; background: #f1f5f9; padding: 3px; border-radius: 9px; }
.tabs button, .devices button { border: none; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--muted); }
.devices button { padding: 5px 9px; }
.tabs button.active, .devices button.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #f1f5f9; color: var(--muted); }
.badge.ai { background: #ede9fe; color: #6d28d9; }
.badge.edited { background: #fef3c7; color: #b45309; }
.spacer { flex: 1; }
.out-body { flex: 1; min-height: 0; position: relative; }
.tab-pane { position: absolute; inset: 0; display: none; }
.tab-pane.active { display: block; }
.frame-stage { height: 100%; overflow: auto; background: repeating-conic-gradient(#f1f5f9 0 25%, #f8fafc 0 50%) 0 0/20px 20px; display: flex; justify-content: center; }
.frame-wrap { width: 100%; height: 100%; transition: width .35s ease; background: #fff; }
.frame-wrap.tablet { width: 768px; box-shadow: 0 0 0 1px var(--line), 0 10px 30px rgba(0,0,0,.08); }
.frame-wrap.mobile { width: 430px; box-shadow: 0 0 0 1px var(--line), 0 10px 30px rgba(0,0,0,.08); }
.frame-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }
#codeEditor {
  width: 100%; height: 100%; border: none; resize: none; outline: none; padding: 16px;
  font-family: "JetBrains Mono", Consolas, monospace; font-size: 12.5px; line-height: 1.6;
  background: #0b1220; color: #e2e8f0; tab-size: 2; white-space: pre;
}
[data-pane=prompt] { overflow: auto; background: #fbfcfe; }
.prompt-meta { display: flex; gap: 12px; padding: 12px 18px 0; font-size: 12px; color: var(--muted); }
#promptView { margin: 0; padding: 12px 18px 24px; white-space: pre-wrap; word-break: keep-all; font-family: Pretendard, sans-serif; font-size: 13.5px; line-height: 1.75; }

/* ---------- Modal / toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; z-index: 100; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 16px; padding: 22px; width: min(440px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-card h3 { margin: 0 0 6px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.6; }
.muted a { color: var(--blue); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 600; transition: .25s; z-index: 200;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto 70vh; overflow-y: auto; }
  .form-scroll { max-height: none; }
  .stepper .lbl { display: none; }
  .stepper button { min-width: 0; justify-content: center; }
}

