:root {
  --bg: #15110e; --panel: #1f1a16; --panel2: #29221d; --line: rgba(255, 255, 255, .08);
  --text: #ece4d9; --muted: #a39484; --accent: #e3a35c; --accent2: #74f5e2; --danger: #e5675c;
  --ui: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--ui); }
a { color: var(--accent); }
input, button, select { font: inherit; color: inherit; }
input[type=text], input[type=password], input:not([type]), input[inputmode] {
  width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line); background: #110e0c; outline: none;
}
input:focus { border-color: rgba(227, 163, 92, .6); box-shadow: 0 0 0 3px rgba(227, 163, 92, .15); }
label { display: block; color: var(--muted); font-size: 13px; }
label > input { margin-top: 5px; color: var(--text); font-size: 14px; }
.stack { display: grid; gap: 14px; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.alert { padding: 10px 12px; border-radius: 9px; margin: 0; font-size: 13px; }
.alert.err { background: rgba(229, 103, 92, .12); color: #f3a59e; border: 1px solid rgba(229, 103, 92, .3); }
.alert.ok { background: rgba(116, 245, 226, .08); color: var(--accent2); border: 1px solid rgba(116, 245, 226, .25); }
code, pre { font-family: ui-monospace, monospace; font-size: 12.5px; }
pre { background: #0e0b09; padding: 12px; border-radius: 9px; overflow: auto; border: 1px solid var(--line); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel2); text-decoration: none; color: var(--text);
  transition: background .15s, border-color .15s; white-space: nowrap;
}
.btn:hover { background: #352c25; }
.btn.primary { background: var(--accent); color: #241505; border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: #eeb271; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(255, 255, 255, .06); }
.btn.danger { color: #f19a91; }
.btn.danger:hover { background: rgba(229, 103, 92, .12); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }

/* 설치 / 로그인 */
.install-box, .login-box { max-width: 440px; margin: 10vh auto; padding: 28px; background: var(--panel); border-radius: 18px; border: 1px solid var(--line); }
.install-box h1, .login-box h1 { margin: 0 0 18px; font-size: 20px; }
.login-box .back { margin: 18px 0 0; font-size: 13px; }

/* 관리 레이아웃 */
.bar { display: flex; align-items: center; gap: 12px; padding: 14px 22px; border-bottom: 1px solid var(--line); background: #110d0b; position: sticky; top: 0; z-index: 10; }
.bar h1 { margin: 0; font-size: 16px; letter-spacing: .08em; }
.bar h1 span { color: var(--muted); font-weight: 400; margin-left: 4px; }
.bar nav { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: calc(100vh - 60px); }
.albums { border-right: 1px solid var(--line); padding: 16px; background: #120f0c; }
.albums-head { display: flex; align-items: center; justify-content: space-between; }
.albums-head span { color: var(--muted); font-weight: 400; }
.album-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; }
.album-list li {
  display: grid; grid-template-columns: 18px 44px 1fr; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent;
}
.album-list li:hover { background: rgba(255, 255, 255, .04); }
.album-list li.sel { background: rgba(227, 163, 92, .1); border-color: rgba(227, 163, 92, .3); }
.album-list .handle { color: #6c5f52; cursor: grab; text-align: center; user-select: none; touch-action: none; }
.album-list .th { width: 44px; height: 44px; border-radius: 4px; background: #2b241e center/cover; display: grid; place-items: center; font-size: 10px; color: #8c7d6d; overflow: hidden; }
.album-list .tx { min-width: 0; }
.album-list .tx b, .album-list .tx span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.album-list .tx b { font-weight: 600; }
.album-list .tx span { color: var(--muted); font-size: 12px; }
.sortable-ghost { opacity: .35; }

.editor { padding: 22px clamp(16px, 3vw, 36px) 100px; min-width: 0; }
.placeholder { color: var(--muted); padding: 60px 0; text-align: center; }
.ed-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.ed-head h2 { margin: 0; font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dirty { font-size: 12px; color: var(--accent); border: 1px solid rgba(227, 163, 92, .4); padding: 2px 8px; border-radius: 99px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 14px; font-size: 15px; }
.card h3 small { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 12px; }
.grid3 { display: grid; grid-template-columns: 2fr 2fr 1fr; gap: 12px; }

.images { display: grid; grid-template-columns: 230px 1fr 1fr; gap: 18px; align-items: start; }
.slot { min-width: 0; }
.pv {
  position: relative; display: grid; place-items: center; overflow: hidden; margin-bottom: 8px;
  background: #110e0c center/contain no-repeat; border: 1px dashed rgba(255, 255, 255, .15); color: #6f6356; font-size: 12px;
  transition: border-color .15s, background-color .15s;
}
.pv.has { border-style: solid; border-color: var(--line); }
.pv.has span { display: none; }
.pv.over { border-color: var(--accent); background-color: rgba(227, 163, 92, .08); }
.pv-spine { width: 44px; height: 180px; border-radius: 3px; background-size: 100% 100%; }
.pv-spine.rot { background-size: 0 0; }
.pv-spine .rimg { position: absolute; left: 50%; top: 50%; width: 180px; height: 44px; transform: translate(-50%, -50%) rotate(90deg); background: center/100% 100% no-repeat; }
.slot[data-kind=spine] { display: grid; grid-template-columns: 44px 1fr; column-gap: 12px; }
.slot[data-kind=spine] .pv { grid-row: 1 / span 2; }
.slot[data-kind=spine] .slot-btns { flex-direction: column; align-items: flex-start; }
.pv-cover { width: 100%; max-width: 200px; aspect-ratio: 1; border-radius: 4px; background-size: cover; }
.pv-cd { width: 100%; max-width: 200px; aspect-ratio: 1; border-radius: 50%; background-size: cover;
  -webkit-mask: radial-gradient(circle, transparent 0 7.3%, #000 7.7%); mask: radial-gradient(circle, transparent 0 7.3%, #000 7.7%); }
.slot-btns { display: flex; gap: 6px; flex-wrap: wrap; }

.drop { border: 1.5px dashed rgba(255, 255, 255, .16); border-radius: 14px; padding: 20px; text-align: center; transition: border-color .15s, background .15s; }
.drop p { margin: 0 0 8px; }
.drop.over { border-color: var(--accent); background: rgba(227, 163, 92, .06); }
.queue { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.queue li { display: grid; grid-template-columns: 1fr 120px 70px; gap: 10px; align-items: center; font-size: 12.5px; color: var(--muted); }
.queue li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue li progress { width: 100%; height: 6px; accent-color: var(--accent); }
.queue li.done { color: var(--accent2); }
.queue li.fail { color: #f19a91; grid-template-columns: 1fr auto; }

.tools { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0 10px; }
.tracks { width: 100%; border-collapse: collapse; }
.tracks th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px; border-bottom: 1px solid var(--line); }
.tracks td { padding: 5px 6px; border-bottom: 1px solid rgba(255, 255, 255, .04); vertical-align: middle; }
.tracks td.h { width: 22px; color: #6c5f52; cursor: grab; user-select: none; text-align: center; touch-action: none; }
.tracks td.n { width: 34px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tracks td.t { width: 42%; }
.tracks td.d { width: 56px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tracks td.f { max-width: 180px; color: #7c6f62; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tracks td.x { width: 66px; text-align: right; white-space: nowrap; }
.x-btn.split { font-size: 13px; }
.x-btn.split:hover { background: rgba(116, 245, 226, .12); color: var(--accent2); }
.tracks input { padding: 6px 8px; border-radius: 7px; }
.tracks tr.changed input { border-color: rgba(116, 245, 226, .35); }
.x-btn { width: 28px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: #8c7d6d; cursor: pointer; font-size: 16px; }
.x-btn:hover { background: rgba(229, 103, 92, .15); color: #f19a91; }

.savebar {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 12px 16px; margin: 0 -4px;
  background: rgba(21, 17, 14, .92); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 14px;
}
.savebar .grow { flex: 1; }
.savebar .msg { color: var(--muted); font-size: 13px; }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); padding: 22px; width: min(380px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h3 { margin: 0; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #2e261f; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  transition: opacity .2s, transform .2s; z-index: 50; max-width: 90vw;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(229, 103, 92, .5); color: #f6b3ac; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .albums { border-right: 0; border-bottom: 1px solid var(--line); max-height: 42vh; overflow: auto; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 label:first-child { grid-column: 1 / -1; }
  .images { grid-template-columns: 1fr 1fr; }
  .slot[data-kind=spine] { grid-column: 1 / -1; }
  .tracks th:nth-child(7), .tracks td.f { display: none; }
}
@media (max-width: 560px) {
  .bar { flex-wrap: wrap; }
  .tracks th:nth-child(4), .tracks td.a { display: none; }
  .tracks td.t { width: auto; }
}

/* 멀티디스크 */
.drop-row { display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; }
select { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: #110e0c; }
.tracks td.c { width: 64px; }
.tracks td.c input { width: 52px; text-align: center; padding: 6px 4px; }
.tracks tr.dsep td { padding: 14px 6px 6px; border-bottom: 1px solid rgba(227, 163, 92, .25); color: var(--accent); font-size: 12px; }
.tracks tr.dsep b { letter-spacing: .12em; margin-right: 10px; }
.tracks tr.dsep span { color: var(--muted); }
.discs { display: grid; gap: 10px; }
.disc-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 8px; border-radius: 12px; background: #17130f; }
.pv-cd.sm { width: 64px; max-width: 64px; margin: 0; }
.disc-meta b { letter-spacing: .1em; font-size: 13px; margin-right: 8px; }
.disc-meta input { margin-top: 6px; }
@media (max-width: 560px) {
  .disc-row { grid-template-columns: 52px 1fr; }
  .disc-row .slot-btns { grid-column: 1 / -1; }
  .pv-cd.sm { width: 52px; }
}

/* 멀티디스크 CD 칸 */
.cd-multi { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; margin-bottom: 10px; max-width: 420px; }
.cd-multi[hidden] { display: none; }
.mini {
  position: relative; display: grid; justify-items: center; gap: 3px; padding: 8px 6px 7px; cursor: pointer;
  border: 1px dashed rgba(255, 255, 255, .15); border-radius: 12px; color: var(--muted); font-size: 12px;
  transition: border-color .15s, background .15s;
}
.mini:hover, .mini.over { border-color: var(--accent); background: rgba(227, 163, 92, .07); }
.mini.has { border-style: solid; border-color: var(--line); }
.mini .md {
  width: 64px; height: 64px; border-radius: 50%; background: #2a241e center/cover no-repeat;
  -webkit-mask: radial-gradient(circle, transparent 0 7.3%, #000 7.7%); mask: radial-gradient(circle, transparent 0 7.3%, #000 7.7%);
}
.mini:not(.has) .md { opacity: .45; }
.mini b { color: var(--text); font-size: 12px; letter-spacing: .06em; }
.mini small { font-size: 11px; }
.mini.has small { color: var(--accent2); }
.mini-x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .5); color: #ddd; cursor: pointer; line-height: 1; }
.mini-x:hover { background: rgba(229, 103, 92, .5); }
.pv[hidden] { display: none; }
