/* 慢学琴 · 清爽浅色风（米色留白，对齐参考图，移动端优先） */
:root {
  --bg: #f4efe6;
  --panel: #fffdf8;
  --panel-2: #fbf6ec;
  --line: #e7ddca;
  --ink: #2b3330;
  --ink-soft: #8a8f88;
  --teal: #2f5d57;
  --teal-2: #3d8b7f;
  --teal-soft: #e3efec;
  --white-key: #fffdf9;
  --black-key: #2a2d2c;
}

* { 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: 40px;
  display: flex;
  flex-direction: column;
}

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

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

/* 曲名大标题区 */
.hero { text-align: center; padding: 18px 8px 6px; }
.hero-title { font-size: 32px; font-weight: 800; letter-spacing: 2px; color: var(--teal); }
.hero-sub { margin-top: 6px; font-size: 14px; color: var(--ink-soft); letter-spacing: 1px; }
.hero-meta { margin-top: 12px; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; }
.meta-chip {
  background: var(--teal-soft);
  color: var(--teal);
  border-radius: 9px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 600;
}
.meta-time { font-size: 12px; color: var(--ink-soft); }

/* 通用卡片 */
.panel {
  background: var(--panel);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 2px 10px rgba(120, 100, 60, .06);
}

/* 速度滑块 */
.speed-row { display: flex; align-items: center; gap: 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(--teal);
  color: #f4efe6;
  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(--teal) 0%, var(--teal) var(--fill, 50%), #e9e0cd var(--fill, 50%), #e9e0cd 100%);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--teal);
  border: 3px solid #fffdf8;
  box-shadow: 0 0 0 2px var(--teal);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--teal);
  border: 3px solid #fffdf8;
  cursor: pointer;
}

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

/* 简谱（一小节一排，居中，超出纵向滚动） */
.score-panel {
  background: var(--panel);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 2px 10px rgba(120, 100, 60, .06);
  height: 240px;
  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 {
  position: relative;
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 14px 6px;
}
.score-row { display: flex; justify-content: center; align-items: center; flex-wrap: nowrap; }
.bar-group { display: flex; gap: 26px; }
.note {
  flex: 0 0 auto;
  min-width: 46px;
  text-align: center;
  position: relative;
  padding: 12px 0 14px;
}
.note .num {
  font-size: 38px;
  font-weight: 800;
  color: #3a423e;
  position: relative;
  display: inline-block;
  transition: transform .12s;
}
.note.active .num {
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 12px;
  padding: 0 10px;
  transform: scale(1.15);
  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(--teal);
}
.note.active .arrow { display: block; }

/* 高低音点：高音上加点，低音下加点（实心深墨圆点，浅色底上清晰可辨） */
.num, .key.white .sol { position: relative; }
.dot-above::before {
  content: "";
  position: absolute; top: -5px; left: 50%; transform: translateX(-50%);
  width: 7px; height: 7px; border-radius: 50%;
  background: #2b3330;
}
.dot-below::after {
  content: "";
  position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  width: 7px; height: 7px; border-radius: 50%;
  background: #2b3330;
}
/* 键盘白键上的高低音点：默认深墨；点亮浅青键上用深青 */
.key.white .dot-above::before, .key.white .dot-below::after { background: #2b3330; }
.key.white.active .dot-above::before, .key.white.active .dot-below::after { background: #173a35; }

/* 钢琴键盘 */
.piano-panel { background: var(--panel); border-radius: 18px; padding: 12px; box-shadow: 0 2px 10px rgba(120, 100, 60, .06); }
.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 var(--line);
  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: 19px; font-weight: 800; color: #2b3330; }
.key.white .pname { font-size: 11px; color: var(--ink-soft); margin-top: 3px; }
.key.white.active {
  background: linear-gradient(180deg, var(--teal-2), var(--teal));
  animation: keyPress .18s ease;
}
.key.white.active .sol, .key.white.active .pname { color: #f4efe6; }

/* 触键下压回弹 */
@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: var(--teal);
  color: #f4efe6;
  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: #9aa1a9; }
.key.black.active { background: var(--teal); }

/* 虚拟手指（跟随触键） */
.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(90, 70, 40, .35));
}
.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: 22px;
  padding: 16px 10px;
  box-shadow: 0 2px 10px rgba(120, 100, 60, .06);
}
.ctrl-btn {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: var(--ink-soft);
  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(--teal); }
.ctrl-btn.disabled { opacity: .45; pointer-events: none; }
.play-btn {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--teal);
  border: none;
  color: #f4efe6;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(47, 93, 87, .28);
}
.play-icon { font-size: 30px; }

/* ---------- 导入功能 ---------- */
.import-entry {
  margin-top: 12px;
  width: 100%;
  background: var(--teal-soft);
  color: var(--teal);
  border: 1px dashed var(--teal-2);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.import-entry:active { background: #d7e7e3; }

.song-chip.custom { border-color: var(--teal-2); color: var(--teal); }
.song-chip .chip-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1;
}
.song-chip.custom .chip-del { background: rgba(47, 93, 87, .12); }

.modal-mask {
  position: fixed; inset: 0;
  background: rgba(43, 51, 48, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 30;
}
.modal-mask.hidden { display: none; }
.modal {
  width: 100%; max-width: 420px;
  background: var(--panel);
  border-radius: 20px;
  padding: 18px 18px 16px;
  box-shadow: 0 12px 36px rgba(60, 45, 20, .25);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.modal-head h3 { font-size: 17px; color: var(--teal); }
.field {
  display: block;
  font-size: 13px; color: var(--ink-soft);
  margin-bottom: 12px;
}
.field input, .field select, .field textarea {
  display: block; width: 100%;
  margin-top: 5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px; color: var(--ink);
  font-family: inherit;
  outline: none;
}
.field textarea { resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal-2); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.file-btn {
  height: 42px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--teal);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.import-help { font-size: 12px; color: var(--ink-soft); line-height: 1.6; margin-bottom: 8px; }
.import-msg { font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.import-msg.err { color: #b4452f; }
.import-msg.ok { color: var(--teal-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.btn-primary {
  background: var(--teal); color: #f4efe6;
  border: none; border-radius: 12px;
  padding: 11px 18px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn-ghost {
  background: var(--panel-2); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 18px; font-size: 15px; cursor: pointer;
}

/* 伴奏设置面板 */
.accomp-panel { display: flex; flex-direction: column; gap: 12px; }
.accomp-top { display: flex; align-items: center; justify-content: space-between; }
.mini-toggle {
  background: var(--teal-soft); color: var(--teal);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.mini-toggle.on { background: var(--teal); color: #f4efe6; }
.vol-row { display: flex; align-items: center; gap: 10px; }
.vol-label { font-size: 13px; color: var(--ink-soft); width: 52px; flex-shrink: 0; }
.vol-row input[type="range"] { flex: 1; }

/* 移调控件 */
.transpose-row { display: flex; align-items: center; justify-content: space-between; }
.transpose-ctrl { display: flex; align-items: center; gap: 12px; }
.mini-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--teal-soft); color: var(--teal); font-size: 20px; font-weight: 700; cursor: pointer;
  line-height: 1;
}
.mini-btn:active { background: var(--teal); color: #f4efe6; }
.transpose-label { min-width: 44px; text-align: center; font-size: 15px; font-weight: 700; color: var(--ink); }
