﻿@font-face {
    font-family: 'LocalKaiShu';
    src: url('../font/楷书.woff2') format('woff2'),
         url('../font/楷书.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'LocalLiShu';
    src: url('../font/隶书.woff2') format('woff2'),
         url('../font/隶书.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'LocalShaoNv';
    src: url('../font/少女.woff2') format('woff2'),
         url('../font/少女.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'LocalSongTi';
    src: url('../font/宋体.woff2') format('woff2'),
         url('../font/宋体.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'LocalXiYuan';
    src: url('../font/细圆.woff2') format('woff2'),
         url('../font/细圆.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
:root { 
    --ink: #1f2328; 
    --paper-padding: 50px; 
    --slur-shift-ratio: -0.11; 
    --base-lyric-size: 20px;
    --note-size: var(--base-note-size);
    --lyric-size: var(--base-lyric-size);
    --title-size: 32px; 
    --score-gap: 40px;
    --header-gap: 15px;
    --lyric-gap: 4px; 
    --lyric-bottom-pad: 0px;
    --staff-gap: 15px;
    --note-gap: 7px; /* 单声部横向间距 */
    --multi-note-gap: 5px; /* 多声部横向间距 */
    --oct-gap: 0px;
    --oct-above-offset: 0px;
    --lyric-punct-offset: 0px;
    --chord-gap: 0px;
    --line-offset: 0px;
    --arc-offset: 0px;
    
    --arc-thickness: 2px;
    --line-thickness: 2px;
    --symbol-offset: 0px; /* 新增：左上角符号偏移 */
	--slur-shift: -6px; 
    
    --font-note-family: "Times New Roman", Times, serif;
    --font-note-weight: bold;
    --font-lyric-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-lyric-weight: bold;
}
* { box-sizing: border-box; }
body { 
    margin: 0; padding: 40px 16px; 
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; 
    color: var(--ink); 
    background: #525659; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    -webkit-font-smoothing: antialiased; 
    -moz-osx-font-smoothing: grayscale; 
    text-rendering: optimizeLegibility;
}
.control-panel { width: 100%; max-width: 794px; background: #fafafa; padding: 20px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); margin-bottom: 20px; position: relative; }
h1 { font-size: 20px; font-weight: 600; margin: 0 0 16px 0; display: flex; justify-content: space-between; align-items: center; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar button { margin: 0; padding: 6px 12px; font-size: 13px; background: #e1e4e8; color: #24292e; border: 1px solid #d1d5da; border-radius: 4px; cursor: pointer; }
.toolbar button:hover { background: #d1d5da; }
.toolbar button.danger { background: #ffeef0; color: #d73a49; border-color: #fdaeb7; }
.toolbar button.danger:hover { background: #ffdce0; }

textarea { width: 100%; min-height: 180px; padding: 12px; font-size: 15px; font-family: ui-monospace, Menlo, Consolas, monospace; border: 1px solid #d0d7de; border-radius: 6px; resize: vertical; outline: none; line-height: 1.5; }
textarea:focus { border-color: #2f81f7; box-shadow: 0 0 0 3px rgba(47,129,247,.15); }
.settings-row { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 15px; padding-top: 15px; border-top: 1px dashed #ccc; }
.setting-item { display: flex; flex-direction: column; font-size: 14px; font-weight: 500; }
.setting-item input[type="range"] { width: 110px; }
.setting-item select { padding: 4px; font-size: 13px; border-radius: 4px; border: 1px solid #ccc; margin-top: 5px; outline: none; cursor: pointer; }

.action-row { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.action-row button { padding: 8px 12px; font-size: 14px; cursor: pointer; border: none; border-radius: 6px; color: #fff; }
.btn-submit { background: #2f81f7; }
.btn-submit:hover { background: #1f6feb; }
.btn-play { background: #2ea043; }
.btn-play:hover { background: #238636; }
.btn-export { background: #8b5cf6; }
.btn-export:hover { background: #7c3aed; }
.btn-help { background: #f59e0b; margin-left: auto; }
.btn-help:hover { background: #d97706; }

.hint { color:#555; font-size: 13px; line-height: 1.8; margin-top: 12px; }
.hint code { background:#eef1f4; padding:2px 6px; border-radius:4px; font-family: monospace; }
.paper { 
    width: 794px; height: 1123px; 
    background: #fff; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.3); 
    padding: var(--paper-padding); 
    position: relative; 
    margin-bottom: 20px; 
    overflow: hidden; 
    transform-origin: top center; 
    transition: transform 0.2s; 
    will-change: transform;
    -webkit-font-smoothing: antialiased; 
    -moz-osx-font-smoothing: grayscale;
}
.paper.landscape { width: 1123px; height: 794px; }
.paper-content { width: 100%; height: calc(100% - 40px); position: relative; display: flex; flex-direction: column; }
.paper-info { position: absolute; bottom: 20px; left: 50px; right: 50px; font-size: 12px; color: #999; text-align: center; padding-top: 0; }

.header { position: relative; display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: var(--header-gap); padding-top: 5px; padding-left: 7px; padding-right: 7px; margin-top: var(--header-margin, 0px) !important;transition: margin-top 0.1s ease;}
.header .meta-left { display: flex; flex-direction: column; gap: 0px; width: 240px; flex-shrink: 0; z-index: 2; margin-top: 7px; }
.header .meta-center { position: absolute; left: 50%; transform: translateX(-50%); top: 5px; width: 60%; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; margin-top: 5px; z-index: 1; }
.header .meta-right { display: flex; flex-direction: column; align-items: flex-start; margin-left: auto; flex-shrink: 0; z-index: 2; margin-top: 7px; padding-right: 7px; }

.header .title { text-align: center; font-size: var(--title-size); font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-weight: 800; letter-spacing: 2px; color: #000; line-height: 1.2; margin: 0; font-size: var(--title-size, 32px);}
.header .subtitle { text-align: center; font-size: 13px; font-weight: bold; margin-top: 5px; color: #000; }
.header .key-time { display: block; font-size: 18px; font-weight: bold; line-height: 1.1; margin-bottom: 2px; white-space: nowrap; }
.header .key-acc { font-size: 0.8em; display: inline-block; transform: translateY(-5px); margin-right: 2px; margin-left: 1px; font-family: "Times New Roman", Times, serif; }
.header .time-sig { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; line-height: 1; vertical-align: middle; margin: 0 8px; }
.header .time-sig .top { border-bottom: 1.5px solid var(--ink); padding: 0 2px 1px 2px; }
.header .time-sig .bottom { padding: 1px 2px 0 2px; }
.header .bpm { font-size: 16px; font-weight: bold; line-height: 1.1; white-space: nowrap; margin-top: -5px !important;}
/* ★ 新增：让 = 后面的文字变成 0.8 倍大小，你也可以改成 0.7em 或 14px */
.header .bpm .bpm-val { font-size: 0.6em; font-weight: bold; }
.header .credit { display: block; text-align: left; font-size: 14px; font-weight: bold; letter-spacing: 1px; white-space: nowrap; min-height: 1.2em; line-height: 1.4; }

.expression { margin: 5px 0; font-size: 16px; font-weight: bold; font-style: italic; color: #333; text-align: right; padding-right: 20px; }

.free-text-wrapper { display: inline-block; width: 0; height: calc(var(--note-size) * 1.2); vertical-align: top; flex-shrink: 0; }
.free-text-inner { position: absolute; transform: translateY(calc(-100% - 4px)); white-space: nowrap; font-size: calc(var(--note-size) * 0.5); font-weight: bold; color: #6f4e37; z-index: 99; line-height: 1; }
.free-text-left .free-text-inner { left: 0; }
.free-text-center .free-text-inner { left: 50%; transform: translateX(-50%) translateY(calc(-100% - 4px)); }
.free-text-right .free-text-inner { right: 0; }

.mark-wrap { display: inline-block; position: relative; width: 0; height: calc(var(--note-size) * 1.2); vertical-align: top; flex-shrink: 0; }
.mark-abs { position: absolute; top: calc(var(--note-size) * 1.2 + 2px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: calc(var(--note-size) * 0.6); font-family: "Times New Roman", Times, serif; font-style: italic; font-weight: bold; white-space: nowrap; color: var(--ink); z-index: 10; }
.mark-line { line-height: 1.15; }

.score { 
    --current-note-gap: var(--note-gap, 0px); /* 新增：动态读取横向间距 */
    position: relative; 
    display: flow-root; 
    width: 100%; 
    font-size: 0; 
    margin-bottom: var(--score-gap); 
    white-space: normal; 
    --note-size: var(--base-note-size); 
    --lyric-size: var(--base-lyric-size); 
    will-change: transform;
}
.score[data-force-nowrap="true"] { white-space: nowrap; }
.score.no-lyrics-mode { margin-bottom: var(--score-gap); padding-bottom: 4px; }
.score-block:first-child .score { margin-top: 0 !important; }
.score > .note-wrap, .score > .barline, .score > .free-text-wrapper, .score > .slur-group, .score > .slur-tail, .score > .note-space, .score > .text-node, .score > .mark-wrap { margin-top: calc(var(--note-size) * 0.1) !important; }
.score > .volta-group { margin-top: calc(var(--note-size) * 0.1) !important; }

.note-wrap { display: inline-flex; flex-direction: column; align-items: center; vertical-align: top; position: relative; font-size: var(--note-size); transition: color 0.1s, transform 0.1s; padding-bottom: calc(var(--lyric-lines, 1) * (var(--lyric-size) + var(--lyric-gap, 4px)) + var(--lyric-bottom-pad, 0px)); }
.note-wrap.no-lyric { padding-bottom: 4px; }
.note-wrap.active { color: #f97316; transform: scale(1.2); z-index: 10; }
.chord-mark { position: absolute; bottom: calc(100% + 2px + var(--chord-gap, 0px)); left: 50%; transform: translateX(-50%); font-size: 0.5em; font-weight: 600; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; white-space: nowrap; color: #888; }
.digit-group { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 !important; height: 1.2em; }
.score .note-wrap { margin-left: var(--note-gap, 0px) !important; margin-right: var(--note-gap, 0px) !important; }
.choir-container .note-wrap { margin-left: var(--multi-note-gap, 0px) !important; margin-right: var(--multi-note-gap, 0px) !important; }
.note-wrap.no-lyric .digit-group { padding-left: 3px; padding-right: 3px; }
.pitch-row { position: relative; display: flex; align-items: center; justify-content: center; height: 1.2em; }
.pitch-row + .pitch-row { margin-top: 0.2em; }
.digit-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.digit { font-family: var(--font-note-family); font-weight: var(--font-note-weight); line-height: 1; }
.dash-char { font-family: Arial, sans-serif; letter-spacing: 2px; }

.aug-dots { display: flex; gap: 2px; position: absolute; left: 100%; top: 50%; transform: translate(-50%, calc(-50% + 2px)); margin-left: 7px; }
.note-wrap.no-lyric .aug-dots { margin-left: 3px; }
.aug-dot { width: 0.15em; height: 0.15em; border-radius: 50%; background: currentColor; display: block; }
.fermata { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); width: 0.5em; height: 0.25em; border: 1.5px solid currentColor; border-bottom: none; border-radius: 50% 50% 0 0 / 100% 100% 0 0; z-index: 99; margin-bottom: 0.02em; }
.fermata::after { content: ''; position: absolute; bottom: -0.06em; left: 50%; transform: translateX(-50%); width: 0.12em; height: 0.12em; background: currentColor; border-radius: 50%; }
.wave-mark { position: absolute; left: 50%; transform: translateX(-50%); font-family: "Times New Roman", Times, serif; font-size: 0.45em; font-weight: normal; font-style: italic; line-height: 1; color: currentColor; z-index: 99; pointer-events: none; }
.accidental { position: absolute; top: -0.1em; left: calc(-5px + var(--symbol-offset, 0px)); font-size: 0.45em; font-weight: bold; font-family: Arial, sans-serif; line-height: 1; color: currentColor; pointer-events: none; }
.note-wrap.no-lyric .accidental { left: calc(-7px + var(--symbol-offset, 0px)); }

.lyric-abs { position: absolute; top: calc(var(--note-size) * 1.2 + 5px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; font-size: var(--lyric-size); font-family: var(--font-lyric-family); font-weight: var(--font-lyric-weight); line-height: 1.1; white-space: nowrap; z-index: 10; }
.lyric-line { white-space: nowrap; position: relative; }
.lyric-line:not(:first-child) { margin-top: var(--lyric-gap, 4px); }
.lyric-abs .lyric-punct-end { 
    position: relative !important; /* 改为相对定位，让它进入文档流产生物理占位 */
    left: auto !important; 
    top: auto !important;
    display: inline-block !important; 
    width: 0.25em !important; /* ★ 核心：强行占据 1/4 字宽的物理空间，挤开后面的元素 */
    overflow: visible !important; /* ★ 核心：让超出的标点文字正常显示出来，不被切掉 */
    vertical-align: top; 
    z-index: 2; 
    font-family: var(--font-lyric-family); 
    font-weight: var(--font-lyric-weight);
    white-space: nowrap;
}
/* 标点整体向右平移，默认离歌词更远一些 */
.lyric-abs .lyric-punct-period { transform: translateX(calc(-0.1em + var(--lyric-punct-offset, 0px))); }
.lyric-abs .lyric-punct-comma { transform: translateX(calc(-0.35em + var(--lyric-punct-offset, 0px))); }
.lyric-abs .lyric-punct-dunhao { transform: translateX(calc(-0.20em + var(--lyric-punct-offset, 0px))); }
.lyric-abs .lyric-punct-semicolon { transform: translateX(calc(-0.42em + var(--lyric-punct-offset, 0px))); }
.lyric-abs .lyric-punct-colon { transform: translateX(calc(-0.35em + var(--lyric-punct-offset, 0px))); }

.oct-above { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column-reverse; gap: 2px; margin-bottom: calc(-2px + var(--oct-above-offset, 0px)); z-index: 90; }
.oct-below { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 2px; margin-top: calc(-3px - var(--oct-gap, 0px)); z-index: 5; }
.note-wrap.lines-1 .oct-below { margin-top: calc(-1px - var(--oct-gap, 0px)); }
.note-wrap.lines-2 .oct-below { margin-top: calc(3px - var(--oct-gap, 0px)); }
.note-wrap.lines-3 .oct-below { margin-top: calc(7px - var(--oct-gap, 0px)); }
.oct-dot { width: 0.14em; height: 0.14em; border-radius: 50%; background: currentColor; display: block; }

.grace-before, .grace-after { 
    position: absolute; 
    top: -0.55em; 
    font-size: 0.4em; 
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1; 
    white-space: nowrap; 
    pointer-events: none; 
    z-index: 10; 
    color: currentColor; 
}

/* 调整默认距离，从 4px 减到 1px（即默认靠近 3px） */
/* 把 - 1px 改成 - 6px，等于整个倚音向右（靠近音符）平移了 5px */
.grace-before { right: calc(100% - 6px - var(--symbol-offset, 0px)); }
.grace-after  { left: calc(100% - 6px + var(--symbol-offset, 0px)); }

.grace-notes-wrap {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 0px; 
    margin-bottom: 0px;
}

.grace-note { 
    font-family: "Times New Roman", Times, serif; 
    font-weight: bold; 
    position: relative; 
    padding: 0; 
    display: inline-flex; 
    justify-content: center; 
    align-items: center; 
    line-height: 1; 
    /* 去掉了原来的 border-bottom 和 width */
    padding-bottom: 2px; /* 给下划线留出空间 */
}

/* 新增：用伪元素强制画一条短一半的下划线 */
.grace-note::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 70%; /* 线宽只占数字的 70%，看起来短小精悍 */
    height: 1px;
    background-color: currentColor;
}
.grace-t { 
    font-size: 0.8em; 
    font-family: Arial, sans-serif; 
    font-weight: normal; 
    line-height: 1; 
    margin-top: -2px; /* 升上来贴紧下划线 */
}
.grace-acc { position: absolute; top: -0.15em; left: calc(-0.35em + var(--symbol-offset, 0px)); font-size: 0.85em; line-height: 1; }
.grace-oct { position: absolute; left: 50%; transform: translateX(-50%); font-size: 0.9em; line-height: 0.6; letter-spacing: -0.5px; }
.grace-oct-up { bottom: 100%; }
.grace-oct-dn { top: 100%; }

.note-space { display: inline-block; width: 0.3em; height: 1px; vertical-align: top; font-size: var(--note-size); }

/* ===== 下划线基础样式（缩短硬编码留白，让单音符下划线更长） ===== */
.note-wrap.lines-1 .digit-group::before, .note-wrap.lines-2 .digit-group::before, .note-wrap.lines-3 .digit-group::before { 
    content: ''; position: absolute; left: 1px; right: 1px; bottom: calc(4px + var(--line-offset, 0px)); height: var(--line-thickness); background: currentColor; 
}
.note-wrap.no-lyric.lines-1 .digit-group::before, .note-wrap.no-lyric.lines-2 .digit-group::before, .note-wrap.no-lyric.lines-3 .digit-group::before { 
    left: 0px; right: 0px; 
}
.note-wrap.lines-2 .digit-group::after, .note-wrap.lines-3 .digit-group::after { 
    content: ''; position: absolute; left: 1px; right: 1px; bottom: calc(0px + var(--line-offset, 0px)); height: var(--line-thickness); background: currentColor; 
}
.note-wrap.no-lyric.lines-2 .digit-group::after, .note-wrap.no-lyric.lines-3 .digit-group::after { 
    left: 0px; right: 0px; 
}
.note-wrap.lines-3 .digit-group::after { 
    box-shadow: 0 calc(var(--line-thickness) + 2px) 0 0 currentColor; 
}

/* ===== 向右延伸（连向下一个音符） ===== */
.note-wrap.extend-right.lines-1 .digit-group::before, 
.note-wrap.extend-right.lines-2 .digit-group::before, 
.note-wrap.extend-right.lines-3 .digit-group::before { 
    right: calc(-1px - var(--current-note-gap, 0px)); 
}
.note-wrap.extend-right.lines-2 .digit-group::after, 
.note-wrap.extend-right.lines-3 .digit-group::after { 
    right: calc(-1px - var(--current-note-gap, 0px)); 
}

/* ===== 向左延伸（连向上一个音符） ===== */
.note-wrap.extend-1.lines-1 .digit-group::before, .note-wrap.extend-1.lines-2 .digit-group::before, .note-wrap.extend-1.lines-3 .digit-group::before, 
.note-wrap.extend-2.lines-2 .digit-group::before, .note-wrap.extend-2.lines-3 .digit-group::before, 
.note-wrap.extend-3.lines-3 .digit-group::before { 
    left: calc(-1px - var(--current-note-gap, 0px)); 
}
.note-wrap.extend-1.lines-2 .digit-group::after, .note-wrap.extend-1.lines-3 .digit-group::after, 
.note-wrap.extend-2.lines-2 .digit-group::after, .note-wrap.extend-2.lines-3 .digit-group::after, 
.note-wrap.extend-3.lines-3 .digit-group::after { 
    left: calc(-1px - var(--current-note-gap, 0px)); 
}

.barline { font-size: var(--note-size); display: inline-flex; width: 2px; height: calc(var(--note-size) * 1.2); background-color: currentColor; margin: 0; vertical-align: top; flex-shrink: 0; position: relative; }
.barline.invisible { background-color: transparent !important; border-color: transparent !important; box-shadow: none !important; }
.barline.invisible::before, .barline.invisible::after { display: none !important; }
.barline.repeat-start { background-color: transparent; width: 9.5px; border-left: 4.5px solid currentColor; border-right: 2px solid currentColor; margin-left: 6px; margin-right: 4px; }
.barline.repeat-start::before, .barline.repeat-start::after { content: ''; position: absolute; width: 4.5px; height: 4.5px; border-radius: 50%; background: currentColor; right: -8px; }
.barline.repeat-start::before { top: 20%; }
.barline.repeat-start::after { bottom: 20%; }
.barline.repeat-end { background-color: transparent; width: 9.5px; border-left: 2px solid currentColor; border-right: 4.5px solid currentColor; margin-left: 4px; margin-right: 6px; }
.barline.repeat-end::before, .barline.repeat-end::after { content: ''; position: absolute; width: 4.5px; height: 4.5px; border-radius: 50%; background: currentColor; left: -8px; }
.barline.repeat-end::before { top: 20%; }
.barline.repeat-end::after { bottom: 20%; }
.barline.end { background-color: transparent; width: 9px; border-left: 2px solid currentColor; border-right: 5px solid currentColor; margin-left: 4px; margin-right: 4px; }
.barline.repeat-end-end { background-color: transparent; width: 9px; border-left: 2px solid currentColor; border-right: 5px solid currentColor; margin-left: 4px; margin-right: 6px; }
.barline.repeat-end-end::before, .barline.repeat-end-end::after { content: ''; position: absolute; width: 4.5px; height: 4.5px; border-radius: 50%; background: currentColor; left: -8px; }
.barline.repeat-end-end::before { top: 20%; }
.barline.repeat-end-end::after { bottom: 20%; }

/* ==================== 连音线：平顶 + 两侧缩进且带尖角的短腿（兼容 html2canvas） ==================== */
/* ==================== 连音线：完美对齐、无缝拼接版 ==================== */
.slur-group { 
    position: relative; 
    display: inline-flex; 
    vertical-align: top; 
    font-size: var(--note-size); 
    align-items: flex-start; 
    /* 高度和偏移改为跟随基础音符大小自动缩放 */
    --slur-h: calc(var(--base-note-size) * 0.18); 
    --slur-thick: var(--arc-thickness, 2px); 
    --slur-top: calc(var(--base-note-size) * -0.1 - var(--arc-offset, 0px));
    --left-inset: calc(var(--base-note-size) * 0.40); /* 25px 时等于 10px */
    --right-inset: calc(var(--base-note-size) * 0.16); /* 25px 时等于 4px */
}
.slur-group .note-wrap { margin-top: 0 !important; }
.slur-group .barline { margin-top: 0 !important; }

/* 左半：左斜腿 + 左半平线 */
.slur-group::before { 
    content: ''; 
    position: absolute; 
    top: var(--slur-top); 
    left: var(--left-inset); 
    right: 50%; 
    height: var(--slur-h); 
    border-top: var(--slur-thick) solid currentColor; 
    border-left: var(--slur-thick) solid currentColor; 
    box-sizing: border-box; 
    transform-origin: top left; 
    transform: translateX(calc(var(--base-note-size) * var(--slur-shift-ratio))) skewX(-45deg);  
    pointer-events: none; 
    z-index: 10;
}

/* 右半：右半平线 + 右斜腿 */
.slur-group::after { 
    content: ''; 
    position: absolute; 
    top: var(--slur-top); 
    left: 50%; 
    right: var(--right-inset); 
    height: var(--slur-h); 
    border-top: var(--slur-thick) solid currentColor; 
    border-right: var(--slur-thick) solid currentColor; 
    box-sizing: border-box; 
    transform-origin: top right; 
    transform: translateX(calc(var(--base-note-size) * var(--slur-shift-ratio))) skewX(45deg); 
    pointer-events: none; 
    z-index: 10;
}

/* 跨小节左半截 */
.slur-group.cross-right::before { right: var(--cross-right-extend, 0px); }
.slur-group.cross-right::after { display: none; }

/* 跨小节右半截 */
.slur-tail { 
    position: relative; 
    display: inline-flex; 
    vertical-align: top; 
    align-items: flex-start; 
    --slur-h: calc(var(--base-note-size) * 0.18); 
    --slur-thick: var(--arc-thickness, 2px); 
    --slur-top: calc(var(--base-note-size) * -0.1 - var(--arc-offset, 0px));
    --right-inset: calc(var(--base-note-size) * 0.16);
}
.slur-tail .note-wrap { margin-top: 0 !important; }
.slur-tail::before { 
    content: ''; 
    position: absolute; 
    top: var(--slur-top); 
    left: var(--slur-tail-extend, 0px); 
    right: var(--right-inset); 
    min-width: 4px; /* 新增：防止多声部负间距时把宽度挤压为负导致消失 */
    height: var(--slur-h); 
    border-top: var(--slur-thick) solid currentColor; 
    border-right: var(--slur-thick) solid currentColor; 
    box-sizing: border-box; 
    transform-origin: top right; 
    transform: translateX(calc(var(--base-note-size) * var(--slur-shift-ratio))) skewX(45deg); 
    pointer-events: none; 
    z-index: 11;
}

/* 嵌套连音线 */
.slur-group.nested, 
.slur-tail.nested { 
    --slur-h: calc(var(--base-note-size) * 0.28); 
    --slur-thick: var(--arc-thickness); /* ★ 让它跟随粗细控制 */
    --slur-top: calc(var(--base-note-size) * -0.28 - var(--arc-offset, 0px));  
}

/* ======== 重叠型（背靠背）斜角完美交汇 ======== */
.slur-group.overlap::before { 
    left: calc(var(--left-inset, 6px) + var(--overlap-left, 0px)); 
    right: 50%; 
}
.slur-group.has-overlap-right::after {
    right: calc(var(--right-inset, 2px) + var(--overlap-shrink, 0px));
}
/* ==================== 分段/结束线整体上移 ==================== */
.seg-start-seg-line::after, 
.seg-start-seg-prelude::after,
.measure-col.seg-start-seg-line::after,
.measure-col.seg-start-seg-prelude::after { 
    content: attr(data-label) !important; position: absolute; top: -12px; left: 50%; transform: translateX(-50%); 
    background: #fff; padding: 0 4px; font-size: 11px; font-weight: bold; color: currentColor !important; 
    z-index: 9999 !important; white-space: nowrap; pointer-events: none; line-height: 1;
}
.seg-start-seg-end::after,
.measure-col.seg-start-seg-end::after { 
    content: attr(data-label) !important; position: absolute; top: -19px; left: 50%; transform: translateX(-50%); 
    background: #fff; padding: 0 4px; font-size: 11px; font-weight: bold; color: currentColor !important; 
    z-index: 9999 !important; white-space: nowrap; pointer-events: none; line-height: 1;
}
.in-seg-line::before { content: '' !important; position: absolute; top: -8px; height: 5px; left: calc(-1px - var(--note-gap, 7px)); right: calc(-1px - var(--note-gap, 7px)); border-top: 1.5px solid currentColor; pointer-events: none; z-index: 9998 !important; }
.seg-start-seg-line::before { left: 0 !important; border-left: 1.5px solid currentColor; }
.seg-end-seg-line::before { right: 0 !important; border-right: 1.5px solid currentColor; }
.seg-start-seg-line.seg-end-seg-line::before { left: 0 !important; right: 0 !important; border-left: 1.5px solid currentColor; border-right: 1.5px solid currentColor; }

/* 结束线防切断并上移 */
.in-seg-end::before { content: '' !important; position: absolute; top: -16px; height: 5px; left: -20px; right: 0; border-top: 1.5px solid currentColor; pointer-events: none; z-index: 9998 !important; }
.seg-start-seg-end::before { left: 0 !important; border-left: 1.5px solid currentColor; }
.seg-end-seg-end::before { right: 0 !important; border-right: 1.5px solid currentColor; }
.seg-start-seg-end.seg-end-seg-end::before { left: 0 !important; right: 0 !important; border-left: 1.5px solid currentColor; border-right: 1.5px solid currentColor; }

.measure-col.in-seg-line::before { content: '' !important; position: absolute; top: -8px; height: 5px; left: 0; right: 10px; border-top: 1.5px solid currentColor; pointer-events: none; z-index: 9998 !important; }
.measure-col.seg-start-seg-line::before { border-left: 1.5px solid currentColor; }
.measure-col.seg-end-seg-line::before { border-right: 1.5px solid currentColor; }
.measure-col.seg-start-seg-line.seg-end-seg-line::before { border-left: 1.5px solid currentColor; border-right: 1.5px solid currentColor; }
.measure-col.in-seg-end::before { content: '' !important; position: absolute; top: -16px; height: 5px; left: 0; right: 10px; border-top: 1.5px solid currentColor; pointer-events: none; z-index: 9998 !important; }
.measure-col.seg-start-seg-end::before { border-left: 1.5px solid currentColor; }
.measure-col.seg-end-seg-end::before { border-right: 1.5px solid currentColor; }
.measure-col.seg-start-seg-end.seg-end-seg-end::before { border-left: 1.5px solid currentColor; border-right: 1.5px solid currentColor; }

.volta-group { display: inline-flex; flex-direction: row; align-items: flex-start; position: relative; vertical-align: top; }
.volta-label { position: absolute; top: -16px; left: 1px; font-size: 14px; font-weight: bold; font-family: Arial; line-height: 1.2; color: currentColor; padding: 0 2px; }
.volta-group::before { content: ''; position: absolute; top: -8px; left: 0; right: 0; height: 5px; border-top: 1.5px solid currentColor; border-left: 1.5px solid currentColor; border-radius: 4px 4px 0 0; border-right: 1.5px solid currentColor; }
.volta-group-inner { display: flex; align-items: flex-start; padding-top: 4px; }

.choir-container { 
    --current-note-gap: var(--multi-note-gap, 0px); 
    display: flex; 
    flex-wrap: nowrap; 
    align-items: flex-start; 
    width: 100%; 
    position: relative; 
    margin-bottom: var(--score-gap); 
    will-change: transform; 
    /* ★ 恢复：不再加 padding，不干扰内部任何排版 */
    padding-left: 0; 
}
.choir-container[data-force-nowrap="true"] { 
    white-space: nowrap; 
    flex-wrap: nowrap; 
}
.score-block:first-child .choir-container { 
    margin-top: 0 !important; 
}

/* ★ 大括号恢复绝对定位，靠负值飘在外面 */
.choir-bracket { 
    position: absolute; 
    left: -7px; /* 向左外浮 16px */
    top: 2px; 
    bottom: 2px; 
    width: 4px; 
    border-left: 2.5px solid currentColor; 
    border-top: 2.5px solid currentColor; 
    border-bottom: 2.5px solid currentColor; 
    border-top-left-radius: 3px; 
    border-bottom-left-radius: 3px; 
    pointer-events: none; 
    z-index: 10; 
    -webkit-print-color-adjust: exact; 
    print-color-adjust: exact; 
}
.measure-col { 
    display: grid; 
    grid-auto-flow: row;
    align-content: start;
    flex-shrink: 0; 
    position: relative; 
}
.measure-cell { 
    display: flex; 
    flex-direction: row; 
    justify-content: flex-start; 
    align-items: flex-start; 
    padding-top: 0; 
    padding-right: 10px; 
    padding-left: 0; 
    white-space: nowrap; 
    position: relative; 
    margin-bottom: 0; 
    box-sizing: border-box; 
}
.measure-cell + .measure-cell { 
    margin-top: var(--staff-gap); 
}
.measure-cell .barline, .measure-cell .repeat-end, .measure-cell .end, .measure-cell .repeat-end-end { 
    margin-left: auto !important;
}
.choir-container .note-wrap { padding-bottom: 0 !important; }
.staff-label { position: absolute; right: calc(100% + 12px); top: 0.15em; white-space: nowrap; font-size: 12px; line-height: 1.2; color: #999; font-weight: 500; letter-spacing: 1px; pointer-events: none; z-index: 5; }

@media print {
  body { background: #fff; padding: 0; }
  .control-panel, .paper-info { display: none !important; }
  .paper { width: 100%; min-height: 0; height: auto; box-shadow: none; margin: 0; padding: 0; transform: none !important; }
  .score-block, .choir-block { page-break-inside: avoid; break-inside: avoid; }
  .note-wrap { transition: none; color: var(--ink) !important; transform: none !important; }
}
#source-content { position: absolute; left: -9999px; top: 0; width: 794px; visibility: hidden; pointer-events: none; display: flex; flex-direction: column; }
.segno-mark { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); width: calc(var(--note-size) * 0.6); height: calc(var(--note-size) * 0.6); z-index: 99; margin-bottom: 4px; color: currentColor; pointer-events: none; }
.segno-mark svg { display: block; width: 100%; height: 100%; }

/* ==================== 延音线多段渲染（优化版） ==================== */
/* ★ 终极覆盖：彻底干掉大间距和长面条 */
.note-wrap.dash-wrap {
    display: inline-flex !important;
    width: auto !important;
    min-width: 0 !important;
    margin-left: var(--note-gap, 0px) !important;
    margin-right: var(--note-gap, 0px) !important;
}
.dash-wrap .digit-group {
    padding: 0 !important;
    width: auto !important;
    display: inline-flex !important;
    justify-content: flex-start !important;
}
.dash-char-new {
    display: inline-flex !important;
    width: auto !important;
    height: 1.2em;
    align-items: center;
}
.dash-char-new .dash-line {
    height: 3px !important;
    background-color: currentColor;
    width: 0.4em !important;           /* 宽度强制锁死 0.4em */
    max-width: 0.4em !important;       /* 哪怕天塌下来也不许变长 */
    flex: 0 0 0.4em !important;        /* 拒绝被拉伸 */
    border-radius: 1.5px;
    display: inline-block !important;
}
.dash-char-new .dash-line + .dash-line {
    margin-left: 0.08em !important; 
}

/* ==================== 单行智能紧凑模式：只缩空隙，不缩字号 ==================== */
.compact-gap { --note-gap: 1px !important; }
.compact-gap .digit-group { padding: 0 1px !important; }
.compact-gap .note-wrap.no-lyric .digit-group { padding-left: 1px !important; padding-right: 1px !important; }
.compact-gap .measure-cell { padding-right: 2px !important; }
.compact-gap .note-wrap { margin-left: 0 !important; margin-right: 0 !important; }
.compact-gap .barline { margin: 0 1px !important; }
.compact-gap .note-space { width: 0.1em !important; }
.compact-gap .dash-wrap { margin: 0 1px !important; } /* 连音线挤干 */

/* 稍微优化：直接作用在主体上，确保两端缩进在紧凑模式下变小 */
.compact-gap .slur-group, .compact-gap .slur-tail {
    --left-inset: 2px; 
    --right-inset: 2px;
}

/* 给延音线一个基础宽度，让它像正常音符一样参与弹性布局 */
.dash-wrap {
    min-width: 1.5em;
}

/* ==================== 新增表情与力度记号 ==================== */
.breath-mark { position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%); font-size: 0.55em; font-family: "Times New Roman", serif; font-weight: bold; color: currentColor; line-height: 1; pointer-events: none; }
.accent-mark { position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%); font-size: 0.8em; font-family: Arial, sans-serif; font-weight: bold; color: currentColor; line-height: 1; pointer-events: none; }
.piano-mark { position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%); font-size: 0.6em; font-family: "Times New Roman", serif; font-style: italic; font-weight: bold; color: currentColor; line-height: 1; pointer-events: none; }
.cresc-mark { position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%); font-size: 0.5em; font-family: sans-serif; white-space: nowrap; color: currentColor; line-height: 1; pointer-events: none; }
.dim-mark { position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%); font-size: 0.5em; font-family: sans-serif; white-space: nowrap; color: currentColor; line-height: 1; pointer-events: none; }

/* ==================== 单行超宽专属：绝对扒光极限模式 ==================== */
.score.compact-extreme, 
.choir-container.compact-extreme {
    display: flex !important;
    flex-wrap: nowrap !important;
}

.score.compact-extreme > *, 
.choir-container.compact-extreme > * {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* 小节线、延音线保留绝对微小的 1px 区分 */
.score.compact-extreme .barline,
.score.compact-extreme .dash-wrap {
    margin: 0 1px !important;
}

/* 强行扒掉圆弧两端自带的留白缩进 */
.score.compact-extreme .slur-group {
    --left-inset: 0px !important;
    --right-inset: 0px !important;
}

/* ==================== p: 强制分段两端对齐拉伸适配 ==================== */

/* 只有原本带 extend-right（需要连向下一个音符）的下划线，才允许跨过新增的空隙 */
.note-wrap.extend-right.lines-1 .digit-group::before, 
.note-wrap.extend-right.lines-2 .digit-group::before, 
.note-wrap.extend-right.lines-3 .digit-group::before { 
    right: calc(-1px - var(--current-note-gap, 0px) - var(--p-stretch, 0px)) !important; 
}
.note-wrap.extend-right.lines-2 .digit-group::after, 
.note-wrap.extend-right.lines-3 .digit-group::after { 
    right: calc(-1px - var(--current-note-gap, 0px) - var(--p-stretch, 0px)) !important; 
}

/* 无歌词模式下的兼容 */
.note-wrap.no-lyric.extend-right.lines-1 .digit-group::before,
.note-wrap.no-lyric.extend-right.lines-2 .digit-group::before,
.note-wrap.no-lyric.extend-right.lines-3 .digit-group::before {
    right: calc(0px - var(--current-note-gap, 0px) - var(--p-stretch, 0px)) !important;
}
.note-wrap.no-lyric.extend-right.lines-2 .digit-group::after,
.note-wrap.no-lyric.extend-right.lines-3 .digit-group::after {
    right: calc(0px - var(--current-note-gap, 0px) - var(--p-stretch, 0px)) !important;
}

/* 兼容原本连音符自带的延伸逻辑，叠加拉伸量 */
.note-wrap.extend-right.lines-1 .digit-group::before, 
.note-wrap.extend-right.lines-2 .digit-group::before, 
.note-wrap.extend-right.lines-3 .digit-group::before { 
    right: calc(-1px - var(--current-note-gap, 0px) - var(--p-stretch, 0px)) !important; 
}
.note-wrap.extend-right.lines-2 .digit-group::after, 
.note-wrap.extend-right.lines-3 .digit-group::after { 
    right: calc(-1px - var(--current-note-gap, 0px) - var(--p-stretch, 0px)) !important; 
}

/* 让连音线圆弧也自动拉伸贴合 */
.slur-group, .slur-tail { 
    --right-inset: calc(var(--base-note-size) * 0.16 - var(--p-stretch, 0px)); 
}

/* ==================== 多声部段落线强制对齐修复 ==================== */
.measure-col.in-seg-line::before,
.measure-col.in-seg-end::before {
    right: 14px !important;
}
.measure-col.seg-end-seg-line::before,
.measure-col.seg-end-seg-end::before,
.measure-col.seg-start-seg-line.seg-end-seg-line::before,
.measure-col.seg-start-seg-end.seg-end-seg-end::before {
    right: 14px !important;
    border-right: 1.5px solid currentColor !important;
}

/* ==================== 终极霸王级覆盖补丁 ==================== */

/* 1. 彻底消灭房号下沉（用 .score > .volta-group 强行压制原版的 -1.8em） */
.score > .volta-group {
    margin-top: calc(var(--note-size) * 0.1) !important;
    display: inline-flex !important; 
    flex-direction: row !important; 
    align-items: flex-start !important; 
    vertical-align: top !important;
    position: relative !important;
}

/* 房号顶部的横线高度对齐 */
.volta-group::before { 
    top: -8px !important; 
    height: 6px !important; 
    border-top: 1.5px solid currentColor !important; 
    border-left: 1.5px solid currentColor !important; 
    right: 0 !important;
}

/* 2. 紧紧勒住疯狂向右越界的横线 (-20px) */
.in-seg-line::before { 
    left: calc(-1px - var(--note-gap, 7px)) !important; 
    right: calc(-1px - var(--note-gap, 7px)) !important; 
}

/* 3. 强行把 {/1} 吸附在小节线上的折角画出来！ */
.score .barline.seg-end-seg-line::before,
.score .barline.seg-end-seg-end::before {
    content: '' !important;
    position: absolute !important;
    top: -8px !important;
    height: 5px !important;
    left: calc(-1px - var(--note-gap, 7px)) !important;
    right: 0 !important; /* 死死卡在小节线上 */
    border-top: 1.5px solid currentColor !important;
    border-right: 1.5px solid currentColor !important; /* 这就是右侧的小竖条 */
    pointer-events: none !important;
    z-index: 9998 !important;
}

/* 4. 如果是遇到终止线 |] ，折角往里收一点 */
.score .barline.end.seg-end-seg-line::before,
.score .barline.end.seg-end-seg-end::before,
.score .barline.repeat-end.seg-end-seg-line::before,
.score .barline.repeat-end.seg-end-seg-end::before {
    right: 8px !important;
}

/* ==================== 悬浮输入规则提示 ==================== */
#floatingHint {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 250px;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid #d1d5da;
    border-radius: 10px;
    padding: 15px 20px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    font-size: 13px;
    line-height: 1.7;
    color: #333;
    z-index: 9999;
    pointer-events: none; /* 不阻挡鼠标点击 */
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}
#floatingHint.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
#floatingHint code {
    background: #f0f3f6;
    padding: 2px 6px;
    border-radius: 4px;
    color: #d73a49;
    font-family: ui-monospace, Consolas, monospace;
    font-weight: bold;
}
@media (max-width: 850px) {
    #floatingHint {
        bottom: 15px;
        right: 15px;
        left: 15px;
        width: auto;
        padding: 10px 15px;
        font-size: 12px;
        line-height: 1.6;
    }
}

/* ==================== 分屏参考对照功能 ==================== */
#referencePanel {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    width: 42vw;
    height: 100vh;
    background: #1e1e1e;
    border-left: 2px solid #333;
    z-index: 9999;
    box-shadow: -5px 0 20px rgba(0,0,0,0.3);
    flex-direction: column;
}

body.is-split {
    padding-right: 42vw !important;
    overflow-x: hidden;
}

body.is-split #referencePanel {
    display: flex;
}

.ref-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px; /* 稍微收紧一点高度 */
    background: #2a2a2a;
    border-bottom: 1px solid #444;
    flex-wrap: nowrap;
}

.ref-upload-btn {
    background: #2f81f7;
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}
.ref-upload-btn:hover { background: #1f6feb; }

.ref-close-btn {
    background: transparent;
    color: #aaa;
    border: 1px solid #555;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.ref-close-btn:hover { color: #fff; border-color: #fff; }

.ref-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
    /* 做成棋盘格背景，透明度调低时也能看清图片 */
    background-image: 
        linear-gradient(45deg, #222 25%, transparent 25%), 
        linear-gradient(-45deg, #222 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #222 75%), 
        linear-gradient(-45deg, transparent 75%, #222 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    outline: none;
	    touch-action: none;
}

.ref-empty-hint {
    color: #666;
    text-align: center;
    font-size: 14px;
    line-height: 1.6;
    pointer-events: none;
}

#refImage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: center center;
    cursor: grab;
    max-width: none;
    user-select: none;
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* ==================== 手机端分屏头部折行优化 ==================== */
@media (max-width: 850px) {
    .ref-header {
        flex-wrap: wrap !important; /* 允许换行 */
        padding: 10px !important;
        position: relative;
        gap: 10px !important;
    }
    
    /* 第一行：标题和上传按钮，给右侧留出关闭按钮的位置 */
    .ref-header > div:first-child {
        width: 100% !important;
        padding-right: 35px !important; 
        justify-content: flex-start !important;
    }
    
    /* 第二行：透明、缩放、居中，自动换行并两端对齐 */
    .ref-header > div:nth-child(2) {
        width: 100% !important;
        margin-top: 2px;
        justify-content: space-between !important; 
        gap: 5px !important;
        flex-wrap: wrap !important;
    }

    /* 缩放和透明度滑块稍微缩短一点，防止挤爆 */
    .ref-header input[type="range"] {
        width: 45px !important;
    }

    /* 关闭按钮绝对定位到右上角，不参与排版 */
    .ref-close-btn {
        position: absolute !important;
        top: 10px !important;
        right: 10px !important;
        margin: 0 !important;
    }
}

/* ==================== 电脑端工具栏极简单排优化 ==================== */
@media (min-width: 851px) {
    /* 强制单排不换行 */
    .header-tools {
        flex-wrap: nowrap !important;
        gap: 8px !important; 
    }
    
    /* 压缩各组之间的间距 */
    .header-tools > div {
        gap: 4px !important; 
    }
    
    /* 稍微缩减所有按钮的左右内边距和字号 */
    .header-tools .toolbar-btn {
        padding: 6px 8px !important;
        font-size: 12px !important;
        white-space: nowrap !important;
    }
    
    /* 单独微调撤销和重做这两个图标按钮，让它们显得更紧凑 */
    .header-tools button[onclick="undoText()"],
    .header-tools button[onclick="redoText()"] {
        padding: 6px 8px !important;
        font-size: 14px !important;
    }

    /* 压缩“1页”下拉框的宽度 */
    #targetPages {
        padding-left: 6px !important;
        padding-right: 2px !important;
        font-size: 12px !important;
    }
}

/* ==================== 歌词左侧附加标签 ==================== */
.lyric-line {
    position: relative; /* 允许子元素绝对定位 */
}
.lyric-label {
    position: absolute;
    right: 100%;
    padding-right: 8px; 
    font-size: 0.65em; 
    color: #999; 
    white-space: nowrap;
    font-weight: normal;
    top: 0.2em;
}

/* ==================== 背靠背圆弧强制居中 ==================== */
/* 强制右侧组的左脚向左延伸，突破短距离限制 */
.slur-group.overlap::before {
    left: calc(var(--left-inset, 6px) - (var(--base-note-size) * 0.5)) !important;
}
/* 强制左侧组的右脚向右延展收缩，形成完美的交汇 */
.slur-group.has-overlap-right::after {
    right: calc(var(--right-inset, 2px) + (var(--base-note-size) * 0.5)) !important;
}

/* ==================== [单行] / p: 强制分段：下距上限 12px ==================== */
.p-break-segment {
    margin-bottom: -25px !important;
    padding-bottom: 0 !important;
}

/* 如果带歌词，note-wrap 的 padding-bottom 会被算进块高，这里也钳一下视觉间隔 */
.p-break-segment .note-wrap {
    padding-bottom: calc(var(--lyric-lines, 1) * (var(--lyric-size) + var(--lyric-gap, 4px))) !important;
}

/* 无歌词模式下原本有 4px padding-bottom，统一归零避免叠加 */
.p-break-segment.no-lyrics-mode {
    padding-bottom: 0 !important;
}

/* 若强制分段块外层还套了 flow-root 包裹（多声部），给包裹层也限制 */
.p-break-segment + .score,
.p-break-segment + .choir-container {
    margin-top: 0 !important;
}

