/* 할렐루야 찬양대 연습장 — 큰 글씨, 넓은 버튼, 차분한 색 */
:root {
  --paper: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #efece5;
  --ink: #1c1b19;
  --ink-2: #45423c;
  --muted: #625e56;
  --line: rgba(28, 27, 25, 0.13);
  --line-strong: rgba(28, 27, 25, 0.28);
  --accent: #54378f;
  --accent-ink: #ffffff;
  --accent-soft: #ece6f6;
  --good: #1d7347;
  --good-soft: #e3f2e9;
  --warn: #9a5300;
  --warn-soft: #fbeedd;
  --bad: #b42318;
  --bad-soft: #fbe6e4;
  --S: #b4380f;
  --A: #8b3fa8;
  --T: #1d67ab;
  --B: #1e7450;
  --stage: #1d1c22;
  --radius: 14px;
  --radius-sm: 10px;
  --tap: 60px;
  --font: 'Pretendard Variable', 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', system-ui, sans-serif;
  --music: 'Noto Music', 'Bravura Text', 'Segoe UI Symbol', serif;
  font-size: 20px;
  color-scheme: light;
}
html[data-size='normal'] { font-size: 18px; }
html[data-size='large'] { font-size: 20px; }
html[data-size='xlarge'] { font-size: 23px; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 틀 ---------- */
.app { max-width: 760px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  min-height: 72px; padding: 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(247, 245, 240, 0.96);
  border-bottom: 1px solid var(--line);
}
.top h1 { flex: 1; margin: 0; font-size: 1.2rem; font-weight: 700; line-height: 1.3; min-width: 0; }
.top h1 small { display: block; font-size: 0.8rem; font-weight: 500; color: var(--muted); }
.back {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 52px; padding: 0 16px 0 10px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); font-weight: 600; font-size: 1rem;
}
.back svg { width: 24px; height: 24px; }
.main { flex: 1; padding: 20px 16px calc(32px + env(safe-area-inset-bottom)); }
.main.flush { padding: 0; display: flex; flex-direction: column; }

.ico { width: 28px; height: 28px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 글 ---------- */
h2 { font-size: 1.15rem; margin: 32px 0 12px; font-weight: 700; }
h2:first-child { margin-top: 0; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.lead { font-size: 1.05rem; color: var(--ink-2); }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); padding: 0 22px;
  border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: var(--surface); font-weight: 600; font-size: 1.05rem; text-decoration: none; color: var(--ink);
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: rgba(180, 35, 24, 0.4); }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 auto; min-width: 0; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seg .btn { padding: 0 6px; font-size: 0.95rem; white-space: normal; line-height: 1.25; }

/* ---------- 카드 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 12px; }

.this-week { padding: 0; overflow: hidden; }
.this-week .tag { display: inline-block; font-size: 0.85rem; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.this-week .body { padding: 20px 20px 16px; }
.this-week h3 { margin: 0; font-size: 1.5rem; line-height: 1.3; }
.this-week .meta { color: var(--muted); margin-top: 4px; }
.this-week .keyband { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--surface-2); border-top: 1px solid var(--line); }
.this-week .go { border-radius: 0; border: 0; border-top: 1px solid var(--line); min-height: 68px; font-size: 1.1rem; }

.song-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.song-list li + li { border-top: 1px solid var(--line); }
.song-list button {
  width: 100%; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px;
  min-height: 80px; padding: 12px 16px 12px 20px; background: none; border: 0; text-align: left;
}
.song-list .t { font-weight: 600; font-size: 1.05rem; line-height: 1.35; }
.song-list .s { color: var(--muted); font-size: 0.85rem; }
.song-list .chev { width: 24px; height: 24px; color: var(--muted); }

/* 조표 배지 */
.keybadge { display: flex; align-items: center; gap: 12px; }
.txt b { display: block; font-size: 1.05rem; }
.txt span { display: block; color: var(--muted); font-size: 0.85rem; }
svg.staff { display: block; overflow: visible; }
svg.staff .line, svg.staff .ledger { stroke: var(--ink); stroke-width: 1.1; opacity: 0.75; }
svg.staff .bar { stroke: var(--ink); stroke-width: 1.2; opacity: 0.6; }
svg.staff .bar.end { stroke-width: 2.4; opacity: 0.8; }
svg.staff .clef, svg.staff .acc, svg.staff .rest { font-family: var(--music); fill: var(--ink); }
svg.staff .acc { font-size: 22px; }
svg.staff .keysig { fill: var(--accent); }
svg.staff .clef-8 { font-size: 11px; font-weight: 700; fill: var(--ink); font-family: var(--font); }
svg.staff .rest { font-size: 30px; }
svg.staff .head { fill: var(--ink); }
svg.staff .head.hollow { fill: var(--surface); stroke: var(--ink); stroke-width: 1.8; }
svg.staff .stem { stroke: var(--ink); stroke-width: 1.4; }
svg.staff .flag { fill: var(--ink); }
svg.staff .note.sel .head, svg.staff .note.sel .flag, svg.staff .note.sel .rest, svg.staff .note.sel .acc { fill: var(--accent); }
svg.staff .note.sel .head.hollow { fill: var(--accent-soft); stroke: var(--accent); }
svg.staff .note.sel .stem { stroke: var(--accent); }
svg.staff .note.sel .hit { fill: var(--accent-soft); }
svg.staff .note.cur .head { fill: var(--good); }
svg.staff .note.cur .head.hollow { fill: var(--good-soft); stroke: var(--good); }
svg.staff .note { cursor: pointer; }

