/* arioso 플레이어 — 세로 화면이 기본. body 클래스로 화면 방식을 나눈다 (js/app.js 가 정함)
   mode-portrait   휴대폰·태블릿 세로: 위 제목 막대 + 아래 재생 막대, 설정은 아래에서 올라오는 시트
   mode-landscape  휴대폰·태블릿 가로: 막대가 악보 위에 떠 있고 재생 중엔 숨는다, 시트는 오른쪽 패널
   mode-desktop    마우스가 있는 넓은 화면: 막대 고정, 시트는 오른쪽 패널 */
:root {
  --bg: #f7f4ee;
  --panel: #ffffff;
  --panel-a: rgba(255, 255, 255, .94);
  --text: #1e1530;
  --muted: #66707c;
  --line: #dde1e6;
  --accent: #2e1b4f;
  --accent-soft: #eeeaf6;
  --accent-text: #ffffff;
  --btn: #eef0f3;
  --btn-hover: #e2e6ea;
  --on: #d97706;
  --solo: #2563eb;
  --error: #b91c1c;
  --paper: #ffffff;
  --top-h: 52px;
  --tp-h: 112px;            /* 재생 막대 높이 (app.js 가 실제 값으로 바꿈) */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #120b1f;
    --panel: #1b1230;
    --panel-a: rgba(27, 18, 48, .94);
    --text: #eee9f6;
    --muted: #9aa3ad;
    --line: #2f353c;
    --accent: #d4b678;
    --accent-soft: #2a2140;
    --accent-text: #1a1028;
    --btn: #2a2f36;
    --btn-hover: #343a42;
    --error: #f87171;
    --paper: #f4f1ea;      /* 악보는 밝은 종이 위에 */
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif; }
body { min-height: 100vh; min-height: 100dvh; overscroll-behavior-y: none; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
svg { width: 24px; height: 24px; display: block; }

/* ── 버튼 ─────────────────────────────── */
.ib { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: transparent; color: var(--text); cursor: pointer; padding: 0; flex: 0 0 auto;
  text-decoration: none; }
.ib:hover:not(:disabled) { background: var(--btn); }
.ib:disabled { opacity: .35; cursor: default; }
.ib.txt { width: auto; min-width: 52px; border-radius: 22px; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.ib.on { color: var(--on); }
.ib .tag { position: absolute; right: 0; top: 2px; font-size: 10px; font-weight: 800; color: var(--on); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--btn); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; }
.btn:hover:not(:disabled) { background: var(--btn-hover); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.on { background: var(--on); border-color: var(--on); color: #fff; }
.btn.solo.on { background: var(--solo); border-color: var(--solo); }
.btn.block { width: 100%; }
.btn.danger { color: var(--error); }
.play { width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: 0 0 auto; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.play svg { width: 30px; height: 30px; }
.play:disabled { opacity: .4; cursor: default; box-shadow: none; }
input[type=range] { accent-color: var(--accent); }
select { height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--btn); color: var(--text);
  font: inherit; padding: 0 8px; max-width: 100%; }

/* ── 위 제목 막대 ─────────────────────────── */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 2px; height: var(--top-h);
  padding: 0 calc(4px + var(--safe-r)) 0 calc(4px + var(--safe-l)); background: var(--panel); border-bottom: 1px solid var(--line);
  transition: transform .25s, opacity .25s; }
.ttl { flex: 1; min-width: 0; padding: 0 4px; }
.t1 { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t2 { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t2:empty { display: none; }
.status { position: sticky; top: var(--top-h); z-index: 19; padding: 6px 14px; font-size: 13px; color: var(--muted);
  background: var(--panel); border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status:empty { display: none; }
.status.error { color: var(--error); }

/* ── 악보 ─────────────────────────────── */
main { padding: 8px 6px calc(var(--tp-h) + 12px); }
.score { background: var(--paper); border-radius: 8px; overflow-x: auto; cursor: pointer; min-height: 40vh; }
.score.idle { display: none; }   /* 악보를 열기 전. 그리는 동안 숨기면 OSMD가 너비를 0으로 재므로 열기 직전에 푼다 */
.score svg { display: block; width: auto; height: auto; max-width: none; }
.empty { text-align: center; padding: 18vh 20px 0; }
.empty .big { font-size: 20px; font-weight: 700; margin: 0 0 6px; }
.empty .row { display: flex; gap: 8px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

/* ── 아래 재생 막대 (세로 기본) ─────────────── */
.transport { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--panel); border-top: 1px solid var(--line);
  padding: 6px calc(10px + var(--safe-r)) calc(6px + var(--safe-b)) calc(10px + var(--safe-l));
  transition: transform .25s, opacity .25s; }
.seekrow { display: flex; align-items: center; gap: 10px; }
.seekrow input { flex: 1; min-width: 0; height: 28px; }
.chord { font-weight: 800; font-size: 15px; color: var(--accent); min-width: 0; white-space: nowrap; }
.chord:empty { display: none; }
.ib.off svg { opacity: .45; }
.choices { display: grid; gap: 8px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--panel); color: var(--text); font: inherit; cursor: pointer; }
.choice span { font-size: 13px; color: var(--muted); }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.choice.on b { color: var(--accent); }
.choice:disabled { opacity: .4; cursor: default; }
.tm { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 38px; text-align: center; }
.btnrow { display: flex; align-items: center; justify-content: space-between; max-width: 520px; margin: 2px auto 0; }

/* ── 시트 (세로: 아래에서 올라옴) ─────────────── */
.sheet-back { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .2s; }
.sheet-back.show { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; max-height: 78vh; max-height: 78dvh; display: flex; flex-direction: column;
  background: var(--panel); border-radius: 16px 16px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.18);
  padding-bottom: var(--safe-b); animation: sheet-up .2s ease-out; }
@keyframes sheet-up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
/* 재생 막대 위에 떠 있는 시트 (반주): 배경을 덮지 않아 재생 버튼을 누를 수 있다 */
.sheet.docked { bottom: var(--tp-h); max-height: calc(78vh - var(--tp-h)); max-height: calc(78dvh - var(--tp-h)); padding-bottom: 0; }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 4px 18px; }
.sheet-head h2 { font-size: 17px; margin: 0; }
.sheet-body { overflow-y: auto; padding: 4px 18px 20px; -webkit-overflow-scrolling: touch; }
.sect { padding: 12px 0; border-top: 1px solid var(--line); }
.sect:first-child { border-top: 0; padding-top: 4px; }
.sect h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.line { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.line > .grow { flex: 1; min-width: 0; }
.line input[type=range] { flex: 1; min-width: 0; height: 32px; }
.val { min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.center { text-align: center; }
.vlabel { flex: 0 0 72px; font-size: 14px; }
details.more summary { cursor: pointer; padding: 8px 0; font-size: 14px; color: var(--muted); }
.tempo-row { justify-content: center; }
.tempo-num { width: 88px; height: 40px; text-align: center; font-size: 18px; font-weight: 700; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--text); font-variant-numeric: tabular-nums; }
.btn.on-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.big-val { font-size: 34px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; margin: 4px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.switch { position: relative; width: 50px; height: 30px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 15px; background: var(--line); transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* 파트 */
.part { padding: 10px 0; border-top: 1px solid var(--line); }
.part:first-child { border-top: 0; }
.part .pname { font-weight: 700; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part select { width: 100%; }
.part .line { min-height: 40px; }

/* 목록 (악보 열기) */
.list { display: flex; flex-direction: column; }
.list button { text-align: left; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--text);
  padding: 12px 4px; font: inherit; cursor: pointer; }
.list button:first-child { border-top: 0; }
.list button:hover { background: var(--btn); }

/* ── 팝업 ─────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(0,0,0,.45); }
.modal .box { width: min(400px, 100%); background: var(--panel); border-radius: 16px; padding: 22px 20px 18px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal h2 { font-size: 18px; margin: 0 0 8px; }
.modal p { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.modal .actions { display: flex; gap: 8px; margin-top: 16px; }
.modal .actions .btn { flex: 1; }

.drop { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 50;
  background: rgba(31, 122, 77, .18); border: 3px dashed var(--accent); font-size: 22px; color: var(--text); }
.drop.show { display: flex; }

/* ── 가로 (휴대폰·태블릿을 돌렸을 때) ─────────────── */
.mode-landscape .topbar { position: fixed; left: 0; right: 0; background: var(--panel-a); backdrop-filter: blur(6px); }
.mode-landscape .status { position: fixed; left: 0; right: 0; top: var(--top-h); background: var(--panel-a); }
.mode-landscape main { padding: 4px calc(4px + var(--safe-r)) 4px calc(4px + var(--safe-l)); }
.mode-landscape .score { min-height: calc(100vh - 8px); min-height: calc(100dvh - 8px); }
.mode-landscape .empty { padding-top: calc(var(--top-h) + 6vh); }
.mode-landscape .transport { background: var(--panel-a); backdrop-filter: blur(6px); display: flex; align-items: center; gap: 8px;
  padding-top: 2px; padding-bottom: calc(2px + var(--safe-b)); }
.mode-landscape .seekrow { flex: 1; order: 2; }
.mode-landscape .btnrow { order: 1; margin: 0; gap: 2px; max-width: none; }
.mode-landscape .play { width: 48px; height: 48px; }
.mode-landscape .play svg { width: 26px; height: 26px; }
/* 재생 중 몇 초 지나면 막대를 숨긴다 (화면을 누르면 다시 보임) */
.mode-landscape.ui-hidden .topbar, .mode-landscape.ui-hidden .status { transform: translateY(-110%); opacity: 0; pointer-events: none; }
.mode-landscape.ui-hidden .transport { transform: translateY(110%); opacity: 0; pointer-events: none; }

/* 가로·데스크톱: 시트는 오른쪽 패널 */
.mode-landscape .sheet, .mode-desktop .sheet { left: auto; top: 0; right: 0; bottom: 0; width: min(380px, 60vw); max-height: none;
  border-radius: 16px 0 0 16px; padding-right: var(--safe-r); animation: sheet-left .2s ease-out; }
.mode-landscape .sheet.docked, .mode-desktop .sheet.docked { bottom: var(--tp-h); max-height: none; border-radius: 16px 0 0 0; }
@keyframes sheet-left { from { transform: translateX(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.mode-landscape .sheet-grip, .mode-desktop .sheet-grip { display: none; }
.mode-landscape .sheet-head, .mode-desktop .sheet-head { padding-top: 10px; }

/* ── 데스크톱 ─────────────────────────────── */
.mode-desktop main { padding: 16px 16px calc(var(--tp-h) + 16px); max-width: 1400px; margin: 0 auto; }
.mode-desktop .transport { display: flex; align-items: center; gap: 16px; padding: 8px 20px; }
.mode-desktop .seekrow { flex: 1; order: 2; }
.mode-desktop .btnrow { order: 1; margin: 0; gap: 4px; max-width: none; }
.mode-desktop .play { width: 52px; height: 52px; }

/* 관리자: 현재 설정 저장 (위쪽 막대) */
.ib.staff-save { width: auto; padding: 0 10px; gap: 4px; border-radius: 22px; color: var(--accent); font-size: 13px; font-weight: 700; }
.ib.staff-save[hidden] { display: none; }
.ib.staff-save svg { width: 20px; height: 20px; }
.ib.staff-save.dirty::after { content: ''; position: absolute; right: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--error); }
@media (max-width: 420px) { .ib.staff-save .lbl { display: none; } .ib.staff-save { padding: 0; width: 44px; } }

/* 시작 카운트다운 */
.countdown { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 40; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 150px; padding: 14px 26px 12px;
  border-radius: 24px; background: color-mix(in srgb, var(--bg, #000) 82%, transparent); box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.countdown[hidden] { display: none; }
.countdown b { font-size: 96px; line-height: 1; font-weight: 900; color: var(--accent); font-variant-numeric: tabular-nums; }
.countdown span { font-size: 13px; color: var(--muted); }
.countdown.beat b { animation: cdPulse .35s ease-out; }
.countdown.last b { color: var(--on); }
@keyframes cdPulse { from { transform: scale(1.35); opacity: .5; } to { transform: scale(1); opacity: 1; } }
@media (orientation: landscape) and (max-height: 500px) { .countdown b { font-size: 64px; } }

/* 키 조절 */
.key-row { justify-content: center; gap: 8px; }
.key-row .big-val { min-width: 120px; }

/* 앙상블 연습실 (r0.2.0) */
.ib.room-btn { width: auto; padding: 0 10px; gap: 5px; border-radius: 22px; background: var(--accent-soft, rgba(31,122,77,.12)); color: var(--accent); font-size: 13px; font-weight: 700; }
.ib.room-btn[hidden] { display: none; }
.ib.room-btn svg { width: 20px; height: 20px; }
.ib.room-btn .rtag { font-size: 11px; font-weight: 800; background: var(--accent); color: var(--accent-text, #fff); border-radius: 8px; padding: 1px 6px; }
.ib.room-btn .rtag:empty { display: none; }
@media (max-width: 420px) { .ib.room-btn .lbl { display: none; } }
.assign .line { gap: 10px; }
.assign select { max-width: 55%; }

/* 유료 악보 미리보기 안내 (r0.3.0) */
.paywall { position: relative; z-index: 6; display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--accent-soft); border-bottom: 1px solid var(--line); font-size: 13px; }
.paywall[hidden] { display: none; }
.paywall .pw-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.paywall .pw-text b { color: var(--accent); }
.paywall .pw-text span { color: var(--text); }
.mode-landscape .paywall { position: fixed; left: 0; right: 0; bottom: var(--tp-h); z-index: 18; background: var(--accent-soft); }
.mode-landscape.ui-hidden .paywall { opacity: 0; pointer-events: none; }

/* 즐겨찾기 (r0.6.0) */
.ib.fav.on { color: #c2416b; }
@media (prefers-color-scheme: dark) { .ib.fav.on { color: #f07a9c; } }
