/* 慢学琴 · 深色青色钢琴学习风（对齐参考图，移动端优先） */
:root {
  --bg: #0b0d10;
  --panel: #171a1f;
  --panel-2: #111418;
  --line: #262b31;
  --ink: #f2f5f7;
  --ink-soft: #8b939c;
  --cyan: #22d3ee;
  --cyan-dark: #06b6d4;
  --white-key: #f4f6f8;
  --black-key: #15171a;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 92px;
  display: flex;
  flex-direction: column;
}

/* 顶部导航 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 42px;
  padding: 0 12px;
}
.topbar-title { font-size: 16px; font-weight: 700; }
.topbar-actions { display: flex; gap: 4px; }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--ink);
  font-size: 18px;
  width: 32px; height: 32px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.content { display: flex; flex-direction: column; gap: 10px; padding: 4px 12px; flex: 1 1 auto; min-height: 0; }

/* 曲目卡片 */
.song-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 12px 14px;
}
.song-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.song-title { font-size: 20px; font-weight: 800; letter-spacing: 1px; }
.song-sub { margin-top: 3px; font-size: 12px; color: var(--ink-soft); }
.song-sub b { color: var(--ink); font-weight: 600; }
.dot-sep { margin: 0 6px; color: var(--line); }
.song-tags { display: flex; gap: 8px; flex-shrink: 0; }
.tag {
  background: #262b31;
  color: #cfd6dc;
  border-radius: 9px;
  padding: 4px 10px;
  font-size: 12px;
}

/* 速度滑块 */
.speed-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.speed-label { font-size: 13px; color: var(--ink-soft); flex-shrink: 0; }
.speed-slider-wrap { position: relative; flex: 1; padding-top: 14px; }
.bpm-bubble {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--cyan);
  color: #062026;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  padding: 1px 8px;
  pointer-events: none;
}
.bpm-label { font-size: 14px; color: var(--ink); width: 74px; text-align: right; flex-shrink: 0; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 6px;
  background: linear-gradient(to right, var(--cyan) 0%, var(--cyan) var(--fill, 50%), #2c323a var(--fill, 50%), #2c323a 100%);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--cyan);
  border: 3px solid #0b0d10;
  box-shadow: 0 0 0 2px var(--cyan);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--cyan);
  border: 3px solid #0b0d10;
  cursor: pointer;
}

/* 选曲 chips */
.song-list { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; padding-bottom: 2px; scrollbar-width: none; }
.song-list::-webkit-scrollbar { display: none; }
.song-chip {
  flex: 0 0 auto;
  background: #20242a;
  color: var(--ink-soft);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}
.song-chip.selected {
  background: rgba(34, 211, 238, .14);
  color: var(--cyan);
  border-color: var(--cyan);
  font-weight: 700;
}