/* 연습 메뉴 */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modes > .mode:first-child:nth-last-child(odd) { grid-column: 1 / -1; min-height: 112px; }
.mode {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  min-height: 132px; padding: 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); text-align: left;
}
.mode .ico { width: 34px; height: 34px; color: var(--accent); }
.mode b { font-size: 1.1rem; line-height: 1.3; }
.mode span { font-size: 0.85rem; color: var(--muted); line-height: 1.4; }
.mode.off { opacity: 0.6; }
.mode:active { background: var(--surface-2); }

/* 성부 고르기 */
.parts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.part-btn {
  display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 0 16px;
  border-radius: var(--radius); border: 2px solid var(--line); background: var(--surface); font-size: 1.05rem; font-weight: 700; white-space: nowrap;
}
.part-btn .dot { width: 18px; height: 18px; border-radius: 50%; flex: none; }
.part-btn[aria-pressed='true'] { border-color: var(--ink); background: var(--surface-2); }
.part-btn[aria-pressed='true']::after { content: '✓'; margin-left: auto; font-size: 0.8rem; font-weight: 600; color: var(--ink-2); }
.partchip { display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; }
.partchip .dot { width: 14px; height: 14px; border-radius: 50%; }

/* ---------- 영상 ---------- */
.video-wrap { background: #000; aspect-ratio: 16 / 9; width: 100%; }
.video-wrap video, .video-wrap iframe { width: 100%; height: 100%; display: block; border: 0; }
.controls { padding: 16px; display: grid; gap: 12px; }
.bigplay { min-height: 76px; font-size: 1.25rem; }
.timebar { display: flex; align-items: center; gap: 12px; font-variant-numeric: tabular-nums; }
.timebar input[type='range'] { flex: 1; }
input[type='range'] { height: 44px; accent-color: var(--accent); }
.loopinfo { font-size: 0.9rem; color: var(--ink-2); background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 14px; }

/* ---------- 악보 ---------- */
.pdfbar { position: sticky; top: 72px; z-index: 5; display: flex; gap: 8px; align-items: center; padding: 8px 16px; background: var(--paper); border-bottom: 1px solid var(--line); }
.pdfbar .pg { flex: 1; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.pdfbar .btn { min-height: 52px; padding: 0 14px; }
.pdfpages { overflow: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
.pdfpages canvas { display: block; margin: 0 auto 12px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

/* ---------- 빈 상태, 알림 ---------- */
.empty { text-align: center; padding: 40px 20px; }
.empty .ico { width: 48px; height: 48px; color: var(--muted); margin-bottom: 8px; }
.empty p { color: var(--ink-2); }
.note-box { border-radius: var(--radius-sm); padding: 12px 16px; background: var(--surface-2); color: var(--ink-2); font-size: 0.92rem; }
.note-box.warn { background: var(--warn-soft); color: #5c3200; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 14px 22px; border-radius: 999px; font-weight: 600; z-index: 100;
  max-width: calc(100% - 32px); text-align: center; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* ---------- 건반 ---------- */
.piano { position: relative; width: 100%; height: 100%; user-select: none; -webkit-user-select: none; touch-action: none; }
.key { position: absolute; top: 0; border: 0; padding: 0; margin: 0; }
.key.white { height: 100%; background: #fdfcf9; border-right: 1px solid #b9b4aa; border-bottom: 1px solid #b9b4aa; border-radius: 0 0 8px 8px; z-index: 1; }
.key.black { height: 60%; background: #23211f; border-radius: 0 0 6px 6px; z-index: 2; box-shadow: inset 0 -4px 0 rgba(255, 255, 255, 0.08); }
.key.white.in-key { background: #fdfcf9; }
.key.black.in-key { background: #4b3880; box-shadow: inset 0 -4px 0 rgba(255, 255, 255, 0.18); }
.key .key-label { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-weight: 700; font-size: 0.82rem; color: var(--ink-2); pointer-events: none; line-height: 1.1; }
.key.black .key-label { color: #fff; bottom: 6px; font-size: 0.7rem; }
.key .key-mid { position: absolute; left: 50%; top: 10px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--muted); }
.key.white.down { background: #e2dccd; }
.key.black.down { background: #000; }
.key.target.white { background: #ffe9a8; }
.key.target.black { background: #c28a00; }
.key.hit-good.white { background: #bfe6cc; }
.key.hit-good.black { background: var(--good); }
.key.hit-bad.white { background: #f6c9c4; }

/* ---------- 리듬 연습 ---------- */
.stage-wrap { position: relative; flex: 1; min-height: 240px; background: var(--stage); overflow: hidden; }
.stage-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage-hud { position: absolute; left: 12px; right: 12px; top: 10px; display: flex; justify-content: space-between; gap: 8px; color: #fff; pointer-events: none; z-index: 2; }
.stage-hud .pill { background: rgba(10, 10, 14, 0.72); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.stage-msg { position: absolute; left: 0; right: 0; top: 30%; text-align: center; color: #fff; font-size: 1.6rem; font-weight: 800; pointer-events: none; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); z-index: 2; }
.piano-wrap { height: clamp(150px, 28vh, 230px); background: #2a2823; padding-top: 4px; }
.playbar { display: grid; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); }
.playbar .row .btn { min-height: 56px; padding: 0 14px; }
.playbar .row { display: grid; grid-template-columns: 1fr 1fr; }
.playbar .row .btn.primary { grid-column: 1 / -1; min-height: 64px; font-size: 1.15rem; }
.opts { display: grid; gap: 16px; }
.opt-label { font-weight: 700; margin-bottom: 6px; display: block; }
.opt-help { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }

.result { text-align: center; }
.result .big { font-size: 3rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.result .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.result .stats div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 4px; }
.result .stats b { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }

/* ---------- 노래 연습 ---------- */
.sing { display: grid; gap: 16px; }
.target-card { text-align: center; padding: 16px; }
.target-card .lbl { color: var(--muted); font-size: 0.9rem; }
.target-card .tname { font-size: 3rem; font-weight: 800; line-height: 1.1; }
.target-card .tsub { color: var(--ink-2); }
.upcoming { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.upcoming span { min-width: 52px; padding: 6px 10px; border-radius: 999px; background: var(--surface-2); font-weight: 600; color: var(--ink-2); }
.meter { position: relative; height: 190px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.meter .zone { position: absolute; left: 0; right: 0; top: 50%; height: 26%; transform: translateY(-50%); background: var(--good-soft); border-top: 2px dashed rgba(29, 115, 71, 0.4); border-bottom: 2px dashed rgba(29, 115, 71, 0.4); }
.meter .center { position: absolute; left: 0; right: 0; top: 50%; border-top: 2px solid var(--good); }
.meter .ball { position: absolute; left: 50%; width: 46px; height: 46px; margin-left: -23px; margin-top: -23px; border-radius: 50%; background: var(--muted); transition: top 0.08s linear, background 0.15s; top: 50%; }
.meter .ball.ok { background: var(--good); }
.meter .ball.hi, .meter .ball.lo { background: var(--warn); }
.meter .ball.none { opacity: 0.25; }
.meter .tag-hi, .meter .tag-lo { position: absolute; left: 12px; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.meter .tag-hi { top: 8px; }
.meter .tag-lo { bottom: 8px; }
.verdict { text-align: center; font-size: 1.6rem; font-weight: 800; min-height: 2.6rem; }
.verdict.ok { color: var(--good); }
.verdict.hi, .verdict.lo { color: var(--warn); }
.hold { height: 14px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.hold i { display: block; height: 100%; width: 0; background: var(--good); transition: width 0.1s linear; }

/* ---------- 편집 ---------- */
.field { display: grid; gap: 6px; margin-bottom: 20px; }
.field label { font-weight: 700; }
.field input[type='text'], .field input[type='date'], .field input[type='url'], .field input[type='number'], .field select {
  min-height: 56px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); font-size: 1.05rem; width: 100%;
}
.field .help { font-size: 0.85rem; color: var(--muted); }
.keygrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.keyopt { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px 10px; border-radius: var(--radius-sm); border: 2px solid var(--line); background: var(--surface); }
.keyopt[aria-pressed='true'] { border-color: var(--accent); background: var(--accent-soft); }
.keyopt b { font-size: 0.95rem; }
.keyopt span { font-size: 0.75rem; color: var(--muted); }
.tabs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
@media (min-width: 560px) { .tabs { grid-template-columns: repeat(4, 1fr); } }
.tabs button { min-height: 56px; border-radius: var(--radius-sm); border: 2px solid var(--line); background: var(--surface); font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 6px; }
.tabs button[aria-selected='true'] { border-color: var(--ink); background: var(--surface-2); }
.tabs .dot { width: 12px; height: 12px; border-radius: 50%; }
.staffbox { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 8px; -webkit-overflow-scrolling: touch; }
.durs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.durs button { min-height: 64px; border-radius: var(--radius-sm); border: 2px solid var(--line); background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; }
.durs button b { font-size: 0.9rem; }
.durs button span { font-size: 0.75rem; color: var(--muted); }
.durs button[aria-pressed='true'] { border-color: var(--accent); background: var(--accent-soft); }
.edit-piano { height: 170px; border-radius: var(--radius-sm); overflow: hidden; background: #2a2823; padding-top: 3px; }
.octrow .btn { padding: 0 14px; }
.octrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.file-pick { display: grid; gap: 8px; }
.file-pick .cur { font-size: 0.9rem; color: var(--ink-2); background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm); }
.sticky-save { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--paper) 24%); }

/* 도움말 그림 */
.howto svg { width: 100%; height: auto; display: block; }

/* 대화상자 */
dialog { border: 0; border-radius: 20px; padding: 24px; width: min(560px, calc(100% - 32px)); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(20, 18, 16, 0.5); }
dialog h2 { margin-top: 0; }

.landscape-tip { display: none; }
@media (orientation: portrait) and (max-width: 600px) {
  .landscape-tip { display: block; }
}
@media (min-width: 700px) {
  .modes { grid-template-columns: repeat(4, 1fr); }
  .parts { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.barsel { min-height: 56px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); font-size: 1rem; flex: 1 1 auto; }
.tempo-row input { flex: 1 1 80px; min-width: 0; text-align: center; font-size: 1.4rem; font-weight: 700; min-height: 60px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); }
.mm-label { font-family: 'Noto Music', 'Pretendard Variable', 'Pretendard', sans-serif; font-size: 1.6rem; font-weight: 700; white-space: nowrap; }
.mm { font-family: 'Noto Music', 'Pretendard Variable', 'Pretendard', sans-serif; white-space: nowrap; }
.tapbtn { min-height: 96px; font-size: 1.2rem; touch-action: manipulation; }
.tapbtn.on { background: var(--accent-soft); border-color: var(--accent); }

/* 카톡 붙여넣기 */
.steps { margin: 0 0 16px; padding-left: 1.4em; display: grid; gap: 6px; }
textarea { width: 100%; min-height: 160px; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); font-size: 1rem; line-height: 1.5; resize: vertical; }
.checks { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.checks li { display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 64px; }
.checks li + li { border-top: 1px solid var(--line); }
.checks li span { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--ink-2); font-size: 0.92rem; }
.checks li b { display: block; color: var(--ink); font-size: 1rem; }
.checks li.ok > .ico { color: var(--good); }
.checks li.no > .ico { color: var(--warn); }
.checks li .btn { min-height: 48px; padding: 0 12px; }
.vtabs { grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.vtabs .btn { gap: 6px; }
.vtabs .dot { width: 10px; height: 10px; border-radius: 50%; }

/* 주차 카드 */
.week-song { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); min-height: 64px; }
.week-song:first-of-type { border-top: 0; }
.week-song > span { flex: 1; min-width: 0; }
.week-song b { display: block; font-size: 1.35rem; line-height: 1.3; }
.week-song small { display: block; color: var(--muted); font-size: 0.88rem; margin-top: 2px; }
.week-song .chev { width: 24px; height: 24px; color: var(--muted); }
.memo { display: inline-block; font-style: normal; font-size: 0.8rem; font-weight: 700; color: var(--warn); background: var(--warn-soft); border-radius: 6px; padding: 2px 8px; margin-top: 6px; }
.txt span .mm { display: inline; }
