:root {
  --h: 140; /* 테마 색상(hue). app.js 가 사용자가 고른 값으로 바꾼다 */
  --bg: hsl(var(--h) 35% 96%);
  --card: #ffffff;
  --ink: hsl(var(--h) 35% 11%);
  --muted: hsl(var(--h) 10% 42%);
  --line: hsl(var(--h) 30% 87%);
  --accent: hsl(var(--h) 72% 36%);
  --accent-strong: hsl(var(--h) 78% 27%);
  --accent-soft: hsl(var(--h) 32% 79%);
  --accent-tint: hsl(var(--h) 45% 92%);
  --on-accent: #fff;
  --danger: #c0392b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: hsl(var(--h) 28% 6%);
    --card: hsl(var(--h) 26% 10%);
    --ink: hsl(var(--h) 35% 93%);
    --muted: hsl(var(--h) 12% 60%);
    --line: hsl(var(--h) 24% 18%);
    --accent: hsl(var(--h) 63% 50%);
    --accent-strong: hsl(var(--h) 68% 64%);
    --accent-soft: hsl(var(--h) 26% 24%);
    --accent-tint: hsl(var(--h) 35% 14%);
    --on-accent: hsl(var(--h) 60% 7%);
    --danger: #ff7b6b;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  min-height: 100vh;
}
[hidden] { display: none !important; }
.wrap { max-width: 760px; margin: 0 auto; padding: 32px 16px 96px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 28px; }
.logo { font-size: 22px; margin: 0; letter-spacing: -0.02em; }
.logo a { color: var(--accent); text-decoration: none; font-weight: 800; }
.logo a::before { content: "▮▮▯ "; font-size: 14px; letter-spacing: -2px; vertical-align: 2px; }
.nav { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.link { font: inherit; color: var(--accent-strong); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
h2 { font-size: 16px; margin: 32px 0 12px; }

/* 버튼 */
.btn {
  font: inherit; font-size: 14px; text-decoration: none; cursor: pointer;
  color: var(--accent-strong); background: var(--accent-tint); border: 1px solid transparent;
  border-radius: 99px; padding: 7px 16px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--danger); background: none; border-color: var(--line); }
.btn:disabled { opacity: .6; cursor: default; }
.error { color: var(--danger); margin: 12px 0 0; min-height: 1.5em; }

/* 업로드 */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 240px; text-align: center; cursor: pointer;
  border: 2px dashed var(--accent-soft); border-radius: 16px; background: var(--card);
  transition: background .15s, border-color .15s;
  padding: 24px;
}
.drop:hover, .drop.over, .drop:focus-visible { background: var(--accent-tint); border-color: var(--accent); outline: none; }
.drop strong { font-size: 20px; }
.drop.busy { cursor: default; pointer-events: none; }
.bar { width: min(360px, 100%); height: 8px; border-radius: 99px; background: var(--accent-tint); overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.bar.spin i { width: 35% !important; animation: slide 1.1s ease-in-out infinite alternate; }
@keyframes slide { from { margin-left: 0; } to { margin-left: 65%; } }
.gate { text-align: center; padding: 48px 24px; }
.gate p { margin: 0 0 16px; }

/* 내 클립 목록 */
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list a { flex: 1; min-width: 0; color: var(--ink); text-decoration: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list a:hover { color: var(--accent-strong); }
.list span { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.usage { margin-bottom: 12px; font-size: 14px; }
.usage-text { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.bar.wide { width: 100%; margin-top: 6px; background: var(--accent-soft); }
.usage.full .bar i { background: var(--danger); }

/* 로그인 */
.auth { max-width: 380px; margin: 0 auto; }
.tabs { display: flex; gap: 4px; background: var(--accent-tint); border-radius: 99px; padding: 4px; margin-bottom: 20px; }
.tabs button { flex: 1; font: inherit; font-size: 14px; border: 0; background: none; color: var(--muted); border-radius: 99px; padding: 8px; cursor: pointer; }
.tabs button.on { background: var(--card); color: var(--ink); font-weight: 600; }
.field { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.field input {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.field input:focus, .num:focus, .title-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.auth .btn { width: 100%; padding: 11px; font-size: 16px; margin-top: 6px; }

/* 플레이어 */
.title-row { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; min-width: 0; }
.title-row h1 { font-size: 22px; margin: 0; overflow-wrap: anywhere; letter-spacing: -0.01em; }
.title-row input {
  flex: 1; min-width: 0; font: inherit; font-size: 22px; font-weight: 700; color: var(--ink);
  background: var(--accent-tint); border: 1px solid var(--accent); border-radius: 8px; padding: 4px 8px;
}
.icon-btn { flex: none; border: 0; background: none; color: var(--muted); cursor: pointer; width: 32px; height: 32px; border-radius: 8px; font-size: 16px; }
.icon-btn:hover { background: var(--accent-tint); color: var(--accent-strong); }
.player { display: flex; align-items: center; gap: 16px; }
.play {
  flex: none; width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: var(--on-accent); display: grid; place-items: center;
  transition: transform .1s, background .15s;
}
.play:hover { background: var(--accent-strong); }
.play:active { transform: scale(.94); }
.play svg { width: 22px; height: 22px; fill: currentColor; }
.wave { flex: 1; min-width: 0; height: 96px; cursor: pointer; touch-action: none; display: block; }
.times { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; margin: 6px 0 0 72px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 20px; }
.foot { margin-top: 16px; font-size: 13px; }

/* 자르기 */
.trim { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.trim-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; font-size: 14px; }
.trim-row label { display: inline-flex; align-items: center; gap: 8px; }
.stepper { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { font: inherit; font-size: 18px; line-height: 1; width: 34px; height: 34px; border: 0; cursor: pointer; background: var(--accent); color: var(--on-accent); }
.stepper button:hover { background: var(--accent-strong); }
.num { font: inherit; font-size: 15px; width: 76px; height: 34px; text-align: center; border: 0; background: var(--bg); color: var(--ink); font-variant-numeric: tabular-nums; }
.num.small { width: 56px; border: 1px solid var(--line); border-radius: 10px; }
.switch input { position: absolute; opacity: 0; }
.switch i { flex: none; width: 40px; height: 22px; border-radius: 99px; background: var(--accent-soft); position: relative; transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch { cursor: pointer; }

/* 테마 설정 (우측 하단) */
.theme-fab {
  position: fixed; right: 16px; bottom: 16px; z-index: 20; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); cursor: pointer; display: grid; place-items: center;
  box-shadow: 0 2px 10px rgb(0 0 0 / .12);
}
.theme-fab i { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-panel {
  position: fixed; right: 16px; bottom: 70px; z-index: 20; width: 228px; padding: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 6px 24px rgb(0 0 0 / .16);
  font-size: 14px;
}
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
.swatches button { aspect-ratio: 1; border-radius: 50%; border: 0; cursor: pointer; background: hsl(var(--sw) 70% 42%); }
.swatches button.on { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px hsl(var(--sw) 70% 42%); }
.hue {
  width: 100%; height: 12px; margin: 4px 0 0; border-radius: 99px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background: linear-gradient(to right, hsl(0 70% 45%), hsl(60 70% 45%), hsl(120 70% 45%), hsl(180 70% 45%), hsl(240 70% 45%), hsl(300 70% 45%), hsl(359 70% 45%));
}
.hue::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }
.hue::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }

@media (max-width: 480px) {
  .card { padding: 16px; }
  .play { width: 48px; height: 48px; }
  .times { margin-left: 64px; }
  .wave { height: 80px; }
}
