/* 2026-08-01 v2 简谱软件样式 - 真实简谱纸风格（HTML+CSS 渲染）
   参考：标准简谱纸（A4 横向 16K 简谱）
   白色纸张 + 黑色音符 + 楷体歌词 + 小节竖线 + 减时线 + 高低音点 + 连音线
   移动指针：红色竖线 + 圆点 + 顶部三角 + 扫光 overlay
*/

/* ===== 全局基础 ===== */
* {
    box-sizing: border-box;
}

html, body {
    font-size: 18px;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: #f4f4f9;
    color: #111;
    font-family: "SimSun", "Songti SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
}

.music-app {
    max-width: 1800px;
    margin: 0 auto;
    padding: 24px;
}

/* ===== 顶部标题栏 ===== */
.music-header {
    text-align: center;
    margin-bottom: 24px;
    padding: 20px 16px;
    background: linear-gradient(180deg, #fffbf0 0%, #fdf6e3 100%);
    border: 1px solid #d4c5a0;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(120, 90, 50, 0.08);
}
.music-header h1 {
    margin: 0;
    font-size: 36px;
    color: #5a3a1a;
    font-weight: 700;
    letter-spacing: 2px;
}
.music-header h1 i {
    color: #c0392b;
    margin-right: 10px;
}
.music-subtitle {
    color: #8a7560;
    font-size: 17px;
    margin-top: 8px;
    font-weight: 500;
}

/* ===== 主体布局 ===== */
.music-main {
    position: relative;
    min-height: calc(100vh - 200px);
}

/* ===== 浮动输入面板 ===== */
.music-input-pane {
    position: fixed;
    top: 80px;
    left: 20px;
    width: 460px;
    max-width: 90vw;
    max-height: calc(100vh - 100px);
    background: #fffbf0;
    border: 1px solid #d4c5a0;
    border-radius: 6px;
    padding: 0;
    box-shadow: 0 2px 8px rgba(120, 90, 50, 0.12);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, padding 0.2s ease;
    overflow: hidden;
    font-size: 17px;
}

.music-input-pane.collapsed {
    /* 关键：宽度必须能容纳两个按钮（34px + 8px gap + 34px = 76px）+ 边距 20px = 96px
       之前设 50px 导致按钮被压扁，点击区不完整，无法触发 */
    width: 96px !important;
    padding: 0;
}

.music-input-pane.collapsed .pane-body {
    display: none;
}
/* 折叠时 h2 仍显示（作为拖动提示），但只显示拖动符号 */
.music-input-pane.collapsed h2 {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    width: 100%;
    cursor: move;
}
/* 默认隐藏拖动符号（展开时 h2 显示完整标题） */
.drag-handle {
    display: none;
    font-size: 18px;
    color: #6a5540;
}
.music-input-pane.collapsed .drag-handle {
    display: inline-block;
}
.music-input-pane.collapsed .h2-title {
    display: none;
}

.music-input-pane.collapsed .pane-header {
    border-bottom: none;
    padding: 12px 8px;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
}
/* 折叠态 h2 在上，作为可拖动抓手（占满宽度，cursor: move） */
.music-input-pane.collapsed .pane-header h2 {
    width: 100%;
    padding: 6px 0;
    border-radius: 4px;
    background: rgba(192, 57, 43, 0.06);
}
.music-input-pane.collapsed .pane-header h2:hover {
    background: rgba(192, 57, 43, 0.12);
}

.music-input-pane.collapsed .pane-actions {
    width: 100%;
    justify-content: center;
}

.music-input-pane.dragging,
.music-input-pane.dragging * {
    cursor: grabbing !important;
    user-select: none;
}

#pane-handle {
    cursor: move;
    user-select: none;
    border-bottom: 1px solid #d4c5a0;
    padding: 16px 18px 12px 18px;
    background: linear-gradient(180deg, #fdf6e3 0%, #f8efd6 100%);
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 40px;
}

#pane-handle:hover {
    background: linear-gradient(180deg, #f5e8c8 0%, #fdf6e3 100%);
}

#pane-handle.dragging {
    background: linear-gradient(180deg, #ffe5b8 0%, #ffd49a 100%);
    border-bottom-color: #c0392b;
}

#pane-handle h2 {
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
}

