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

body {
  min-height: 100vh;
  background: linear-gradient(135deg, #e8d5f5 0%, #d4e8ff 50%, #f5d4e8 100%);
  font-family: 'Segoe UI', sans-serif;
  color: #4a4060;
  display: flex;
  flex-direction: column;
}

/* ── 헤더 ── */
header {
  text-align: center;
  padding: 28px 0 12px;
}
header h1 {
  font-size: 1.5rem;
  font-weight: 300;
  letter-spacing: 0.2em;
  color: #7b6fa0;
}
header h1 span { color: #c9a0dc; }
header p {
  font-size: 0.78rem;
  color: #a090c0;
  margin-top: 4px;
  letter-spacing: 0.1em;
}

/* ── 메인 레이아웃 ── */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 24px 32px;
}

/* ── 카드 ── */
.card {
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(180,160,220,0.18);
}

/* ── 왼쪽: 업로드 ── */
.upload-card { display: flex; flex-direction: column; gap: 14px; }

/* 입력 탭 */
.input-tabs {
  display: flex;
  gap: 6px;
}
.tab-btn {
  flex: 1;
  padding: 6px 0;
  border: 1px solid rgba(180,150,220,0.4);
  border-radius: 10px;
  background: transparent;
  color: #a090c0;
  font-size: 0.75rem;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: all 0.2s;
}
.tab-btn.active {
  background: rgba(201,160,220,0.18);
  border-color: #c9a0dc;
  color: #7b6fa0;
  font-weight: 600;
}

/* 드롭존 */
#drop-zone {
  min-height: 200px;
  border: 2px dashed rgba(180,150,220,0.5);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}
#drop-zone:hover, #drop-zone.drag-over {
  border-color: #c9a0dc;
  background: rgba(201,160,220,0.08);
}
#drop-zone .icon { font-size: 2.4rem; opacity: 0.5; }
#drop-zone .hint {
  font-size: 0.82rem;
  color: #a090c0;
  text-align: center;
  line-height: 1.6;
}
#drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* 미리보기 — 클릭하면 재업로드 */
#preview-wrap {
  display: none;
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: #f0eaff;
  cursor: pointer;
}
#preview-wrap::after {
  content: '🔄 클릭해서 바꾸기';
  position: absolute;
  inset: 0;
  background: rgba(120,100,180,0.0);
  color: white;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.25s;
}
#preview-wrap:hover::after {
  background: rgba(120,100,180,0.45);
  opacity: 1;
}
#preview-wrap img {
  width: 100%;
  object-fit: contain;
  max-height: 280px;
  display: block;
}
/* 숨겨진 재업로드 input */
#reupload-input {
  display: none;
}

/* URL 입력 패널 */
#url-panel {
  display: none;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  border: 2px dashed rgba(180,150,220,0.5);
  border-radius: 18px;
  padding: 20px;
  align-items: center;
  justify-content: center;
}
.url-input-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.url-input-wrap label {
  font-size: 0.75rem;
  color: #a090c0;
  letter-spacing: 0.08em;
}
#url-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid rgba(180,150,220,0.4);
  border-radius: 12px;
  background: rgba(255,255,255,0.6);
  font-size: 0.82rem;
  color: #4a4060;
  outline: none;
  transition: border-color 0.2s;
}
#url-input:focus { border-color: #c9a0dc; }
#url-input::placeholder { color: #c0b0d8; }

/* URL 미리보기 */
#url-preview-wrap {
  display: none;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #f0eaff;
}
#url-preview-img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  display: block;
}

/* 슬라이더 */
.sliders { display: flex; flex-direction: column; gap: 8px; }
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: #8878a8;
}
.slider-row label { width: 120px; white-space: nowrap; }
.slider-row input[type=range] { flex: 1; accent-color: #c9a0dc; height: 4px; }
.slider-row .val { width: 32px; text-align: right; font-weight: 600; color: #7b6fa0; }

/* 분석 버튼 */
#analyze-btn {
  background: linear-gradient(135deg, #c9a0dc, #a0b8f0);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 13px;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}
#analyze-btn:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
#analyze-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── 오른쪽: 결과 ── */
.result-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  max-height: calc(100vh - 160px);
}

#result-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  opacity: 0.4;
}
#result-placeholder .big-icon { font-size: 2.8rem; }
#result-placeholder p { font-size: 0.82rem; color: #a090c0; text-align: center; }

#loading {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 14px;
}
.spinner { font-size: 2rem; animation: spin 1.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#loading p { font-size: 0.82rem; color: #a090c0; }

#result-content { display: none; flex-direction: column; gap: 14px; }

/* rating */
.rating-row { display: flex; gap: 8px; flex-wrap: wrap; }
.rating-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.73rem;
  letter-spacing: 0.06em;
  font-weight: 600;
  opacity: 0.3;
  transition: opacity 0.3s;
}
.rating-badge.active { opacity: 1; }
.rating-badge.general     { background: #d4f5d4; color: #3a7a3a; }
.rating-badge.sensitive   { background: #fff3d4; color: #8a6a20; }
.rating-badge.questionable{ background: #ffd4d4; color: #8a3030; }
.rating-badge.explicit    { background: #f5d4f5; color: #7a307a; }

/* 태그 섹션 */
.tag-section { display: flex; flex-direction: column; gap: 5px; }
.tag-section-title {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #b0a0d0;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(180,160,220,0.2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tag-section-title .cat-icon { font-size: 0.85rem; }

.tag-row {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeUp 0.3s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tag-name {
  width: 150px;
  font-size: 0.79rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag-name a {
  color: #5a4880;
  text-decoration: none;
  transition: color 0.15s;
}
.tag-name a:hover { color: #c9a0dc; text-decoration: underline; }

.tag-bar-wrap {
  flex: 1;
  height: 6px;
  background: rgba(180,160,220,0.15);
  border-radius: 4px;
  overflow: hidden;
}
.tag-bar {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #c9a0dc, #a0b8f0);
  transition: width 0.6s ease;
}

.tag-pct {
  font-size: 0.72rem;
  color: #9080b0;
  width: 36px;
  text-align: right;
}
.tag-count {
  font-size: 0.65rem;
  color: #b8aad0;
  width: 52px;
  text-align: right;
  white-space: nowrap;
}

/* 작가 추천 */
.artist-section { display: flex; flex-direction: column; gap: 6px; }
.artist-loading {
  font-size: 0.75rem;
  color: #b0a0c8;
  display: flex;
  align-items: center;
  gap: 6px;
}
.artist-loading .mini-spin {
  display: inline-block;
  animation: spin 1.2s linear infinite;
}
.artist-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.artist-chip {
  padding: 4px 10px;
  background: rgba(160,184,240,0.18);
  border: 1px solid rgba(160,184,240,0.4);
  border-radius: 20px;
  font-size: 0.73rem;
  color: #6070a0;
  text-decoration: none;
  transition: background 0.2s;
  cursor: pointer;
}
.artist-chip:hover { background: rgba(160,184,240,0.35); }
.artist-chip .chip-count {
  font-size: 0.65rem;
  color: #9090b8;
  margin-left: 4px;
}

.elapsed {
  font-size: 0.7rem;
  color: #b0a0c8;
  text-align: right;
}

/* ── 반응형 ── */
@media (max-width: 660px) {
  main { grid-template-columns: 1fr; }
  .result-card { max-height: none; }
}
