:root {
  --bg: #0d1117;
  --bg-elevated: #161b22;
  --bg-card: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --green: #3fb950;
  --red: #f85149;
  --max-width: 980px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard",
               "Apple SD Gothic Neo", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4rem 1.5rem;
}

/* ---- Hero ---- */
.hero {
  background: linear-gradient(180deg, #1f2937 0%, var(--bg) 100%);
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.hero h1 {
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(90deg, #58a6ff 0%, #a371f7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 1rem;
}
.hero .lead {
  font-size: 1.4rem;
  color: var(--text);
  margin-bottom: 0.6rem;
}
.hero .sub {
  color: var(--text-dim);
  font-size: 1rem;
  max-width: 720px;
  margin: 0 auto 2rem;
}
.cta { margin-top: 2rem; }
.btn {
  display: inline-block;
  padding: 0.85rem 1.8rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  margin: 0 0.4rem;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; transform: translateY(-1px); }
.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: var(--bg-elevated); }

/* ---- Sections ---- */
h2 {
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
  letter-spacing: -0.01em;
}
h3 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}
section p { color: var(--text-dim); }
section p strong { color: var(--text); }

.note {
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
  padding: 0.8rem 1rem;
  margin: 1.5rem 0;
  border-radius: 0 4px 4px 0;
  font-size: 0.95rem;
}

/* ---- Feature grid ---- */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.4rem;
}

/* ---- Steps ---- */
.steps {
  list-style: none;
  counter-reset: step;
}
.steps li {
  counter-increment: step;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  margin-bottom: 0.7rem;
  position: relative;
  padding-left: 3.5rem;
  color: var(--text-dim);
}
.steps li strong { color: var(--text); }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 1rem;
  top: 1rem;
  width: 1.8rem;
  height: 1.8rem;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

/* ---- Interactive single-player (hot-swap variants) ---- */
.player-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.4rem;
  margin-top: 1rem;
}

/* Mode toggle (전체 믹스 / 보컬 stem) — segmented control 스타일 */
.mode-row {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 1rem;
  gap: 0;
}
.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 0.5rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 5px;
  transition: all 0.12s;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active {
  background: var(--accent);
  color: #fff;
}

/* 트랙 picker — 가로 스크롤 chip 행 (모바일에서 자연스러운 패턴) */
.track-picker {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.4rem;
  margin-bottom: 1rem;
  scroll-snap-type: x proximity;
}
.track-picker::-webkit-scrollbar { height: 4px; }
.track-picker::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.track-chip {
  flex: 0 0 auto;
  padding: 0.55rem 0.95rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: all 0.12s;
  scroll-snap-align: start;
}
.track-chip:hover { border-color: var(--accent); color: var(--text); }
.track-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.track-chip[data-kind="human"].active {
  background: var(--green);
  border-color: var(--green);
}

/* Track title + tag row */
.track-meta { margin-bottom: 1rem; }
.track-title-line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.05rem;
  font-weight: 600;
  flex-wrap: wrap;
}
.loading-indicator {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
}
.loading-indicator::before {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin-right: 0.5em;
  vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Transport: play button + seek bar + time */
.transport {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
}
.transport-btn {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}
.transport-btn:hover:not(:disabled) { background: var(--accent-hover); }
.transport-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#seek {
  flex: 1 1 auto;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-elevated);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
#seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
  cursor: pointer;
}
#seek::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
  cursor: pointer;
}
.time-display {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--text-dim);
  min-width: 5.5em;
  text-align: right;
}

/* Variant section — wet / diff 그룹 분리 */
.variant-section { margin-top: 0.9rem; }
.variant-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

