/* genplaylist — dugudugu 에디토리얼 디자인 언어 × 모바일 앱 플로우 */

:root {
  --paper: #fbfaf6; /* dugudugu Color(0.984, 0.980, 0.965) */
  --paper-elevated: #ffffff;
  --soft-fill: #f7f5f0;
  --ink: #171714; /* Color(0.09, 0.09, 0.08) */
  --muted-ink: #63615a; /* Color(0.39, 0.38, 0.35) */
  --hairline: #e0dbd1; /* Color(0.88, 0.86, 0.82) */
  --ok: #3d7a4a;
  --err: #a63b32;
  --miss: #9a7328;
  --melon: #00cd3c;
  --apple: #fa2d48;
  --spotify: #1db954;
  --serif: 'Noto Serif KR', 'Apple SD Gothic Neo', serif;
  --sans: 'Noto Sans KR', -apple-system, 'Apple SD Gothic Neo', sans-serif;
}

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

html {
  height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
  word-break: keep-all; /* 한국어 어절 단위 줄바꿈 */
}

/* ---------- 상단 바 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}

.wordmark {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-toggle {
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  color: var(--muted-ink);
  font-family: var(--sans);
  letter-spacing: 0.03em;
}

.lang-toggle:hover {
  border-color: var(--ink);
  color: var(--ink);
}

#acct-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.8rem;
  color: var(--muted-ink);
  font-family: var(--sans);
}

#acct-toggle .dot {
  width: 6px;
  height: 6px;
}

/* ---------- 계정 패널 ---------- */
.acct-panel {
  position: sticky;
  top: 53px;
  z-index: 19;
  background: var(--paper-elevated);
  border-bottom: 1px solid var(--hairline);
  padding: 10px 20px 14px;
  box-shadow: 0 8px 20px rgba(23, 23, 20, 0.06);
}

.acct-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  max-width: 500px;
  margin: 0 auto;
}

.acct-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  font-weight: 500;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid var(--muted-ink);
  background: transparent;
  display: inline-block;
  flex-shrink: 0;
}

.acct-row.connected .dot,
.dot.on {
  background: var(--ok);
  border-color: var(--ok);
}

.acct-btn {
  background: transparent;
  color: var(--muted-ink);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 6px 18px;
  font-size: 0.82rem;
  font-family: var(--sans);
}

.acct-row.connected .acct-btn {
  color: var(--err);
}

.acct-note {
  font-size: 0.76rem;
  color: var(--muted-ink);
  max-width: 500px;
  margin: 4px auto 0;
}

/* ---------- 화면(스텝) ---------- */
main {
  max-width: 540px;
  margin: 0 auto;
  padding: 28px 20px 130px; /* 하단 고정 바 공간 */
}

.screen {
  animation: rise 0.25s ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.kicker {
  font-family: var(--serif);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted-ink);
}

h2 {
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 6px 0 8px;
}

.lede {
  font-family: var(--serif);
  color: var(--muted-ink);
  font-size: 0.92rem;
  margin-bottom: 22px;
}

.back-btn {
  background: transparent;
  color: var(--muted-ink);
  font-size: 0.85rem;
  padding: 0 0 14px;
  font-family: var(--sans);
}

/* ---------- 하단 고정 CTA ---------- */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 15;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 65%, transparent);
}

.bottom-bar .primary {
  max-width: 500px;
  margin: 0 auto;
  display: block;
}

/* ---------- 입력 모드 탭 ---------- */
.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 3px;
  background: var(--paper-elevated);
  margin-bottom: 16px;
}

.mode-tab {
  padding: 9px 0;
  background: transparent;
  color: var(--muted-ink);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
}

.mode-tab.active {
  background: var(--ink);
  color: var(--paper);
}

.mode-panel textarea,
.mode-panel > input {
  margin-bottom: 2px;
}

/* ---------- 입력 ---------- */
.drop-zone {
  border: 1px dashed var(--hairline);
  background: var(--soft-fill);
  border-radius: 6px;
  padding: 44px 16px;
  text-align: center;
  color: var(--muted-ink);
  font-family: var(--serif);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone.over {
  border-color: var(--ink);
  background: var(--paper-elevated);
}

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.thumb {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--hairline);
  background: var(--paper-elevated);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-del {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(23, 23, 20, 0.75);
  color: var(--paper);
  font-size: 10px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb-no {
  position: absolute;
  left: 4px;
  bottom: 3px;
  font-size: 0.68rem;
  color: var(--paper);
  background: rgba(23, 23, 20, 0.6);
  border-radius: 4px;
  padding: 1px 5px;
}

.thumb-add {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-ink);
  font-size: 1.3rem;
  border-style: dashed;
  cursor: pointer;
}

.drop-zone small {
  font-size: 0.8rem;
}

.drop-zone img {
  max-width: 100%;
  max-height: 46vh;
  border-radius: 3px;
  box-shadow: 0 2px 14px rgba(23, 23, 20, 0.14);
}

.alt-input {
  margin-top: 14px;
  color: var(--muted-ink);
  font-size: 0.86rem;
}

.alt-input summary {
  cursor: pointer;
}

.alt-input textarea {
  margin-top: 10px;
}

textarea,
input:not([type='checkbox']) {
  width: 100%;
  background: var(--paper-elevated);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 12px 13px;
  font-size: 16px; /* iOS 줌 방지 */
  font-family: var(--sans);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.field-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted-ink);
  margin: 14px 0 6px;
}

