*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f5f5;
  color: #222;
  min-height: 100vh;
}

/* 헤더 */
header {
  background: #1a1a2e;
  color: #fff;
  padding: 24px 32px;
}
header h1 { font-size: 1.6rem; margin-bottom: 4px; }
header p  { font-size: 0.9rem; opacity: 0.7; }

/* 메인 */
main { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }

/* 카테고리 */
.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.category-btn {
  padding: 8px 20px;
  border: 2px solid #ddd;
  border-radius: 24px;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
}
.category-btn:hover  { border-color: #4f6ef7; color: #4f6ef7; }
.category-btn.active { background: #4f6ef7; border-color: #4f6ef7; color: #fff; }

/* ── 모드 탭 ──────────────────────────────────────── */
.mode-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: #e8e8e8;
  padding: 4px;
  border-radius: 10px;
  width: fit-content;
}
.mode-tab {
  padding: 7px 22px;
  border: none;
  border-radius: 7px;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: #777;
  transition: all 0.15s;
}
.mode-tab:hover { color: #4f6ef7; }
.mode-tab.active {
  background: #fff;
  color: #4f6ef7;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

/* ── 완성형 레이아웃 ──────────────────────────────── */
.content-area {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  align-items: start;
}

/* 템플릿 목록 */
#template-list-panel {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
#template-list-panel h2 { font-size: 0.85rem; color: #888; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }
#template-list { list-style: none; }
#template-list li {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.1s;
  border-left: 3px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#template-list li:hover  { background: #f0f4ff; }
#template-list li.active {
  background: #e8eeff;
  border-left-color: #4f6ef7;
  font-weight: 600;
}
#template-list li.active .tpl-name { color: #4f6ef7; }
.tpl-name { font-size: 0.88rem; font-weight: 500; color: #222; }
.tpl-desc { font-size: 0.76rem; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 상세 패널 */
#template-detail-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 템플릿 정보 */
#template-info {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
#template-name { font-size: 1.3rem; margin-bottom: 8px; }
#template-description { color: #555; font-size: 0.9rem; margin-bottom: 12px; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tag {
  padding: 3px 10px;
  background: #eef0ff;
  color: #4f6ef7;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

.example-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.example-block {
  background: #f8f9ff;
  border-radius: 8px;
  padding: 12px;
}
.example-block h4 { font-size: 0.8rem; color: #888; margin-bottom: 8px; }
.example-block pre {
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: #333;
  line-height: 1.8;
  max-height: 180px;
  overflow-y: auto;
  padding: 4px 2px;
}

/* 폼 */
#form-section {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
#form-section h3 { font-size: 1rem; margin-bottom: 16px; }

.form-field { margin-bottom: 16px; }
.form-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #333;
}
.form-field label .required { color: #e53e3e; margin-left: 2px; }
.form-field label .optional { color: #aaa; font-weight: 400; font-size: 0.8rem; margin-left: 4px; }
.form-field input,
.form-field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s;
  resize: vertical;
}
.form-field input:focus,
.form-field textarea:focus { outline: none; border-color: #4f6ef7; }

.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* 결과 */
#result-section {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.result-header h3 { font-size: 1rem; }

.prompt-output {
  background: #1a1a2e;
  border-radius: 8px;
  padding: 16px;
  position: relative;
}
.prompt-output pre {
  color: #e0e0f0;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  margin-bottom: 12px;
}
.copy-feedback {
  font-size: 0.8rem;
  color: #68d391;
  margin-left: 10px;
}

/* 버튼 */
.btn {
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:hover  { opacity: 0.85; }
.btn:active { transform: scale(0.97); }
.btn-primary   { background: #4f6ef7; color: #fff; }
.btn-secondary { background: #eef0ff; color: #4f6ef7; }
.btn-ghost     { background: transparent; color: #888; border: 1.5px solid #ddd; }

/* 결과 강조 애니메이션 */
@keyframes highlight-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(79, 110, 247, 0.4); }
  60%  { box-shadow: 0 0 0 8px rgba(79, 110, 247, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 110, 247, 0); }
}
.result-highlight { animation: highlight-pulse 0.9s ease-out; }

/* 복사 완료 버튼 */
.btn-copied { background: #2f855a !important; color: #fff !important; }

/* 알림 배너 */
.notification {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 16px;
  animation: notification-in 0.2s ease-out;
}
@keyframes notification-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.notification-error {
  background: #fff5f5;
  border: 1.5px solid #feb2b2;
  color: #c53030;
}
.notification-success {
  background: #f0fff4;
  border: 1.5px solid #9ae6b4;
  color: #276749;
}
.notification-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  color: inherit;
  opacity: 0.6;
  padding: 0 4px;
  flex-shrink: 0;
}
.notification-close:hover { opacity: 1; }

/* 필드 에러 */
.field-error-msg {
  display: block;
  font-size: 0.78rem;
  color: #c53030;
  margin-top: 4px;
  min-height: 1em;
}
.input-error {
  border-color: #fc8181 !important;
  background: #fff5f5;
}
.input-error:focus { border-color: #e53e3e !important; outline: none; }

/* 생성 버튼 로딩 */
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* 유틸 */
.hidden { display: none !important; }

/* 빈 상태 안내 카드 */
.empty-state { text-align: center; color: #aaa; padding: 60px 16px; }
.empty-state-title { font-size: 1rem; font-weight: 600; color: #888; margin-bottom: 24px; }
.guide-cards {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}
.guide-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px 20px;
  width: 180px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.guide-step {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #4f6ef7;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.guide-card strong { font-size: 0.9rem; color: #333; }
.guide-card p { font-size: 0.78rem; color: #999; line-height: 1.5; }

/* ── 조합형 모드 ───────────────────────────────────── */

.composer-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 카드 (조합형 공통) */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.card h3 { font-size: 1rem; margin-bottom: 16px; }
.card-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}
.card-header h3 { margin-bottom: 0; }
.card-hint { font-size: 0.78rem; color: #aaa; }
.optional-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  color: #6c757d;
  background: #f1f3f5;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  padding: 1px 6px;
  vertical-align: middle;
  margin-left: 6px;
}

/* 조합 그리드 */
.combinator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}
.combinator-col { display: flex; flex-direction: column; gap: 8px; }
.combinator-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
}
.multi-hint {
  font-style: normal;
  font-weight: 400;
  font-size: 0.78rem;
  color: #aaa;
  margin-left: 4px;
}
.combinator-desc {
  font-size: 0.78rem;
  color: #888;
  line-height: 1.5;
  min-height: 1.5em;
}

/* Framework 드롭다운 */
.composer-select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 0.88rem;
  font-family: inherit;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.composer-select:focus { outline: none; border-color: #4f6ef7; }

/* Chip 다중 선택 */
.chip-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chip-placeholder {
  font-size: 0.8rem;
  color: #bbb;
  padding: 6px 0;
}
.no-options {
  font-size: 0.8rem;
  color: #bbb;
  padding: 6px 0;
}
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fff;
  font-size: 0.84rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  width: 100%;
  color: #444;
}
.chip:hover { border-color: #4f6ef7; color: #4f6ef7; }
.chip.selected {
  border-color: #4f6ef7;
  background: #eef0ff;
  color: #3a5ce5;
  font-weight: 600;
}
.chip-recommended {
  font-size: 0.7rem;
  padding: 2px 7px;
  background: #d1fae5;
  color: #065f46;
  border-radius: 10px;
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}
.chip.selected .chip-recommended {
  background: #c7d2fe;
  color: #3730a3;
}

/* 유효성 검사 배너 */
.composer-validation {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  animation: notification-in 0.2s ease-out;
}
.composer-validation.has-warnings {
  background: #fffbeb;
  border: 1.5px solid #f6e05e;
  color: #744210;
}
.composer-validation.has-errors {
  background: #fff5f5;
  border: 1.5px solid #feb2b2;
  color: #c53030;
}
.validation-title {
  font-weight: 700;
  font-size: 0.82rem;
  margin-bottom: 6px;
}
.validation-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.validation-list li { font-size: 0.82rem; }
.validation-list li::before { content: '• '; }

/* 조합형 변수 입력 폼 */
#composer-form-section h3 { font-size: 1rem; margin-bottom: 16px; }

/* 미리보기 */
.preview-hint {
  color: #bbb;
  font-size: 0.88rem;
  padding: 24px 0;
  text-align: center;
}
#composer-prompt-output pre {
  max-height: 400px;
  overflow-y: auto;
}
.composer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 프레임워크 description + effect */
.desc-effect {
  display: block;
  color: #4f6ef7;
  font-size: 0.75rem;
  margin-top: 3px;
  font-style: italic;
}

/* 칩 래퍼 (chip-item) */
.chip-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* 칩 아래 설명 텍스트 */
.chip-desc {
  font-size: 0.74rem;
  color: #999;
  line-height: 1.4;
  padding: 0 2px;
}

/* CSS 툴팁 (effect 표시) */
.chip[data-effect] {
  position: relative;
}
.chip[data-effect]:hover::after {
  content: attr(data-effect);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a2e;
  color: #e8eeff;
  font-size: 0.76rem;
  font-weight: 500;
  padding: 7px 11px;
  border-radius: 7px;
  white-space: normal;
  width: max-content;
  max-width: 200px;
  z-index: 200;
  pointer-events: none;
  text-align: center;
  line-height: 1.5;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}
.chip[data-effect]:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1a1a2e;
  z-index: 200;
  pointer-events: none;
}

/* 반응형 */
@media (max-width: 800px) {
  .combinator-grid { grid-template-columns: 1fr; }
  .content-area { grid-template-columns: 1fr; }
  #template-list-panel { display: none; }
}
