:root {
  color-scheme: light;
  --bg: #f4f2ee;          /* 따뜻한 종이색 */
  --panel: #ffffff;
  --panel2: #f7f6f2;
  --panel3: #eeece6;
  --line: rgba(20, 20, 30, .08);
  --line2: rgba(20, 20, 30, .15);
  --hover: rgba(20, 20, 30, .05);
  --text: #16161d;        /* 잉크색 */
  --muted: #6b6b77;
  --accent: #ff5a1f;      /* BLOCX 주황 */
  --accent2: #c2560a;
  --grad: linear-gradient(135deg, #ff5a1f 0%, #ff8c2e 100%);
  --hl: rgba(255, 90, 31, .22);
  --tab: #d9d9e3;
  --mono: "JetBrains Mono", "D2Coding", Consolas, "Courier New", monospace;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 18px 40px -22px rgba(20, 20, 30, .28);
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--text); min-height: 100vh; display: flex; flex-direction: column;
  font-family: "Pretendard Variable", "Pretendard", "Malgun Gothic", system-ui, sans-serif; font-size: 15px;
  -webkit-font-smoothing: antialiased; letter-spacing: -.01em;
  background:
    radial-gradient(1100px 520px at 8% -12%, rgba(255, 90, 31, .12), transparent 62%),
    radial-gradient(900px 460px at 105% -5%, rgba(255, 176, 32, .10), transparent 60%),
    var(--bg);
}
::selection { background: rgba(255, 90, 31, .35); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.warn { color: var(--accent2); font-size: 13px; margin-top: 6px; }

/* ---- 머리말: 로고(BLOCX) + LICENSED TO */
.top {
  position: sticky; top: 0; z-index: 40; display: flex; justify-content: space-between; align-items: center;
  height: 66px; padding: 0 28px; border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .72); backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.mark { width: 32px; height: 32px; filter: drop-shadow(0 4px 12px rgba(255, 90, 31, .35)); }
.mark .m-a { fill: var(--accent); }
.mark .m-b { fill: var(--text); }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-weight: 800; font-size: 20px; letter-spacing: .32em; margin-right: -.32em; white-space: nowrap; }
.brand-name .prod { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.licensed { margin-top: 5px; font-size: 9.5px; letter-spacing: .2em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.licensed b { color: var(--text); letter-spacing: .06em; font-weight: 700; margin-left: 3px; }
.licensed.unreg b { color: var(--accent); }
.top-actions { display: flex; gap: 8px; }

main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 26px 20px 40px; flex: 1; }
.card {
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 18px; padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow);
}

/* ---- 버튼·입력 */
button, .btn {
  font: inherit; font-size: 14px; font-weight: 500; border-radius: 10px; padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--line2); background: var(--panel2); color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
}
button:hover, .btn:hover { border-color: rgba(20, 20, 30, .28); background: var(--panel3); }
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible { outline: 2px solid rgba(255, 90, 31, .7); outline-offset: 2px; }
button:disabled { opacity: .4; cursor: not-allowed; }
.ghost { background: var(--panel); }
.ghost:hover { background: var(--panel2); }
.btn.disabled { opacity: .35; pointer-events: none; }
.primary, .accent-btn {
  background: var(--grad); border-color: transparent; color: #fff; font-weight: 700;
  box-shadow: 0 12px 30px -12px rgba(255, 90, 31, .75);
}
.primary { width: 100%; padding: 15px; font-size: 16px; margin-top: 18px; border-radius: 12px; letter-spacing: .02em; }
.primary:hover:not(:disabled), .accent-btn:hover:not(:disabled) { filter: brightness(1.08); border-color: transparent; background: var(--grad); }
.danger-btn:hover { border-color: #dc2626; color: #dc2626; }
.icon-btn { width: 34px; height: 34px; padding: 0; border-radius: 50%; }

select, input[type=number], input[type=text], input[type=password], textarea {
  font: inherit; font-size: 14px; background: var(--panel2); color: var(--text);
  border: 1px solid var(--line2); border-radius: 10px; padding: 8px 10px; transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus, textarea:focus { outline: none; border-color: rgba(255, 90, 31, .7); box-shadow: 0 0 0 3px rgba(255, 90, 31, .15); }
input[type=range] { accent-color: var(--accent); }
output { color: var(--accent2); font-weight: 600; }

/* ---- 첫 화면 */
.hero { text-align: center; padding: 10px 0 22px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .32em; color: var(--accent); }
.hero h1 { margin: 12px 0 10px; font-size: clamp(30px, 4.4vw, 52px); font-weight: 800; letter-spacing: -.045em; line-height: 1.02; }
.hero h1 .g { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 0 auto; max-width: 620px; font-size: 15.5px; line-height: 1.6; }
.drop {
  display: block; position: relative; border: 1.5px dashed rgba(20, 20, 30, .2); border-radius: 16px; padding: 40px 24px;
  text-align: center; cursor: pointer; transition: .18s; background: var(--panel2);
}
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(255, 90, 31, .06); box-shadow: 0 0 0 6px rgba(255, 90, 31, .06); }
.drop-icon { width: 54px; height: 54px; margin: 0 auto; border-radius: 16px; display: grid; place-items: center;
  background: rgba(255, 90, 31, .12); border: 1px solid rgba(255, 90, 31, .3); }
.drop-icon svg { width: 26px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.drop-title { font-weight: 700; font-size: 16px; margin: 14px 0 4px; }

.opts { margin-top: 22px; }
fieldset { border: none; padding: 0; margin: 0 0 18px; }
legend { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .08em; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label input { display: none; }
.chips label span {
  display: inline-block; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line2);
  cursor: pointer; user-select: none; font-size: 14px; font-weight: 500; background: var(--panel); transition: .15s;
}
.chips label span:hover { border-color: rgba(20, 20, 30, .32); }
.chips label input:checked + span { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 8px 20px -10px rgba(255, 90, 31, .8); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 18px; }
.grid2 label { display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); }

/* ---- 진행 */
.prog-head { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 12px; }
.bar { height: 10px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--grad); transition: width .4s; box-shadow: 0 0 16px rgba(255, 90, 31, .6); }