#playlist-name {
  margin-bottom: 12px;
  font-family: var(--serif);
}

/* ---------- 버튼 공통 ---------- */
button {
  font-family: var(--sans);
  font-size: 16px;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.05s, background 0.15s;
}

button:active {
  transform: scale(0.99);
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

.primary {
  width: 100%;
  padding: 16px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
  border-radius: 4px;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 14px rgba(23, 23, 20, 0.18);
}

.primary:hover:not(:disabled) {
  opacity: 0.88;
}

.ghost {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  background: transparent;
  color: var(--muted-ink);
  border: 1px dashed var(--hairline);
  border-radius: 4px;
  font-size: 0.9rem;
}

/* ---------- ② 곡 목록 (매거진 목차 스타일) ---------- */
.track-row {
  display: grid;
  grid-template-columns: 34px 1fr 40px;
  gap: 8px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--hairline);
}

.track-no {
  font-family: var(--serif);
  font-size: 0.85rem;
  color: var(--muted-ink);
}

.track-fields {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.track-row input {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 2px 0;
}

.track-row .t-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1rem;
}

.track-row .t-artist {
  font-size: 0.85rem;
  color: var(--muted-ink);
}

.track-row input:focus {
  outline: none;
  box-shadow: 0 1px 0 var(--ink);
}

.t-del {
  background: transparent;
  color: var(--muted-ink);
  font-size: 14px;
  padding: 10px;
}

/* ---------- ③ 이름 제안 ---------- */
.name-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 6px;
}

.chips-tag {
  width: 100%;
  font-family: var(--serif);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--muted-ink);
}

.name-chip {
  background: var(--paper-elevated);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 8px 15px;
  font-family: var(--serif);
  font-size: 0.87rem;
}

.name-chip.picked {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* ---------- 플레이리스트 미리보기 카드 ---------- */
.pl-preview {
  display: flex;
  gap: 16px;
  background: var(--paper-elevated);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 16px;
  margin: 18px 0 10px;
  box-shadow: 0 1px 10px rgba(23, 23, 20, 0.05);
}

.pl-cover {
  position: relative;
  width: 128px;
  height: 128px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--soft-fill);
  border: 1px solid var(--hairline);
}

.pl-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 커버 생성 중: 오로라 애니메이션 */
.pl-cover-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #14131a;
}

.aurora {
  position: absolute;
  width: 120%;
  height: 120%;
  border-radius: 50%;
  filter: blur(16px);
  opacity: 0.75;
  mix-blend-mode: screen;
}

.aurora.a1 {
  background: radial-gradient(circle at 35% 35%, #00de2d 0%, transparent 60%);
  animation: drift1 5s ease-in-out infinite alternate;
}

.aurora.a2 {
  background: radial-gradient(circle at 65% 45%, #fa2d48 0%, transparent 55%);
  animation: drift2 6.5s ease-in-out infinite alternate;
}

.aurora.a3 {
  background: radial-gradient(circle at 50% 75%, #4a6cff 0%, transparent 55%);
  animation: drift3 7.5s ease-in-out infinite alternate;
}

.aurora.a4 {
  background: conic-gradient(from 0deg, transparent 60%, rgba(251, 250, 246, 0.35) 78%, transparent 90%);
  filter: blur(6px);
  border-radius: 0;
  animation: sweep 3.2s linear infinite;
}

@keyframes drift1 {
  from {
    transform: translate(-18%, -14%) scale(1);
  }
  to {
    transform: translate(14%, 10%) scale(1.35);
  }
}

@keyframes drift2 {
  from {
    transform: translate(16%, -10%) scale(1.25) rotate(0deg);
  }
  to {
    transform: translate(-12%, 14%) scale(0.95) rotate(40deg);
  }
}

@keyframes drift3 {
  from {
    transform: translate(-8%, 16%) scale(1.1);
  }
  to {
    transform: translate(10%, -14%) scale(1.4);
  }
}

@keyframes sweep {
  to {
    transform: rotate(360deg);
  }
}

.cover-loading-text {
  position: relative;
  z-index: 1;
  font-family: var(--serif);
  font-size: 0.72rem;
  line-height: 1.5;
  text-align: center;
  color: #fbfaf6;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
  animation: breathe 2.4s ease-in-out infinite;
}

.pl-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.pv-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.pv-count {
  font-size: 0.78rem;
  color: var(--muted-ink);
  margin: 2px 0 8px;
}

.pv-tracks {
  list-style: none;
  font-size: 0.8rem;
  overflow: hidden;
}

.pv-tracks li {
  display: flex;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.55;
}

.pv-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.pv-artist {
  color: var(--muted-ink);
  flex-shrink: 0;
}

.pv-more {
  color: var(--muted-ink);
}

.cover-actions {
  display: flex;
  gap: 8px;
}

.cover-download {
  background: transparent;
  color: var(--muted-ink);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 0.82rem;
}

.cover-download:hover {
  border-color: var(--ink);
  color: var(--ink);
}

/* ---------- ③ 서비스 선택 (행 리스트) ---------- */
.svc-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 22px;
}

.gen-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  background: var(--paper-elevated);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  text-align: left;
}

.gen-btn:hover:not(:disabled) {
  border-color: var(--ink);
}

.svc-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  flex-shrink: 0;
  object-fit: contain;
}