.pane-body {
    padding: 16px 18px 20px 18px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.btn-icon {
    background: transparent;
    border: 1px solid #d4c5a0;
    color: #6a5540;
    width: 34px;
    height: 34px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
    font-size: 18px;
}
.btn-icon:hover {
    background: #f0e5c8;
    color: #5a3a1a;
    border-color: #b8a070;
}
/* 帮助按钮：激活态（帮助展开时高亮） */
.btn-icon.active {
    background: #c0392b;
    color: #fff;
    border-color: #c0392b;
}

/* ===== 主预览区（占满宽度） ===== */
.music-preview-pane {
    background: #fffbf0;
    border: 1px solid #d4c5a0;
    border-radius: 6px;
    padding: 18px;
    box-shadow: 0 1px 3px rgba(120, 90, 50, 0.08);
    margin-left: 480px;
    transition: margin-left 0.2s ease;
    position: relative;
    min-height: 500px;
}

@media (max-width: 900px) {
    .music-input-pane {
        width: 340px;
        top: 60px;
        left: 10px;
    }
    .music-preview-pane {
        margin-left: 360px;
    }
}

@media (max-width: 600px) {
    .music-input-pane {
        position: relative;
        top: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        margin-bottom: 16px;
    }
    .music-preview-pane {
        margin-left: 0;
    }
}

.music-input-pane.collapsed ~ .music-preview-pane {
    /* 与 .collapsed 的 panel 宽度（96px）保持对齐，加点间距让布局自然 */
    margin-left: 116px;
}

.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #d4c5a0;
}
.pane-header h2 {
    margin: 0;
    font-size: 24px;
    color: #5a3a1a;
    font-weight: 700;
}
.pane-header h2 i {
    margin-right: 8px;
    color: #c0392b;
    font-size: 22px;
}
.pane-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ===== 按钮（简谱风格：暖棕色调） ===== */
.btn-primary,
.btn-mini {
    cursor: pointer;
    border: 1px solid #b8a070;
    border-radius: 4px;
    padding: 9px 20px;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    background: #fdf6e3;
    color: #5a3a1a;
}
.btn-primary {
    background: #c0392b;
    color: #fff;
    padding: 11px 24px;
    font-size: 19px;
    border-color: #a02818;
    box-shadow: 0 1px 3px rgba(192, 57, 43, 0.3);
}
.btn-primary:hover:not(:disabled) {
    background: #a93226;
    border-color: #80231a;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(192, 57, 43, 0.4);
}
.btn-primary:disabled {
    background: #c0a890;
    border-color: #a89080;
    cursor: not-allowed;
    box-shadow: none;
}
.btn-mini {
    background: #fdf6e3;
    color: #5a3a1a;
    padding: 8px 16px;
    font-size: 17px;
}
.btn-mini:hover:not(:disabled) {
    background: #f0e5c8;
    border-color: #8a7050;
}
.btn-mini:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.btn-mini.btn-clear {
    background: #f9e0e0;
    color: #a93226;
    border-color: #c98a8a;
    margin-left: 8px;
}
.btn-mini.btn-clear:hover {
    background: #f0c8c8;
}

/* ===== 输入区 ===== */
.example-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 14px;
    padding: 12px;
    background: #fdf6e3;
    border: 1px solid #e0d4b0;
    border-radius: 4px;
}
.example-label {
    font-size: 17px;
    color: #6a5540;
    margin-right: 6px;
    font-weight: 600;
}

.music-help {
    margin-bottom: 14px;
    background: #fdf6e3;
    border: 1px solid #e0d4b0;
    border-radius: 4px;
    padding: 0 16px;
    font-size: 16px;
    color: #5a3a1a;
}
.music-help summary {
    cursor: pointer;
    padding: 12px 0;
    color: #a93226;
    user-select: none;
    font-size: 17px;
    font-weight: 600;
}
.music-help summary:hover {
    color: #80231a;
}
.music-help ul {
    padding: 6px 0 16px 24px;
    margin: 0;
}
.music-help li {
    margin: 6px 0;
    line-height: 1.7;
}
.music-help code {
    background: #fff;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 15px;
    color: #a93226;
    border: 1px solid #d4c5a0;
    font-family: "Consolas", "Courier New", monospace;
}

