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

body {
  font-family: 'Noto Sans KR', sans-serif;
  background: #0a0a0a;
  color: #e8e8e0;
  min-height: 100vh;
}

.app { max-width: 1200px; margin: 0 auto; padding: 32px 20px; }

.header { text-align: center; margin-bottom: 36px; }
.header h1 {
  font-size: 26px; font-weight: 900;
  background: linear-gradient(135deg, #f5c518, #ff8c00);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 6px;
}
.header p { color: #555; font-size: 13px; }

.main { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }

.panel {
  background: #111111;
  border: 1px solid #1e1e1e;
  border-radius: 14px;
  padding: 20px;
}

.right-col { display: flex; flex-direction: column; gap: 16px; }

/* 폼 요소 */
.section { margin-bottom: 20px; }
.label {
  display: block; font-size: 11px; font-weight: 700;
  color: #555; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px;
}

.api-key-row { display: flex; gap: 8px; }
.input, .textarea {
  flex: 1; background: #0a0a0a; border: 1px solid #252525;
  border-radius: 8px; padding: 10px 12px;
  color: #e8e8e0; font-size: 13px; font-family: 'Noto Sans KR', sans-serif;
  outline: none; transition: border-color 0.2s;
}
.input:focus, .textarea:focus { border-color: #f5c518; }
.textarea { width: 100%; resize: vertical; min-height: 110px; line-height: 1.6; }

.key-status { display: block; font-size: 11px; margin-top: 5px; color: #555; }
.key-status.ok { color: #4ade80; }
.key-status.err { color: #f87171; }

.template-row { display: flex; gap: 6px; }
.template-btn {
  flex: 1; padding: 8px 4px; border-radius: 8px;
  border: 1px solid #252525; background: transparent;
  color: #555; font-size: 12px; font-family: 'Noto Sans KR', sans-serif; cursor: pointer;
  transition: all 0.2s;
}
.template-btn:hover { border-color: #f5c518; color: #f5c518; }
.template-btn.active { border-color: #f5c518; background: #1a1500; color: #f5c518; font-weight: 700; }

.content-type-btn {
  flex: 1; padding: 8px 4px; border-radius: 8px;
  border: 1px solid #252525; background: transparent;
  color: #555; font-size: 12px; font-family: 'Noto Sans KR', sans-serif; cursor: pointer;
  transition: all 0.2s;
}
.content-type-btn:hover { border-color: #f5c518; color: #f5c518; }
.content-type-btn.active { border-color: #f5c518; background: #1a1500; color: #f5c518; font-weight: 700; }

/* 버튼 */
.btn {
  padding: 11px 16px; border-radius: 9px; border: none;
  font-family: 'Noto Sans KR', sans-serif; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all 0.2s; width: 100%;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #f5c518, #ff8c00); color: #000; }
.btn-primary:not(:disabled):hover { opacity: 0.88; transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1px solid #252525; color: #777; }
.btn-outline:hover { border-color: #f5c518; color: #f5c518; }
.btn-sm { width: auto; padding: 9px 13px; font-size: 12px; background: #1a1a14; color: #f5c518; border: 1px solid #252525; border-radius: 7px; }
.btn-sm:hover { background: #252520; }

.error { margin-top: 10px; padding: 10px 12px; background: #1a0808; border: 1px solid #f87171; border-radius: 8px; color: #f87171; font-size: 12px; line-height: 1.5; }

.divider { height: 1px; background: #1e1e1e; margin: 16px 0; }

/* 배경 업로드 */
.bg-drop {
  border: 2px dashed #252525; border-radius: 10px; padding: 20px;
  text-align: center; cursor: pointer; transition: all 0.2s;
  min-height: 90px; display: flex; align-items: center; justify-content: center;
}
.bg-drop:hover, .bg-drop.drag { border-color: #f5c518; background: #1a1500; }
.bg-drop.has-image { padding: 6px; border-style: solid; border-color: #f5c51844; }
.bg-drop p { font-size: 12px; color: #666; }
.bg-preview { width: 100%; border-radius: 7px; max-height: 140px; object-fit: cover; }
.clear-btn { width: 100%; margin-top: 6px; color: #f87171; border-color: #f8717133; }

/* 미리보기 패널 */
.preview-panel { }

/* 이미지 상태 */
.img-status {
  text-align: center; font-size: 11px; color: #f5c518;
  padding: 6px 0 0; letter-spacing: 0.04em; font-weight: 700;
}

/* 슬라이드 도트 */
.slide-dots { display: flex; justify-content: center; gap: 7px; padding: 14px 0 2px; min-height: 34px; }
.slide-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #252525; cursor: pointer; transition: all 0.22s; flex-shrink: 0;
}
.slide-dot.active { background: #f5c518; width: 22px; border-radius: 4px; }
.slide-dot:hover { background: #f5c51888; }

/* 캔버스 아래 컨트롤 */
.preview-controls {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0 2px; gap: 8px;
}
.candidate-tabs { display: flex; gap: 6px; }
.tab {
  padding: 6px 10px; border-radius: 20px; border: 1px solid #252525;
  background: transparent; color: #555; font-size: 12px; font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer; transition: all 0.2s; font-weight: 700;
}
.tab:hover { border-color: #f5c518; color: #f5c518; }
.tab.active { border-color: #f5c518; background: #1a1500; color: #f5c518; }

.nav-row { display: flex; align-items: center; gap: 10px; }
.card-counter { font-size: 13px; color: #666; font-weight: 700; min-width: 46px; text-align: center; }
.nav-btn {
  width: 38px; height: 38px; border-radius: 9px; border: 1px solid #252525;
  background: #0d0d0a; color: #777; font-size: 22px; cursor: pointer;
  transition: all 0.2s; display: flex; align-items: center; justify-content: center;
}
.nav-btn:not(:disabled):hover { border-color: #f5c518; color: #f5c518; background: #1a1500; }
.nav-btn:disabled { opacity: 0.2; cursor: not-allowed; }

.canvas-wrap {
  position: relative; width: 100%; aspect-ratio: 3/4;
  background: #0a0a0a; border-radius: 10px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
#cardCanvas { max-width: 100%; max-height: 100%; border-radius: 6px; display: none; }
.empty-state { text-align: center; color: #2a2a2a; font-size: 14px; line-height: 1.8; }

.loading {
  position: absolute; inset: 0; background: rgba(10,10,10,0.88);
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  display: none;
}
.loading.active { display: flex; }
.loading p { color: #ccc; font-size: 13px; font-weight: 700; }
.spinner {
  width: 32px; height: 32px;
  border: 3px solid #1e1e1e; border-top-color: #f5c518;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.action-row { display: flex; gap: 8px; margin-top: 14px; }
.action-row .btn { flex: 1; width: auto; }

/* 주제 칩 */
.topic-chips { margin-top: 12px; }
.chips-label { font-size: 10px; font-weight: 700; color: #3a3a3a; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 11px; border-radius: 20px; font-size: 11px; font-family: 'Noto Sans KR', sans-serif;
  border: 1px solid #252525; background: #0d0d0a; color: #777;
  cursor: pointer; transition: all 0.18s; white-space: nowrap;
}
.chip:hover { border-color: #f5c518; color: #f5c518; background: #1a1500; }

/* 이미지 패널 */
.img-panel { }
.img-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

/* AI 이미지 제안 */
.ai-suggest {
  background: #0d0d0a; border: 1px solid #252525; border-radius: 10px;
  padding: 16px; text-align: center;
}
.ai-suggest p { font-size: 13px; color: #aaa; margin-bottom: 12px; line-height: 1.6; }
.suggest-btns { display: flex; gap: 8px; }

.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.photo-thumb {
  aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; cursor: pointer;
  border: 2px solid transparent; transition: all 0.18s; width: 100%;
}
.photo-thumb:hover { border-color: #f5c51888; transform: scale(1.03); }
.photo-thumb.selected { border-color: #f5c518; box-shadow: 0 0 0 2px #f5c51844; }

.img-spinner {
  width: 16px; height: 16px;
  border: 2px solid #1e1e1e; border-top-color: #f5c518;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}

/* 캡션 패널 */
.caption-panel { }
.caption-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.caption-section { padding: 12px 0; border-bottom: 1px solid #1a1a1a; }
.caption-section:last-child { border-bottom: none; padding-bottom: 0; }
.caption-tag { font-size: 10px; font-weight: 700; color: #f5c518; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.caption-text { font-size: 13px; color: #bbb; line-height: 1.75; white-space: pre-wrap; word-break: break-all; }
.caption-text.hashtags { color: #f5c518; font-size: 12px; }

/* 히스토리 */
.btn-history {
  margin-top: 10px; padding: 7px 16px; border-radius: 20px;
  border: 1px solid #252525; background: transparent;
  color: #555; font-size: 12px; font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer; transition: all 0.2s; font-weight: 700;
}
.btn-history:hover { border-color: #f5c518; color: #f5c518; }
.btn-history.active { border-color: #f5c518; background: #1a1500; color: #f5c518; }

.history-panel {
  background: #111111; border: 1px solid #1e1e1e; border-radius: 14px;
  padding: 16px 20px; margin-bottom: 20px;
}
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.history-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.history-item {
  display: flex; align-items: center; gap: 12px;
  background: #0d0d0a; border: 1px solid #1e1e1e; border-radius: 10px;
  padding: 12px 14px; cursor: pointer; transition: all 0.18s;
}
.history-item:hover { border-color: #f5c518; background: #1a1500; }
.history-item-info { flex: 1; min-width: 0; }
.history-item-topic { font-size: 13px; font-weight: 700; color: #e8e8e0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item-meta { font-size: 11px; color: #555; margin-top: 3px; }
.history-item-del { background: none; border: none; color: #3a3a3a; font-size: 16px; cursor: pointer; padding: 4px; transition: color 0.15s; flex-shrink: 0; }
.history-item-del:hover { color: #f87171; }
.history-empty { text-align: center; color: #333; font-size: 13px; padding: 24px 0; }

/* 무료 이미지 검색 패널 */
.free-img-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.free-img-card-tag {
  font-size: 11px; font-weight: 700; color: #f5c518;
  background: #1a1500; border: 1px solid #f5c51844;
  border-radius: 20px; padding: 3px 10px;
}
.free-img-search-row { display: flex; gap: 8px; }
.free-img-search-row .input { flex: 1; }
.free-img-hint { font-size: 11px; color: #444; margin-top: 7px; }
.free-img-empty { font-size: 12px; color: #444; text-align: center; padding: 16px 0; }
.free-img-thumb {
  aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; cursor: pointer;
  border: 2px solid transparent; transition: all 0.18s; width: 100%;
}
.free-img-thumb:hover { border-color: #f5c51888; transform: scale(1.03); }
.free-img-thumb.active { border-color: #f5c518; box-shadow: 0 0 0 2px #f5c51844; }

/* 카드 편집 패널 */
.edit-panel {
  margin-top: 10px; padding: 14px 16px;
  background: #0d0d0a; border: 1px solid #f5c51844; border-radius: 10px;
}
.edit-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.edit-close-btn { background: none; border: none; color: #555; font-size: 15px; cursor: pointer; padding: 2px 6px; }
.edit-close-btn:hover { color: #f87171; }
.edit-field { margin-bottom: 10px; }
.edit-field:last-child { margin-bottom: 0; }
.edit-field-label { font-size: 10px; font-weight: 700; color: #555; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 5px; display: block; }
.edit-field .input, .edit-field .textarea { width: 100%; font-size: 13px; }
.edit-field .textarea { min-height: 70px; resize: vertical; }

.copy-img-panel {
  margin-top: 8px; padding: 12px 14px;
  background: #0d0d0a; border: 1px solid #252525; border-radius: 10px;
}
.copy-img-label { display: block; font-size: 11px; color: #555; margin-bottom: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.copy-img-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* 폰트 선택 */
.font-row { display: flex; gap: 6px; }
.font-btn {
  flex: 1; padding: 8px 4px; border-radius: 8px;
  border: 1px solid #252525; background: transparent;
  color: #555; font-size: 12px; font-family: 'Noto Sans KR', sans-serif; cursor: pointer;
  transition: all 0.2s;
}
.font-btn:hover { border-color: #f5c518; color: #f5c518; }
.font-btn.active { border-color: #f5c518; background: #1a1500; color: #f5c518; font-weight: 700; }

/* 편집 패널 — 텍스트 크기/색상/카드 조작 버튼 */
.edit-size-row, .edit-color-row, .edit-reorder-row {
  display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap;
}
.edit-size-btn, .edit-color-btn, .edit-reorder-btn, .edit-add-btn {
  flex: 1; padding: 7px 6px; border-radius: 7px;
  border: 1px solid #252525; background: transparent;
  color: #555; font-size: 11px; font-family: 'Noto Sans KR', sans-serif; cursor: pointer;
  transition: all 0.2s; white-space: nowrap;
}
.edit-size-btn:hover, .edit-color-btn:hover { border-color: #f5c518; color: #f5c518; }
.edit-size-btn.active, .edit-color-btn.active { border-color: #f5c518; background: #1a1500; color: #f5c518; font-weight: 700; }
.edit-reorder-btn { color: #888; }
.edit-reorder-btn:hover { border-color: #aaa; color: #e8e8e0; }
.edit-reorder-btn.del { color: #f87171; }
.edit-reorder-btn.del:hover { border-color: #f87171; background: #1a0808; }
.edit-add-btn { border-color: #f5c51844; color: #f5c518; background: #0d0d0a; margin-top: 4px; }
.edit-add-btn:hover { background: #1a1500; border-color: #f5c518; }
.edit-section-label { font-size: 10px; font-weight: 700; color: #555; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 5px; display: block; }

/* 주제 분석 패널 */
.analysis-panel { }
.analysis-content { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.analysis-row {
  background: #0d0d0a; border: 1px solid #1e1e1e; border-radius: 8px;
  padding: 10px 12px;
}
.analysis-row.full { grid-column: 1 / -1; }
.analysis-row-label { font-size: 10px; font-weight: 700; color: #555; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.analysis-row-value { font-size: 13px; color: #e8e8e0; font-weight: 700; }
.analysis-row-value.score { font-size: 22px; color: #f5c518; }

/* 해시태그 칩 */
.caption-text.hashtags { display: flex; flex-wrap: wrap; gap: 6px; white-space: normal; }
.hashtag-chip {
  display: inline-block; padding: 4px 10px; border-radius: 20px;
  border: 1px solid #f5c51866; background: #0d0d0a;
  color: #f5c518; font-size: 12px; cursor: pointer;
  transition: all 0.18s; user-select: none;
}
.hashtag-chip:hover { border-color: #f5c518; background: #1a1500; }
.hashtag-chip.copied { background: #f5c518; color: #000; border-color: #f5c518; }

/* 인스타그램 미리보기 모달 */
.insta-modal {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.88);
  display: flex; align-items: center; justify-content: center;
}
.insta-modal[hidden] { display: none; }
.insta-modal-inner {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 24px 16px; max-height: 100vh; overflow-y: auto;
}
.insta-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 390px;
}
.insta-modal-title { font-size: 15px; font-weight: 700; color: #e8e8e0; }
.insta-modal-close {
  background: none; border: none; color: #888; font-size: 20px; cursor: pointer; padding: 4px 8px;
  transition: color 0.15s;
}
.insta-modal-close:hover { color: #f87171; }
.insta-phone {
  max-width: 390px; width: 100%;
  background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 8px 48px rgba(0,0,0,0.7);
}
.insta-post-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid #f0f0f0;
}
.insta-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #f5c518, #ff8c00);
}
.insta-username { font-size: 13px; font-weight: 700; color: #111; font-family: sans-serif; }
.insta-card-scroll {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.insta-card-scroll::-webkit-scrollbar { display: none; }
.insta-card-scroll img {
  flex-shrink: 0; width: 100%; scroll-snap-align: start;
  display: block; object-fit: cover;
}
.insta-actions {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px; font-size: 14px; color: #111; font-family: sans-serif;
  border-top: 1px solid #f0f0f0;
}
.insta-dots-row { display: flex; justify-content: center; padding: 6px 0 10px; }
.insta-dots { display: flex; gap: 5px; }
.insta-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #ccc; transition: all 0.2s;
}
.insta-dot.active { background: #3797f0; width: 18px; border-radius: 3px; }

@media (max-width: 760px) {
  .main { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: repeat(3, 1fr); }
}