.svc-label {
  display: flex;
  flex-direction: column;
  flex: 1;
  font-weight: 500;
  line-height: 1.35;
}

.svc-label small {
  font-weight: 400;
  font-size: 0.76rem;
  color: var(--muted-ink);
}

.chev {
  color: var(--muted-ink);
  font-size: 1.2rem;
}

.hint {
  color: var(--muted-ink);
  font-size: 0.8rem;
  margin-top: 12px;
}

/* ---------- 결과 바텀 시트 ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(23, 23, 20, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: 100%;
  max-width: 540px;
  max-height: 78vh;
  overflow-y: auto;
  background: var(--paper);
  border-radius: 14px 14px 0 0;
  padding: 10px 24px calc(28px + env(safe-area-inset-bottom));
  animation: slideup 0.28s cubic-bezier(0.2, 0.8, 0.3, 1);
  box-shadow: 0 -8px 40px rgba(23, 23, 20, 0.2);
}

@keyframes slideup {
  from {
    transform: translateY(40%);
    opacity: 0.5;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--hairline);
  margin: 4px auto 18px;
}

.result h3 {
  font-family: var(--serif);
  font-weight: 600;
  margin-bottom: 10px;
}

.result a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  word-break: break-all;
}

.result .melon-open,
.result .open-btn {
  display: inline-block;
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
  padding: 13px 22px;
  border-radius: 4px;
  text-decoration: none;
  margin: 8px 8px 8px 0;
  transition: opacity 0.15s;
}

.result .melon-open:active,
.result .open-btn:active {
  opacity: 0.8;
}

.result .open-btn::after {
  content: ' ↗';
  opacity: 0.7;
}

.melon-qrs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 10px 0;
}

.melon-qrs canvas {
  border: 1px solid var(--hairline);
  border-radius: 3px;
  background: #fff;
  padding: 5px;
}

.qr-tag {
  font-size: 0.8rem;
  color: var(--muted-ink);
}

.result ul {
  list-style: none;
  font-size: 0.86rem;
  color: var(--muted-ink);
  margin: 4px 0 12px;
}

.result pre {
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.8rem;
  color: var(--muted-ink);
}

.result p.ok,
.result p.miss {
  font-weight: 500;
  font-size: 0.88rem;
}

.ok {
  color: var(--ok);
}

.err {
  color: var(--err);
}

.miss {
  color: var(--miss);
}

.version-tag {
  margin-top: 10px;
  font-family: var(--serif);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--hairline);
}

.site-footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
  font-size: 0.78rem;
  color: var(--muted-ink);
  line-height: 1.7;
}

/* ---------- 로딩 ---------- */
.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  margin-right: 9px;
  animation: spin 0.8s linear infinite;
  opacity: 0.9;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 버튼 로딩 상태: 은은한 숨쉬기 */
button.loading {
  animation: breathe 1.8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes breathe {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.72;
  }
}

/* 시트 로딩: 스피너 + 세리프 문구 */
.sheet-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 4px;
}

.sheet-loading .spinner {
  width: 18px;
  height: 18px;
  margin: 0;
  color: var(--ink);
}

.sheet-loading p {
  font-family: var(--serif);
  font-size: 1rem;
}

.sheet-loading small {
  display: block;
  color: var(--muted-ink);
  font-family: var(--sans);
  font-size: 0.78rem;
}

.hidden {
  display: none !important;
}