.music-input {
    width: 100%;
    min-height: 320px;
    padding: 14px;
    font-family: "Consolas", "Courier New", monospace;
    font-size: 16px;
    line-height: 1.8;
    border: 1px solid #d4c5a0;
    border-radius: 4px;
    resize: vertical;
    color: #2a2520;
    background: #fffef5;
    outline: none;
    transition: border-color 0.15s;
    caret-color: #c0392b;
}
/* 修复默认浅色主题下的占位符、选区颜色 */
.music-input::placeholder {
    color: #8a7560;
    opacity: 0.6;
}
.music-input::selection {
    background: #c0392b;
    color: #fff;
}
.music-input:focus {
    border-color: #c0392b;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.1);
}

.pane-footer {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.parse-status {
    font-size: 16px;
    color: #8a7560;
    flex: 1;
}
.parse-status.success {
    color: #27ae60;
    font-weight: 600;
}
.parse-status.error {
    color: #a93226;
    font-weight: 600;
}

/* ===== 预览区 - 简谱纸张风格 ===== */
.music-empty {
    color: #b0a080;
    text-align: center;
    padding: 80px 20px;
    font-style: italic;
    font-size: 18px;
}

/* 简谱主体 - 白色纸张
   2026-08-02 改造：
   - min-height 320px → 480px（让短简谱也显得大气）
   - max-height 600px → 1200px（让长简谱不滚动）
   - padding 20px → 28px（音符和容器边缘留更多空间） */
.music-score {
    background: #fff;
    border: 1px solid #c8b890;
    border-radius: 4px;
    padding: 28px;
    min-height: 480px;
    margin-bottom: 16px;
    overflow-x: auto;
    max-height: 1200px;
    overflow-y: auto;
    box-shadow: 0 2px 12px rgba(60, 40, 20, 0.08);
    font-family: "SimSun", "Songti SC", "Georgia", serif;
}

/* 简谱整体布局 */
.sheet-music {
    position: relative;
    padding: 10px 20px 20px 20px;
    min-width: 720px;
}

/* 标题 + 元信息 */
.score-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 14px;
    border-bottom: 2px solid #111;
    position: relative;
    z-index: 5;
}

.score-title {
    margin: 0 0 12px 0;
    font-size: 32px;
    font-weight: bold;
    color: #111;
    letter-spacing: 4px;
    font-family: "SimHei", "Microsoft YaHei", "STHeiti", sans-serif;
}

.score-meta {
    display: flex;
    justify-content: space-between;
    font-size: 15px;
    font-weight: bold;
    color: #222;
    padding: 0 8px;
}

.score-meta span {
    font-family: "Georgia", "Times New Roman", serif;
}

/* 乐谱主体（容纳所有 system + overlay + playhead） */
.score-body {
    position: relative;
    padding: 0 10px;
    min-height: 200px;
    overflow: visible;
}

/* 一行乐谱 */
.system {
    display: flex;
    align-items: stretch;
    margin-top: 28px;
    position: relative;
    min-height: 110px;
}

.system:first-child {
    margin-top: 12px;
}

/* 一个小节 */
.measure {
    flex: 1;
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    position: relative;
    padding: 22px 8px 6px 8px;
    border-right: 1.5px solid #111;
    min-height: 110px;
}

/* 首小节粗线 */
.measure.first {
    border-left: 2.5px solid #111;
}

/* 终止线（双竖线） */
.measure.double-bar {
    border-right: 4px double #111;
}

/* 小节序号标注 */
.measure-no {
    position: absolute;
    top: 0;
    left: 4px;
    font-size: 12px;
    color: #888;
    font-family: "Consolas", monospace;
    user-select: none;
}

/* 一个音符 + 歌词 */
.note-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-width: 32px;
    padding: 0 2px;
    flex: 1;
    transition: all 0.2s ease;
    cursor: pointer;
}

/* 数字 + 升降号容器 */
.note-head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    line-height: 1;
    font-family: "Georgia", "Times New Roman", serif;
    user-select: none;
}

/* 主数字 */
.pitch {
    font-size: 26px;
    font-weight: bold;
    line-height: 1;
    color: #111;
    position: relative;
    display: inline-block;
}

/* 休止符（用 Unicode 字符 𝄽 画一个矩形） */
.pitch.rest-mark {
    font-size: 22px;
    color: #111;
}

/* 升降号 */
.accidental {
    font-size: 20px;
    font-weight: bold;
    color: #111;
    margin-right: 2px;
    line-height: 1;
    font-family: "Georgia", serif;
}

