:root {
  --bg: #0f1013;
  --surface: #17191e;
  --surface-2: #1f2228;
  --line: #2a2e36;
  --text: #ecedf0;
  --muted: #8b909b;
  --accent: #ff7a45;
  --accent-soft: rgba(255, 122, 69, 0.14);
  --ok: #4cc38a;
  --warn: #f5b84a;
  --danger: #ef5a5a;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', sans-serif; font-size: 15px; line-height: 1.5; padding-bottom: 96px; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* 상단바 */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 28px; padding: 14px 28px; background: rgba(15, 16, 19, 0.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.brand-mark { color: var(--accent); font-size: 20px; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { padding: 7px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.topbar nav a.active, .topbar nav a:hover { color: var(--text); background: var(--surface-2); }
.me { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.badge { background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.role-chip { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }

main { max-width: 1120px; margin: 0 auto; padding: 32px 24px; }

/* 버튼 & 폼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; background: var(--accent); color: #fff; font: inherit; font-weight: 700; padding: 10px 18px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.ok { background: var(--ok); }
.btn.warn { background: var(--warn); color: #222; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
  width: 100%; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; }
.field { margin-bottom: 16px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.error { color: var(--danger); font-size: 14px; min-height: 20px; }

/* 파일 드롭 */
.drop { position: relative; border: 1.5px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center; background: var(--surface-2); cursor: pointer; transition: border-color .15s; }
.drop:hover, .drop.over { border-color: var(--accent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop .drop-title { font-weight: 700; }
.drop .drop-file { color: var(--accent); font-size: 13px; margin-top: 4px; word-break: break-all; }

/* 카드 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.filters { display: flex; gap: 6px; margin-bottom: 18px; }
.chip { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.song-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.song-card { display: flex; flex-direction: column; gap: 12px; transition: border-color .15s, transform .15s; }
.song-card:hover { border-color: #3c414b; transform: translateY(-2px); }
.song-card .cover { height: 96px; border-radius: 10px; display: flex; align-items: flex-end; padding: 12px; font-weight: 800; font-size: 13px; color: rgba(255,255,255,.85); }
.song-card h3 { font-size: 17px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 2px 9px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.tag.on { color: var(--text); }
.status { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 6px; }
.status.open { background: rgba(76,195,138,.14); color: var(--ok); }
.status.closed { background: var(--surface-2); color: var(--muted); }
.status.pending { background: rgba(139,144,155,.16); color: #c3c7cf; }
.status.revision { background: rgba(245,184,74,.15); color: var(--warn); }
.status.approved { background: rgba(76,195,138,.14); color: var(--ok); }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }

/* 곡 상세 */
.song-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 26px; }
.song-head .meta { margin-top: 10px; }
.detail-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.track { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.track:last-child { border-bottom: 0; padding-bottom: 0; }
.track:first-of-type { padding-top: 4px; }
.track-icon { width: 44px; height: 44px; flex: none; border-radius: 10px; display: grid; place-items: center; font-size: 18px; background: var(--accent-soft); color: var(--accent); }
.track-body { flex: 1; min-width: 0; }
.track-name { font-weight: 700; }
.track-file { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.circle-play { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg); font-size: 13px; cursor: pointer; flex: none; }
.circle-play.playing { background: var(--accent); color: #fff; }
.lyrics { white-space: pre-wrap; font-size: 15px; line-height: 1.9; max-height: 560px; overflow: auto; color: #d8dae0; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sub-item { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); margin-bottom: 12px; }
.sub-item:last-child { margin-bottom: 0; }
.sub-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.sub-note { font-size: 14px; color: #cfd2d8; margin: 6px 0 12px; white-space: pre-wrap; }
.sub-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* 인증 */
.auth-wrap { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.auth { width: 100%; max-width: 420px; }
.auth h1 { margin-bottom: 6px; }
.auth .switch { margin-top: 16px; text-align: center; font-size: 14px; color: var(--muted); }
.auth .switch a { color: var(--accent); font-weight: 700; }
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role-pick label { margin: 0; cursor: pointer; padding: 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: var(--surface-2); }
.role-pick input { display: none; }
.role-pick label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.role-pick b { display: block; font-size: 15px; }
.role-pick span { font-size: 12px; color: var(--muted); font-weight: 500; }

/* 메시지 */
.chat-layout { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 200px); min-height: 480px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.thread-list { border-right: 1px solid var(--line); overflow: auto; }
.thread { display: block; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.thread:hover { background: var(--surface-2); }
.thread.active { background: var(--accent-soft); }
.thread-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.thread-song { font-size: 12px; color: var(--accent); font-weight: 700; }
.thread-last { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat { display: flex; flex-direction: column; min-height: 0; }
.chat-head { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.chat-body { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 72%; display: flex; flex-direction: column; gap: 3px; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 10px 14px; border-radius: 14px; background: var(--surface-2); white-space: pre-wrap; word-break: break-word; }
.msg.mine .bubble { background: var(--accent); color: #fff; }
.msg-meta { font-size: 11px; color: var(--muted); }
.attach { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: rgba(0,0,0,.25); margin-top: 6px; font-size: 13px; }
.attach a { text-decoration: underline; }
.chat-input { border-top: 1px solid var(--line); padding: 12px; display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { min-height: 44px; max-height: 160px; height: 44px; }
.attach-btn { position: relative; overflow: hidden; }
.attach-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.attach-name { font-size: 12px; color: var(--accent); padding: 0 12px 8px; }

/* 플레이어 */
.player { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 12px 24px; background: rgba(23, 25, 30, 0.96); backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.play-btn { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 16px; cursor: pointer; flex: none; }
.pl-info { width: 220px; min-width: 0; }
.pl-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-seek { flex: 1; display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pl-seek input { flex: 1; }
.pl-mix, .pl-vol { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.pl-mix input { width: 110px; }
.pl-vol input { width: 80px; }
input[type=range] { accent-color: var(--accent); }

.toast { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 30; background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.toast.err { background: var(--danger); color: #fff; }

@media (max-width: 860px) {
  .detail-grid { grid-template-columns: 1fr; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .thread-list { max-height: 220px; border-right: 0; border-bottom: 1px solid var(--line); }
  .chat { height: 70vh; }
  .topbar { padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
  .me #me-name { display: none; }
  main { padding: 20px 16px; }
  .player { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .pl-info { flex: 1; width: auto; }
  .pl-seek { order: 5; flex-basis: 100%; }
  .pl-vol { display: none; }
  .row { flex-direction: column; gap: 0; }
  .song-head { flex-direction: column; }
}

/* ───── 메인(로그인) 화면 ───── */
body.landing { padding-bottom: 0; }
body.landing main { max-width: none; padding: 0; }
.landing-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.25fr 1fr; }
.hero { position: relative; overflow: hidden; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  background: radial-gradient(120% 80% at 0% 0%, rgba(255,122,69,.28), transparent 60%), radial-gradient(90% 70% at 100% 100%, rgba(120,90,255,.22), transparent 60%), #121318; border-right: 1px solid var(--line); }
.brand.big { font-size: 20px; }
.hero-copy h1 { font-size: clamp(34px, 4.2vw, 56px); line-height: 1.15; letter-spacing: -0.035em; font-weight: 800; }
.hero-copy h1 em { font-style: normal; color: var(--accent); }
.hero-copy p { color: #b8bcc6; font-size: 17px; margin: 20px 0 0; line-height: 1.7; }
.eq { display: flex; align-items: flex-end; gap: 5px; height: 72px; }
.eq span { flex: 1; max-width: 10px; border-radius: 3px; background: linear-gradient(to top, var(--accent), #ffb38f); opacity: .85; animation: eq 1.1s ease-in-out infinite alternate; transform-origin: bottom; }
@keyframes eq { from { transform: scaleY(.25); } to { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) { .eq span { animation: none; } }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.steps li { display: flex; gap: 12px; padding: 16px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.07); }
.steps b { color: var(--accent); font-size: 13px; padding-top: 2px; }
.steps strong { display: block; }
.steps span { font-size: 13px; color: var(--muted); }
.login-side { display: grid; place-items: center; padding: 48px 32px; }
.login-box { width: 100%; max-width: 380px; }
.login-box h2 { font-size: 28px; }
.login-box > p { margin: 6px 0 28px; }
.login-note { margin-top: 22px; padding: 14px 16px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; color: var(--muted); line-height: 1.6; }

/* 계정 관리 */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 0 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.dim td { opacity: .5; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn { margin-left: 4px; }
.cred { margin-top: 18px; padding: 16px; border-radius: 12px; border: 1px solid var(--accent); background: var(--accent-soft); display: flex; flex-direction: column; gap: 10px; }
.cred-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.cred code { color: var(--text); font-size: 14px; user-select: all; }
#me-name:hover { color: var(--accent); }

@media (max-width: 860px) {
  .landing-wrap { grid-template-columns: 1fr; }
  .hero { padding: 32px 20px; border-right: 0; border-bottom: 1px solid var(--line); }
  .steps { grid-template-columns: 1fr; }
  .eq { height: 48px; }
  .table .actions { white-space: normal; }
}

/* 곡 첨부 파일 여러 개 */
.track-group { font-size: 13px; font-weight: 700; color: var(--muted); margin-top: 18px; padding-bottom: 4px; }
.track-group:first-of-type { margin-top: 0; }
.cur-files { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.cur-file { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.cur-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cur-file .x { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 4px; }
.cur-file .x:hover { color: var(--danger); }

/* ───── 레이아웃 깨짐 수정 ───── */
.detail-grid > *, .stack > *, .track-body, .sub-item { min-width: 0; }
.track-name { word-break: break-all; line-height: 1.4; }
.track-file, .sub-item .track-file { word-break: break-all; }
.track-group { display: flex; align-items: center; gap: 6px; }
.track-actions { flex: none; }
.cur-file span { min-width: 0; }
.cur-file.new { border-style: dashed; border-color: var(--accent); }
.cur-file em { font-style: normal; color: var(--muted); margin-left: 4px; }
.pending-files { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.pending-files:empty { display: none; }
.row > .field { min-width: 0; }
.drop .drop-title, .drop .muted { word-break: keep-all; }
.topbar nav a { white-space: nowrap; }
.btn { word-break: keep-all; }

@media (max-width: 860px) {
  .detail-grid > .card[style*="sticky"] { position: static !important; }
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar .brand { flex: 1; }
  .topbar nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .song-head > div:last-child { flex-wrap: wrap; }
  .track { gap: 10px; }
  .track-actions .btn { padding: 6px 10px; }
  .sub-actions .btn { flex: 1 1 auto; }
  .table thead { display: none; }
  .table td { display: block; border: 0; padding: 4px 0; }
  .table tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .table .actions { text-align: left; }
  .table .actions .btn { margin: 4px 4px 0 0; }
}
@media (max-width: 860px) { .detail-grid { grid-template-columns: 1fr !important; } }

/* 곡 진행 상태 */
.status.todo { background: rgba(245,184,74,.15); color: var(--warn); }
.status.done { background: rgba(76,195,138,.14); color: var(--ok); }
.status.off { background: var(--surface-2); color: var(--muted); }

/* 보컬 제출물 여러 파일 */
.sub-files { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; }
.sub-file { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.sub-file .track-icon { width: 38px; height: 38px; font-size: 15px; }
.sub-file-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; flex: none; max-width: 60%; }
.sub-item .sub-actions { margin-top: 12px; }
@media (max-width: 860px) {
  .sub-file { flex-wrap: wrap; }
  .sub-file-actions { max-width: none; flex-basis: 100%; justify-content: flex-start; }
}
.sub-file { flex-wrap: wrap; row-gap: 8px; }
.sub-file .track-body { flex: 1 1 0; }
.sub-file-actions { max-width: none; flex-basis: 100%; justify-content: flex-start; padding-left: 50px; }
@media (max-width: 860px) { .sub-file-actions { padding-left: 0; } }
