:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f0f2f6;
  --text: #1a1d26;
  --muted: #6b7280;
  --line: #e3e6ec;
  --accent: #1f2a44;
  --accent-text: #ffffff;
  --accent-soft: #e8ecf5;
  --danger: #c0392b;
  --ok: #1e8e5a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .05);
  --font: "Noto Sans KR", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --surface: #171b24; --surface-2: #1e232e; --text: #e8eaf0; --muted: #9aa3b2;
    --line: #2a303d; --accent: #8fa7e8; --accent-text: #0f1218; --accent-soft: #232b3d;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --surface: #171b24; --surface-2: #1e232e; --text: #e8eaf0; --muted: #9aa3b2;
  --line: #2a303d; --accent: #8fa7e8; --accent-text: #0f1218; --accent-soft: #232b3d;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
h2 { font-size: 20px; margin: 0 0 12px; letter-spacing: -.01em; }
h3 { font-size: 16px; margin: 22px 0 10px; }
.mt { margin-top: 28px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 12px; }
.req { color: var(--danger); font-weight: 700; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; font-size: 16px; white-space: nowrap; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 7px 8px; border-radius: 2px; background: var(--accent-text); opacity: .9; }
.tabs { display: flex; gap: 2px; }
.tab { background: none; border: 0; padding: 8px 12px; border-radius: 8px; color: var(--muted); font: inherit; font-weight: 500; cursor: pointer; }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

main { padding: 24px 16px 64px; }
.view[hidden] { display: none; }

/* steps */
.steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 20px; counter-reset: s; overflow-x: auto; }
.step { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 13px; white-space: nowrap; cursor: pointer; }
.step-num { width: 20px; height: 20px; border-radius: 50%; background: var(--surface-2); display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; }
.step.active { border-color: var(--accent); color: var(--text); font-weight: 700; }
.step.active .step-num { background: var(--accent); color: var(--accent-text); }
.step.done .step-num { background: var(--ok); color: #fff; }

/* panels */
.panel { display: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.panel.active { display: block; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .grid.two { grid-template-columns: 1fr; } .top-inner { height: auto; padding: 10px 0; flex-wrap: wrap; } .tabs { width: 100%; } }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; line-height: 1.5; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 8px; margin: 16px 0 0; }
legend { font-size: 13px; color: var(--muted); padding: 0 6px; }
.date-row { display: grid; grid-template-columns: 110px 80px 80px 1fr; gap: 10px; align-items: end; }
.date-row .hint { grid-column: 1 / -1; margin: 6px 0 2px; }
@media (max-width: 640px) { .date-row { grid-template-columns: 1fr 1fr; } }
.check { flex-direction: row; align-items: center; gap: 8px; margin: 14px 0 4px; color: var(--text); }
.check input { width: auto; }

.actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 22px; }
.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 10px 16px; border-radius: 9px; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-style: dashed; color: var(--muted); }
.btn.danger { color: var(--danger); }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn.small { padding: 6px 10px; font-size: 13px; }

/* songs */
.song { display: grid; grid-template-columns: 32px 1fr 1fr 1fr 36px; gap: 10px; align-items: start; padding: 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; background: var(--surface-2); }
.song .num { font-weight: 700; color: var(--muted); padding-top: 32px; text-align: center; }
.song .lyrics { grid-column: 2 / -1; }
.song .lyrics summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.song .del { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; padding-top: 28px; }
.song .del:hover { color: var(--danger); }
@media (max-width: 640px) { .song { grid-template-columns: 28px 1fr 36px; } .song label:nth-of-type(2), .song label:nth-of-type(3) { grid-column: 2; } }

/* versions */
.versions { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 14px; }
.vgroup { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); }
.vgroup strong { display: block; font-size: 13px; margin-bottom: 6px; }
.vopt { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--text); padding: 3px 0; }
.vopt input { width: auto; }

/* concepts */
.ai-row { display: flex; align-items: center; gap: 12px; margin: 6px 0 10px; flex-wrap: wrap; }
.ai-key { margin-bottom: 12px; }
.concepts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .concepts { grid-template-columns: 1fr; } }
.concepts textarea { min-height: 190px; font-size: 14px; }

/* downloads */
.downloads { display: grid; gap: 10px; }
.dl-card { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.dl-icon { width: 40px; height: 48px; border-radius: 6px; flex: none; position: relative; }
.dl-icon.doc { background: #2b579a; } .dl-icon.xls { background: #217346; }
.dl-icon::after { content: ""; position: absolute; left: 9px; right: 9px; top: 14px; height: 4px; background: rgba(255,255,255,.85); border-radius: 2px; box-shadow: 0 9px 0 rgba(255,255,255,.85), 0 18px 0 rgba(255,255,255,.85); }
.dl-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dl-body strong { word-break: break-all; }
.dl-body .hint { margin: 2px 0 0; }
.lyrics-dl { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* preview (document look) */
.doc-preview { background: #fff; color: #111; border: 1px solid var(--line); border-radius: 8px; padding: 18px; font-size: 13px; line-height: 1.5; font-family: "Malgun Gothic", "Noto Sans KR", sans-serif; }
.doc-preview .dtitle { text-align: center; font-weight: 700; background: #eaeaea; padding: 10px; border: 1px solid #000; }
.doc-preview .dtitle .hl { color: #f00; background: #ff0; padding: 0 2px; }
.doc-preview table { width: 100%; border-collapse: collapse; }
.doc-preview td { border: 1px solid #000; padding: 6px 8px; vertical-align: middle; }
.doc-preview td.k { width: 110px; background: #eaeaea; font-weight: 700; }
.doc-preview .dbody { border: 1px solid #000; border-top: 0; padding: 10px; white-space: pre-wrap; }
.doc-preview .dbody b { display: block; }

/* list */
.list { display: grid; gap: 10px; }
.item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.item .meta { color: var(--muted); font-size: 13px; }
.item .ops { display: flex; gap: 6px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* artist links */
.link-row { display: grid; grid-template-columns: 1fr 1fr 2fr 36px; gap: 8px; margin-bottom: 8px; align-items: center; }
.link-row .del { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; }
@media (max-width: 640px) { .link-row { grid-template-columns: 1fr 1fr 36px; } .link-row input:nth-child(3) { grid-column: 1 / 3; } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.toast.err { background: var(--danger); color: #fff; }
.toast[hidden] { display: none; }

.user-box { display: inline-flex; align-items: center; gap: 8px; margin-left: 10px; padding-left: 12px; border-left: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.user-box .logout { color: var(--muted); text-decoration: underline; }
@media (max-width: 640px) { .user-box { margin-left: 0; padding-left: 0; border: 0; width: 100%; } }
.user-box[hidden] { display: none; }