/* 延音线 cell（独立成列，视觉上与 3、4 这种相邻音符完全一致）
   每个 - 占 1 拍，作为一个独立的 note-column */
.tie-cell {
    /* 复用 .note-column 的所有 flex 布局，只加点差异化样式 */
    opacity: 0.85;
}
.tie-cell .note-head {
    /* 让延音线垂直居中（数字音符在底部对齐） */
    justify-content: center;
    align-items: center;
}
.tie-cell .underline-spacer,
.tie-cell .lyric {
    /* 延音线 cell 不显示歌词 */
    visibility: hidden;
}
.tie-cell .duration-tip {
    color: #888;
    font-size: 12px;
}

/* 延音线（-）：独立 cell 内的一条横线 */
.tie-line {
    display: block;
    width: 16px;       /* 加宽，让它像 1 个完整"符号" */
    height: 4px;
    background: #111;
    border-radius: 1px;
    margin: 0 auto;    /* 居中显示 */
}

/* 附点 - 数字右侧的小点 */
.dot-after {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #111;
    margin-left: 1px;
    margin-bottom: 4px;
    align-self: flex-end;
    margin-top: auto;
}

.has-dot .dot-after {
    margin-bottom: 2px;
}

/* 低音点 - 数字下方（2026-08-02 调整：远离 5 + 圆圈加大）
   bottom: -8px 让圆点距离 5 数字 8px（避免覆盖）
   width/height: 7px 圆圈稍微大一点，更明显 */
.note-column.octave-low .pitch::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -8px;
    transform: translateX(-50%);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #111;
}

/* 高音点 - 数字上方（2026-08-02 同步调整：远离 5 + 圆圈加大） */
.note-column.octave-high .pitch::before {
    content: "";
    position: absolute;
    left: 50%;
    top: -8px;
    transform: translateX(-50%);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #111;
}

/* 减时线（数字下方） */
.underline {
    width: 28px;
    height: 2px;
    background: #111;
    margin-top: 4px;
    margin-bottom: 4px;
}
.underline.double {
    box-shadow: 0 4px 0 0 #111;
}
.underline-spacer {
    height: 10px;
    width: 1px;
    margin: 0 auto;
}

/* 歌词 */
.lyric {
    margin-top: 6px;
    font-size: 17px;
    font-family: "KaiTi", "楷体", "STKaiti", serif;
    color: #111;
    min-height: 24px;
    line-height: 24px;
    text-align: center;
    user-select: none;
    transition: color 0.2s ease, font-weight 0.2s ease;
}

/* 持续时间标注 */
.duration-tip {
    margin-top: 3px;
    font-size: 11px;
    color: #888;
    font-family: "Consolas", "Courier New", monospace;
    text-align: center;
    user-select: none;
    white-space: nowrap;
}
.duration-tip.small {
    font-size: 10px;
    color: #aaa;
}

/* 连音线（slur） */
.slur-over {
    position: absolute;
    top: 10px;
    height: 12px;
    border-top: 2px solid #111;
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
    pointer-events: none;
    z-index: 2;
}

/* 合并的延音（被合并的音） */
.note-column.merged .pitch {
    color: #666;
    font-size: 18px;
}
.note-column.merged .lyric {
    color: transparent;
}
.note-column.merged .duration-tip {
    color: #aaa;
}

/* ===== 移动指针 + 扫光 ===== */
.score-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
    background: transparent;
    transition: background 0.05s linear;
}

.playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 0;
    pointer-events: none;
    z-index: 20;
    display: none;
    overflow: visible;
}
.playhead.visible {
    display: block;
}

.playhead-line {
    position: absolute;
    top: 12px;
    bottom: 0;
    left: 0;
    width: 3px;
    background: #c0392b;
    transform: translateX(-50%);
    box-shadow: 0 0 8px rgba(192, 57, 43, 0.5);
    opacity: 0.9;
    z-index: 30;  /* 高于 overlay (10) */
    /* 关键：left/top 实时由 JS 写入；不加 transition，避免每帧阻尼 */
    will-change: left, top, height;
}

.playhead-arrow {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 10px solid #c0392b;
    transform: translateX(-50%);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
    z-index: 30;  /* 高于 overlay */
}

