/* 钢琴陪练 v2 —— 练琴优先 · 深色精致 · 手机/平板优先。 */

:root {
  --bg: #0d1016;
  --bg-2: #121720;
  --card: #171d27;
  --card-2: #1e2632;
  --card-hover: #253040;
  --line: #2a3341;
  --line-soft: #222a36;
  --text: #eef3fa;
  --text-dim: #97a4b8;
  --text-mute: #6b7789;
  --accent: #5aa9ff;
  --accent-2: #3479d8;
  --accent-soft: rgba(90, 169, 255, .14);
  --ok: #38d39a;
  --warn: #f5bb4e;
  --bad: #f47166;
  --piano-white: #f7f9fc;
  --piano-black: #1b1f26;
  --piano-key-gap: 1px;
  --black-w: 4.2%;
  --radius: 16px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior: none;
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: calc(72px + var(--safe-b));
}
body.practicing { padding-bottom: calc(84px + var(--safe-b)); }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: .01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.18rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
button { font: inherit; color: inherit; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: rgba(13, 16, 22, .92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 1.08rem; font-weight: 750; white-space: nowrap; }
.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 1.1rem;
  box-shadow: 0 4px 14px rgba(52, 121, 216, .35);
}
.now-playing {
  color: var(--text-dim); font-size: .88rem;
  max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.now-playing.filled { color: var(--accent); }
.topbar .spacer { flex: 1; }
.status-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; color: var(--text-dim); white-space: nowrap;
}
.status-dot::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-mute); box-shadow: 0 0 0 3px rgba(255,255,255,.04);
}
.status-dot.online::before { background: var(--ok); }
.status-dot.offline::before { background: var(--warn); }