/* (기존 .track-card는 무사 — 다른 곳에 안 쓰임, 안전하게 유지) */
.track-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.2rem;
  margin-bottom: 1.5rem;
}
.track-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.track-title {
  font-weight: 600;
  font-size: 1.1rem;
}
.track-tag {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.15rem 0.7rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.track-tag.ai { background: #3a1d3d; color: #d2a8ff; border-color: #6e3a87; }
.track-tag.human { background: #1d3a2c; color: #79c87f; border-color: #2d5b3e; }
.variant-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}
.variant-btn {
  flex: 1 1 auto;
  min-width: 100px;
  padding: 0.5rem 0.8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s;
}
.variant-btn:hover { border-color: var(--accent); }
.variant-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.variant-btn[data-kind="diff"] {
  border-style: dashed;
  font-style: italic;
  color: var(--text-dim);
}
.variant-btn[data-kind="diff"].active {
  background: #6e3a87;
  border-color: #a371f7;
  color: #fff;
}
audio {
  width: 100%;
  margin-top: 0.4rem;
  filter: invert(0.85) hue-rotate(180deg);
}
.gain-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.8rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.gain-row input[type=range] {
  flex: 1;
  accent-color: var(--accent);
}

/* ---- Trial form ---- */
.trial-section {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 0;
  padding-top: 4rem;
  padding-bottom: 4rem;
  max-width: none;
}
.trial-section > * { max-width: var(--max-width); margin-left: auto; margin-right: auto; }
#trial-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem 1rem;
  max-width: 600px;
  margin: 1.5rem auto;
}
#trial-form label {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: -0.3rem;
}
#trial-form input,
#trial-form select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.65rem 0.8rem;
  color: var(--text);
  font: inherit;
  width: 100%;
}
#trial-form input:focus,
#trial-form select:focus {
  outline: none;
  border-color: var(--accent);
}
#trial-form button {
  grid-column: 1 / -1;
  margin-top: 0.5rem;
}
.trial-result {
  max-width: 600px;
  margin: 1rem auto;
  padding: 1rem 1.2rem;
  border-radius: 6px;
  font-size: 0.95rem;
}
.trial-result.success {
  background: #1d3a2c;
  border: 1px solid #2d5b3e;
  color: #79c87f;
}
.trial-result.error {
  background: #3a1d1d;
  border: 1px solid #5b2d2d;
  color: #ff7b72;
}
.hidden { display: none; }
.small {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 1rem;
}
kbd {
  display: inline-block;
  padding: 0.1em 0.4em;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.78em;
  color: var(--text);
  margin: 0 0.15em;
}

/* ---- Footer ---- */
footer {
  text-align: center;
  color: var(--text-dim);
  padding: 2rem 1.5rem;
  font-size: 0.9rem;
}

/* iOS Safari가 16px 미만 input에 zoom 적용. 16px 명시로 zoom 방지. */
input,
select,
textarea,
button {
  font-size: 16px;
}

/* Tap highlight + selection 톤 정리 (회색 박스 → accent 톤). */
* { -webkit-tap-highlight-color: rgba(88, 166, 255, 0.18); }
::selection { background: rgba(88, 166, 255, 0.35); color: #fff; }

/* anchor 점프 시 hero 위로 너무 붙는 거 방지. */
html { scroll-padding-top: 1rem; }

/* iOS Safari 100vh 버그 회피 — hero에서 100vh 안 씀. body에 큰 영향 없음. */

/* 태블릿 (1024px ↓): hero 약간 축소. */
@media (max-width: 1024px) {
  .hero h1 { font-size: 3rem; }
  .hero .lead { font-size: 1.25rem; }
  .container { padding: 3.5rem 1.25rem; }
}

/* 모바일 (768px ↓): variant 버튼을 2-column grid로, audio 컨트롤
   원복 (filter invert는 iOS에서 시각 깨짐), hero 더 축소. */
@media (max-width: 768px) {
  .hero h1 { font-size: 2.2rem; line-height: 1.1; }
  .hero .lead { font-size: 1.05rem; }
  .hero .sub { font-size: 0.95rem; padding: 0 0.5rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.05rem; }
  .container { padding: 2.5rem 1rem; }

  .cta { display: flex; flex-direction: column; gap: 0.6rem; }
  .cta .btn { margin: 0; width: 100%; }

  /* variant 버튼: 2열 grid + 더 큰 tap target (Apple HIG 44px) */
  .variant-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  .variant-btn {
    min-height: 44px;
    min-width: 0;        /* grid가 폭 결정, min-width 무효화 */
    padding: 0.7rem 0.5rem;
    font-size: 0.95rem;
  }

  /* audio: dark filter 제거 — iOS Safari에서 컨트롤 색 깨짐 */
  audio { filter: none; }

  /* track header: title + tag 줄바꿈 시 깔끔하게 */
  .track-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  /* hero CTA 영역 */
  .hero { padding-top: 1rem; }

  #trial-form { grid-template-columns: 1fr; }
  .trial-section { padding: 3rem 1rem; }

  .steps li { padding: 0.85rem 1rem 0.85rem 3rem; font-size: 0.95rem; }
  .steps li::before { left: 0.7rem; top: 0.85rem; }

  .grid-3 { gap: 0.7rem; }
  .card { padding: 1.1rem; }
}

/* 작은 모바일 (380px ↓, iPhone SE 등): 한층 더 축소. */
@media (max-width: 380px) {
  .hero h1 { font-size: 1.85rem; }
  .hero .lead { font-size: 0.98rem; }
  .variant-row { grid-template-columns: 1fr; }   /* 1열, 가독성 우선 */
}

/* 가로 모드 + 짧은 화면 (landscape phone): hero 컴팩트 */
@media (max-height: 480px) and (orientation: landscape) {
  .hero { padding-top: 1.5rem; }
  .hero h1 { font-size: 2rem; }
  .container { padding: 2.5rem 1rem; }
}

/* prefers-reduced-motion: 호버 transform 제거 */
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .btn:hover { transform: none; }
  html { scroll-behavior: auto; }
}