.playhead-dot {
    position: absolute;
    top: 24px;
    left: 0;
    width: 14px;
    height: 14px;
    background: #c0392b;
    border: 2px solid #fff;
    border-radius: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 12px rgba(192, 57, 43, 0.7);
    z-index: 30;  /* 高于 overlay */
    will-change: left, top;
}

/* ===== 当前播放高亮 ===== */
.note-column.active .pitch {
    color: #c0392b !important;
    transform: scale(1.25);
    display: inline-block;
    transform-origin: center;
}
.note-column.active {
    background: linear-gradient(180deg, rgba(192, 57, 43, 0.08) 0%, rgba(192, 57, 43, 0.02) 100%);
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(192, 57, 43, 0.2);
}
.note-column.active .lyric {
    color: #c0392b !important;
    font-weight: bold;
    font-size: 19px;
    animation: lyric-bounce 0.6s ease-in-out infinite alternate;
}
.note-column.active .duration-tip {
    color: #c0392b !important;
    font-weight: bold;
}
.note-column.active .accidental {
    color: #c0392b !important;
}

@keyframes lyric-bounce {
    0% { transform: scale(1); }
    100% { transform: scale(1.15); }
}

/* 已播放的音符：略微淡一点（与淡蓝玻璃 overlay 叠加后形成"扫过区域"视觉）
   2026-08-02 调整：从 .pitch 强制 #999 改成 .note-column.played 整体 opacity 0.6
   这样和上方的 rgba(120,180,240,0.22) 玻璃叠加，整体呈现"略淡的蓝色玻璃"效果 */
.note-column.played {
    opacity: 0.62;
}
/* 用 opacity 整体淡化已经够，所以下面的强 color 改用不那么深：
   旧：#999（深灰）  →  新：让 opacity 来做透明，颜色保持原色
   这样在浅色 / 暗黑模式下都自然，不会出现"过深灰色"问题 */

/* ===== 播放控制条（乐器 + 音量 + 进度） ===== */
.music-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 14px 18px;
    background: #fdf6e3;
    border: 1px solid #d4c5a0;
    border-radius: 4px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-label {
    font-size: 17px;
    color: #5a3a1a;
    font-weight: 600;
    white-space: nowrap;
}

.control-select {
    font-size: 17px;
    padding: 7px 12px;
    border: 1px solid #b8a070;
    border-radius: 4px;
    background: #fffef5;
    color: #5a3a1a;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    min-width: 140px;
}
.control-select:hover {
    border-color: #8a7050;
    background: #fff;
}
.control-select:focus {
    outline: none;
    border-color: #c0392b;
    box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.1);
}

.control-volume {
    min-width: 220px;
}

.control-range {
    -webkit-appearance: none;
    appearance: none;
    width: 140px;
    height: 8px;
    background: linear-gradient(to right, #c0392b 0%, #c0392b 50%, #d4c5a0 50%, #d4c5a0 100%);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}
.control-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #c0392b;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}
.control-range::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}
.control-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #c0392b;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.vol-display {
    font-size: 16px;
    color: #5a3a1a;
    font-weight: 600;
    min-width: 50px;
    font-family: "Consolas", monospace;
}

.control-progress {
    flex: 1;
    min-width: 280px;
}

/* ===== 进度条 ===== */
.time-display {
    font-family: "Consolas", monospace;
    font-size: 17px;
    color: #5a3a1a;
    min-width: 64px;
    text-align: center;
    font-weight: 500;
}
#time-current {
    text-align: right;
}
#time-total {
    text-align: left;
}

.progress-track {
    flex: 1;
    height: 12px;
    background: #e8dcb8;
    border-radius: 6px;
    position: relative;
    cursor: pointer;
    transition: height 0.15s;
}
.progress-track:hover {
    height: 16px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #c0392b, #e87a2b);
    border-radius: 6px;
    width: 0%;
    transition: width 0.05s linear;
    pointer-events: none;
}

.progress-thumb {
    position: absolute;
    top: 50%;
    width: 22px;
    height: 22px;
    background: #fff;
    border: 3px solid #c0392b;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    left: 0%;
    cursor: grab;
    pointer-events: auto;
    transition: transform 0.1s, box-shadow 0.15s;
    box-shadow: 0 2px 4px rgba(120, 90, 50, 0.3);
}
.progress-thumb:hover {
    transform: translate(-50%, -50%) scale(1.25);
    box-shadow: 0 2px 8px rgba(192, 57, 43, 0.5);
}

