/* Notavela 웹 — 라이트/다크, 모바일 우선. 외부 폰트 · 프레임워크 없음 */
:root {
  --bg: #f7f6f3; --surface: #ffffff; --surface-2: #f0eee9; --text: #1f1f1f; --muted: #6b6860;
  --line: #e2dfd8; --accent: #2f5d8a; --accent-text: #ffffff; --accent-soft: #e6eef6;
  --danger: #a33a2c; --danger-soft: #f7e8e5; --ok: #2d6a3e; --ok-soft: #e5f1e8; --warn-soft: #f6efdd;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a; --surface: #1d2024; --surface-2: #25292e; --text: #e8e6e1; --muted: #9a978f;
    --line: #30343a; --accent: #7fb0e0; --accent-text: #0f1a25; --accent-soft: #1f2d3b;
    --danger: #e38a7c; --danger-soft: #3a2320; --ok: #8cc79b; --ok-soft: #1f3226; --warn-soft: #36301f;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "Noto Sans KR", "Apple SD Gothic Neo", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 2rem 0 .75rem; }
p { margin: .25rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* 머리 */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1080px; margin: 0 auto; padding: .6rem 16px; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--muted); padding: .3rem .6rem; border-radius: 8px; }
.nav a:hover, .nav a.on { color: var(--text); background: var(--surface-2); text-decoration: none; }
.who { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .9rem; }
.who form { margin: 0; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

main { max-width: 1080px; margin: 0 auto; padding: 1.25rem 16px 3rem; }
.narrow { max-width: 420px; margin: 2rem auto; }
/* 개인정보처리방침 — 읽는 글이라 더 넓게 */
.narrow.privacy { max-width: 720px; }
/* 앱 다운로드 */
.narrow.download { max-width: 640px; }
.download .notice { background: var(--warn-soft); }
.download ol { padding-left: 1.3rem; margin: .2rem 0 .6rem; }
.download li { margin: .35rem 0; }
.download code { font-size: .9em; background: var(--surface-2); padding: .05rem .3rem; border-radius: 4px; }
.download .sha { word-break: break-all; font-size: .75rem; }
.download h2 { margin-top: 1.6rem; }
.download details.notes { margin-top: .6rem; }
.download details.notes summary { cursor: pointer; font-size: .9rem; }
.download .release-notes { font-size: .88rem; margin-top: .4rem; }
.download .release-notes h3, .download .release-notes h4, .download .release-notes h5, .download .release-notes h6 { font-size: .95rem; margin: .9rem 0 .3rem; }
.download .release-notes ul { padding-left: 1.2rem; margin: .2rem 0; }
.download .release-notes li { margin: .2rem 0; }
.download .release-notes blockquote { margin: .4rem 0; padding-left: .7rem; border-left: 3px solid var(--line); }
.download .release-notes blockquote p { margin: .2rem 0; }
.download .history { padding-left: 1.2rem; margin: .4rem 0 0; }
.privacy h2 { font-size: 1rem; margin: 1.6rem 0 .5rem; }
.privacy h2:first-of-type { margin-top: 1.2rem; }
.privacy ul { padding-left: 1.2rem; margin: .3rem 0 .6rem; }
.privacy li { margin: .25rem 0; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
footer { max-width: 1080px; margin: 0 auto; padding: 1rem 16px 2rem; color: var(--muted); font-size: .8rem; }

/* 메시지 */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .6rem .8rem; border-radius: var(--radius); margin-bottom: .5rem; background: var(--accent-soft); }
.messages .success { background: var(--ok-soft); }
.messages .error { background: var(--danger-soft); }
.messages .warning { background: var(--warn-soft); }

/* 카드 · 상자 */
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.box + .box { margin-top: 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column; color: var(--text); }
.card:hover { text-decoration: none; border-color: var(--accent); }
.thumb { aspect-ratio: 3 / 4; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.thumb .ph { color: var(--muted); font-size: .8rem; }
.card-body { padding: .55rem .7rem .7rem; }
.card-title { font-weight: 600; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-meta { color: var(--muted); font-size: .8rem; margin-top: .25rem; display: flex; flex-wrap: wrap; gap: .25rem; }
.card-sub { color: var(--muted); font-size: .8rem; margin-top: .2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-block; font-size: .72rem; padding: .05rem .45rem; border-radius: 99px; background: var(--accent-soft); color: var(--text); white-space: nowrap; }
.badge.plain { background: var(--surface-2); }

/* 표 */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: .8rem; }
.table-wrap { overflow-x: auto; }

/* 폼 */
form.stack > * + * { margin-top: .8rem; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.field .help { color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.field .errorlist { list-style: none; padding: 0; margin: .25rem 0 0; color: var(--danger); font-size: .85rem; }
.errorlist.nonfield { background: var(--danger-soft); color: var(--text); padding: .5rem .7rem; border-radius: var(--radius); list-style: none; margin: 0 0 .8rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .6rem; }
input[type=file] { font: inherit; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row > input, .row > select { width: auto; flex: 1 1 140px; }
.inline { display: inline; margin: 0; }

.btn { display: inline-block; font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; padding: .5rem .9rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { padding: .25rem .6rem; font-size: .85rem; font-weight: 500; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* 상세 */
.detail { display: grid; grid-template-columns: 220px 1fr; gap: 1.5rem; align-items: start; }
.detail .thumb { border-radius: var(--radius); border: 1px solid var(--line); }
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 1rem 0; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; }
@media (max-width: 640px) {
  .top-inner { gap: .25rem .75rem; }
  .brand { flex: 1; }
  .nav { order: 3; flex: 1 0 100%; margin: 0 -.6rem; }
  .detail { grid-template-columns: 1fr; }
  .detail .thumb { max-width: 220px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
}

.quota { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: .4rem 0; }
.quota span { display: block; height: 100%; background: var(--accent); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .05em; }
/* 기기 코드 — 글자마다 칸, 가운데 대시는 보여 주기만 한다 */
.code-boxes { display: flex; align-items: center; gap: .35rem; flex-wrap: nowrap; }
.code-boxes input[type=text] { width: 2.6rem; height: 3.1rem; padding: 0; text-align: center; font-size: 1.45rem; font-weight: 700;
  text-transform: uppercase; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; flex: 0 1 2.6rem; min-width: 0; }
.code-boxes input[type=text]:not(:placeholder-shown) { background: var(--accent-soft); border-color: var(--accent); }
.code-dash { color: var(--muted); font-size: 1.4rem; font-weight: 700; padding: 0 .1rem; user-select: none; }
.code-boxes.bad input[type=text] { animation: code-shake .25s; }
@keyframes code-shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.copy { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
details > summary { cursor: pointer; color: var(--accent); }
.danger-zone { border-color: var(--danger-soft); }
.pager { display: flex; gap: .75rem; justify-content: center; align-items: center; margin-top: 1.25rem; }

/* 앙상블 곡 목록 — 곡마다 파트 칩 */
.songs td:first-child { font-weight: 600; }
.parts { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { display: inline-block; padding: .2rem .6rem; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: .85rem; }
.chip:hover { border-color: var(--accent); text-decoration: none; }

/* 좁은 화면: 표의 행을 세로로 쌓는다 (멤버 · 초대 — 오른쪽 버튼이 잘리지 않게) */
@media (max-width: 640px) {
  table.stacked thead { display: none; }
  table.stacked tr { display: block; padding: .6rem 0; border-bottom: 1px solid var(--line); }
  table.stacked td { display: block; border: 0; padding: .2rem 0; text-align: left !important; min-width: 0 !important; }
  table.stacked .row > input, table.stacked .row > select { flex: 1 1 100%; }
}

/* 체크박스 · 라디오 줄 — .row > input(텍스트 칸을 늘리는 규칙)을 쓰지 않는다 */
.choice { display: flex; align-items: center; gap: .55rem; padding: .3rem 0; cursor: pointer; line-height: 1.4; }
.choice input { width: auto; flex: none; margin: 0; accent-color: var(--accent); }
.choice .muted { margin-left: .25rem; }
.option { border: 1px solid var(--line); border-radius: 8px; padding: .55rem .8rem; }
.option + .option { margin-top: .5rem; }
.option:has(> .choice input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option .hint { color: var(--muted); font-size: .8rem; margin: .1rem 0 0 1.6rem; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0 1rem; margin: .35rem 0 .1rem 1.6rem; }

/* TV 카드 */
.device { max-width: 760px; }
.device + .device { margin-top: 1rem; }
.device-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.device-head h2 { margin: 0; font-size: 1.15rem; }
.device-meta { color: var(--muted); font-size: .85rem; margin: .2rem 0 .8rem; }
.device-head > div { flex: 1; min-width: 0; }
/* 기기 이름 — 이름을 누르면 그 자리에서 고친다(JS 가 없으면 입력칸이 그대로 보인다) */
.name-show { all: unset; cursor: pointer; border-radius: 6px; padding: .05rem .3rem; margin: 0 -.3rem; overflow-wrap: anywhere; }
.name-show:hover, .name-show:focus-visible { background: var(--accent-soft); }
.name-show:focus-visible { outline: 2px solid var(--accent); }
.name-pen { color: var(--muted); font-size: .9em; font-weight: 400; margin-left: .4rem; opacity: 0; }
.name-show:hover .name-pen, .name-show:focus-visible .name-pen { opacity: 1; }
@media (hover: none) { .name-pen { opacity: 1; } }
.name-edit h2 { margin: 0; }
.js .name-edit .name-form { display: none; }
.js .name-edit.editing h2 { display: none; }
.js .name-edit.editing .name-form { display: block; }
.name-form { background: var(--accent-soft); border: 2px solid var(--accent); border-radius: var(--radius); padding: .6rem .7rem; max-width: 460px; }
.name-form .row { margin: .35rem 0 .2rem; }
.name-form input[type=text] { font-size: 1.1rem; font-weight: 700; }
.badge.editing { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.device h3 { font-size: .9rem; margin: 0 0 .5rem; color: var(--muted); font-weight: 600; }
/* .field label(칸 제목) 규칙이 선택지 글자에 번지지 않게 */
.field .choice { display: flex; font-weight: 400; font-size: 1rem; margin: 0; }
.field .choice.small { font-size: .85rem; }

.brand-version { font-size: .72rem; font-weight: 500; color: var(--muted); margin-left: .2rem; letter-spacing: 0; }

/* 쪽 보기 */
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.page-thumb { display: block; text-align: center; color: var(--muted); text-decoration: none; font-size: .8rem; }
.page-thumb img { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1.414; object-fit: contain; background: #fff;
  border: 1px solid var(--line); border-radius: 4px; }
.page-thumb:hover img, .page-thumb:focus-visible img { border-color: var(--accent); }
.page-viewer { width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: none; margin: 0; padding: 0;
  border: 0; background: var(--bg); color: var(--text); overflow: auto; }
.page-viewer::backdrop { background: rgba(0, 0, 0, .7); }
body.reader { overflow: hidden; }   /* 쪽 보기 주소(scores/<id>/pages/) — 보기 칸만 스크롤 */
.page-viewer-bar { position: sticky; top: 0; display: flex; gap: .5rem; align-items: center; justify-content: center;
  padding: .5rem; background: var(--bg); border-bottom: 1px solid var(--line); }
.page-viewer-bar { flex-wrap: wrap; z-index: 1; }
.page-viewer-fit { display: inline-flex; gap: .25rem; }
.page-viewer-fit .btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.page-viewer-pages { display: flex; justify-content: center; align-items: flex-start; gap: 4px; cursor: pointer; position: relative; }
.page-notes { position: absolute; pointer-events: none; overflow: visible; }
.page-notes[hidden] { display: none; }
.page-notes .notes-conductor { opacity: .8; }
.page-viewer-pages img { display: block; background: #fff; min-width: 0; }
.page-viewer-pages img[hidden] { display: none; }
/* 너비 맞춤: 가로를 채우고 세로로 스크롤 — 두 쪽이면 반씩 */
.page-viewer.fit-width .page-viewer-pages img { width: 100%; height: auto; }
.page-viewer.fit-width.spread-2 .page-viewer-pages img { width: calc(50% - 2px); }
/* 높이 맞춤: 한 화면에 — 두 쪽이 화면보다 넓으면 가로로 스크롤 */
.page-viewer.fit-height .page-viewer-pages { width: max-content; min-width: 100%; }
.page-viewer.fit-height .page-viewer-pages img { width: auto; max-width: none; height: calc(100dvh - var(--bar-h, 3rem)); }

/* 악보 인식 결과 */
.omr-box table { margin-top: .6rem; }
.omr-box td input[type=text] { width: 100%; max-width: 20rem; }
.page-viewer-player { display: inline-flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.page-viewer-player input[type=range] { width: 7rem; vertical-align: middle; }
.page-viewer-player [data-status] { min-width: 3.5rem; }
.player-parts { position: relative; }
.player-parts > summary { list-style: none; cursor: pointer; }
.player-parts > summary::-webkit-details-marker { display: none; }
.player-parts-list { position: absolute; top: 110%; left: 0; z-index: 2; display: grid; gap: .3rem; min-width: 9rem;
  padding: .5rem .7rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }

/* 목록 카드 — 썸네일 위 쪽수 */
.card .thumb { position: relative; }
.thumb-pages { position: absolute; right: .4rem; bottom: .4rem; padding: .05rem .4rem; border-radius: 999px;
  background: rgba(0, 0, 0, .62); color: #fff; font-size: .72rem; line-height: 1.5; }

/* 올리기 드롭존 — 크게 */
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem;
  min-height: 15rem; padding: 2rem 1rem; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface-2); transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone:focus-within { border-color: var(--accent); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon { font-size: 2.4rem; line-height: 1; color: var(--accent); }
.dropzone strong { font-size: 1.1rem; }
.dropzone.compact { min-height: 8rem; padding: 1.2rem 1rem; }
.dropzone.compact .dropzone-icon { font-size: 1.8rem; }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone-files { display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem; margin-top: .4rem; }
.dropzone-file { padding: .15rem .55rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: .85rem; }

.pipeline span.done { color: var(--ok); }

/* 악보 영역의 하위 탭 — 모든 악보 | 세트리스트 */
.subtabs { display: flex; gap: .25rem; margin: -.25rem 0 1rem; border-bottom: 1px solid var(--line); }
.subtabs a { padding: .45rem .8rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subtabs a:hover { color: var(--text); text-decoration: none; }
.subtabs a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
