/* ===== 口风琴交互样式（自定义类，不依赖构建期 Tailwind 扫描） ===== */
.mel-panel { user-select: none; -webkit-user-select: none; }
body.mel-playing, body.mel-playing * { user-select: none !important; -webkit-user-select: none !important; }

.mel-btn-start {
    padding: 8px 22px; border-radius: 10px; font-weight: 700; font-size: 14px;
    color: #fff; background: #4f46e5; border: 1px solid #4f46e5; cursor: pointer; transition: all .15s;
}
.mel-btn-start:hover { background: #4338ca; }
.mel-btn-start.mel-on { background: #fff; color: #4f46e5; }
.dark .mel-btn-start.mel-on { background: #1f2937; }

.mel-status {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px;
    background: #f3f4f6; color: #6b7280; border: 1px solid #e5e7eb;
}
.dark .mel-status { background: #111827; color: #9ca3af; border-color: #374151; }
.mel-status.mel-live { background: #eef2ff; color: #4f46e5; border-color: #c7d2fe; }
.dark .mel-status.mel-live { background: #312e81; color: #e0e7ff; border-color: #4338ca; }
.mel-dot { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; }
.mel-status.mel-live .mel-dot { background: #22c55e; animation: melPulse 1.2s infinite; }
@keyframes melPulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.mel-mouse-state { display: flex; flex-wrap: wrap; gap: 8px; }
.mel-chip {
    font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
    background: #f3f4f6; color: #9ca3af; border: 1px solid #e5e7eb; transition: all .12s;
}
.dark .mel-chip { background: #111827; border-color: #374151; }
.mel-chip.mel-chip-now { background: #eef2ff; color: #4f46e5; border-color: #c7d2fe; }
.dark .mel-chip.mel-chip-now { background: #312e81; color: #e0e7ff; border-color: #4338ca; }
.mel-chip.mel-hot { background: #4f46e5; color: #fff; border-color: #4f46e5; }

.mel-keyboard { margin-top: 4px; }
.mel-key-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }

.mel-key {
    display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
    min-width: 64px; padding: 12px 10px; border-radius: 12px; cursor: pointer;
    background: #fff; border: 1px solid #e5e7eb; color: #374151;
    transition: background .1s, transform .08s, border-color .1s; touch-action: none;
}
.dark .mel-key { background: #1f2937; border-color: #374151; color: #e5e7eb; }
.mel-key:hover { border-color: #a5b4fc; }
.mel-key-main { font-size: 18px; font-weight: 800; line-height: 1.2; }
.mel-key-sub { font-size: 11px; color: #9ca3af; margin-top: 2px; }
.mel-key.mel-key-on {
    background: #4f46e5 !important; border-color: #4f46e5 !important; color: #fff !important;
    transform: translateY(2px);
}
.mel-key.mel-key-on .mel-key-sub { color: #c7d2fe !important; }

/* ===== 琴谱与跟奏 ===== */
.mel-select {
    padding: 8px 12px; border-radius: 10px; border: 1px solid #e5e7eb; background: #fff;
    color: #374151; font-size: 14px; font-weight: 600;
}
.dark .mel-select { background: #1f2937; border-color: #374151; color: #e5e7eb; }
.mel-btn-ghost {
    padding: 8px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
    background: #fff; color: #4f46e5; border: 1px solid #c7d2fe; cursor: pointer; transition: all .15s;
}
.mel-btn-ghost:hover { background: #eef2ff; }
.dark .mel-btn-ghost { background: #1f2937; border-color: #4338ca; color: #a5b4fc; }

.mel-strip {
    display: flex; align-items: stretch; gap: 6px; overflow-x: auto; padding: 12px;
    background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 12px;
}
.dark .mel-strip { background: #111827; border-color: #374151; }
.mel-note {
    position: relative; flex: 0 0 auto; min-width: 46px; padding: 10px 8px; text-align: center;
    border-radius: 10px; background: #fff; border: 1px solid #e5e7eb;
    font-weight: 800; font-size: 18px; color: #374151; transition: all .15s;
}
.dark .mel-note { background: #1f2937; border-color: #374151; color: #e5e7eb; }
.mel-note em { font-style: normal; color: #9ca3af; font-weight: 600; margin-left: 2px; }
.dark .mel-note em { color: #6b7280; }
.mel-note .k { display: block; font-style: normal; font-size: 10px; font-weight: 600; color: #9ca3af; margin-top: 2px; line-height: 1; }
.dark .mel-note .k { color: #6b7280; }
.mel-note.mel-cur .k, .mel-note.mel-ok .k { color: inherit; opacity: .8; }
.mel-note .o { display: none; position: absolute; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 11px; font-weight: 700; line-height: 1; color: #4f46e5; }
.dark .mel-note .o { color: #818cf8; }
.mel-note .o.up { display: block; top: 2px; }
.mel-note .o.down { display: block; bottom: 2px; }
.mel-note .s { display: none; position: absolute; left: 50%; transform: translateX(-50%); top: 2px; font-style: normal; font-size: 11px; font-weight: 700; line-height: 1; color: #4f46e5; }
.mel-note .s.on { display: block; }
.dark .mel-note .s { color: #818cf8; }
.mel-note.mel-cur .o, .mel-note.mel-cur .s { color: inherit; }
.mel-note.mel-cur {
    background: #4f46e5; border-color: #4f46e5; color: #fff;
    transform: translateY(-2px); box-shadow: 0 4px 12px rgba(79,70,229,.35);
}
.mel-note.mel-ok { background: #ecfdf5; border-color: #6ee7b7; color: #059669; }
.dark .mel-note.mel-ok { background: #064e3b; border-color: #065f46; color: #6ee7b7; }
.mel-note.mel-bad { animation: melShake .35s; }
@keyframes melShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.mel-key.mel-hint { border-color: #4f46e5 !important; animation: melHint 1s infinite; }
@keyframes melHint { 0%,100% { box-shadow: 0 0 0 3px rgba(79,70,229,.28); } 50% { box-shadow: 0 0 0 6px rgba(79,70,229,.14); } }

/* 说明区 */
.mel-doc h3 { font-size: 15px; font-weight: 700; margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.mel-doc-no {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 8px; font-size: 12px; font-weight: 800;
    background: #4f46e5; color: #fff;
}
.mel-doc p { font-size: 14px; line-height: 1.9; color: #4b5563; margin: 0 0 8px; }
.dark .mel-doc p { color: #d1d5db; }
.mel-doc kbd {
    display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 12px; font-weight: 700;
    background: #f3f4f6; border: 1px solid #d1d5db; border-bottom-width: 2px; color: #374151;
    font-family: ui-monospace, monospace;
}
.dark .mel-doc kbd { background: #111827; border-color: #4b5563; color: #e5e7eb; }
.mel-doc-foot { margin-top: 16px; font-size: 12px !important; color: #9ca3af !important; }

/* ===== 录制 / 回放 / 琴谱弹窗 ===== */
.mel-rec-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.mel-rec-status { font-size: 12px; font-weight: 700; color: #dc2626; }
.dark .mel-rec-status { color: #f87171; }
.mel-rec-status.mel-idle { color: #9ca3af; }
.dark .mel-rec-status.mel-idle { color: #6b7280; }
.mel-modal { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; background: rgba(17,24,39,.55); padding: 16px; }
.mel-modal[hidden] { display: none; }
.mel-modal-box { background: #fff; border-radius: 16px; max-width: 920px; width: 100%; max-height: 88vh; display: flex; flex-direction: column; padding: 16px 18px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.dark .mel-modal-box { background: #1f2937; }
.mel-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.mel-modal-head h3 { margin: 0; font-size: 16px; font-weight: 800; color: #111827; }
.dark .mel-modal-head h3 { color: #f3f4f6; }
.mel-modal-x { border: none; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; color: #9ca3af; padding: 2px 8px; }
.mel-modal-body { overflow: auto; border: 1px solid #e5e7eb; border-radius: 12px; background: #f9fafb; }
.dark .mel-modal-body { border-color: #374151; background: #111827; }
.mel-modal-body canvas { display: block; max-width: 100%; height: auto; }
.mel-modal-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.mel-copy-msg { font-size: 12px; font-weight: 600; color: #059669; }
.mel-copy-msg.mel-err { color: #dc2626; }

/* ===== 琴谱编辑区 ===== */
.mel-sheet-editor { margin-top: 12px; border: 1px dashed #d1d5db; border-radius: 12px; padding: 12px; }
.dark .mel-sheet-editor { border-color: #4b5563; }
.mel-se-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mel-se-title-row label { font-size: 13px; font-weight: 700; color: #374151; }
.dark .mel-se-title-row label { color: #d1d5db; }
#mel-sheet-title {
    flex: 1 1 200px; min-width: 0; padding: 7px 10px; border-radius: 8px;
    border: 1px solid #d1d5db; font-size: 13px; background: #fff; color: #111827;
}
.dark #mel-sheet-title { background: #1f2937; border-color: #4b5563; color: #f3f4f6; }
.mel-se-chips {
    display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px;
    max-height: 140px; overflow-y: auto; padding: 2px;
}
.mel-se-chip {
    flex: 0 0 auto; padding: 5px 8px; border-radius: 8px; cursor: pointer;
    background: #fff; border: 1px solid #e5e7eb; font-weight: 800; font-size: 14px;
    color: #374151; line-height: 1.2; transition: all .12s;
}
.dark .mel-se-chip { background: #1f2937; border-color: #374151; color: #e5e7eb; }
.mel-se-chip:hover { border-color: #4f46e5; }
.mel-se-chip.mel-se-on { background: #4f46e5; border-color: #4f46e5; color: #fff; }
.mel-se-chip .m { font-size: 10px; font-weight: 700; color: #4f46e5; margin-left: 1px; }
.mel-se-chip.mel-se-on .m { color: #fff; }
.mel-se-chip.mel-se-mark { font-weight: 700; font-size: 12px; color: #6b7280; }
.dark .mel-se-chip.mel-se-mark { color: #9ca3af; }
.mel-se-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; min-height: 34px; }
.mel-se-tools:empty { display: none; }
.mel-se-tools select {
    padding: 6px 8px; border-radius: 8px; border: 1px solid #d1d5db;
    font-size: 13px; background: #fff; color: #111827;
}
.dark .mel-se-tools select { background: #1f2937; border-color: #4b5563; color: #f3f4f6; }
.mel-se-tools button {
    padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
    background: #eef2ff; color: #4f46e5; border: 1px solid #c7d2fe; transition: all .12s;
}
.dark .mel-se-tools button { background: #1f2937; border-color: #4338ca; color: #a5b4fc; }
.mel-se-tools button:hover { background: #4f46e5; color: #fff; border-color: #4f46e5; }
.mel-se-tools button.mel-se-danger:hover { background: #dc2626; border-color: #dc2626; }
.mel-se-hint { font-size: 11px; color: #9ca3af; margin-top: 8px; line-height: 1.5; }

/* ===== 守夜人口琴获取入口 ===== */
.mel-harmonica {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 16px 20px; border-radius: 16px; color: #fff;
    background: linear-gradient(120deg, #4f46e5 0%, #6d28d9 60%, #7c3aed 100%);
    box-shadow: 0 6px 20px rgba(79, 70, 229, .28);
}
.mel-harmonica-icon {
    flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: 12px;
    background: rgba(255, 255, 255, .16); color: #fff;
}
.mel-harmonica-text { flex: 1 1 220px; min-width: 0; }
.mel-harmonica-title { font-weight: 800; font-size: 16px; line-height: 1.3; }
.mel-harmonica-desc { font-size: 13px; opacity: .85; margin-top: 2px; }
.mel-harmonica-btn {
    flex: 0 0 auto; display: inline-block; padding: 9px 18px; border-radius: 999px;
    background: #fff; color: #4f46e5; font-weight: 700; font-size: 14px;
    text-decoration: none; transition: all .15s;
}
.mel-harmonica-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, .2); color: #4338ca; }