/* ===== 暗色主题适配 ===== */
@media (prefers-color-scheme: dark) {
    body { background: #2a2520; color: #e8d8b8; }
    .music-app { color: #e8d8b8; }
    .music-header { background: linear-gradient(180deg, #3a3025 0%, #2a2520 100%); border-color: #4a4030; }
    .music-header h1 { color: #f0d8a0; }
    .music-subtitle { color: #b0a080; }
    .music-input-pane { background: #3a3025; border-color: #4a4030; }
    .music-preview-pane { background: #3a3025; border-color: #4a4030; }
    .music-help { background: #2a2520; color: #d0c0a0; }
    .music-help code { background: #2a2520; border-color: #4a4030; color: #f0a090; }
    .example-buttons { background: #2a2520; border-color: #4a4030; }
    .pane-header { border-color: #4a4030; }
    .pane-header h2 { color: #f0d8a0; }
    .music-score {
        background: #faf6ec;
        color: #111;
    }
    .music-input { background: #1a1510; color: #e8d8b8; border-color: #4a4030; }
    .music-controls { background: #2a2520; border-color: #4a4030; }
    .control-select { background: #1a1510; color: #e8d8b8; border-color: #4a4030; }
    .control-range { background: linear-gradient(to right, #c0392b 0%, #c0392b 50%, #4a4030 50%, #4a4030 100%); }
    .btn-mini { background: #2a2520; color: #e8d8b8; border-color: #4a4030; }
    .btn-mini:hover:not(:disabled) { background: #3a3025; }
    .progress-track { background: #4a4030; }
}

/* ============ 2026-08-02 暗黑模式适配（用于 office 文章系统嵌入） ============
   触发条件：body[data-theme="dark"]（由 office 的 theme.js 设置）
   覆盖 music.css 中所有硬编码的 #111 / #222 等黑色，让乐谱在暗色背景上可见 */
body[data-theme="dark"] .score-title,
body[data-theme="dark"] .pitch,
body[data-theme="dark"] .accidental,
body[data-theme="dark"] .lyric {
    color: #e2e8f0;
}
body[data-theme="dark"] .score-meta {
    color: #cbd5e1;
}
body[data-theme="dark"] .score-header {
    border-bottom-color: #94a3b8;
}
body[data-theme="dark"] .measure {
    border-right-color: #94a3b8;
}
body[data-theme="dark"] .measure.first {
    border-left-color: #94a3b8;
}
body[data-theme="dark"] .measure.double-bar {
    border-right-color: #94a3b8;
}
body[data-theme="dark"] .tie-line,
body[data-theme="dark"] .dot-after,
body[data-theme="dark"] .underline,
body[data-theme="dark"] .note-column.octave-low .pitch::after,
body[data-theme="dark"] .note-column.octave-high .pitch::before {
    background: #e2e8f0;
}
body[data-theme="dark"] .underline.double {
    box-shadow: 0 4px 0 0 #e2e8f0;
}
body[data-theme="dark"] .slur-over {
    border-top-color: #e2e8f0;
}
body[data-theme="dark"] .duration-tip {
    color: #94a3b8;
}
body[data-theme="dark"] .duration-tip.small {
    color: #64748b;
}
body[data-theme="dark"] .measure-no {
    color: #64748b;
}
body[data-theme="dark"] .note-column.merged .pitch {
    color: #64748b;
}
body[data-theme="dark"] .note-column.merged .duration-tip {
    color: #475569;
}
body[data-theme="dark"] .playhead-dot {
    border-color: #1a1a1a;  /* 圆点边框改成深色，避免白边在深色背景上太突兀 */
}
body[data-theme="dark"] .note-column.played .pitch,
body[data-theme="dark"] .note-column.played .lyric {
    color: #555 !important;
}
body[data-theme="dark"] .note-column.played .tie-line,
body[data-theme="dark"] .note-column.played .dot-after,
body[data-theme="dark"] .note-column.played .underline {
    background: #555 !important;
}
body[data-theme="dark"] .note-column.played .duration-tip {
    color: #475569 !important;
}

/* ============ 2026-08-02 曲库弹窗样式 ============ */
.btn-mini.btn-library {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: #fff;
    border-color: #357abd;
    margin-left: 6px;
}
.btn-mini.btn-library:hover {
    background: linear-gradient(135deg, #5aa0f2 0%, #4587c7 100%);
    transform: translateY(-1px);
}
body[data-theme="dark"] .btn-mini.btn-library {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border-color: #1d4ed8;
}
body[data-theme="dark"] .btn-mini.btn-library:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

/* 锁定 body 滚动 */
body.music-lib-open {
    overflow: hidden;
}

/* 模态框 */
.music-lib-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.music-lib-modal[hidden] {
    display: none !important;
}
.music-lib-mask {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: music-lib-fade 0.18s ease;
}
.music-lib-dialog {
    position: relative;
    width: min(640px, 92vw);
    max-height: 80vh;
    background: #fdfaf2;
    border: 1px solid #d6cba4;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    animation: music-lib-slide-up 0.22s ease;
    overflow: hidden;
}
body[data-theme="dark"] .music-lib-dialog {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}
.music-lib-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: linear-gradient(135deg, #fff8e1 0%, #fdf3d0 100%);
}
body[data-theme="dark"] .music-lib-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-bottom-color: #334155;
}
.music-lib-header h3 {
    margin: 0;
    font-size: 18px;
    color: #5d4e2a;
    font-weight: 600;
}
body[data-theme="dark"] .music-lib-header h3 {
    color: #fbbf24;
}
.music-lib-close {
    background: transparent;
    border: none;
    font-size: 20px;
    color: #888;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 4px;
    transition: all 0.15s;
}
.music-lib-close:hover {
    background: rgba(192, 57, 43, 0.1);
    color: #c0392b;
}
.music-lib-toolbar {
    display: flex;
    gap: 8px;
    padding: 10px 18px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
body[data-theme="dark"] .music-lib-toolbar {
    border-bottom-color: #334155;
}
.music-lib-search {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d6cba4;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    color: #333;
}
body[data-theme="dark"] .music-lib-search {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}
.music-lib-refresh {
    padding: 8px 14px;
    border: 1px solid #4a90e2;
    background: #4a90e2;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
.music-lib-refresh:hover {
    background: #357abd;
}
.music-lib-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    min-height: 200px;
    max-height: 60vh;
}
.music-lib-empty,
.music-lib-loading {
    text-align: center;
    color: #888;
    padding: 60px 20px;
    font-size: 14px;
}
.music-lib-empty.err {
    color: #c0392b;
}
.music-lib-item {
    padding: 12px 18px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: all 0.15s;
}
.music-lib-item:hover {
    background: rgba(74, 144, 226, 0.08);
    transform: translateX(2px);
}
body[data-theme="dark"] .music-lib-item {
    border-bottom-color: #334155;
}
body[data-theme="dark"] .music-lib-item:hover {
    background: rgba(74, 144, 226, 0.18);
}
.music-lib-item-title {
    font-size: 15px;
    font-weight: 600;
    color: #4a3818;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.music-lib-item-title .fa-music {
    color: #4a90e2;
}
body[data-theme="dark"] .music-lib-item-title {
    color: #fbbf24;
}
.music-lib-item-id {
    font-size: 12px;
    color: #888;
    font-weight: 400;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: auto;
}
body[data-theme="dark"] .music-lib-item-id {
    background: rgba(255, 255, 255, 0.08);
}
.music-lib-item-preview {
    font-size: 12px;
    color: #6a5540;
    font-family: "Cascadia Code", "Consolas", "Courier New", monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 4px 0 6px;
    padding-left: 22px;
}
body[data-theme="dark"] .music-lib-item-preview {
    color: #94a3b8;
}
.music-lib-item-meta {
    font-size: 11px;
    color: #999;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-left: 22px;
}
.music-lib-item-link {
    color: #4a90e2;
    text-decoration: none;
}
.music-lib-item-link:hover {
    text-decoration: underline;
}
.music-lib-footer {
    padding: 10px 18px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #888;
    background: rgba(0, 0, 0, 0.02);
}
body[data-theme="dark"] .music-lib-footer {
    border-top-color: #334155;
    background: rgba(0, 0, 0, 0.15);
    color: #94a3b8;
}
.music-lib-hint {
    color: #6a5540;
}
body[data-theme="dark"] .music-lib-hint {
    color: #94a3b8;
}

@keyframes music-lib-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes music-lib-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