/* 简谱（一小节一排，固定显示两排，居中，超出纵向滚动，不横向滚动） */
.score-panel {
  position: relative;
  background: var(--panel-2);
  border-radius: 16px;
  padding: 12px 12px;
  flex: 0 0 auto;
  height: 190px;
  display: flex;
}
.score-strip {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  scrollbar-width: none;
}
.score-strip::-webkit-scrollbar { display: none; }
.score-inner {
  margin: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 12px 6px;
}
.score-row { display: flex; justify-content: center; align-items: center; flex-wrap: nowrap; }
.bar-group { display: flex; gap: 24px; }
.note {
  flex: 0 0 auto;
  min-width: 46px;
  text-align: center;
  position: relative;
  padding: 10px 0 12px;
}
.note .num {
  font-size: 36px;
  font-weight: 700;
  color: #c7ced5;
  position: relative;
  transition: color .1s, transform .12s;
}
.note.active .num { color: var(--cyan); transform: scale(1.2); animation: notePop .18s ease; }
@keyframes notePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.32); }
  100% { transform: scale(1.2); }
}
.arrow {
  display: none;
  width: 0; height: 0;
  margin: 6px auto 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid var(--cyan);
}
.note.active .arrow { display: block; }
.search-btn { position: absolute; right: 10px; top: 10px; background: #20242a; color: var(--ink-soft); width: 32px; height: 32px; font-size: 18px; }

/* 高低音点：高音上加点，低音下加点（实心圆，不依赖字体字形；简谱 .num 与键盘 .sol 通用） */
.num, .key.white .sol { position: relative; }
.dot-above::before {
  content: "";
  position: absolute; top: -5px; left: 50%; transform: translateX(-50%);
  width: 8px; height: 8px; border-radius: 50%;
  background: #ffffff;
}
.dot-below::after {
  content: "";
  position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  width: 8px; height: 8px; border-radius: 50%;
  background: #ffffff;
}
/* 键盘白键为浅底，高低音点用深色以保证对比；点亮键随文字转深青 */
.key.white .dot-above::before, .key.white .dot-below::after { background: #222; }
.key.white.active .dot-above::before, .key.white.active .dot-below::after { background: #062026; }

/* 钢琴键盘 */
.piano-panel { background: var(--panel-2); border-radius: 16px; padding: 12px; }
.piano { display: flex; overflow-x: auto; scrollbar-width: none; position: relative; }
.piano::-webkit-scrollbar { display: none; }
.octave {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  width: min(52vw, 300px);
  height: 168px;
}
.key { position: relative; }
.key.white {
  flex: 1 1 0;
  background: var(--white-key);
  border: 1px solid #000;
  border-radius: 0 0 8px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 8px;
  margin-right: 1px;
}
.key.white .sol { font-size: 18px; font-weight: 800; color: #222; }
.key.white .pname { font-size: 11px; color: #9aa1a9; margin-top: 2px; }
.key.white.active {
  background: linear-gradient(180deg, var(--cyan), var(--cyan-dark));
  animation: keyPress .18s ease;
}
.key.white.active .sol, .key.white.active .pname { color: #062026; }

/* 触键下压回弹：每次音头独立触发一次 */
@keyframes keyPress {
  0% { transform: translateY(0); }
  35% { transform: translateY(4px); }
  100% { transform: translateY(0); }
}
.solfa {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: #062026;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  padding: 3px 9px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
.key.white.active .solfa { opacity: 1; }
.key.black {
  position: absolute;
  top: 0;
  width: 12%;
  height: 56%;
  background: var(--black-key);
  border: 1px solid #000;
  border-radius: 0 0 6px 6px;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
}
.key.black .bname { font-size: 9px; color: #8b939c; }
.key.black.active { background: var(--cyan-dark); }

/* 虚拟手指（跟随触键） */
.finger {
  position: absolute;
  bottom: 88px;
  left: 0;
  width: 36px;
  height: 80px;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: left .13s ease, bottom .09s ease, opacity .15s ease;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .45));
}
.finger.idle { opacity: 0; }
.finger.visible { opacity: 1; }
.finger-body {
  width: 22px;
  height: 50px;
  margin: 0 auto;
  background: linear-gradient(180deg, #cf9666, #b57c4d);
  border-radius: 10px 10px 6px 6px;
}
.finger-tip {
  width: 32px;
  height: 34px;
  margin: -6px auto 0;
  background: radial-gradient(circle at 35% 28%, #f9dcb4, #eeb987 68%, #dfa26d);
  border-radius: 50% 50% 46% 46%;
  box-shadow: inset 0 -3px 5px rgba(150, 90, 40, .35);
  transition: transform .08s ease;
}
/* 按下触键 */
.finger.down { bottom: 6px; }
.finger.down .finger-tip { transform: scaleY(.88); }
.finger.down.black-key { bottom: 84px; }
.finger.down.black-key .finger-tip { transform: scaleY(.88); }

/* 控制条 */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--panel);
  border-radius: 20px;
  padding: 16px 10px;
}
.ctrl-btn {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: #cfd6dc;
  cursor: pointer;
}
.ctrl-icon { font-size: 24px; }
.ctrl-text { font-size: 12px; color: var(--ink-soft); }
.ctrl-btn.on .ctrl-icon, .ctrl-btn.on .ctrl-text { color: var(--cyan); }
.play-btn {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--cyan);
  border: none;
  color: #062026;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(34, 211, 238, .35);
}
.play-icon { font-size: 30px; }

/* 底部 Tab */
.tabbar {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: #0e1114;
  border-top: 1px solid var(--line);
  display: flex;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}
.tab-item {
  flex: 1;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--ink-soft);
  font-size: 12px;
  cursor: pointer;
}
.tab-item.active { color: var(--cyan); }
.tab-icon { font-size: 22px; }