/* ---- 결과 */
.result-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.result-head h2 { margin: 0 0 6px; font-size: 21px; font-weight: 800; letter-spacing: -.02em; word-break: break-all; }
.head-actions { display: flex; gap: 8px; }

.transport { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.transport #seek { flex: 1; min-width: 160px; }
.round { width: 48px; height: 48px; border-radius: 50%; padding: 0; background: var(--grad); border-color: transparent; color: #fff;
  font-size: 17px; box-shadow: 0 10px 24px -8px rgba(255, 90, 31, .8); }
.round:hover { background: var(--grad); filter: brightness(1.08); border-color: transparent; }
.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.loop-range input { width: 58px; padding: 5px 7px; }

.mixer { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.ch {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
  display: flex; align-items: center; gap: 8px; font-size: 13px;
}
.ch .nm { min-width: 70px; font-weight: 500; }
.ch button { padding: 3px 9px; font-size: 12px; border-radius: 7px; }
.ch button.on.m { background: #6b6b77; color: #fff; border-color: #6b6b77; }
.ch button.on.s { background: var(--accent2); color: #000; border-color: var(--accent2); }
.ch input[type=range] { width: 80px; }
.ch.off .nm { color: var(--muted); text-decoration: line-through; }
.ch.loading { opacity: .45; }
.ch.loading .nm::after { content: " (불러오는 중)"; font-size: 11px; color: var(--muted); }

.tab-toolbar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.track-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.track-tabs button.active { background: var(--grad); border-color: transparent; color: #fff; font-weight: 700; }
.tab-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- 꼬리말 */
.foot { display: flex; justify-content: center; gap: 8px; padding: 20px 16px 26px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--line); letter-spacing: .02em; }
.foot .dot { opacity: .5; }
#footLic { font-weight: 600; letter-spacing: .08em; }

/* ---- 설정·사용 등록 */
.settings-dlg { width: min(560px, 94vw); padding: 0; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 6px; }
.dlg-head h3 { margin: 0; font-size: 18px; }
.dlg-head form { margin: 0; }
.set-sec { padding: 10px 22px 18px; border-top: 1px solid var(--line); }
.set-sec:first-of-type { border-top: none; }
.set-sec h4 { margin: 8px 0 12px; font-size: 12px; letter-spacing: .14em; color: var(--muted); font-weight: 700; }
.set-sec label { display: block; margin: 8px 0; }
.set-sec textarea { display: block; width: 100%; margin-top: 6px; font-family: var(--mono); font-size: 12.5px; resize: vertical; }
.set-sec input[type=text] { display: block; width: 100%; margin-top: 6px; }
.lic-gate { background: #fff6e8; border: 1px solid #f6cf94; color: #8a4b00;
  border-radius: 12px; padding: 12px 14px; font-size: 13.5px; line-height: 1.55; margin: 0 0 12px; }
.lic-card { border-radius: 14px; padding: 18px; margin-bottom: 8px; border: 1px solid #ffcfb8;
  background: linear-gradient(135deg, #fff0e8, #fffaf5); }
.lic-k { font-size: 10px; letter-spacing: .24em; font-weight: 700; color: var(--accent); }
.lic-name { font-size: 22px; font-weight: 800; margin: 6px 0 4px; letter-spacing: -.01em; }
#licMsg.ok { color: #15803d; }
#licMsg.err { color: #dc2626; }

.tab-view {
  position: relative; margin-top: 12px; background: #15151b; border-radius: 14px; padding: 16px 14px;
  max-height: 68vh; overflow: auto; font-family: var(--mono); font-size: 14px; color: var(--tab);
}
.system { position: relative; margin: 0 0 20px; }
.system pre { margin: 0; font: inherit; line-height: 1.32; white-space: pre; }
.system .num { color: #ffb020; opacity: .8; }
.system .lbl { color: var(--accent); }
.m { cursor: pointer; border-radius: 2px; }
.m:hover { background: rgba(255, 255, 255, .05); }
.m.cur { background: var(--hl); }
.cursor {
  position: absolute; width: 2px; background: var(--accent); box-shadow: 0 0 8px var(--accent);
  pointer-events: none; z-index: 2; transition: left .06s linear;
}

.score-wrap {
  position: relative; margin-top: 12px; background: #fdfdfb; border-radius: 14px; padding: 8px 0;
  box-shadow: 0 0 0 1px var(--line2), 0 18px 40px -26px rgba(20, 20, 30, .35);
  max-height: 72vh; overflow: auto; color: #222; scrollbar-gutter: stable;
}
.score-wrap #score { position: relative; }
.score-wrap #scoreLoading { padding: 20px; color: #777; }
.bar-hl {
  position: absolute; background: rgba(255, 90, 31, .10); border-radius: 3px; pointer-events: none; z-index: 1;
}
.score-cursor {
  position: absolute; width: 2px; background: var(--accent); box-shadow: 0 0 6px var(--accent);
  pointer-events: none; z-index: 2;
}
.score-wrap .at-surface { cursor: pointer; }

.edit-bar {
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 10px; padding: 10px 12px;
  background: #fff5ef; border: 1px solid #ffd6c2; border-radius: 12px; font-size: 13px;
}
.edit-bar button { padding: 4px 9px; font-size: 13px; }
.edit-bar button.active { background: var(--accent); border-color: var(--accent); }
.edit-bar .save { border-color: var(--accent); }
.edit-bar .save.dirty { background: var(--accent); font-weight: 700; }
.ed-sel { color: var(--accent2); min-width: 240px; font-family: var(--mono); }
.ed-group { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; color: var(--muted); }
.ed-help { width: 100%; color: var(--muted); }
.ed-help summary { cursor: pointer; }
.ed-help ul { margin: 6px 0 0; padding-left: 18px; line-height: 1.7; }
/* 편집 선택 표시: 박 위치 세로 띠 + 음표 고리 + 이름표 (hover = 마우스를 올린 곳 미리 보기) */
.sel-band, .sel-ring, .sel-tag { position: absolute; pointer-events: none; z-index: 3; }
.sel-band { background: linear-gradient(180deg, rgba(255, 90, 31, 0), rgba(255, 90, 31, .13) 18%, rgba(255, 90, 31, .13) 82%, rgba(255, 90, 31, 0));
  border-radius: 6px; }
.sel-ring { border: 2.5px solid var(--accent); border-radius: 50%; box-shadow: 0 0 0 3px rgba(255, 90, 31, .25), 0 0 10px rgba(255, 90, 31, .55);
  transition: left .08s, top .08s; }
.sel-ring.empty { border-style: dashed; background: rgba(255, 90, 31, .1); }
.sel-tag { background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; padding: 0 7px;
  border-radius: 9px; white-space: nowrap; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }
.sel-band.hover { background: rgba(31, 122, 255, .06); }
.sel-ring.hover { border: 2px solid rgba(31, 122, 255, .7); box-shadow: none; transition: none; }
.sel-ring.hover.empty { border-style: dashed; background: none; }
.sel-tag.hover { background: rgba(31, 122, 255, .85); font-weight: 600; }
#editBtn.active { background: var(--accent); border-color: var(--accent); }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #333; color: #fff;
  padding: 10px 18px; border-radius: 10px; z-index: 50; font-size: 14px; box-shadow: 0 4px 20px rgba(0,0,0,.4);
}

/* 우클릭 원형 메뉴 */
.radial { position: fixed; width: 0; height: 0; z-index: 60; animation: radialIn .12s ease-out; }
@keyframes radialIn { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.radial-ring {
  position: absolute; border-radius: 50%; transform: translate(-50%, -50%);
  background: rgba(22, 22, 28, .92); border: 1px solid #3a3a46; box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}
.radial-item, .radial-center {
  position: absolute; transform: translate(-50%, -50%); border-radius: 50%; padding: 0;
  display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1.1;
  background: #2b2b35; border: 1px solid #444455; color: #eee; font-size: 12.5px; word-break: keep-all; white-space: pre-line;
}
.radial-item:hover { background: #3a3a48; border-color: var(--accent); transform: translate(-50%, -50%) scale(1.12); }
.radial-item.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.radial-item.danger:hover { background: #8a2020; border-color: #c33; }
.radial-item.fret { font-family: var(--mono); font-size: 14px; font-weight: 700; }
.radial-item:disabled { opacity: .3; pointer-events: none; }
.radial-center { background: #1b1b22; color: var(--muted); font-size: 12px; }
.radial-center:hover { color: #fff; border-color: var(--accent); }
.radial-title {
  position: absolute; transform: translate(-50%, 0); white-space: nowrap; font-size: 12px; color: #ffb020;
  background: rgba(22, 22, 28, .92); padding: 3px 8px; border-radius: 6px; pointer-events: none;
}

/* PDF(인쇄)용 악보: 평소에는 화면 밖에 A4 폭으로 그려 두고, 인쇄할 때만 이것만 보이게 */
#printArea { position: absolute; left: -10000px; top: 0; width: 720px; background: #fff; color: #000; }
@media print {
  @page { size: A4; margin: 12mm; }
  html, body { background: #fff !important; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { position: static; left: 0; width: auto; }
}

.ref-dlg { width: min(760px, 94vw); }
.ref-dlg textarea {
  width: 100%; margin: 8px 0; font-family: var(--mono); font-size: 13px; background: #111115; color: var(--tab);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px;
}
.ref-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.ref-row form { margin: 0; }
.ref-log { max-height: 180px; overflow: auto; background: #111115; padding: 8px; border-radius: 8px; font-size: 12px; white-space: pre-wrap; }
#refResult b { color: var(--accent2); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line2); border-radius: 18px; min-width: 380px; max-width: 90vw;
  box-shadow: 0 40px 80px -24px rgba(20, 20, 30, .45); padding: 20px 22px; }
dialog h3 { margin-top: 0; }
dialog::backdrop { background: rgba(22, 22, 30, .38); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#historyList { list-style: none; padding: 0; margin: 0 0 12px; max-height: 60vh; overflow: auto; }
#historyList li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
#historyList a { color: var(--text); cursor: pointer; }
#historyList a:hover { color: var(--accent); }

@media (max-width: 640px) {
  .top { padding: 0 14px; }
  .brand-name { font-size: 17px; }
  .licensed { font-size: 8.5px; }
}

.meta-dlg { width: min(520px, 94vw); }
.meta-dlg label { display: block; margin: 10px 0; }
.meta-dlg input[type=text] { display: block; width: 100%; margin-top: 4px; box-sizing: border-box; }

.ed-tu { margin-left: 10px; padding-left: 10px; border-left: 1px solid var(--line2); white-space: nowrap; }

.video-bar { height: 8px; background: var(--panel3); border-radius: 4px; overflow: hidden; margin: 10px 0; }
.video-bar > div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }

/* ---- 로그인 화면 */
.login-screen { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(900px 480px at 15% -10%, rgba(255, 90, 31, .16), transparent 60%),
    radial-gradient(800px 420px at 100% 110%, rgba(255, 176, 32, .12), transparent 60%),
    var(--bg); }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line2); border-radius: 22px;
  padding: 34px 30px 22px; box-shadow: 0 40px 80px -30px rgba(20, 20, 30, .4); text-align: center; }
.login-card .mark { width: 44px; height: 44px; }
.login-brand { margin-top: 12px; font-weight: 800; font-size: 24px; letter-spacing: .3em; margin-right: -.3em; }
.login-brand .prod { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-sub { margin: 6px 0 22px; font-size: 11px; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.login-card label { display: block; text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 10px 0; }
.login-card input { display: block; width: 100%; margin-top: 6px; padding: 11px 12px; font-size: 15px; }
.login-msg { min-height: 18px; color: #dc2626; text-align: left; }
.login-card .primary { margin-top: 10px; }
.login-foot { margin-top: 18px; font-size: 11px; color: var(--muted); }
/* ---- 설정: 접속 계정 */
.acc-list { list-style: none; margin: 6px 0 10px; padding: 0; }
.acc-list li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.acc-list li b { flex: 1; }
.acc-list .role { font-size: 11px; color: var(--accent); font-weight: 700; letter-spacing: .06em; }
.acc-list button { padding: 4px 9px; font-size: 12px; }
.acc-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.acc-add input[type=text], .acc-add input[type=password] { flex: 1 1 160px; }
.acc-admin { display: inline-flex; align-items: center; gap: 4px; }
#accMsg.ok { color: #15803d; }
#accMsg.err { color: #dc2626; }