/* ---------- 布局 ---------- */
main { flex: 1; width: 100%; max-width: 1600px; margin: 0 auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 14px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.practice-column { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.side-column { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.card.tight { padding: 12px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { flex: 1; }
.card-sub { color: var(--text-dim); font-size: .84rem; }

/* ---------- 首次引导 ---------- */
.guide { border-color: rgba(90,169,255,.4); background: linear-gradient(135deg, rgba(90,169,255,.10), rgba(52,121,216,.05)); }
.guide-row { display: flex; align-items: center; gap: 16px; }
.guide-icon { font-size: 2rem; flex: 0 0 auto; }
.guide-copy { flex: 1; }
.guide-copy h2 { margin-bottom: 4px; }
.guide-copy p { color: var(--text-dim); font-size: .92rem; }

/* ---------- 按钮 ---------- */
.mini-btn {
  min-height: 34px; padding: 0 12px;
  border-radius: 9px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text-dim);
  font-size: .84rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.mini-btn:hover { background: var(--card-hover); color: var(--text); }
.mini-btn.primary { background: var(--accent-soft); border-color: rgba(90,169,255,.45); color: var(--accent); }
.mini-btn.danger { color: var(--bad); border-color: rgba(244,113,102,.35); background: rgba(244,113,102,.08); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font-size: 1rem; font-weight: 600;
  cursor: pointer;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; box-shadow: 0 4px 16px rgba(52,121,216,.3); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: #5d2d2d; color: var(--bad); }
.btn.big { min-height: 56px; font-size: 1.05rem; padding: 0 24px; border-radius: 14px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row.end { justify-content: flex-end; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: .9rem;
  cursor: pointer;
  white-space: nowrap;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip-label { font-size: .8rem; color: var(--text-mute); align-self: center; margin-right: 2px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- 侧栏标签 ---------- */
.panel-tabs {
  display: flex; gap: 4px;
  padding: 4px; border-radius: 12px;
  background: var(--bg-2); border: 1px solid var(--line-soft);
}
.panel-tab {
  flex: 1; min-height: 40px; padding: 0 6px;
  border-radius: 9px; border: none; background: transparent;
  color: var(--text-dim); font-size: .88rem; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.panel-tab.on { background: var(--card-2); color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.panel { display: none; }
.panel.on { display: block; }

/* ---------- 曲库列表 ---------- */
.score-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 48vh; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.score-list::-webkit-scrollbar { width: 8px; }
.score-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
.score-item {
  display: flex; flex-direction: column; gap: 5px;
  padding: 11px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--card-2);
  text-align: left;
  cursor: pointer;
  min-height: 78px;
  transition: border-color .15s ease, background .15s ease, transform .06s ease;
}
.score-item:hover { border-color: var(--accent); background: var(--card-hover); }
.score-item:active { transform: scale(.98); }
.score-item .t { font-weight: 650; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-item .m { color: var(--text-dim); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-item .badge {
  align-self: flex-start;
  font-size: .7rem; padding: 1px 7px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.score-item .badge.builtin { background: rgba(56,211,154,.14); color: var(--ok); }

/* 曲库多选删除 */
.library-manage-bar {
  display: flex; align-items: center; gap: 10px;
  margin: -4px 0 12px; padding: 8px 10px;
  border-radius: 10px; background: var(--card-2); border: 1px solid var(--line);
}
.library-manage-bar .manage-count { flex: 1; color: var(--text-dim); font-size: .85rem; }
.mini-btn.danger { background: rgba(255, 94, 94, .14); color: #ff7a7a; border-color: rgba(255, 94, 94, .4); }
.mini-btn.danger:disabled { opacity: .4; cursor: not-allowed; }
.mini-btn:disabled { opacity: .4; cursor: not-allowed; }
.score-list.managing .score-item.deletable { position: relative; }
.score-list.managing .score-item.deletable::before {
  content: ''; position: absolute; top: 8px; right: 8px;
  width: 18px; height: 18px; border-radius: 5px;
  border: 2px solid var(--line); background: var(--card);
}
.score-list.managing .score-item.deletable.selected::before {
  background: var(--accent); border-color: var(--accent);
  box-shadow: inset 0 0 0 3px var(--card);
}
.score-list.managing .score-item.deletable.selected { border-color: var(--accent); background: var(--card-hover); }
.score-list.managing .score-item.not-deletable { opacity: .45; cursor: default; }

/* ---------- 练习路径 / 教案 ---------- */
.path { display: flex; flex-direction: column; gap: 7px; max-height: 52vh; overflow-y: auto; }
.path-step {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--card-2);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s ease, background .15s ease;
}
.path-step:hover { border-color: var(--accent); }
.path-step .no {
  flex: 0 0 auto;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--line);
  font-size: .8rem; font-weight: 700; color: var(--text-dim);
}
.path-step.done .no { background: rgba(56,211,154,.18); border-color: var(--ok); color: var(--ok); }
.path-step .body { flex: 1; min-width: 0; }
.path-step .t { font-weight: 620; font-size: .92rem; }
.path-step .g { color: var(--text-dim); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 认音符 ---------- */
.quiz-body { display: flex; flex-direction: column; gap: 10px; }
.quiz-q { font-size: 1.02rem; font-weight: 650; }
.quiz-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.quiz-choice {
  min-width: 52px; min-height: 48px;
  border-radius: 11px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text);
  font-size: 1rem; font-weight: 650;
  cursor: pointer;
}
.quiz-choice.ok { border-color: var(--ok); background: rgba(56,211,154,.16); color: var(--ok); }
.quiz-choice.bad { border-color: var(--bad); background: rgba(244,113,102,.14); color: var(--bad); }
.quiz-tip { color: var(--text-dim); font-size: .84rem; }

/* ---------- 练习台 ---------- */
.stage { display: flex; flex-direction: column; gap: 12px; }
.stage-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.stage-title { font-size: 1.22rem; font-weight: 720; }
.stage-meta { color: var(--text-dim); font-size: .85rem; margin-top: 2px; }
.speed-badge {
  flex: 0 0 auto; font-size: .82rem; font-weight: 650;
  color: var(--accent); background: var(--accent-soft);
  padding: 5px 11px; border-radius: 999px;
}
.stage-actions { margin-top: 2px; }

.waterfall-wrap {
  position: relative; width: 100%;
  height: min(40vh, 340px);
  border-radius: 14px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 0%, #151b25, #0a0d12 70%);
  border: 1px solid var(--line-soft);
}
body.practicing .waterfall-wrap { height: min(38vh, 320px); }
/* 练习时收起「设置类」控件：模式/声部/输入是开始前的准备，弹琴时不需要再动。 */
body.practicing #mode-chips,
body.practicing .more-settings,
body.practicing .stage-actions { display: none !important; }
#waterfall { display: block; width: 100%; height: 100%; }
.waterfall-hint {
  position: absolute; inset: auto 0 12px 0; text-align: center;
  color: var(--text-mute); font-size: .85rem; pointer-events: none;
}

/* 五线谱视图 */
.view-chip-row { align-items: center; flex-wrap: wrap; }
.staff-size-row { margin-top: -4px; }
.staff-host {
  position: relative; width: 100%;
  height: min(40vh, 340px);
  border-radius: 14px;
  overflow: auto;                 /* 放大后可双向滚动，配合当前行跟随 */
  background: #fbfcfe;
  border: 1px solid var(--line-soft);
  --staff-bg: #fbfcfe;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
body.practicing .staff-host { height: min(46vh, 440px); }
#staff-svg { display: block; width: 100%; height: 100%; touch-action: pan-x pan-y; }
/* 谱面本身由 setZoom 用 inline width/height 精确控制放大倍率；上面 100% 只是未布局时的兜底。 */
.staff-hint {
  position: sticky; left: 0; bottom: 0; text-align: center;
  color: #7b8794; font-size: .82rem; padding: 4px 8px;
  pointer-events: none;
}
.staff-line { stroke: #4a5568; stroke-width: 1; }
.staff-brace-line { stroke: #4a5568; stroke-width: 1.2; }
.staff-brace { fill: #4a5568; font-size: 62px; font-family: serif; }
.staff-clef { fill: #2d3748; font-size: 40px; font-family: serif; }
.staff-keysig { fill: #2d3748; font-size: 17px; font-family: serif; letter-spacing: -1px; }
.staff-timesig { fill: #2d3748; font-size: 15px; font-weight: 700; font-family: serif; }
.staff-bar-no { fill: #9aa5b1; font-size: 9px; font-family: system-ui, sans-serif; }
.staff-barline { stroke: #a0aec0; stroke-width: 1; }
.staff-note { fill: #2d3748; color: #2d3748; cursor: pointer; }
.staff-note:hover { fill: var(--accent); color: var(--accent); }
.staff-note:focus { outline: none; fill: var(--accent); color: var(--accent); }
.staff-note.done { fill: var(--ok); color: var(--ok); }
.staff-note.want { fill: var(--warn); color: var(--warn); }
.staff-note.pressed { fill: var(--accent); color: var(--accent); }
.staff-note.want.done { fill: var(--ok); color: var(--ok); }
.staff-stem, .staff-flag { stroke: currentColor; stroke-width: 1.6; }
.staff-ledger { stroke: currentColor; stroke-width: 1.4; }
.staff-dot { fill: currentColor; }
.staff-accidental { fill: currentColor; font-size: 15px; font-family: serif; }
.staff-finger { fill: #718096; font-size: 9px; font-family: system-ui, sans-serif; }
.staff-rest { fill: #2d3748; font-size: 24px; font-family: serif; }
.staff-beam { fill: currentColor; }
.staff-beams { color: #2d3748; }
.staff-playhead { stroke: rgba(90, 169, 255, .6); stroke-width: 2; stroke-dasharray: 3 3; }
/* 实时光标：箭头 + 脉冲光圈，锚定当前应弹音符 */
.staff-cursor { pointer-events: none; }
.staff-cursor-ring {
  fill: rgba(245, 187, 78, .18);
  stroke: var(--warn); stroke-width: 2.5;
  transform-box: fill-box; transform-origin: center;
  animation: staff-pulse 1.2s ease-in-out infinite;
}
.staff-cursor-arrow { fill: var(--warn); stroke: #fff; stroke-width: 1; }
@keyframes staff-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .55; transform: scale(1.18); }
}
@media (prefers-reduced-motion: reduce) {
  .staff-cursor-ring { animation: none; }
}

.more-settings { border-top: 1px solid var(--line-soft); padding-top: 8px; }
.more-settings summary {
  cursor: pointer; color: var(--text-dim); font-size: .84rem;
  padding: 4px 0; list-style: none; user-select: none;
}
.more-settings summary::-webkit-details-marker { display: none; }
.more-settings summary::before { content: '▸ '; color: var(--text-mute); }
.more-settings[open] summary::before { content: '▾ '; }
.more-settings .chip-row { margin-top: 8px; }

/* 实时反馈条 */
.feedback-bar {
  display: flex; align-items: center; gap: 12px;
  min-height: 64px; padding: 10px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  transition: background .18s ease, border-color .18s ease;
}
.feedback-bar .icon { flex: 0 0 auto; font-size: 1.4rem; line-height: 1; }
.feedback-bar .msg { flex: 1; font-size: 1.02rem; font-weight: 600; }
.feedback-bar .hint { display: block; font-size: .84rem; color: var(--text-dim); font-weight: 400; margin-top: 2px; }
.feedback-bar.ok { border-color: rgba(56,211,154,.5); background: rgba(56,211,154,.10); }
.feedback-bar.ok .icon { color: var(--ok); }
.feedback-bar.warn { border-color: rgba(245,187,78,.5); background: rgba(245,187,78,.10); }
.feedback-bar.warn .icon { color: var(--warn); }
.feedback-bar.bad { border-color: rgba(244,113,102,.55); background: rgba(244,113,102,.12); }
.feedback-bar.bad .icon { color: var(--bad); }
.feedback-bar.info { border-color: var(--line); }

/* 进度 */
.progress-line { display: flex; align-items: center; gap: 10px; }
.progress-track { flex: 1; height: 7px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .2s ease; }
.progress-text { font-variant-numeric: tabular-nums; color: var(--text-dim); font-size: .85rem; }

/* ---------- 琴键 ---------- */
.piano { position: relative; width: 100%; user-select: none; -webkit-user-select: none; }
.keys {
  position: relative; display: flex; width: 100%; height: 150px;
  gap: var(--piano-key-gap); touch-action: none;
}
body.practicing .keys { height: 168px; }
.key {
  position: relative; padding: 0; margin: 0; border: none;
  border-radius: 0 0 8px 8px; cursor: pointer; touch-action: none;
  transition: background .06s ease, transform .06s ease;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  overflow: hidden;
}
.key.white {
  flex: 1 1 0;
  background: linear-gradient(180deg, #ffffff, #e6ebf2);
  color: #566;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.12);
}
.key.black {
  position: absolute; top: 0; width: var(--black-w); height: 62%; z-index: 2;
  background: linear-gradient(180deg, #2b3038, #14181d);
  color: #aab;
  box-shadow: 0 3px 6px rgba(0,0,0,.5);
  border-radius: 0 0 6px 6px;
}
.key .kname { font-size: .78rem; opacity: .8; padding-bottom: 6px; pointer-events: none; }
.key .kkey { font-size: .78rem; font-weight: 700; opacity: .92; padding-bottom: 18px; pointer-events: none; }
.key.black .kkey { padding-bottom: 8px; font-size: .72rem; }
.key.white.on { background: linear-gradient(180deg, #cfe6ff, #a9cdff); }
.key.black.on { background: linear-gradient(180deg, #4c7fb5, #2b5c8f); }
.key.white.good { background: linear-gradient(180deg, #b8f0d3, #86e0b4); }
.key.black.good { background: linear-gradient(180deg, #38d39a, #229a68); }
.key.white.bad { background: linear-gradient(180deg, #ffc9c3, #f79b91); }
.key.black.bad { background: linear-gradient(180deg, #f47166, #b8433a); }
.key.white.want { box-shadow: inset 0 0 0 3px var(--accent), inset 0 -4px 0 rgba(0,0,0,.12); }
.key.black.want { box-shadow: 0 0 0 3px var(--accent), 0 3px 6px rgba(0,0,0,.5); }
.key .finger-tag {
  position: absolute; top: 4px; left: 50%; transform: translateX(-50%);
  font-size: .66rem; font-weight: 800; color: #2b6cb0; opacity: .8; pointer-events: none;
}

/* ---------- 底部固定操作栏（练习态） ---------- */
.actionbar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 10px 14px calc(10px + var(--safe-b));
  background: rgba(13,16,22,.95);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  gap: 10px;
}
body.practicing .actionbar { display: flex; }
.actionbar .btn { flex: 1 1 0; min-height: 52px; }
.actionbar .btn.wide { flex: 2 1 0; }

/* ---------- 设置抽屉 ---------- */
.settings-card {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 60;
  width: min(420px, 92vw);
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 32px rgba(0,0,0,.5);
  padding: 18px 20px calc(20px + var(--safe-b));
  overflow-y: auto;
  transform: translateX(102%);
  transition: transform .22s ease;
}
.settings-card.show { transform: translateX(0); }
.settings-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.settings-note { padding: 10px 0; }
.field { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.field .label { flex: 1; }
.field .label small { display: block; color: var(--text-dim); font-size: .8rem; font-weight: 400; }
.field .ctrl { flex: 0 0 auto; }
.switch {
  position: relative; width: 52px; height: 30px; border-radius: 999px;
  background: #333a47; border: none; cursor: pointer; transition: background .15s ease;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; transition: transform .15s ease;
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(22px); }
input[type=range] { width: 160px; accent-color: var(--accent); }

/* ---------- 空态 / 汇总 / 提示 ---------- */
.empty { text-align: center; color: var(--text-dim); padding: 26px 10px; }
.empty .big { font-size: 1.1rem; color: var(--text); margin-bottom: 6px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat .v { font-size: 1.5rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--text-dim); font-size: .8rem; }
.advice {
  margin-top: 12px; padding: 14px;
  border-radius: 12px; border: 1px solid rgba(90,169,255,.35);
  background: rgba(90,169,255,.08);
  font-size: .98rem;
}
.bar-heat { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 10px; }
.bar-cell {
  width: 26px; height: 26px; border-radius: 6px;
  display: grid; place-items: center;
  font-size: .7rem; font-variant-numeric: tabular-nums;
  background: var(--card-2); color: var(--text-dim);
}
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%) translateY(14px);
  max-width: min(560px, 92vw);
  padding: 12px 18px; border-radius: 12px;
  background: #2a3140; color: var(--text);
  box-shadow: var(--shadow);
  font-size: .95rem;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 90;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.hidden { display: none !important; }

/* 练习态：曲库侧栏整体收起，屏幕只留谱面与琴键（外加练习信息栏，宽屏时显示）。 */
body.practicing .hide-in-practice { display: none !important; }

/* 练习态信息侧栏：默认隐藏（窄屏/竖屏单列），宽屏横屏时才显示 */
.practice-info { display: none; min-width: 0; }
.practice-info-card { position: sticky; top: 70px; display: flex; flex-direction: column; gap: 12px; }
.practice-info-card .pi-title { font-size: 1.12rem; font-weight: 720; }
.practice-info-card .pi-step { color: var(--accent); font-size: .95rem; line-height: 1.5; }
.practice-info-card .pi-rows { display: flex; flex-direction: column; gap: 8px; }
.practice-info-card .pi-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 10px; background: var(--card-2);
  font-size: .88rem; color: var(--text-dim);
}
.practice-info-card .pi-row b { color: var(--text); font-variant-numeric: tabular-nums; }
.practice-info-card .pi-tip {
  padding: 12px; border-radius: 10px; line-height: 1.6;
  border: 1px solid rgba(90,169,255,.3); background: rgba(90,169,255,.07);
  color: var(--text); font-size: .92rem;
}

/* 窄屏（含 iPad 竖屏 834）单列。注意：iPad 横屏 1180/1194/1366 宽度 >1100，
   必须保持双栏，否则侧栏会被挤到首屏外——只用宽度判断，不再用 pointer 粗指针。 */
@media (max-width: 1100px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .side-column { order: 2; }
  .practice-column { order: 1; }
  main { padding: 10px 12px; }
  .score-list { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* 矮横屏（iPad 横屏 834 高）练习态紧凑排版：确保琴键落在首屏内 */
@media (min-width: 1101px) {
  body.practicing main { padding-top: 8px; }
  body.practicing .workspace { grid-template-columns: minmax(0, 1fr) 320px; gap: 12px; }
  body.practicing .practice-info { display: block; }
  body.practicing .practice-column { gap: 10px; }
  body.practicing .stage { gap: 8px; }
  body.practicing .stage-head { flex-wrap: nowrap; }
  body.practicing #demo-btn { display: none; }
  /* 主列放大铺满高度：瀑布流与琴键都按视口高度给，充分利用平板横屏 */
  body.practicing .waterfall-wrap { height: clamp(150px, 26vh, 300px); }
  /* 五线谱在平板横屏给足高度，音符更大、当前行更清楚 */
  body.practicing .staff-host { height: clamp(200px, 34vh, 340px); }
  body.practicing #staff-size-chips { display: flex !important; }
  body.practicing .keyboard-card { padding: 10px 14px; }
  body.practicing .keys { height: clamp(150px, 26vh, 240px); }
  body.practicing .actionbar { padding-top: 6px; }
  body.practicing .actionbar .btn { min-height: 44px; }
}
/* 较矮横屏（≤900px 高，如 iPad 1180x820 / 桌面 1280x800）收紧一档保证一屏装下 */
@media (min-width: 1101px) and (max-height: 900px) {
  body.practicing .waterfall-wrap { height: clamp(130px, 20vh, 200px); }
  body.practicing .staff-host { height: clamp(170px, 26vh, 250px); }
  body.practicing .keys { height: clamp(130px, 20vh, 190px); }
  body.practicing .stage-head .stage-meta { display: none; }
}

@media (max-width: 720px) {
  .brand span:last-child { display: none; }
  .now-playing { max-width: 40vw; }
  h1 { font-size: 1.3rem; }
  .keys { height: 132px; }
  body.practicing .keys { height: 168px; }
  .key .kname { display: none; }
  .actionbar .btn { min-height: 48px; font-size: .92rem; padding: 0 8px; }
  .feedback-bar .msg { font-size: .95rem; }
  .guide-row { flex-wrap: wrap; }
  .guide-copy { flex-basis: 100%; }
}

/* 桌面宽屏：侧栏贴右，主列更宽 */
@media (min-width: 1400px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 420px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
