:root {
  --bg: #0b0b0f;
  --bg2: #16161d;
  --bg3: #22222c;
  --fg: #f2f2f5;
  --fg2: #a3a3b0;
  --accent: #ff4d6d;
  --accent2: #ffb84d;
  --nav-h: 60px;
  --mini-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font-family: -apple-system, "Pretendard", "Noto Sans KR", "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; }
.hidden { display: none !important; }
svg { width: 24px; height: 24px; fill: currentColor; display: block; }

/* 로고: 원형 그라데이션 + 음파 */
.logo-mark { width: 26px; height: 26px; border-radius: 50%;
  background: conic-gradient(from 210deg, var(--accent), var(--accent2), var(--accent));
  position: relative; }
.logo-mark::after { content: ""; position: absolute; inset: 8px 6px; border-radius: 3px;
  background: repeating-linear-gradient(90deg, #0b0b0f 0 2px, transparent 2px 5px); }
.logo-mark.big { width: 72px; height: 72px; margin: 0 auto 12px; }
.logo-mark.big::after { inset: 22px 16px; background: repeating-linear-gradient(90deg, #0b0b0f 0 5px, transparent 5px 12px); }

/* 로그인 */
.login { position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 20%, #2a1220, var(--bg) 60%); }
.login-box { width: min(320px, 86vw); text-align: center; }
.login h1 { margin: 0 0 24px; font-size: 28px; letter-spacing: -0.5px; }
.login input { width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--bg3);
  background: var(--bg2); color: var(--fg); outline: none; }
.login input:focus { border-color: var(--accent); }
.login button { width: 100%; margin-top: 12px; padding: 14px; border-radius: 12px;
  background: var(--fg); color: #000; font-weight: 700; }
.err { color: var(--accent); min-height: 1.2em; font-size: 14px; }

/* 상단바 / 탭 */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: linear-gradient(var(--bg) 70%, transparent); }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 800; font-size: 19px; letter-spacing: -0.4px; }
#view { padding: 0 0 calc(var(--nav-h) + var(--mini-h) + var(--safe-b) + 16px); }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b); display: flex; background: #101016; border-top: 1px solid #1d1d26; }
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; color: var(--fg2); }
.tabs button.active { color: var(--fg); }
.tabs .ti svg { width: 24px; height: 24px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--fg); }
.icon-btn:active { background: #ffffff14; }
.icon-btn.big svg { width: 34px; height: 34px; }

/* 섹션 / 카드 */
.section { margin: 8px 0 24px; }
.section h2 { font-size: 20px; margin: 0 16px 12px; letter-spacing: -0.3px; }
.section .sub { color: var(--fg2); font-size: 13px; margin: -8px 16px 12px; }
.shelf { display: grid; grid-auto-flow: column; grid-template-rows: repeat(4, auto); grid-auto-columns: 88%;
  gap: 4px 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 0 16px; scrollbar-width: none; }
.shelf::-webkit-scrollbar { display: none; }
.shelf .row { scroll-snap-align: start; }
.cards { display: flex; gap: 14px; overflow-x: auto; padding: 0 16px; scrollbar-width: none; }
.cards::-webkit-scrollbar { display: none; }
.card { flex: 0 0 140px; text-align: left; }
.card img { width: 140px; height: 140px; border-radius: 8px; object-fit: cover; background: var(--bg3); }
.card .t1 { margin-top: 8px; }
.empty { color: var(--fg2); text-align: center; padding: 48px 24px; line-height: 1.6; }

/* 곡 목록 */
.list { list-style: none; margin: 0; padding: 0 8px; }
.row { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 8px; min-width: 0; }
.row:active { background: #ffffff0d; }
.row img { width: 48px; height: 48px; border-radius: 4px; object-fit: cover; background: var(--bg3); flex: none; }
.row .meta { flex: 1; min-width: 0; }
.t1 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t2 { font-size: 13px; color: var(--fg2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.row.now .t1 { color: var(--accent); }
.badge { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent2);
  margin-right: 6px; vertical-align: middle; }
.row .more { color: var(--fg2); }

/* 검색 */
.searchbar { position: sticky; top: 56px; z-index: 4; padding: 4px 16px 12px; background: var(--bg); }
.searchbar form { display: flex; align-items: center; gap: 8px; background: var(--bg2); border-radius: 999px; padding: 0 6px 0 16px; }
.searchbar input { flex: 1; min-width: 0; background: none; border: 0; color: var(--fg); padding: 12px 0; outline: none; font-size: 16px; }
.chips { display: flex; gap: 8px; padding: 0 16px 12px; }
.chip { padding: 7px 14px; border-radius: 8px; background: var(--bg2); font-size: 14px; }
.chip.active { background: var(--fg); color: #000; }
.hist { padding: 0 8px; }
.hist button { display: flex; width: 100%; gap: 14px; align-items: center; padding: 12px; color: var(--fg2); text-align: left; }

/* 보관함 */
.lib-head { display: flex; gap: 8px; padding: 0 16px 12px; overflow-x: auto; }
.lib-actions { display: flex; gap: 10px; padding: 0 16px 12px; }
.pill { padding: 10px 18px; border-radius: 999px; background: var(--fg); color: #000; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.pill.ghost { background: var(--bg2); color: var(--fg); }
.pill svg { width: 18px; height: 18px; }

/* 미니 플레이어 */
.mini { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b)); z-index: 9;
  height: var(--mini-h); display: flex; align-items: center; gap: 12px; padding: 0 8px 0 12px; background: #1b1b23; }
.mini img { width: 44px; height: 44px; border-radius: 4px; object-fit: cover; background: var(--bg3); }
.mini-meta { flex: 1; min-width: 0; }
.mini-progress { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: #ffffff1a; }
#mini-bar { height: 100%; width: 0; background: var(--fg); }

/* 전체 플레이어 */
.player { position: fixed; inset: 0; z-index: 20; transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  background: var(--bg); overflow: hidden; }
.player.open { transform: translateY(0); }
.player-bg { position: absolute; inset: -40px; background-size: cover; background-position: center;
  filter: blur(60px) saturate(1.4) brightness(.45); transform: scale(1.2); transition: background-image .4s; }
.player-inner { position: relative; height: 100%; display: flex; flex-direction: column;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 24px calc(24px + var(--safe-b)); max-width: 560px; margin: 0 auto; }
.player-top { display: flex; align-items: center; justify-content: space-between; }
.spacer { width: 44px; }
.seg { display: flex; gap: 4px; background: #00000040; border-radius: 999px; padding: 4px; }
.seg button { padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--fg2); }
.seg button.active { background: #ffffff26; color: var(--fg); }
.pane { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; margin: 16px 0; }
#pane-queue, #pane-lyrics { align-items: stretch; overflow-y: auto; margin: 16px -24px; }
#pane-queue .list { width: 100%; }
.art-wrap { position: relative; width: min(100%, 52vh); aspect-ratio: 1; }
.art-wrap img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; box-shadow: 0 20px 60px #0009; background: var(--bg3); }
.spinner { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px; border-radius: 50%;
  border: 4px solid #ffffff40; border-top-color: #fff; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.p-meta { display: flex; align-items: center; gap: 12px; }
.p-titles { flex: 1; min-width: 0; }
.pt1 { font-size: 22px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.3px; }
.pt2 { font-size: 16px; color: var(--fg2); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.like.on { color: var(--accent); }
.seek { margin-top: 18px; }
.seek input { width: 100%; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px; outline: none;
  background: linear-gradient(to right, var(--fg) var(--p, 0%), #ffffff33 var(--p, 0%)); }
.seek input::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--fg); }
.seek input::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--fg); }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--fg2); margin-top: 6px; font-variant-numeric: tabular-nums; }
.controls { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.controls .icon-btn.on { color: var(--accent); }
.play-btn { width: 72px; height: 72px; border-radius: 50%; background: var(--fg); color: #000; display: grid; place-items: center; }
.play-btn svg { width: 36px; height: 36px; }

/* 가사 */
.lyrics { padding: 8px 24px 40vh; font-size: 22px; font-weight: 700; line-height: 1.5; color: #ffffff59; white-space: pre-wrap; }
.lyrics .ln { margin: 0 0 14px; transition: color .2s; cursor: pointer; }
.lyrics .ln.on { color: var(--fg); }
.lyrics.plain { color: var(--fg); font-size: 18px; font-weight: 500; }
.lyrics .src { font-size: 12px; color: var(--fg2); font-weight: 400; margin-top: 24px; }

/* 메뉴 시트 */
.sheet { position: fixed; inset: 0; z-index: 30; background: #0008; display: flex; align-items: flex-end; }
.sheet-box { width: 100%; background: #1d1d26; border-radius: 16px 16px 0 0; padding: 8px 0 calc(8px + var(--safe-b)); max-width: 560px; margin: 0 auto; }
.sheet-head { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid #ffffff14; }
.sheet-head img { width: 44px; height: 44px; border-radius: 4px; object-fit: cover; }
.sheet-box > button { display: block; width: 100%; text-align: left; padding: 15px 20px; font-size: 15px; }
.sheet-box > button:active { background: #ffffff0d; }
.sheet-box .muted { color: var(--fg2); }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--mini-h) + var(--safe-b) + 16px); z-index: 40;
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; transition: .2s;
  background: #f2f2f5; color: #000; padding: 10px 16px; border-radius: 8px; font-size: 14px; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 900px) {
  .shelf { grid-auto-columns: 40%; }
  #view { max-width: 1100px; margin: 0 auto; }
}

/* 아티스트 / 앨범 */
.row .num { width: 32px; text-align: center; color: var(--fg2); font-variant-numeric: tabular-nums; flex: none; }
.row img.round { border-radius: 50%; }
.section h2 .cnt { color: var(--fg2); font-size: 14px; font-weight: 500; margin-left: 4px; }
.agrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px 14px; padding: 0 16px; }
.agrid .card img { width: 100%; height: auto; aspect-ratio: 1; }
.agrid .t1, .cards .t1 { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.hero { position: relative; height: 300px; margin-top: -60px; background-size: cover; background-position: center 30%; display: flex; align-items: flex-end; }
.hero-fade { position: absolute; inset: 0; background: linear-gradient(transparent 30%, var(--bg)); }
.hero h1 { position: relative; margin: 0 16px 12px; font-size: 34px; letter-spacing: -0.8px; }
.album-head { text-align: center; padding: 8px 24px 16px; }
.album-head img { width: min(240px, 62vw); aspect-ratio: 1; object-fit: cover; border-radius: 8px; box-shadow: 0 16px 40px #0008; background: var(--bg3); }
.album-head h1 { font-size: 24px; margin: 18px 0 6px; letter-spacing: -0.4px; }
.album-head .t2 { white-space: normal; }
.album-head a { color: var(--fg); text-decoration: underline; cursor: pointer; }
.brand .icon-btn { margin-left: -12px; }

/* 눌림/호버 피드백 */
.row, .card, .chip, .pill, .icon-btn, .hist button, .play-btn, .album-head a { cursor: pointer; }
.row, .card, .pill, .chip, .play-btn { transition: transform .12s ease, background-color .15s ease; }
.card img { transition: transform .2s ease, filter .2s ease, box-shadow .2s ease; }
.row:active, .pill:active, .chip:active, .play-btn:active { transform: scale(.97); }
.card:active { transform: scale(.95); }
.icon-btn { transition: background-color .15s ease, transform .12s ease; }
.icon-btn:active { transform: scale(.9); }
@media (hover: hover) {
  .row:hover { background: #ffffff10; }
  .card:hover img { transform: translateY(-3px); filter: brightness(1.12); box-shadow: 0 10px 24px #0009; }
  .card:hover .t1 { text-decoration: underline; }
  .icon-btn:hover { background: #ffffff14; }
  .pill:hover { filter: brightness(1.1); }
  .hist button:hover { color: var(--fg); }
}
.loading-bar { height: 3px; margin: 8px 16px; border-radius: 2px; overflow: hidden; background: #ffffff14; position: relative; }
.loading-bar::after { content: ""; position: absolute; inset: 0; width: 35%; background: var(--accent); border-radius: 2px; animation: lb 1s ease-in-out infinite; }
@keyframes lb { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.album-head .ph { width: min(240px, 62vw); aspect-ratio: 1; margin: 0 auto; border-radius: 8px; background: var(--bg3); }

/* ---- v3: 계정 / 플레이리스트 / 캐러셀 ---- */
.login input + input { margin-top: 10px; }
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 0 16px 12px; }
.sec-head h2 { margin: 0; }
.sec-head .sub { margin: 4px 0 0; }
.sec-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.see-all { padding: 6px 12px; border: 1px solid #ffffff33; border-radius: 999px; font-size: 13px; color: var(--fg); }
.see-all:hover { background: #ffffff14; }
.pill.sm { padding: 7px 14px; font-size: 14px; }
.pill.danger { background: #ff4d6d; color: #fff; }
.danger-t { color: #ff6b81 !important; }
.tag { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: var(--accent); color: #fff; vertical-align: middle; margin-left: 4px; }
.greet { margin: 4px 16px 20px; font-size: 26px; font-weight: 800; letter-spacing: -0.6px; }
.lib-actions.center { justify-content: center; flex-wrap: wrap; }
select.chip { border: 0; color: var(--fg); appearance: none; -webkit-appearance: none; padding-right: 14px; }

.carousel { position: relative; }
.car-btn { display: none; position: absolute; top: 34%; z-index: 2; width: 40px; height: 40px; border-radius: 50%;
  background: #1d1d26ee; box-shadow: 0 4px 14px #0008; place-items: center; }
.car-btn.prev { left: 4px; } .car-btn.next { right: 4px; }
@media (hover: hover) { .carousel:hover .car-btn { display: grid; } }
.cards { scroll-behavior: smooth; }
.section.expanded .cards { flex-wrap: wrap; overflow: visible; }
.section.expanded .cards .card { flex: 0 0 140px; }
.section.expanded .shelf { grid-auto-flow: row; grid-template-rows: none; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); overflow: visible; }
.section.expanded .car-btn { display: none !important; }
.collapsible:not(.expanded) .list li:nth-child(n+6) { display: none; }
.artist-card { text-align: center; }
.artist-card img { border-radius: 50% !important; }

.hero-text { position: relative; margin: 0 16px 12px; }
.hero-text h1 { margin: 0 0 4px; font-size: 34px; letter-spacing: -0.8px; }
.bio { margin: 0 16px; color: var(--fg2); line-height: 1.7; font-size: 14px; white-space: pre-wrap; cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.bio.open { -webkit-line-clamp: unset; display: block; }

.edit-btns { display: flex; flex: none; }
.edit-btns .icon-btn { width: 38px; height: 38px; }
.pl-ph { display: grid; place-items: center; width: 100%; aspect-ratio: 1; border-radius: 8px; background: var(--bg3); color: var(--fg2); }
.album-head .pl-ph { width: min(240px, 62vw); margin: 0 auto; }
.pl-ph svg { width: 40%; height: 40%; }
.avatar { width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700;
  background: conic-gradient(from 210deg, var(--accent), var(--accent2), var(--accent)); color: #000; }
.link { cursor: pointer; }
.pt1.link:hover, .pt2.link:hover { text-decoration: underline; }
.spin svg { animation: spin .8s linear infinite; }

.modal { position: fixed; inset: 0; z-index: 50; background: #000a; display: grid; place-items: center; padding: 20px; }
.modal-box { width: min(380px, 100%); background: #1d1d26; border-radius: 14px; padding: 20px; }
.modal-box h3 { margin: 0 0 12px; font-size: 18px; }
.modal-box label { display: block; font-size: 13px; color: var(--fg2); margin-top: 12px; }
.modal-box input { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--bg3);
  background: var(--bg2); color: var(--fg); outline: none; font-size: 16px; }
.modal-box input:focus { border-color: var(--accent); }
.modal-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
#menu { z-index: 35; }
.usage { margin: 4px 16px 14px; }
.sheet-head .usage { margin: 8px 0 0; }
.ubar { height: 6px; border-radius: 3px; background: #ffffff1f; overflow: hidden; margin-top: 6px; }
.ubar > div { height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: 3px; }
.row .meta .ubar { max-width: 220px; height: 4px; }
.chip { white-space: nowrap; flex: none; }
.dl { display: inline-flex; vertical-align: -2px; margin-right: 4px; color: var(--accent2); }
.dl svg { width: 14px; height: 14px; }
