:root {
  --bg: #FFFFFF;                                /* 순백 */
  --surface: #FFFFFF;
  --frame-bg: #1F2533;                          /* 살짝 따뜻한 네이비 */
  --text: #2A3349;
  --text-soft: #5C6680;
  --muted: #A0AAC2;
  --line: #EBEEF3;                              /* 중성 라이트 그레이 */

  --accent: #A8C8E8;                            /* 파스텔 블루 (메인) */
  --accent-dark: #6B9BC8;                       /* 진한 블루 (텍스트/호버) */
  --accent-soft: rgba(168, 200, 232, 0.22);
  --accent-glow: rgba(168, 200, 232, 0.50);

  --yellow: #FFE49C;                            /* 파스텔 옐로우 (서브 포인트) */
  --yellow-dark: #D9A82E;                       /* 머스터드 (텍스트) */
  --yellow-soft: rgba(255, 228, 156, 0.35);
  --yellow-glow: rgba(255, 228, 156, 0.55);

  --danger: #F5A5A5;                            /* 파스텔 코랄 */

  --shadow-canvas: 0 28px 70px rgba(42, 51, 73, 0.14), 0 12px 28px rgba(42, 51, 73, 0.07);
  --shadow-button: 0 6px 16px rgba(168, 200, 232, 0.32);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;   /* 모바일 회색 탭 하이라이트 제거 */
}

html, body {
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Apple SD Gothic Neo',
               'Pretendard', 'Inter', 'Helvetica Neue', sans-serif;
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;                  /* iOS 고무줄 스크롤 방지 */
}

body {
  overflow-x: hidden;
}

.stage {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 48px 32px 64px;
}

/* --- Header / Title --- */

.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: -4px;
}

.title {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text);
  line-height: 1;
}

.subtitle {
  font-size: 11px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--accent-dark);
  font-weight: 700;
}

/* --- Canvas Frame --- */

.frame {
  position: relative;
  width: min(70vmin, 620px);
  height: min(70vmin, 620px);
  background: var(--frame-bg);
  border-radius: 32px;
  overflow: hidden;
  box-shadow: var(--shadow-canvas);
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;                /* 길게 눌렀을 때 컨텍스트 메뉴 차단 */
  touch-action: none;                         /* 미디어 로드 후: 페이지 스크롤 차단 */
}

#canvas.dragging { cursor: grabbing; }
#canvas.empty {
  cursor: pointer;
  touch-action: auto;                         /* 빈 캔버스: 페이지 스크롤은 통과시킴 */
}

.hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 16px;
  letter-spacing: 0.1em;
  font-weight: 700;
  pointer-events: none;
  user-select: none;
}

.hint.hide { display: none; }

/* --- Controls --- */

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  width: min(70vmin, 620px);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 22px;
  width: 100%;
}

.label {
  min-width: 64px;
  color: var(--text-soft);
  font-size: 15px;
  letter-spacing: 0.04em;
  font-weight: 800;
}

.value {
  min-width: 64px;
  text-align: right;
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  letter-spacing: 0.04em;
  font-weight: 800;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  border: 4px solid var(--surface);
  /* 블루 thumb + 옐로우 halo로 두 톤 자연스럽게 믹스 */
  box-shadow: 0 0 0 2px var(--yellow-soft), 0 4px 14px var(--yellow-glow);
  cursor: pointer;
  transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.08);
}

input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  border: 4px solid var(--surface);
  box-shadow: 0 0 0 2px var(--yellow-soft), 0 4px 14px var(--yellow-glow);
  cursor: pointer;
}

.hint-row {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
  margin-top: 2px;
}

/* --- Buttons --- */

.buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 6px;
}

.btn {
  background: var(--surface);
  border: 2px solid var(--line);
  color: var(--text);
  padding: 14px 28px;
  font-size: 14px;
  letter-spacing: 0.04em;
  font-weight: 800;
  font-family: inherit;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s, border-color 0.2s, color 0.2s, background 0.2s;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 22px var(--accent-soft);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

/* primary: upload + play */
.upload-btn,
#play {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

.upload-btn:hover,
#play:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #FFFFFF;
  box-shadow: var(--shadow-button);
}

/* social: 공유 — 옐로우 포인트로 눈에 띄게 */
#share {
  background: var(--yellow);
  border-color: var(--yellow);
  color: var(--yellow-dark);
}

#share:hover:not(:disabled) {
  background: var(--yellow-dark);
  border-color: var(--yellow-dark);
  color: #FFFFFF;
  box-shadow: 0 8px 22px var(--yellow-glow);
}

/* file input은 시각적으로만 숨김 — 모바일 호환성 위해 display:none 안 씀 */
.upload-btn { position: relative; overflow: hidden; }
.upload-btn input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  clip: rect(0 0 0 0);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.hide { display: none !important; }

/* recording state */
.btn.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: #FFFFFF;
  animation: pulse 1.1s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 165, 165, 0.6); }
  50%      { box-shadow: 0 0 0 14px rgba(245, 165, 165, 0); }
}

/* --- Drop Overlay --- */

.drop-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at center, rgba(255, 228, 156, 0.55) 0%, rgba(255, 228, 156, 0) 55%),
    rgba(168, 200, 232, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s;
  z-index: 10;
  backdrop-filter: blur(6px);
}

.drop-overlay.active { opacity: 1; }

.drop-overlay span {
  font-size: 22px;
  letter-spacing: 0.08em;
  color: #FFFFFF;
  font-weight: 800;
}

/* --- Responsive --- */

@media (max-width: 720px) {
  .stage { padding: 28px 18px 56px; gap: 28px; }
  .title { font-size: 34px; }
  .frame { border-radius: 24px; }
  .slider-row { gap: 14px; }
  .label { min-width: 52px; font-size: 14px; }
  .value { min-width: 56px; font-size: 13px; }

  /* 모바일 터치 타깃: Apple HIG 권장 44px 이상으로 */
  .btn {
    padding: 18px 26px;
    font-size: 15px;
    min-height: 54px;
    border-radius: 999px;
  }
  .buttons { gap: 12px; width: 100%; }

  /* 슬라이더 thumb도 손가락 친화적으로 */
  input[type="range"] { height: 10px; }
  input[type="range"]::-webkit-slider-thumb { width: 30px; height: 30px; }
  input[type="range"]::-moz-range-thumb     { width: 30px; height: 30px; }

  .hint { font-size: 14px; }
  .hint-row { font-size: 12px; }
  .drop-overlay span { font-size: 18px; }
}
