:root {
  /* 어두운 화면 (처음 다크 모드 색). 악보는 흰 종이색 그대로 */
  --bg: #1b1d20; --panel: #24272b; --ink: #e8e6e1; --sub: #a3a7ad; --line: #3a3e44;
  --acc: #6e9fd1; --acc-ink: #10151b; --on: #57b07c; --slow: #6b5526; --fast: #2f5a3e; --loop: #33466a; --err: #ff8a80;
  --list-w: 260px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.4 -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  display: flex; flex-direction: column; overflow: hidden; -webkit-text-size-adjust: 100%; }
button, select, input { font: inherit; color: inherit; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-height: 36px; min-width: 36px; cursor: pointer; touch-action: manipulation; }
button:active { transform: translateY(1px); }
button.ghost { background: transparent; }
select, input[type=number], input[type=search] { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; min-height: 36px; }
input[type=number] { width: 64px; }
input[type=range] { accent-color: var(--acc); }

header#top { display: flex; align-items: center; gap: 6px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--panel); border-bottom: 1px solid var(--line); }
#songTitle { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.spacer { flex: 1; }

#wrap { flex: 1; display: flex; min-height: 0; position: relative; }
aside#list { width: var(--list-w); flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.listHead { display: flex; gap: 6px; padding: 8px; align-items: center; border-bottom: 1px solid var(--line); }
.listHead input[type=search] { flex: 1; min-width: 0; }
#songs { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
#songs li { display: flex; gap: 8px; align-items: baseline; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
#songs li b { min-width: 40px; text-align: right; color: var(--acc); font-variant-numeric: tabular-nums; }
#songs li span { flex: 1; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#songs li i { color: #d4a017; font-style: normal; }
#songs li em { font-style: normal; font-size: 12px; color: var(--sub); }
#songs li.on { background: var(--acc); color: var(--acc-ink); }
#songs li.on span, #songs li.on em, #songs li.on b { color: inherit; }
body:not(.showList) aside#list { display: none; }
@media (min-width: 900px) { body aside#list { display: flex !important; } body.hideList aside#list { display: none !important; } }
@media (max-width: 899px) {
  aside#list { position: absolute; inset: 0 auto 0 0; z-index: 20; width: min(340px, 90vw); box-shadow: 4px 0 20px rgba(0,0,0,.25); }
}

main#stage { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#panel { order: 0; background: var(--panel); border-bottom: 1px solid var(--line); padding: 6px 10px; max-height: 60vh; overflow-y: auto; }
#score { order: 1; flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 10px; }
body.panelBottom #panel { order: 2; border-bottom: 0; border-top: 1px solid var(--line); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
#scoreInner { margin: 0 auto; max-width: 100%; }
#scoreInner[style*="width"] { max-width: none; }
#scoreInner img { display: block; width: 100%; height: auto; background: #fff; margin: 0 auto 10px; border-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.empty { color: var(--sub); text-align: center; margin-top: 20vh; }

.row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding: 4px 0; }
#more .row { border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 4px; align-items: flex-start; }
.grp { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.grp.col { flex-direction: column; align-items: stretch; flex: 1 1 320px; }
.grp.pos { flex: 1 1 220px; }
.grp.pos input { flex: 1; min-width: 120px; }
.lbl { color: var(--sub); font-size: 13px; }
.sub { color: var(--sub); font-size: 12.5px; }
.val { min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
#posText { font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap; }
button.play { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); min-width: 52px; font-size: 18px; }
button.toggle.on { background: var(--on); border-color: var(--on); color: #10241a; }
button.part { min-width: 40px; font-weight: 700; opacity: .5; text-decoration: line-through; }
button.part.on { opacity: 1; text-decoration: none; background: var(--on); border-color: var(--on); color: #10241a; }
.tag { font-size: 11px; background: var(--acc); color: var(--acc-ink); border-radius: 4px; padding: 0 4px; }
.chk { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.chk input { width: 18px; height: 18px; }
#melVol { width: 120px; }

#bars { display: flex; flex-wrap: wrap; gap: 4px; }
#bars button { min-width: 38px; min-height: 32px; padding: 2px 6px; font-variant-numeric: tabular-nums; }
#bars button.slow { background: var(--slow); }
#bars button.fast { background: var(--fast); }
#bars button.loop { box-shadow: inset 0 -4px 0 var(--acc); }
#bars button.cur { outline: 3px solid var(--acc); outline-offset: 0; font-weight: 700; }

table { border-collapse: collapse; }
th, td { padding: 3px 6px; text-align: left; font-size: 14px; }
th { color: var(--sub); font-weight: 500; font-size: 12.5px; }
#partTable select { max-width: 150px; }
#saxInfo { margin-top: 6px; max-width: 640px; }

#status { font-size: 13px; color: var(--sub); }
#status:empty { display: none; }
#status.err { color: var(--err); font-weight: 600; }

/* 악보 크게 보기 */
body.focus header#top, body.focus #panel, body.focus aside#list { display: none !important; }
#focusBar { position: fixed; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); display: none; gap: 8px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px; box-shadow: 0 4px 16px rgba(0,0,0,.2); z-index: 30; }
body.focus #focusBar { display: none; }
body.focus { background: #fff; }
body.focus #score { padding: 0; background: #fff; cursor: pointer; }
body.focus #scoreInner { width: auto !important; max-width: none; }
body.focus #scoreInner img { width: auto; max-width: 100vw; height: 100vh; height: 100dvh; object-fit: contain; margin: 0 auto; box-shadow: none; border-radius: 0; }

/* 악보1 / 악보2 고르기 */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; min-width: 0; padding: 6px 10px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--acc); color: var(--acc-ink); font-weight: 700; }

/* 악보2: 미디로 그린 큰보표 */
div.score2 { background: #fff; color: #000; border-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.12); padding: 4px 0 10px; }
.score2 .sys { line-height: 0; }
.score2 svg { display: block; }
.score2 .lyr text { font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; font-weight: bold; fill: #111; paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
.score2 .vf-stavenote { cursor: pointer; }
.score2 .vf-stavenote.hl path, .score2 .vf-stavenote.hl rect { fill: #d6336c; stroke: #d6336c; }
body.focus .score2 { box-shadow: none; border-radius: 0; }

@media (max-width: 600px) {
  #btnFocus, #btnPanelPos, #btnMore { font-size: 13px; padding: 6px; }
  .grp.pos { flex-basis: 100%; }
}

#btnFav { white-space: nowrap; }
@media (max-width: 900px) { #btnFav .favTxt { display: none; } }

#volBox { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; color: var(--sub); font-size: 13px; flex: none; }
#volBox .volIco { font-size: 15px; }
#vol { width: 110px; }
@media (max-width: 900px) { #volBox .volTxt { display: none; } #vol { width: 64px; } }
@media (max-width: 600px) { #volBox .volIco { display: none; } #vol { width: 52px; } }
@media (min-width: 601px) { header#top > button, header#top > .seg, header#top .seg button { flex-shrink: 0; white-space: nowrap; } }
@media (max-width: 900px) { header#top > button, header#top .seg button { padding-left: 8px; padding-right: 8px; } }
#awakeBadge { white-space: nowrap; } #awakeBadge.warn { color: #e0703a; font-weight: 600; }
