/* ── 악보 공방 — 흰 바탕 + 검정 잉크 + 팀박스 하늘색 포인트 (SSOT: demo.html) ── */
:root {
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --ink: #111111;
  --ink-soft: #6b7280;
  --line: #e5e5e5;
  --line-strong: #d4d4d4;
  --sky: #7FB3D5;        /* 팀박스 로고 하늘 (tb-blue-100) */
  --sky-deep: #3A6EA5;   /* 팀박스 로고 중간 (tb-blue-500) — 글자 대비용 */
  --sky-soft: #EDF3F9;   /* 연한 틴트 (tb-action-soft) */
  --sky-border: #DCE3EC;
  --font: -apple-system, BlinkMacSystemFont, "Malgun Gothic", sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; }
body {
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-soft);
  -webkit-tap-highlight-color: transparent;
  display: flex; flex-direction: column;
}
button { font-family: inherit; }

/* ══ 상단 고정 도구 클러스터 ═══════════════════════════ */
.topdeck {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 24px -20px rgba(0, 0, 0, 0.25);
}

/* 1단 — 브랜드 · 도구탭 · 파일 · 보기 전환 */
.deck-head {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 16px;
}
.brand { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; margin-right: 4px; }
.brand em { font-style: normal; color: var(--sky-deep); font-size: 15px; }
.brand strong { font-size: 15px; letter-spacing: 0.05em; }
.filecell { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.filecell .fname {
  font-size: 12.5px; font-weight: 700; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px;
}
.linklike {
  border: 0; background: none; font: inherit; font-size: 12px; color: var(--ink-soft);
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap;
}
.linklike:active { color: var(--ink); }
/* 보기 전환(원본/나란히/결과) */
.viewseg { display: flex; border: 1px solid var(--line-strong); background: var(--bg); border-radius: 8px; overflow: hidden; }
.viewseg button {
  min-height: 32px; padding: 0 12px; font-size: 12px; letter-spacing: 0.06em;
  background: none; border: 0; color: var(--ink-soft); cursor: pointer;
}
.viewseg button + button { border-left: 1px solid var(--line); }
.viewseg button.on { background: var(--ink); color: #fff; font-weight: 700; }

/* 도구탭 — 같은 줄의 알약형 */
.tabrow { display: flex; align-items: center; gap: 4px; }
.tab {
  min-height: 36px; padding: 0 12px;
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  font-size: 13px; letter-spacing: 0.03em; color: var(--ink-soft); cursor: pointer;
}
.tab .glyph { font-size: 14px; }
.tab.on {
  background: var(--sky-soft); border-color: var(--sky-border);
  color: var(--ink); font-weight: 700;
}
.tab.on .glyph { color: var(--sky-deep); }

/* 2단 — 활성 탭의 도구 선반(슬림) */
.shelf {
  background: var(--bg); border-top: 1px solid var(--line);
  padding: 5px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  min-height: 46px;
}
.shelf .hint { font-size: 12px; color: var(--ink-soft); letter-spacing: 0.03em; }
.shelf .linebtns { display: inline-flex; gap: 4px; }
.shelf .linebtns .btn { padding: 4px 8px; font-size: 12px; }
.shelf .sep { width: 1px; height: 22px; background: var(--line); }
.spacer { flex: 1; }

/* 조옮김 선반 */
.shift-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--ink); background: var(--bg); color: var(--ink);
  font-size: 16px; cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, transform 0.08s ease;
}
.shift-btn:active { transform: scale(0.92); background: var(--ink); color: #fff; }
.seal {
  width: 38px; height: 38px; border-radius: 8px;
  background: linear-gradient(160deg, #5B8FBF, var(--sky-deep));
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.35), 0 8px 18px -8px rgba(58, 110, 165, 0.6);
  transform: rotate(-3deg);
}
.seal span { font-size: 15px; font-weight: 700; line-height: 1; }
.seal small { display: none; }
.seal.stamp { animation: stamp 0.28s ease; }
@keyframes stamp {
  0% { transform: rotate(-3deg) scale(1.25); }
  60% { transform: rotate(-3deg) scale(0.94); }
  100% { transform: rotate(-3deg) scale(1); }
}
.keychange { font-size: 13px; color: var(--ink-soft); }
.keychange b { color: var(--sky-deep); font-size: 14px; }

/* 공용 버튼 */
.btn {
  font: inherit; font-size: 13px; letter-spacing: 0.04em;
  min-height: 36px; padding: 0 13px; cursor: pointer;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 8px;
  transition: background 0.12s ease, color 0.12s ease;
}
.btn:active { background: var(--sky-soft); border-color: var(--sky-border); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 700; }
.btn:disabled { opacity: 0.45; cursor: wait; }
.selbadge { font-size: 13px; font-weight: 700; min-width: 120px; color: var(--sky-deep); }
.field { display: flex; align-items: center; gap: 8px; }
.field label { font-size: 12px; color: var(--ink-soft); letter-spacing: 0.1em; }
.tinput {
  font: inherit; font-size: 13.5px;
  border: 1px solid var(--line-strong); background: var(--bg); border-radius: 8px;
  min-height: 36px; padding: 0 10px; color: var(--ink);
}
.tinput:focus { outline: none; border-color: var(--sky-deep); }
.tinput.title { width: 230px; }
.tinput.lyric { width: 110px; }

/* ══ 악보 무대 ═══════════════════════════ */
.stagewrap { max-width: 1500px; width: 100%; margin: 0 auto; padding: 24px 24px 48px; flex: 1; }
.panes { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.panes.only-orig { grid-template-columns: 1fr; }
.panes.only-orig .pane.result { display: none; }
.panes.only-result { grid-template-columns: 1fr; }
.panes.only-result .pane.orig { display: none; }
.pane h2 {
  font-size: 12px; font-weight: 400; letter-spacing: 0.35em;
  color: var(--ink-soft); margin: 0 0 10px 4px;
}
.pane-body {
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
  min-height: 420px; max-height: calc(100vh - 220px); overflow: auto; padding: 26px 22px;
  box-shadow: 0 16px 32px -26px rgba(0, 0, 0, 0.3);
}
.orig .pane-body { background: var(--bg-soft); }
.pane-body img, .pane-body embed { width: 100%; display: block; }
.pane-body embed { height: calc(100vh - 280px); }
.sheet svg { width: 100%; height: auto; display: block; }
.sheet .page + .page { border-top: 1px dashed var(--line); margin-top: 14px; padding-top: 14px; }
.sheet.refreshing { opacity: 0.35; transition: opacity 0.15s; }
.sheet.editing g.note, .sheet.editing g.chord { cursor: pointer; }
.sheet g.note.sel *, .sheet g.chord.sel * { fill: var(--sky-deep) !important; stroke: var(--sky-deep) !important; }

/* ══ 업로드 ═══════════════════════════ */
.stage { width: 100%; max-width: 860px; margin: 0 auto; padding: 28px 32px 40px; flex: 1; }
.upload-brand { text-align: center; margin-top: 6vh; }
.upload-brand em { font-style: normal; color: var(--sky-deep); font-size: 22px; margin-right: 6px; }
.upload-brand strong { font-size: 22px; letter-spacing: 0.06em; }
.upload-brand small { font-size: 12px; color: var(--ink-soft); letter-spacing: 0.4em; margin-left: 10px; }
.dropzone {
  position: relative; display: block; cursor: pointer;
  margin-top: 26px; padding: 84px 40px;
  background: var(--bg);
  border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: 0 18px 40px -28px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.dropzone:hover, .dropzone.dragover {
  transform: translateY(-3px);
  box-shadow: 0 26px 48px -26px rgba(0, 0, 0, 0.4);
}
.dropzone.dragover { border-color: var(--sky-deep); }
.dz-lines { position: absolute; inset: 50% 36px auto; height: 56px; display: flex; flex-direction: column; justify-content: space-between; transform: translateY(-50%); }
.dz-lines i { height: 1px; background: var(--line); }
.dz-body { position: relative; text-align: center; display: flex; flex-direction: column; gap: 10px; }
.dz-note { font-size: 56px; line-height: 1; color: var(--ink); }
.dropzone:hover .dz-note { animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }
.dz-body strong { font-size: 20px; letter-spacing: 0.04em; }
.dz-sub { font-size: 14px; color: var(--ink-soft); }

/* ══ 처리 중 ═══════════════════════════ */
.processing { margin-top: 10vh; text-align: center; }
.proc-staff { position: relative; height: 64px; max-width: 420px; margin: 0 auto 34px; display: flex; flex-direction: column; justify-content: space-between; }
.proc-staff i { height: 1px; background: var(--line-strong); }
.proc-staff .pn {
  position: absolute; top: 8px; font-size: 30px; color: var(--ink);
  left: -10%; animation: glide 2.8s linear infinite; animation-delay: var(--d);
  opacity: 0;
}
@keyframes glide {
  0% { left: -8%; opacity: 0; }
  12% { opacity: 1; }
  85% { opacity: 1; }
  100% { left: 104%; opacity: 0; }
}
.processing p { font-size: 16px; letter-spacing: 0.03em; }
.proc-sub { margin-top: 10px; font-size: 13px; color: var(--ink-soft); }

/* ══ 오류·바닥글 ═══════════════════════════ */
.errorbox { margin-top: 10vh; text-align: center; display: flex; flex-direction: column; gap: 18px; align-items: center; }
.errorbox strong { font-size: 19px; }
.errorbox pre {
  max-width: 640px; max-height: 220px; overflow: auto; text-align: left;
  font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 14px;
  white-space: pre-wrap; color: var(--ink-soft);
}
.colophon { text-align: center; padding: 4px 0 26px; font-size: 12px; color: var(--ink-soft); letter-spacing: 0.08em; }

/* 좁은 화면(아이패드 세로·폰) */
@media (max-width: 1100px) {
  /* 좁은 화면: 파일명만 숨기고 '다른 악보'(파일 바꾸기)는 항상 남긴다 */
  .filecell .fname { display: none; }
}
@media (max-width: 900px) {
  .panes { grid-template-columns: 1fr; }
  .deck-head { flex-wrap: wrap; }
}
