:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2330;
  --border: #2d3644;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #4cc9f0;
  --accent-2: #f72585;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 상단 바 ---------- */

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  font-weight: 900;
  font-size: 22px;
  color: var(--accent);
  text-decoration: none;
}
.logo em { color: var(--accent-2); font-style: normal; }

header .spacer { flex: 1; }

.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #26303f; border-color: var(--accent); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn:disabled:hover { background: var(--panel-2); border-color: var(--border); }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121a;
  font-weight: 700;
}
.btn.primary:hover { background: #7cdcf7; }

/* ---------- 레이아웃 ---------- */

main {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sidebar {
  width: 300px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  flex-shrink: 0;
}

.sidebar.right {
  border-right: none;
  border-left: 1px solid var(--border);
  width: 320px;
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  min-width: 0;
  background:
    radial-gradient(circle at 30% 20%, rgba(76, 201, 240, 0.06), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(247, 37, 133, 0.05), transparent 50%);
}

#canvas {
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  cursor: move;
  touch-action: none;
}

.ratio-select {
  width: auto !important;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}

/* ---------- 섹션 ---------- */

.section { margin-bottom: 24px; }

.section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.row label {
  font-size: 13px;
  color: var(--muted);
  width: 64px;
  flex-shrink: 0;
}

.row .value {
  font-size: 12px;
  color: var(--muted);
  width: 36px;
  text-align: right;
}

input[type="range"] { flex: 1; accent-color: var(--accent); }

input[type="color"] {
  width: 36px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  padding: 2px;
  cursor: pointer;
}

select, textarea, input[type="text"] {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}

textarea { resize: vertical; min-height: 60px; }

select:focus, textarea:focus, input:focus { outline: 1px solid var(--accent); }

.file-label {
  display: block;
  text-align: center;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.file-label:hover { border-color: var(--accent); color: var(--text); }
.file-label input { display: none; }

/* ---------- 템플릿 갤러리 ---------- */

#template-gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tpl-card {
  position: relative;
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.12s, border-color 0.12s;
  font-family: inherit;
}
.tpl-card:hover { transform: translateY(-2px); border-color: var(--accent); }

.tpl-preview {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
}

.tpl-name {
  display: block;
  font-size: 12px;
  color: var(--text);
  padding: 7px 8px;
  text-align: left;
}

.tpl-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--accent-2);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 999px;
}

#pro-preview-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(247, 37, 133, 0.12);
  border: 1px solid var(--accent-2);
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 14px;
}
#pro-preview-banner .btn { padding: 6px 14px; font-size: 13px; }

/* ---------- 레이어 목록 ---------- */

#layer-list { display: flex; flex-direction: column; gap: 6px; }

.layer-item {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  background: var(--panel-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-item:hover { border-color: var(--accent); }
.layer-item.active { border-color: var(--accent); background: rgba(76, 201, 240, 0.1); }

.add-buttons { display: flex; gap: 8px; margin-bottom: 12px; }
.add-buttons .btn { flex: 1; font-size: 13px; padding: 8px 6px; }

/* ---------- 인스펙터 ---------- */

#empty-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.align-group { display: flex; gap: 6px; flex: 1; }
.align-btn {
  flex: 1;
  padding: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.align-btn.active { border-color: var(--accent); color: var(--accent); }

.danger {
  width: 100%;
  margin-top: 8px;
  border-color: #6e2a35;
  color: #ff8fa3;
}
.danger:hover { border-color: var(--accent-2); background: rgba(247, 37, 133, 0.08); }

/* ---------- PRO 모달 ---------- */

#pro-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: min(440px, 92vw);
  position: relative;
}

.modal-box h2 {
  font-weight: 900;
  font-size: 26px;
  margin-bottom: 8px;
}
.modal-box h2 span { color: var(--accent-2); }

.modal-box p { color: var(--muted); font-size: 14px; line-height: 1.7; margin-bottom: 16px; }

.modal-box ul {
  list-style: none;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 2;
}
.modal-box ul li::before { content: "✓ "; color: var(--accent); font-weight: 700; }

.price-tag {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 16px;
}

.buy-btn {
  display: block;
  text-align: center;
  background: var(--accent-2);
  color: #fff;
  font-weight: 700;
  padding: 13px;
  border-radius: 10px;
  text-decoration: none;
  margin-bottom: 16px;
}
.buy-btn:hover { filter: brightness(1.15); }

.key-row { display: flex; gap: 8px; }
.key-row input { flex: 1; }

#pro-status { font-size: 13px; color: var(--accent-2); margin-top: 10px; min-height: 18px; }

#pro-demo-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 12px;
  padding: 10px;
  background: var(--panel-2);
  border-radius: 8px;
}

#pro-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
}
#pro-close:hover { color: var(--text); }

.hidden { display: none !important; }

/* ---------- 모바일 ---------- */

@media (max-width: 900px) {
  body { overflow: auto; height: auto; }
  main { flex-direction: column; }
  .sidebar, .sidebar.right { width: 100%; border: none; border-bottom: 1px solid var(--border); }
  .stage { padding: 12px; }
}
