/* 播放页样式(自 song.html 拆出;四段内联样式按原顺序合并,层叠顺序不变) */
  * { box-sizing: border-box; }
  body { margin: 0; font-family: -apple-system, "PingFang SC", sans-serif; background: #0d0d0d; color: #eee; overflow: hidden; }

  /* Header bar */
  .hdr {
    display: flex;
    align-items: center;
    padding: 6px 14px;
    gap: 14px;
    background: #0a0a0a;
    border-bottom: 1px solid #2a2a2a;
    font-size: 13px;
    height: 36px;
  }
  .hdr a { color: #4a9eff; text-decoration: none; }
  .hdr .title { font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hdr .stats { opacity: 0.5; font-family: 'SF Mono', monospace; font-size: 11px; }
  .hdr label { display: flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; opacity: 0.85; }

  /* ===== Panel grid: 4 free-combining panels (video/chord/roll/sheet).
     Template + areas are set by applyPanels() based on which chips are on. ===== */
  body:not(.mobile) #panelGrid { flex: 1; min-height: 0; display: grid; gap: 0; padding: 8px; }
  body:not(.mobile) #panelGrid > .panel {
    min-width: 0; min-height: 0; display: none; position: relative;
    flex-direction: column; overflow: hidden; border-radius: 8px;
  }
  body:not(.mobile) #panelGrid > .panel.on { display: flex; }
  body:not(.mobile) #panelGrid > .panel.drop-target { outline: 2px dashed #4a9eff; outline-offset: -2px; }
  /* Drag grip: hold to swap two panels */
  .pgrip {
    position: absolute; top: 4px; right: 4px; z-index: 9;
    width: 20px; height: 16px; border-radius: 4px; cursor: grab;
    background: rgba(90,90,90,0.35); color: #bbb; font-size: 9px; line-height: 16px;
    text-align: center; user-select: none; opacity: 0.35; transition: opacity 0.15s;
  }
  .panel:hover .pgrip { opacity: 1; }
  .pgrip:hover { background: #4a9eff; color: #fff; }
  #sheetPanel .pgrip { background: rgba(0,0,0,0.15); color: #666; }
  /* Resize dividers between grid tracks */
  .pg-div { display: none; z-index: 5; border-radius: 3px; transition: background 0.12s; }
  .pg-div.show { display: block; }
  .pg-div.pg-v { cursor: col-resize; margin: 0 1px; }
  .pg-div.pg-h { cursor: row-resize; margin: 1px 0; }
  .pg-div:hover, .pg-div.dragging { background: #4a9eff; }
  body:not(.mobile) #pVideo { background: #161616; padding: 8px; }
  body:not(.mobile) #pVideo .video-wrap { flex: 1; min-height: 0; }
  body:not(.mobile) #pChord { background: #131313; overflow-y: auto; }
  body:not(.mobile) #pChord .chord-block { flex-shrink: 0; height: auto; overflow-x: auto; }
  /* Mobile keeps its own fixed-position layout: grid off, chord/sheet gone */
  body.mobile #panelGrid { display: block; }
  body.mobile #pVideo, body.mobile #pRoll { display: block !important; }
  /* Panels are per-view on mobile: only the active mview-* shows its panel */
  body.mobile #pChord, body.mobile #sheetPanel, body.mobile #pJazz, body.mobile #p3d, body.mobile #pLearn { display: none !important; }
  body.mobile.mview-chord #pChord, body.mobile.mview-sheet #sheetPanel, body.mobile.mview-jazz #pJazz, body.mobile.mview-r3d #p3d, body.mobile.mview-learn #pLearn {
    display: block !important; position: fixed; left: 0; right: 0; top: 36px; bottom: var(--mbh, 92px);
    overflow: auto; z-index: 40;
  }
  body.mobile.mview-chord #pChord { background: #131313; }
  /* Chord view on phones: stack full-width — big current chord on top, then
     BPM beside the snowman, keyboard stretched; taller touch-friendly rows. */
  body.mobile.mview-chord #pChord .chord-block {
    display: grid; grid-template-columns: 1fr; gap: 10px; padding: 12px; height: auto;
  }
  body.mobile.mview-chord .cb-card { padding: 12px 14px; }
  body.mobile.mview-chord .chord-seq { overflow-x: auto; gap: 9px; padding-bottom: 2px; }
  body.mobile.mview-chord .cs-cur .cs-lab { font-size: 44px; }
  body.mobile.mview-chord .cs-past .cs-lab { font-size: 16px; }
  body.mobile.mview-chord .cs-future .cs-lab { font-size: 18px; }
  body.mobile.mview-chord .chord-now-lbl { font-size: 12px; }
  body.mobile.mview-chord .chord-key-val { font-size: 16px; }
  body.mobile.mview-chord .cb-tempo b { font-size: 20px; }
  body.mobile.mview-chord .fp-solf { font-size: 13px; }
  body.mobile.mview-chord #scaleMini { width: 100%; max-width: 280px; height: auto; }
  body.mobile.mview-chord #miniLegend { font-size: 11px; }
  body.mobile.mview-jazz #jzDrillRow .drill-btn { display: none; }  /* bottom bar has A/B/▶ */
  body.mobile.mview-sheet #sheetPanel { background: #fff; border: none; }
  /* 手机上的乐谱工具条:单行横向滑动(以前每个按钮竖排换行,占掉 100px);状态文字收短 */
  /* 手机上的乐谱工具条:一行放得下——状态文字(可截断)+ 调 + 「⋯ 更多」;其余按钮收进底部菜单(5-sheet.js openMore) */
  body.mobile #sheetTop { flex-wrap: nowrap; gap: 8px; padding: 6px 10px; }
  body.mobile #sheetTop > * { flex: 0 0 auto; white-space: nowrap; }
  body.mobile #sheetTop > b { display: none; }
  body.mobile #sheetTop #sheetSt { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
  body.mobile #sheetTop #stMore { display: none; }
  body.mobile #sheetTop #stMoreBtn { display: inline-flex; }
  body.mobile #sheetTop .st-btn { min-height: 32px; padding: 4px 12px; font-size: 13px; border-radius: 16px; }
  body.mobile #mBottom button, body.mobile #mTop button, body.mobile #sheetTop button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  body.mobile.sheet-m #sheetBox { padding: 2px 3px 14px; }
  body.mobile.sheet-m #sheetBox .mspg { margin-bottom: 2px; }
  /* Panel chips in the header */
  #panelChips { display: inline-flex; gap: 4px; }
  #panelChips .pchip {
    font-size: 11px; padding: 3px 10px; border-radius: 12px; cursor: pointer;
    background: #1c1c1c; color: #777; border: 1px solid #333; line-height: 1.4; white-space: nowrap;
  }
  #panelChips .pchip.on { background: #21354d; color: #9fc3ff; border-color: #3a6ea5; }
  video { width: 100%; height: 100%; border-radius: 6px; background: #000; object-fit: contain; display: block; }
  /* Drag handle between video and chord (top-row layout) */
  .v-divider {
    background: transparent;
    cursor: col-resize;
    position: relative;
    transition: background 0.15s;
  }
  .v-divider:hover, .v-divider.dragging { background: #4a9eff; }
  .v-divider::before {
    content: ""; position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: 2px; height: 30px; border-radius: 1px;
    background: #444;
  }
  .v-divider:hover::before, .v-divider.dragging::before { background: #fff; }

  /* Chord panel = three cards: current chord · mode/scale keyboard · chord structure */
  .chord-block {
    display: grid;
    grid-template-columns: minmax(280px, 1.35fr) minmax(250px, 1fr) minmax(220px, 0.9fr);
    gap: 10px;
    align-items: stretch;
    padding: 8px;
    height: auto;
  }
  .cb-card { background: #1a1a1a; border: 1px solid #262626; border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
  .cb-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: #8a8a8a; }
  .cb-tempo { font-family: 'SF Mono', monospace; text-transform: none; letter-spacing: 0; display: inline-flex; align-items: center; gap: 5px; color: #9a9a9a; }
  .cb-tempo b { color: #66e3a0; font-size: 15px; font-weight: 600; }
  .cb-anchor { color: #7dd6a3; text-transform: none; letter-spacing: 0; font-family: 'SF Mono', monospace; font-size: 12px; }
  .cb-now { justify-content: center; }
  .cb-now .chord-seq { justify-content: safe center; gap: 10px; overflow-x: auto; padding: 6px 0; scrollbar-width: none; }
  .cb-now .cs-cur .cs-lab { font-size: 46px; }
  .cb-now .cs-past .cs-lab { font-size: 15px; } .cb-now .cs-future .cs-lab { font-size: 17px; }
  .cb-now .cs-cur .cs-sub { font-size: 12px; color: #7dd6a3; opacity: 1; height: auto; margin-top: 4px; }
  .cb-scale #scaleMini { display: block; margin-top: 2px; border-radius: 4px; }
  .cb-legend { display: flex; gap: 12px; font-size: 10px; color: #9a9a9a; }
  .lg { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
  .lg-c { background: #5a9bff; } .lg-t { background: #7dd6a3; } .lg-a { background: #f3b0a0; }
  .cb-fp-body { display: flex; align-items: flex-start; gap: 16px; }
  .cb-tones { display: flex; flex-wrap: wrap; gap: 6px 10px; font-family: 'SF Mono', monospace; align-content: flex-start; padding-top: 4px; }
  .cb-tones .ct { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
  .cb-tones .ct b { font-size: 15px; font-weight: 600; color: #e2e2e2; }
  .cb-tones .ct small { font-size: 10px; color: #7fb0ff; margin-top: 2px; }
  .cb-tones .ct.root b { color: #7fb0ff; }
  .cb-tones:empty { display: none; }
  /* 按面板自身宽度(不是视口)换列数:并排放卷帘时面板只有半屏 */
  #pChord { container-type: inline-size; }
  @container (max-width: 860px) { .chord-block { grid-template-columns: 1fr 1fr; } .cb-now { grid-column: 1 / -1; } }
  @container (max-width: 540px) { .chord-block { grid-template-columns: 1fr; } }
  .chord-now-lbl { font-size: 10px; opacity: 0.5 }
  .chord-now-val { font-family: 'SF Mono', monospace; font-size: 36px; font-weight: 600; color: #ffeb3b; line-height: 1; }
  /* Chord sequence (prev3 · current · next3) */
  .chord-seq { display: flex; align-items: center; gap: 7px; font-family: 'SF Mono', monospace; }
  /* Current-chord fingerprint: staff-snowball + figured bass + root solfège */
  .chord-fp { display: flex; flex-direction: column; align-items: center; gap: 6px; font-family: 'SF Mono', monospace; }
  .chord-fp:empty { display: none; }
  .fp-top { display: flex; align-items: flex-end; gap: 9px; }   /* snowball + figures share the bass baseline */
  .fp-solf { white-space: nowrap; font-size: 12px; }
  .fp-stack { position: relative; flex: none; }
  .fp-fig { flex: none; font-size: 14px; text-align: center; }
  .fp-fig .hi { background: rgba(127,176,255,0.20); color: #aecbff; border-radius: 3px; padding: 0 2px; }
  .fp-fig .lo { color: #6f6f6f; }
  .fp-q { font-size: 17px; color: #7fb0ff; align-self: flex-start; }
  .fp-solf { font-size: 12px; color: #8a8a8a; }
  .fp-solf b { font-weight: 600; color: #e2e2e2; }
  .fp-solf b.chrom { color: #ffb870; }
  .cs-item { display: flex; flex-direction: column; align-items: center; line-height: 1; }
  .cs-lab { white-space: nowrap; }
  .cs-sub { font-size: 8px; opacity: 0.5; height: 9px; margin-top: 2px; }
  .cs-past .cs-lab   { font-size: 14px; color: #777; }
  .cs-future .cs-lab { font-size: 15px; color: #cfd8e0; }
  .cs-cur .cs-lab    { font-size: 34px; font-weight: 600; }
  .cs-arrow { opacity: 0.25; font-size: 12px; }
  .cs-empty { width: 14px; }
  .chord-key-val { font-family: 'SF Mono', monospace; font-size: 15px; opacity: 0.9; }

  /* BPM block */
  .bpm-val { font-family: 'SF Mono', monospace; font-size: 24px; font-weight: 600; color: #66e3a0; line-height: 1; display: flex; align-items: center; gap: 8px; }
  .beat-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: #66e3a0;
    transition: transform 0.06s ease-out, opacity 0.5s ease-out;
    opacity: 0.4;
  }
  .beat-dot.downbeat { background: #ff5252; }
  .beat-dot.flash { opacity: 1; transform: scale(1.6); transition: none; }

  .drill-row-label { font-size: 10px; opacity: 0.45; flex-shrink: 0; }
  .drill-btn {
    padding: 3px 9px; font-size: 11px; background: #2a2a2a; color: #ccc;
    border: 1px solid #444; border-radius: 4px; cursor: pointer; white-space: nowrap;
  }
  .drill-btn:hover:not(:disabled) { background: #3a3a3a; color: #fff; }
  .drill-btn:disabled { opacity: 0.4; cursor: default; }
  .drill-btn.armed { background: #ffeb3b; color: #000; border-color: #ffeb3b; animation: drillPulse 1s ease-in-out infinite; }
  .drill-btn-go { background: #2a4a2a; color: #8f8; border-color: #4a6a4a; }
  .drill-btn-go:hover:not(:disabled) { background: #3a5a3a; }
  .drill-btn-go.training { background: #aa4a4a; color: #fff; border-color: #cc6a6a; }
  @keyframes drillPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,235,59,0.6); } 50% { box-shadow: 0 0 0 3px rgba(255,235,59,0); } }

  /* Roll grid - auto-fits number of panels */
  #compareWrap {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 10px;
    padding: 8px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  select, button { padding: 4px 9px; background: #2a2a2a; color: #eee; border: 1px solid #444; border-radius: 4px; cursor: pointer; font-size: 12px; }
  button:hover, select:hover { background: #3a3a3a; }
  button.active { background: #4a9eff; border-color: #4a9eff; color: #fff; }
  input[type=range] { width: 100px; vertical-align: middle; }
  .speed-slider-wrap {
    display: inline-block;
    position: relative;
    width: 220px;
    height: 18px;
    margin-left: 4px;
    vertical-align: middle;
  }
  .speed-slider-wrap input[type=range] {
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 100%;
    margin: 0;
    z-index: 2;
    background: transparent;
  }
  /* dot markers overlaid on the slider track (above the track, below the thumb visually) */
  .speed-ticks {
    position: absolute;
    left: 0; right: 0; top: 50%;
    height: 0;
    pointer-events: none;
    z-index: 3;
  }
  .speed-ticks .tick {
    position: absolute;
    top: 0;
    transform: translate(-50%, -50%);
    width: 5px; height: 5px;
    border-radius: 50%;
    background: #cfcfcf;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.6);
    cursor: pointer;
    pointer-events: auto;
    transition: background 0.12s, transform 0.12s;
  }
  .speed-ticks .tick[data-speed="1"] { width: 7px; height: 7px; background: #fff; }  /* 1x emphasized */
  .speed-ticks .tick:hover { background: #fff; transform: translate(-50%, -50%) scale(1.5); }
  .speed-ticks .tick.snap { background: #66e3a0; box-shadow: 0 0 4px #66e3a0; }

  /* Footer settings */
  .footer-settings {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 6px 14px;
    background: #0e0e0e;
    border-top: 1px solid #2a2a2a;
    font-size: 12px;
    flex-wrap: wrap;
  }
  .footer-settings { flex-shrink: 0; }
  .footer-settings label { opacity: 0.7; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
  .global-time { font-family: 'SF Mono', Monaco, monospace; font-size: 12px; padding: 2px 8px; background: #000; border-radius: 3px; opacity: 0.7; margin-left: auto; }

  /* Settings popover: the rarely-used controls, opened from the ⚙ button */
  .settings-btn { background: #1a1a1a; color: #ccc; border: 1px solid #333; border-radius: 6px;
    padding: 4px 12px; font-size: 12px; cursor: pointer; }
  .settings-btn:hover, .settings-btn.open { background: #2a2a2a; color: #fff; }
  .settings-panel {
    position: fixed; right: 12px; bottom: 44px; z-index: 60;
    display: flex; flex-direction: column; gap: 12px;
    background: #161616; border: 1px solid #3a3a3a; border-radius: 10px;
    padding: 14px 16px; font-size: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.6);
  }
  .settings-panel label { opacity: 0.85; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
  .settings-panel input[type=range] { width: 130px; }
  [dir="rtl"] .settings-panel { right: auto; left: 12px; }

  /* ===== Mobile mode: two fullscreen views (video / roll), driven by
     body.mobile + body.mview-video|mview-roll. Desktop untouched. ===== */
  #mTop, #mBottom, #mToast { display: none; }
  body.mobile .hdr, body.mobile .chord-strip, body.mobile .footer-settings,
  body.mobile .roll-divider, body.mobile .top-row > .chord-block,
  body.mobile .v-divider, body.mobile .sidebar-divider,
  body.mobile .tool-header { display: none !important; }
  body.mobile { padding-left: 0 !important; }
  body.mobile .top-row { display: block; padding: 0; height: auto; border: none; background: none; }
  body.mobile .video-wrap { position: fixed; z-index: 45; background: #000; }
  body.mobile.mview-video .video-wrap { inset: 0; width: auto; height: auto; }
  body.mobile.mview-video .video-wrap video { border-radius: 0; }
  body.mobile.mview-video #compareWrap, body.mobile.mview-video #mBottom { display: none !important; }
  /* non-video views keep the video element alive offscreen so audio + clock continue */
  body.mobile:not(.mview-video) .video-wrap { left: 0; top: 0; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
  body.mobile #compareWrap {
    position: fixed; left: 0; right: 0; top: 36px; bottom: var(--mbh, 92px);
    z-index: 40; padding: 0 2px; gap: 0;
  }
  body.mobile:not(.mview-roll) #compareWrap { display: none !important; }
  /* view chips in the top bar */
  .mview-chip {
    background: #2a2a2a; border: none; border-radius: 12px;
    padding: 4px 8px; font-size: 15px; line-height: 1;
  }
  .mview-chip.on { background: #21354d; box-shadow: inset 0 0 0 1px #3a6ea5; }
  #mBack { color: #8fb3d9; text-decoration: none; font-size: 24px; line-height: 1; padding: 0 4px 3px 0; }
  #mShare { background: none; border: none; color: #8fb3d9; font-size: 17px; line-height: 1; padding: 0 2px; cursor: pointer; }
  #mTitle { flex: 1; min-width: 0; font-size: 12px; opacity: 0.65; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  body.mobile #mTop {
    display: flex; position: fixed; top: 0; left: 0; right: 0; height: 36px; z-index: 46;
    align-items: center; gap: 8px; padding: 0 10px 0 6px;
    background: rgba(13,13,13,0.88); border-bottom: 1px solid #2a2a2a;
  }
  body.mobile #mBottom {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 46;
    flex-direction: column; gap: 6px;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    background: #101010; border-top: 1px solid #2a2a2a;
  }
  .mchip {
    flex: 1; text-align: center; background: #2a2a2a; color: #ccc;
    font-size: 12px; padding: 7px 0; border-radius: 14px; border: none;
  }
  .mchip.on { background: #1d9e75; color: #fff; font-weight: 600; }
  .mbtn {
    flex: 1; text-align: center; background: #2a2a2a; color: #ffd84d;
    font-size: 13px; padding: 8px 0; border-radius: 14px; border: none; font-weight: 600;
  }
  .mbtn:disabled { opacity: 0.35; }
  .mbtn.go { background: #2e5e46; color: #9fe1cb; }
  .mbtn.go.training { background: #aa4a4a; color: #fff; }
  .mbtn.armed { background: #ffeb3b; color: #000; }
  .mbtn.sec { background: #243a52; color: #a9d2ff; }
  .mbtn.sec.on { background: #1d9e75; color: #fff; }
  /* ---- 小段练习条(手机底栏):开启时替换常规两行 ---- */
  body.sec-on #mBottom > .mrow { display: none !important; }
  body.sec-on #tpill { display: none !important; }
  body.mobile.sec-on #sheetTop { display: none; }            /* 练一小段时把乐谱工具条收起,多留一行谱 */
  #secBar { display: flex; flex-direction: column; gap: 7px; }
  #secBar[hidden] { display: none; }
  #secTop { display: flex; align-items: center; gap: 8px; }
  .sec-nav { flex: 0 0 52px; height: 44px; border: none; border-radius: 14px; background: #2a2a2a; color: #fff; font-size: 26px; line-height: 1; }
  .sec-nav:disabled { opacity: .3; }
  #secLabel { flex: 1; min-width: 0; height: 44px; border: none; border-radius: 14px; background: #1b2a22; color: #dff7ea;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
  #secLabel b { font-size: 15px; font-weight: 600; }
  #secLabel small { font-size: 11px; opacity: .7; font-variant-numeric: tabular-nums; }
  #secChips { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding: 1px 0; }
  #secChips::-webkit-scrollbar { display: none; }
  #secChips button { flex: 0 0 auto; min-width: 44px; height: 26px; padding: 0 8px; border: none; border-radius: 9px; background: #222; color: #888;
    font-size: 11px; font-variant-numeric: tabular-nums; }
  #secChips button.done { background: #1d3a2a; color: #7fdca0; }
  #secChips button.cur { background: #ffd84d; color: #111; font-weight: 700; }
  #secCtl { display: flex; align-items: center; gap: 6px; }
  #secPlay { flex: 0 0 56px; height: 44px; border: none; border-radius: 14px; background: #2a6a4a; color: #dfffe9; font-size: 18px; }
  .sec-seg { flex: 1; display: flex; align-items: center; background: #1f1f1f; border-radius: 12px; padding: 3px; gap: 2px; min-width: 0; }
  .sec-seg button { flex: 1; height: 38px; border: none; border-radius: 10px; background: none; color: #aaa; font-size: 12px; padding: 0; }
  .sec-seg button.on { background: #3a3a3a; color: #fff; font-weight: 600; }
  .sec-seg span { font-size: 10px; color: #777; padding: 0 5px 0 2px; white-space: nowrap; }
  #secDone, #secExit { flex: 0 0 44px; height: 44px; border: none; border-radius: 14px; background: #2a2a2a; color: #9fe1cb; font-size: 17px; }
  #secDone.on { background: #1d9e75; color: #fff; }
  #secExit { color: #bbb; flex-basis: 40px; }
  /* 谱面上的当前段底色带(在音符之下) */
  #sheetBox .ms-hl { position: absolute; z-index: 0; background: rgba(255, 214, 64, .24); border-radius: 8px; pointer-events: none; }
  #sheetBox .mspg > svg { position: relative; z-index: 1; }
  body.mobile #mToast {
    display: block; position: fixed; left: 50%; top: 42%; transform: translate(-50%,-50%);
    z-index: 60; background: rgba(30,30,30,0.92); color: #fff; font-size: 22px;
    padding: 12px 22px; border-radius: 14px; opacity: 0; pointer-events: none;
    transition: opacity 0.25s;
  }
  body.mobile .settings-panel { right: 10px; left: 10px; bottom: 100px; }
  body.mobile .kb-canvas { height: 84px; }
  /* Portrait: rotate the roll 90° so the 88 keys run along the LONG edge
     (keyboard on the right, notes flow left→right toward it). The canvases
     keep their layout size (swapped vs the screen) and are rotated as a
     whole — drawing code is untouched. */
  @media (orientation: portrait) {
    body.mobile.mview-roll .tool-panel { position: relative; width: 100%; height: 100%; overflow: hidden; }
    body.mobile.mview-roll .tool-canvases {
      position: absolute; top: 0; left: 0;
      width: calc(100dvh - 36px - var(--mbh, 92px));   /* on-screen vertical span (36 top + bottom bar) */
      height: calc(100dvw - 4px);    /* on-screen horizontal span */
      transform-origin: top left;
      transform: rotate(-90deg) translateX(-100%);
    }
  }
  /* Landscape is supported for the sheet view; keep the rotate hint available
     for other mobile views without covering the score. */
  #mRotateHint { display: none; }
  @media (orientation: landscape) {
    body.mobile:not(.mview-sheet) #mRotateHint {
      display: flex; position: fixed; inset: 0; z-index: 80;
      flex-direction: column; align-items: center; justify-content: center;
      background: #0d0d0d; color: #ccc; font-size: 16px; text-align: center; padding: 20px;
    }
    body.mobile.mview-sheet #sheetPanel {
      display: block; position: fixed; inset: 36px 0 var(--mbh, 92px); z-index: 40;
      overflow: auto; background: #fff;
    }
    body.mobile.mview-sheet #sheetBox { padding: 4px 8px 16px; }
    body.mobile.mview-sheet #sheetBox .mspg { margin: 0 auto 6px; max-width: 1100px; }
  }

  /* Narrow screens: shrink the speed slider */
  @media (max-width: 1200px) {
    .speed-slider-wrap { width: 150px; }
    .footer-settings { gap: 10px; font-size: 11px; }
  }
  @media (max-width: 1000px) {
    .footer-settings { gap: 8px; padding: 5px 10px; }
    .speed-slider-wrap { width: 120px; }
    .global-time { display: none; }
  }

  body { display: flex; flex-direction: column; height: 100vh; }

  /* === Sidebar layout: video on left, takes full vertical space === */
  body.layout-side { padding-left: var(--sidebar-w, 360px); }
  body.layout-side .video-wrap {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w, 360px);
    height: 100vh;
    max-height: none;
    z-index: 10;
    background: #000;
    border-right: none;
  }
  body.layout-side .video-wrap video {
    border-radius: 0;
    object-fit: contain;
  }
  body.layout-side .top-row {
    grid-template-columns: 1fr;
    height: auto;
  }
  body.layout-side .top-row > .v-divider { display: none; }
  body.layout-side .top-row > .chord-block { margin-left: 0; }
  body.layout-side .chord-block { padding: 10px 14px; }

  /* === Bottom layout: piano roll on top, video+chord at bottom === */
  body.layout-bottom .hdr          { order: 0; }
  body.layout-bottom .chord-strip  { order: 1; }
  body.layout-bottom #compareWrap  { order: 2; }
  body.layout-bottom .top-row      { order: 4; border-top: 1px solid #2a2a2a; border-bottom: none; }
  body.layout-bottom .footer-settings { order: 5; }
  /* Vertical sidebar divider (only visible in sidebar layout) */
  .sidebar-divider {
    display: none;
    position: fixed;
    left: var(--sidebar-w, 360px);
    top: 0; bottom: 0;
    width: 6px;
    margin-left: -3px;
    background: transparent;
    cursor: col-resize;
    z-index: 11;
    transition: background 0.15s;
  }
  body.layout-side .sidebar-divider { display: block; }
  .sidebar-divider:hover, .sidebar-divider.dragging { background: #4a9eff; }
  .sidebar-divider::before {
    content: ""; position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: 2px; height: 40px; border-radius: 1px;
    background: #444;
  }
  .sidebar-divider:hover::before, .sidebar-divider.dragging::before { background: #fff; }
  /* Horizontal divider above the piano roll: drag to trade video-row height
     for roll height (the roll is flex:1 and absorbs whatever is freed). */
  .roll-divider {
    height: 7px;
    margin: -3px 0;          /* generous hit area without eating layout space */
    flex-shrink: 0;
    cursor: row-resize;
    position: relative;
    z-index: 12;
    background: transparent;
    touch-action: none;       /* needed for pointer-event dragging on touch */
    transition: background 0.15s;
  }
  .roll-divider:hover, .roll-divider.dragging { background: #4a9eff; }
  .roll-divider::before {
    content: ""; position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: 36px; height: 3px; border-radius: 2px;
    background: #444;
  }
  .roll-divider:hover::before, .roll-divider.dragging::before { background: #fff; }
  /* bottom layout: divider sits between the roll (order 2) and video row (order 4) */
  body.layout-bottom .roll-divider { order: 3; }
  /* side layout: video height isn't row-based there; sidebar divider is the lever */
  body.layout-side .roll-divider { display: none; }
  /* When sidebar, hide the toolpanel header which is redundant; expand roll */
  .layout-toggle {
    padding: 2px 8px;
    background: #2a2a2a;
    color: #ccc;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
  }
  .layout-toggle:hover { background: #3a3a3a; color: #fff; }
  .layout-toggle.active { background: #4a9eff; border-color: #4a9eff; color: #fff; }
  .lang-select { background: #2a2a2a; color: #eee; border: 1px solid #444; border-radius: 4px; padding: 3px 6px; font-size: 12px; cursor: pointer; }

  /* Help overlay */
  #helpOverlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
  }
  .help-card {
    background: #1a1a1a; border: 1px solid #3a3a3a; border-radius: 14px;
    padding: 20px 24px; max-width: 760px; width: 90%;
    box-shadow: 0 12px 48px rgba(0,0,0,0.7);
  }
  .help-head {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 17px; font-weight: 600; margin-bottom: 16px;
  }
  .help-close { cursor: pointer; opacity: 0.6; font-size: 18px; padding: 0 6px; }
  .help-close:hover { opacity: 1; }
  .help-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 28px;
  }
  .help-sec h4 { margin: 0 0 8px; font-size: 12px; color: #4a9eff; font-weight: 600; }
  .help-sec > div { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 13px; }
  .help-sec > div > span { opacity: 0.8; }
  .help-sec kbd {
    background: #2e2e2e; border: 1px solid #555; border-bottom-width: 2px;
    border-radius: 4px; padding: 1px 7px; font-family: 'SF Mono', monospace;
    font-size: 11px; min-width: 16px; text-align: center; color: #eee;
  }
  .help-tip { font-size: 11px !important; opacity: 0.55 !important; margin-top: 4px; }
  /* 卷帘视图与和弦面板同一套卡片语言(.cb-card):#1a1a1a 底、#262626 边、8px 圆角、小写灰标题 */
  .tool-panel {
    background: #1a1a1a;
    border-radius: 8px;
    border: 1px solid #262626;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
  }
  .tool-panel.disabled { opacity: 0.4; }
  .tool-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 12px;
    background: transparent;
    border-bottom: 1px solid #262626;
    font-size: 12px;
    flex-shrink: 0;
  }
  .tool-header > div { display: flex; align-items: center; gap: 6px; min-width: 0; }
  .tool-title { font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: #8a8a8a; font-weight: 500; margin-right: 4px; }
  .tool-stats { font-size: 11px; color: #9a9a9a; font-family: 'SF Mono', monospace; white-space: nowrap; }
  .tool-canvases { flex: 1; display: flex; flex-direction: column; min-height: 0; }
  .roll-canvas { flex: 1; background: #050505; display: block; min-height: 0; }
  .kb-canvas { height: 120px; background: #1a1a1a; flex-shrink: 0; display: block; }
  .pdf-link { font-size: 11px; color: #7fb0ff; text-decoration: none; padding: 3px 9px; border: 1px solid #2a3a52; border-radius: 6px; background: #1c2431; }
  .pdf-link:hover { background: #24314a; }
  .play-btn {
    padding: 3px 10px;
    background: #1f2a24;
    color: #7dd6a3;
    border: 1px solid #2f4a3a;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    margin-left: 0;
  }
  .play-btn:hover { background: #274033; }
  .play-btn.playing { background: #6a2a2a; color: #ffc9c9; border-color: #8a3a3a; }
  .play-btn.stop { background: #232323; color: #aaa; border-color: #3a3a3a; padding: 3px 8px; }

/* ---- (原 song.html 第二段内联样式) ---- */
  body:not(.mobile) #sheetPanel{background:#fff;position:relative;border:1px solid #2a2a2a;
              display:none;overflow:auto;overscroll-behavior:contain}
  /* #panelGrid > .panel 的 overflow:hidden 特异性更高,这里点名压过它(只管 overflow,
     不能带 display——否则会压过 .panel.on 的 display:flex 让面板消失):谱面要能手动滚动 */
  body:not(.mobile) #panelGrid > #sheetPanel.panel{overflow:auto}
  body.mobile.mview-sheet #sheetPanel{-webkit-overflow-scrolling:touch;overscroll-behavior:contain}
  body:not(.mobile) #sheetPanel.on{display:block}
  #sheetTop{position:sticky;top:0;background:#fafafa;border-bottom:1px solid #e6e6e6;
            padding:5px 10px;font-size:12px;color:#555;display:flex;align-items:center;gap:8px;z-index:2;flex-wrap:wrap}
  #sheetSt{color:#777}
  /* 乐谱工具条按钮(以前每个按钮一串内联样式):统一外形,颜色按功能分 */
  #sheetTop .st-badge{font-size:11px;background:#137333;color:#fff;border-radius:4px;padding:1px 6px}
  #sheetTop #stMore{display:contents}
  #sheetTop #stMoreBtn{display:none;font-size:16px;font-weight:700;letter-spacing:1px}
  .st-btn{display:inline-flex;align-items:center;gap:4px;font:inherit;font-size:11.5px;line-height:1.5;padding:2px 10px;
          border-radius:6px;border:1px solid #cfd3dc;background:#fff;color:#444;cursor:pointer;white-space:nowrap;
          touch-action:manipulation;-webkit-tap-highlight-color:transparent}
  .st-btn:hover{filter:brightness(.97)} .st-btn:disabled{opacity:.55;cursor:default}
  .st-btn.st-right{margin-left:auto}
  .st-key{background:#eef0f8;border-color:#9aa6d6;color:#2d3a7a;font-weight:600}
  .st-key .st-ico{font-size:11px;letter-spacing:-1px;opacity:.75;font-weight:400} .st-key i{font-style:normal;font-size:10px;opacity:.7}
  .st-key.busy::after{content:"";width:10px;height:10px;border:2px solid #9aa6d6;border-top-color:#2d3a7a;border-radius:50%;animation:stSpin .8s linear infinite}
  .st-layout{background:#e9f3ee;border-color:#8fc3a6;color:#1d5c3d}
  .st-edit{background:#fdecea;border-color:#e0938a;color:#8a2a1f} .st-edit.on{background:#8a2a1f;color:#fff}
  .st-tempo{background:#eaf4fb;border-color:#8dbbd8;color:#1c5275}
  .st-solfa{background:#f3effc;border-color:#b9a6e6;color:#5b3fd4}
  .st-anch{background:#f2f2f2;border-color:#bbb;color:#555}
  .st-pdf{background:#fff4e6;border-color:#e0b07a;color:#8a4b08}
  .st-fing{background:#f4f0e6;border-color:#cbbf9e;color:#6b5b2e}
  .st-fingt{background:#fff8e8;border-color:#d6b56d;color:#805d12} .st-fingt.on{background:#805d12;color:#fff}
  .st-omr{background:#e8f0e8;border-color:#9ec49e;color:#2c5e2c}
  @keyframes stSpin{to{transform:rotate(360deg)}}
  /* 乐谱弹层:桌面是贴着按钮的小浮层,手机是底部抽屉(调的选择、「更多」菜单共用) */
  #sPopBk{position:fixed;inset:0;z-index:940}
  body.mobile #sPopBk{background:rgba(0,0,0,.38)}
  #sPop{position:fixed;z-index:941;left:8px;top:8px;width:340px;max-width:calc(100vw - 16px);background:#fff;color:#222;
        border-radius:12px;box-shadow:0 10px 40px rgba(0,0,0,.28);padding:12px;font-size:13px}
  body.mobile #sPop{left:0 !important;right:0;top:auto !important;bottom:0;width:auto;max-width:none;max-height:78vh;overflow:auto;
        border-radius:16px 16px 0 0;padding:14px 14px calc(16px + env(safe-area-inset-bottom));animation:sPopUp .18s ease-out}
  @keyframes sPopUp{from{transform:translateY(24px);opacity:.4}to{transform:none;opacity:1}}
  #sPop .sp-hd{display:flex;align-items:baseline;gap:8px;margin-bottom:10px;font-size:15px;font-weight:600}
  #sPop .sp-hd small{font-weight:400;color:#777;font-size:12px}
  #sPop .sp-x{margin-left:auto;align-self:center;border:0;background:#f0f0f3;width:30px;height:30px;border-radius:50%;font-size:13px;cursor:pointer;color:#555}
  #sPop .ks-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
  #sPop .ks-key{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-height:54px;
        border:1px solid #d9dce6;border-radius:10px;background:#fff;color:#222;font:inherit;cursor:pointer;padding:6px 2px;
        touch-action:manipulation;-webkit-tap-highlight-color:transparent}
  #sPop .ks-key b{font-size:17px;font-weight:600}
  #sPop .ks-key b .acc{font-style:normal;font-size:.8em;margin:0 -2px 0 -1px;vertical-align:.08em}
  #sPop .ks-key small{font-size:10.5px;color:#888}
  #sPop .ks-key.ready{border-color:#9aa6d6;background:#f3f5fd}
  #sPop .ks-key.ready::before{content:"";position:absolute;top:6px;right:7px;width:6px;height:6px;border-radius:50%;background:#4a63c9}
  #sPop .ks-key.orig small{color:#137333;font-weight:600}
  #sPop .ks-key.cur{background:#2d3a7a;border-color:#2d3a7a;color:#fff}
  #sPop .ks-key.cur small{color:#cfd6ff} #sPop .ks-key.cur::before{background:#fff}
  #sPop .ks-key:disabled{opacity:.45;cursor:default}
  #sPop .ks-key.busy{border-color:#2d3a7a}
  #sPop .ks-key.busy::after{content:"";position:absolute;top:5px;right:5px;width:10px;height:10px;border:2px solid #c5cdee;border-top-color:#2d3a7a;border-radius:50%;animation:stSpin .8s linear infinite}
  #sPop .ks-msg{margin-top:10px;font-size:12px;line-height:1.5;color:#666;min-height:18px}
  #sPop .ks-msg a{color:#2d3a7a;font-weight:600}
  #sPop .sm-list{display:grid;grid-template-columns:1fr 1fr;gap:8px}
  #sPop .sm-item{min-height:46px;border:1px solid #d9dce6;border-radius:10px;background:#fff;color:#222;font:inherit;font-size:14px;cursor:pointer;padding:6px 10px;
        touch-action:manipulation;-webkit-tap-highlight-color:transparent}
  #sPop .sm-item.on{background:#2d3a7a;border-color:#2d3a7a;color:#fff}
  #sPop .sm-item:disabled{opacity:.5}
  #sheetBox{padding:8px}
  #sheetBox svg{width:100%;height:auto}
  /* 谱面水印:极淡的 piano.ai2.fun 平铺(内联 SVG 图块作背景,在音符之下;零 JS、零额外节点,图块只栅格化一次) */
  #sheetBox .mspg{position:relative;background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='140'%3E%3Cg font-family='Helvetica,Arial,sans-serif' font-size='11' fill='%23000' fill-opacity='0.045' transform='rotate(-24 120 70)'%3E%3Ctext x='8' y='52'%3Epiano.ai2.fun%3C/text%3E%3Ctext x='128' y='122'%3Epiano.ai2.fun%3C/text%3E%3C/g%3E%3C/svg%3E") repeat;margin-bottom:6px;
    -webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
  #sheetBox .mspg svg{display:block;width:100%;height:auto}
  /* 初学辅助开关:唱名徽章(Lyrics)/加线锚点音名(Fingering),CSS 类整体隐显 */
  #sheetBox.hide-solfa .Lyrics{display:none}
  #sheetBox.hide-anch .Fingering{display:none}
  #fingToggle.on{background:#805d12 !important;color:#fff !important;border-color:#805d12 !important}
  #msCur{position:absolute;width:3px;background:rgba(211,52,20,.75);border-radius:2px;
         pointer-events:none;display:none}
  .seg-head{position:sticky;top:30px;display:flex;align-items:center;gap:10px;
    background:#eef4ee;border:1px solid #cfe0cf;border-radius:6px;
    padding:4px 12px;margin:10px 0 4px;font-size:12px;color:#2c5e2c;cursor:pointer;z-index:1}
  .seg-head:hover{background:#dfeedf}
  .seg-head b{font-weight:600}
  .seg-head span{color:#6a8a6a}

/* ---- (原第三段) ---- */
  /* 与五线谱和弦记号同款字体(MuseScore MuseJazz Text 子集,OFL) */
  @font-face {
    font-family: 'MuseJazz Text';
    src: url('fonts/MuseJazzText.woff2') format('woff2');
    font-display: swap;
  }
  body:not(.mobile) #pJazz { background:#f7f4ea; color:#232019; overflow:auto; }
  #jazzTop { position:sticky; top:0; background:#efe9d8; border-bottom:1px solid #ddd2b0;
             padding:6px 12px; font-size:12px; color:#5a5330; display:flex; align-items:center; gap:10px; flex-wrap:wrap; z-index:2; }
  #jazzTop b { color:#2a2410; font-size:14px; }
  #jazzTop .src { font-size:10px; background:#8a7a3a; color:#fff; border-radius:4px; padding:1px 6px; }
  #jazzGrid { padding:12px; display:flex; flex-direction:column; gap:6px; }
  .jz-row { display:grid; grid-template-columns:repeat(4,1fr); gap:6px; }
  .jz-sec { font-size:11px; font-weight:700; color:#9a5cc7; margin:6px 0 -2px 2px; letter-spacing:.5px; }
  .jz-bar { position:relative; background:#fff; border:1px solid #d8cfb0; border-radius:5px;
            min-height:52px; display:flex; align-items:center; justify-content:center; gap:2px;
            font-family:'SF Mono',monospace; padding:2px 4px; transition:background .1s,box-shadow .1s;
            -webkit-user-select:none; user-select:none; -webkit-touch-callout:none; }
  .jz-bar.two { justify-content:space-around; }
  .jz-bar.slots { display:grid; grid-template-columns:repeat(4,1fr); align-items:center;
                  column-gap:2px; justify-content:stretch; }
  .jz-bar.slots .jz-ch { font-size:12px; letter-spacing:-0.3px;
                         min-width:0; overflow:hidden; align-items:flex-start; }
  .jz-sec { margin:8px 2px 2px; padding:3px 12px; font-size:12px; font-weight:700; color:#5a5330;
            background:#efe9d8; border:1px solid #ddd2b0; border-radius:6px; cursor:pointer;
            display:flex; gap:12px; align-items:baseline; }
  .jz-sec small { font-weight:400; color:#9a8f60; }
  .jz-ch { font-size:17px; font-weight:600; color:#232019; white-space:nowrap;
           font-family:'MuseJazz Text','SF Mono',monospace; line-height:1.05;
           display:inline-flex; flex-direction:column; align-items:center; }
  .jz-ch .ext { font-size:11px; vertical-align:super; opacity:.85; }
  .jz-ch .rm { font-size:9px; font-weight:400; opacity:.55; letter-spacing:0; }
  .jz-ch.repeat { color:#b0a678; font-size:22px; }
  .jz-bar.now { background:#fff6d8; box-shadow:0 0 0 2px #e0a92a inset; }
  .jz-bar .bn { position:absolute; top:1px; left:3px; font-size:8px; color:#bbb;
                font-family:'SF Mono',monospace; }
  /* ii-V-I 进行括线(格底彩色下划线,跨格连续,首格带类型小标) */
  .jz-prog { position:absolute; left:-4px; right:-4px; bottom:2px; height:3px;
             border-radius:0; opacity:.85; cursor:pointer; }
  .jz-prog.p0 { left:2px; border-top-left-radius:2px; border-bottom-left-radius:2px; }
  .jz-prog.p1 { right:2px; border-top-right-radius:2px; border-bottom-right-radius:2px; }
  .jz-prog-lb { position:absolute; left:3px; bottom:6px; font-size:7px; font-weight:700;
                font-family:'SF Mono',monospace; color:#9a8f60; pointer-events:none; }
  /* AB 练习段:覆盖小节高亮 + 长按预选 */
  .jz-bar.drill { box-shadow:0 0 0 2px #66b37f inset; background:#eef7ef; }
  .jz-bar.drill-current { box-shadow:0 0 0 2px #e0a92a inset; background:#fff3c4;
                          animation: drillPulse 1.2s ease-in-out infinite; }
  .jz-bar.drill-arm { box-shadow:0 0 0 2px #e6c619 inset; background:#fffbe0;
                      animation: drillPulse 1s ease-in-out infinite; }
  #jazzEmpty { padding:24px; text-align:center; color:#9a9270; font-size:13px; }
  #jazzDock { position:sticky; bottom:0; z-index:2; }
  #jazzPlay { background:#efe9d8; border-top:1px solid #ddd2b0;
    padding:6px 10px; display:flex; align-items:center; gap:8px; flex-wrap:wrap; font-size:12px; color:#5a5330; }
  #jazzPlay label { display:inline-flex; align-items:center; gap:3px; }
  #jazzPlay select, #jazzPlay button { font-size:12px; background:#fff; color:#232019; border:1px solid #c9bd97; border-radius:4px; padding:2px 6px; cursor:pointer; }
  #jbPlay { font-size:14px; min-width:32px; }
  #jbPlay.on { background:#2c5e2c; color:#fff; border-color:#2c5e2c; }
  .jb-mini { padding:0 6px !important; }
  /* 练习段(AB)工具行:并入爵士谱底栏,浅色主题 */
  #jzDrillRow { background:#efe9d8; border-top:1px solid #ddd2b0;
    padding:5px 10px; display:flex; align-items:center; gap:6px; flex-wrap:wrap;
    font-size:12px; color:#5a5330; }
  #jzDrillRow .drill-btn { background:#fff; color:#5a5330; border:1px solid #c9bd97; }
  #jzDrillRow .drill-btn:hover:not(:disabled) { background:#f2ecda; color:#2a2410; }
  #jzDrillRow .drill-btn-go { background:#e2efe2; color:#2c5e2c; border-color:#9ec49e; }
  #jzDrillRow .drill-btn-go.training { background:#aa4a4a; color:#fff; border-color:#cc6a6a; }
  #drillChips { display:flex; align-items:center; gap:5px; flex-wrap:wrap; flex:1; min-width:0; }
  .drill-chip { display:inline-flex; align-items:center; gap:4px; font-size:11px;
    font-family:'SF Mono',monospace; background:#eef7ef; color:#2c5e2c;
    border:1px solid #9ec49e; border-radius:10px; padding:1px 8px; cursor:pointer; white-space:nowrap; }
  .drill-chip.current { background:#fff3c4; color:#7a5c00; border-color:#e0a92a;
    animation: drillPulse 1.2s ease-in-out infinite; }
  .drill-chip .x-btn { color:#c0392b; cursor:pointer; padding:0 1px; }
  .drill-hint { font-size:10px; opacity:.5; }

/* ---- (原第四段) ---- */
  #tpill { position: fixed; left: 50%; transform: translateX(-50%);
    bottom: calc(var(--mbh, 92px) + 8px); z-index: 800;
    display: none; align-items: center; gap: 8px; padding: 5px 16px 5px 6px;
    background: rgba(18,18,18,.74); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,.14); border-radius: 999px;
    box-shadow: 0 4px 18px rgba(0,0,0,.45); }
  #tpill.show { display: flex; }
  #tpillBtn { width: 44px; height: 44px; border-radius: 50%; border: none;
    background: #2a6a4a; color: #dfffe9; font-size: 17px; cursor: pointer; line-height: 1; }
  #tpillT { font-size: 13px; color: #ccc; font-variant-numeric: tabular-nums; min-width: 38px; }

/* ---- 嵌入模式 ?embed=1(主页 iframe / 第三方嵌入):只留面板,页头页脚不显示,
   悬浮播放胶囊常驻,右上角一个「在 piano.ai2.fun 打开」出口 ---- */
  html.embed .hdr, html.embed .footer-settings, html.embed #sidebarDivider { display: none !important; }
  html.embed body:not(.mobile) #mTop, html.embed body:not(.mobile) #mBottom { display: none !important; }
  html.embed body:not(.mobile) #panelGrid { padding: 4px; }
  html.embed body:not(.mobile) #tpill { bottom: 12px; }
  /* 手机里的嵌入(主页首图 iframe):保留顶栏视图切换 + 底栏走带,去掉返回 / 分享 / 曲名,出口挪到顶栏左端 */
  html.embed body.mobile #mBack, html.embed body.mobile #mShare, html.embed body.mobile #mTitle { display: none !important; }
  html.embed body.mobile #mTop { padding-left: 64px; }
  html.embed body.mobile #embedOpen { left: 6px; right: auto; top: 5px; padding: 3px 8px; font-size: 12px; }
  html.embed body.mobile #embedOpen span { display: none; }
  #embedOpen { display: none; position: fixed; right: 8px; top: 6px; z-index: 900;
    align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: 12px;
    color: #dfe8f5; text-decoration: none; background: rgba(18,18,18,.72);
    border: 1px solid rgba(255,255,255,.16); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
  #embedOpen:hover { background: rgba(42,106,74,.85); color: #fff; }
  html.embed #embedOpen { display: inline-flex; }

  /* ---- 3D 叠加面板(透明侧视卷帘 + 幽灵键盘) ---- */
  #p3d { background: #0b0c10; display: none; flex-direction: column; }
  body:not(.mobile) #panelGrid > #p3d.on { display: flex; }
  body.mobile.mview-r3d #p3d { display: flex !important; background: #0b0c10; }
  .r3d-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 12px; border-bottom: 1px solid #262626; font-size: 12px; color: #9a9a9a; flex-shrink: 0; }
  .r3d-bar b { color: #e2e2e2; font-weight: 500; margin-right: 4px; }
  .r3d-bar label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
  .r3d-bar select { background: #1a1a1a; color: #ddd; border: 1px solid #333; border-radius: 6px; padding: 2px 6px; font-size: 12px; }
  .r3d-bar input[type=range] { width: 90px; accent-color: #7dd6a3; }
  .r3d-bar button { background: #232323; color: #ccc; border: 1px solid #3a3a3a; border-radius: 6px; padding: 3px 9px; font-size: 11px; cursor: pointer; }
  .r3d-hint { margin-left: auto; font-size: 11px; color: #6b6b6b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
  .r3d-stage { position: relative; flex: 1; min-height: 160px; overflow: hidden;
    background: #0b0c10 radial-gradient(ellipse at 50% 80%, #14171d 0%, #0b0c10 70%); }
  .r3d-stage canvas, canvas.r3d-over { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
  canvas.r3d-over { z-index: 5; }
  .r3d-handles { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
  .r3d-handles.r3d-over { z-index: 6; }
  .r3d-h { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: rgba(125,214,163,0.9); border: 2px solid #fff; box-shadow: 0 0 0 4px rgba(125,214,163,0.25); cursor: grab; pointer-events: auto; touch-action: none; }
  .r3d-h:active { cursor: grabbing; }
  .r3d-h i { position: absolute; left: 26px; top: 1px; font-style: normal; font-size: 11px; color: #dffbe9; white-space: nowrap; text-shadow: 0 1px 2px #000; }

/* ---- 学和弦 · 音阶面板(11-learn.js)---- */
  #pLearn { background: #121417; color: #e6e8e5; display: none; overflow: auto; }
  body:not(.mobile) #panelGrid > #pLearn.on { display: block; }
  body.mobile.mview-learn #pLearn { background: #121417; padding-bottom: 76px; }
  /* 学和弦视图满屏都是按钮和键盘图:居中的悬浮播放胶囊会盖住「听音阶」和图例,收成右下角一个圆钮 */
  body.mobile.mview-learn #tpill { left: auto; right: 10px; transform: none; padding: 4px; }
  body.mobile.mview-learn #tpillT { display: none; }
  #pLearn .lp-top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; background: #171a1e; border-bottom: 1px solid #2a2e31; font-size: 12px; }
  #pLearn .lp-top b { font-size: 13px; }
  #pLearn .lp-key { color: #9aa0a3; }
  #pLearn .lp-follow { margin-left: auto; display: flex; align-items: center; gap: 5px; color: #b9c0c4; cursor: pointer; }
  #pLearn select { background: #1f2326; color: #ddd; border: 1px solid #333; border-radius: 6px; padding: 3px 6px; font-size: 12px; }
  #pLearn .lp-list { display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px 6px; scrollbar-width: thin; }
  #pLearn .lp-chip { flex: 0 0 auto; display: flex; align-items: baseline; gap: 6px; padding: 6px 10px; border-radius: 10px; border: 1px solid #2a2e31; border-left: 4px solid var(--c, #888);
    background: #1a1d21; color: #e6e8e5; cursor: pointer; font-size: 13px; touch-action: manipulation; }
  #pLearn .lp-chip small { color: #9aa0a3; font-size: 11px; } #pLearn .lp-chip i { color: #6f777b; font-size: 10px; font-style: normal; }
  #pLearn .lp-chip.on { background: #24313c; border-color: #4a9eff; }
  #pLearn .lp-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; padding: 6px 12px 16px; }
  #pLearn .lp-side { display: grid; gap: 10px; align-content: start; }
  #pLearn .lp-card { background: #171a1e; border: 1px solid #2a2e31; border-radius: 10px; padding: 12px; min-width: 0; }
  #pLearn #lpQuiz { margin: 10px 12px; }
  #pLearn .lp-h { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
  #pLearn .lp-name { font-size: 26px; font-weight: 700; color: #ffd84d; font-family: 'SF Mono', monospace; }
  #pLearn .lp-roman { font-size: 16px; color: #8fd0ff; } #pLearn .lp-q { font-size: 12px; color: #9aa0a3; } #pLearn .lp-score { margin-left: auto; font-size: 13px; color: #7fdca0; }
  #pLearn .lp-sub { font-size: 12px; color: #b9c0c4; margin-bottom: 8px; }
  #pLearn .lp-h2 { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #b9c0c4; margin: 10px 0 6px; } #pLearn .lp-h2 small { color: #6f777b; margin-left: auto; }
  #pLearn .lp-card > .lp-h2:first-child { margin-top: 0; }
  #pLearn .lp-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
  #pLearn .lp-occ { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }
  #pLearn .lp-btn { background: #2a6a4a; color: #dfffe9; border: 1px solid #3a8a5f; border-radius: 8px; padding: 7px 12px; font-size: 12px; cursor: pointer; touch-action: manipulation; }
  #pLearn .lp-btn.ghost { background: #1f2326; color: #cfd6da; border-color: #333; }
  #pLearn .lp-mini { background: #1f2326; color: #cfd6da; border: 1px solid #333; border-radius: 7px; min-width: 30px; height: 30px; cursor: pointer; font-size: 14px; }
  #pLearn .lp-prog { display: flex; align-items: baseline; gap: 8px; width: 100%; text-align: left; background: #1a1d21; border: 1px solid #2a2e31; border-radius: 8px; padding: 7px 10px; margin-bottom: 6px; color: #e6e8e5; cursor: pointer; font-size: 13px; }
  #pLearn .lp-prog small { color: #9aa0a3; font-size: 11px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } #pLearn .lp-prog i { color: #7fdca0; font-style: normal; font-size: 11px; }
  #pLearn .lp-empty { color: #6f777b; font-size: 12px; padding: 6px 0; }
  #pLearn .lp-legend { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #9aa0a3; margin-top: 4px; flex-wrap: wrap; }
  #pLearn .lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 8px; } #pLearn .lg.tone { background: #ffd84d; } #pLearn .lg.tension { background: #6ec6ff; } #pLearn .lg.avoid { background: #ff8a80; }
  #pLearn .lp-kb { width: 100%; max-width: 520px; height: auto; display: block; }
  #pLearn .lp-kb rect.w { fill: #f4f4f1; stroke: #555; stroke-width: 1; } #pLearn .lp-kb rect.b { fill: #15171a; stroke: #000; stroke-width: 1; }
  #pLearn .lp-kb rect.root { fill: #ff9f1c; } #pLearn .lp-kb rect.tone { fill: #ffd84d; } #pLearn .lp-kb rect.tension { fill: #6ec6ff; } #pLearn .lp-kb rect.avoid { fill: #ff8a80; }
  #pLearn .lp-kb rect.pick { fill: #9fb7ff; } #pLearn .lp-kb rect.ok { fill: #7fdca0; } #pLearn .lp-kb rect.miss { fill: #ffd84d; } #pLearn .lp-kb rect.bad { fill: #ff8a80; }
  #pLearn .lp-kb text.kl { font-size: 8px; font-weight: 700; fill: #111; pointer-events: none; } #pLearn .lp-kb text.kc { font-size: 8px; fill: #6f777b; }
  @media (max-width: 760px) { #pLearn .lp-cols { grid-template-columns: 1fr; } #pLearn .lp-name { font-size: 22px; } }

/* ---- 五线谱在线编辑(12-edit.js)---- */
  #editBtn.on { background: #c0392b !important; color: #fff !important; border-color: #c0392b !important; }
  #sheetBox .ms-col { position: absolute; z-index: 0; border-radius: 6px; pointer-events: none; }
  #sheetBox .ms-col.sel { background: rgba(74, 158, 255, .28); outline: 2px solid rgba(74, 158, 255, .7); }
  #sheetBox .ms-col.pend { background: rgba(255, 152, 0, .30); }
  #sheetBox .ms-col.bar { background: rgba(170, 110, 255, .16); border-left: 3px solid rgba(170, 110, 255, .95); border-radius: 0 6px 6px 0; }
  body.sheet-edit #sheetBox .mspg { cursor: crosshair; }
  body.sheet-edit #sheetPanel { padding-bottom: 260px; }
  #edSheet { position: fixed; left: 50%; transform: translateX(-50%); bottom: 12px; z-index: 900; width: min(640px, calc(100vw - 16px)); max-height: 60vh; overflow: auto;
    background: #171a1e; color: #e6e8e5; border: 1px solid #2f3438; border-radius: 14px; box-shadow: 0 10px 36px rgba(0,0,0,.5); padding: 10px 12px; font-size: 13px; }
  #edSheet[hidden] { display: none; }
  body.mobile #edSheet { bottom: calc(var(--mbh, 92px) + 6px); }
  body.sheet-edit #tpill { display: none !important; }
  #edSheet .ed-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
  #edSheet #edStatus { flex: 1; min-width: 0; font-size: 12px; color: #9aa0a3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #edSheet #edStatus.ok { color: #7fdca0; } #edSheet #edStatus.err { color: #ff8a80; }
  #edSheet .ed-x { background: none; border: none; color: #999; font-size: 15px; cursor: pointer; }
  #edSheet .ed-note { display: flex; align-items: center; gap: 5px; padding: 6px 0; border-top: 1px solid #24282c; flex-wrap: wrap; }
  #edSheet .ed-note:first-child { border-top: 0; }
  #edSheet .ed-note b { min-width: 46px; font-family: 'SF Mono', monospace; font-size: 15px; } #edSheet .ed-note b.h1 { color: #6ec6ff; } #edSheet .ed-note b.h0 { color: #ffb86c; }
  #edSheet .ed-note small { color: #9aa0a3; min-width: 34px; font-size: 11px; }
  #edSheet .ed-note.edited b::after { content: ' •'; color: #ff9800; }
  #edSheet .ed-note button, #edSheet .ed-mini { background: #22262a; color: #d6dadd; border: 1px solid #333; border-radius: 8px; padding: 6px 9px; font-size: 12px; cursor: pointer; touch-action: manipulation; }
  #edSheet .ed-note button.danger { color: #ff9a9a; margin-left: auto; }
  #edSheet .ed-empty { color: #8a9196; font-size: 12px; padding: 8px 0; }
  #edSheet #edAnchors { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; max-height: 84px; overflow: auto; padding: 0 0 8px; margin-bottom: 4px; border-bottom: 1px solid #24282c; }
  #edSheet #edAnchors[hidden] { display: none; }
  #edSheet .ed-anc-lbl { font-size: 11px; color: #b79cff; }
  #edSheet .ed-anc { display: inline-flex; border: 1px solid #4a3d6e; border-radius: 9px; overflow: hidden; background: #221d33; }
  #edSheet .ed-anc.on { border-color: #aa6eff; box-shadow: 0 0 0 1px #aa6eff; }
  #edSheet .ed-anc button { background: none; border: 0; color: #d9ccff; font-size: 12px; padding: 6px 8px; cursor: pointer; font-family: 'SF Mono', monospace; touch-action: manipulation; }
  #edSheet .ed-anc button.x { color: #ff9a9a; border-left: 1px solid #4a3d6e; padding: 6px 9px; font-family: inherit; }
  #edSheet .ed-btn.ghost.danger { color: #ff9a9a; border-color: #6e3d3d; }
  #edSheet .ed-addbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 6px; font-size: 12px; color: #b9c0c4; }
  #edSheet .ed-seg { display: inline-flex; background: #1f2326; border-radius: 9px; padding: 2px; }
  #edSheet .ed-seg button { background: none; border: none; color: #aaa; padding: 5px 10px; border-radius: 7px; font-size: 12px; cursor: pointer; }
  #edSheet .ed-seg button.on { background: #3a3f44; color: #fff; }
  #edSheet #edKeys { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; }
  #edSheet .ed-key { height: 40px; border: 1px solid #555; border-radius: 5px; background: #f4f4f1; color: #222; font-size: 10px; cursor: pointer; padding: 0; touch-action: manipulation; }
  #edSheet .ed-key.b { background: #15171a; color: #fff; } #edSheet .ed-key.has { background: #ffd84d; opacity: .6; cursor: default; }
  #edSheet .ed-foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
  #edSheet #edPending { flex: 1; min-width: 0; font-size: 12px; color: #ffb86c; }
  #edSheet .ed-btn { background: #2a6a4a; color: #dfffe9; border: 1px solid #3a8a5f; border-radius: 9px; padding: 8px 14px; font-size: 13px; cursor: pointer; touch-action: manipulation; }
  #edSheet .ed-btn.ghost { background: #22262a; color: #cfd6da; border-color: #333; }
  #edSheet .ed-btn:disabled { opacity: .4; cursor: default; }
