:root, [data-theme="dark"] {
  --bg: #0e1116;
  --bg2: #1a2130;
  --panel: #161a22;
  --panel2: #1d222c;
  --line: #2a3140;
  --text: #e8ecf3;
  --muted: #8b95a7;
  --brand: #6c8cff;
  --brand2: #3aa0d0;
  --ok: #2fbf71;
  /* 语义色（供深浅两套切换） */
  --bar: rgba(20,25,33,.72);          /* 顶栏毛玻璃底 */
  --bar-line: rgba(255,255,255,.09);  /* 顶栏发丝线 */
  --hair: rgba(255,255,255,.075);     /* 卡片发丝边框 */
  --surf-1: rgba(255,255,255,.055);   /* 分段控件/次级面 */
  --surf-2: rgba(255,255,255,.045);   /* hover 面 */
  --surf-3: #10141b;                  /* 内嵌面（网格格、下拉、进度槽） */
  --surf-4: #141a24;                  /* 拍线格 */
  --surf-5: #1b2434;                  /* 标尺 hover */
  --line-2: #232a37;                  /* 细边框 */
  --line-3: #2a3140;
  --line-4: #3a4252;
  --muted-2: #8892a6;                 /* 弱文字/图例点 */
  --muted-3: #5f6b80;                 /* 标尺刻度 */
  --muted-4: #6b7688;                 /* 末尾列符号 */
  --sw-thumb: #8b95a8;                /* 开关滑块 */
  --stripe: rgba(255,255,255,.03);    /* 斜纹填充 */
  --card-shadow: 0 1px 2px rgba(0,0,0,.25);
  --toast-bg: #232a37;
  --btn-hover: #262d3a;               /* 按钮 hover 面 */
  --ghost-hover: #202634;             /* ghost 按钮 hover 面 */
  --thumb-ring: rgba(0,0,0,.35);      /* 开关滑块描边/投影 */
  --scroll: #3a4252;
  --track-bg: #10141b;
}
[data-theme="light"] {
  --bg: #f4f6f9;
  --bg2: #e8edf6;
  --panel: #ffffff;
  --panel2: #f4f6fa;
  --line: #dfe4ec;
  --text: #171b22;
  --muted: #5f6878;
  --brand: #4a6cf0;
  --brand2: #2f8fc4;
  --ok: #1d9d5b;
  --bar: rgba(252,253,255,.78);
  --bar-line: rgba(16,22,34,.10);
  --hair: rgba(16,22,34,.09);
  --surf-1: rgba(16,22,34,.045);
  --surf-2: rgba(16,22,34,.05);
  --surf-3: #f6f8fb;
  --surf-4: #eaeef5;
  --surf-5: #e6ecf8;
  --line-2: #e4e9f0;
  --line-3: #d9dfe8;
  --line-4: #c6ceda;
  --muted-2: #7b8496;
  --muted-3: #98a1b0;
  --muted-4: #818a99;
  --sw-thumb: #ffffff;
  --stripe: rgba(16,22,34,.035);
  --card-shadow: 0 1px 2px rgba(16,22,34,.06), 0 6px 18px -10px rgba(16,22,34,.12);
  --toast-bg: #2b3240;
  --btn-hover: #e7ebf3;               /* 浅色：hover 面要浅，文字才看得清 */
  --ghost-hover: #eef1f7;
  --thumb-ring: rgba(16,22,34,.22);
  --scroll: #c6ceda;
  --track-bg: #eef1f6;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1100px 520px at 50% -12%, var(--bg2) 0%, var(--bg) 62%), var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  display: flex; flex-direction: column; height: 100dvh; height: 100vh;
  overflow: hidden;
}

/* Topbar —— 顶部导航（毛玻璃 + 发丝分隔线，苹果现代风） */
.topbar {
  display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; column-gap: 10px;
  padding: calc(9px + env(safe-area-inset-top)) 16px 9px;
  border-bottom: .5px solid var(--bar-line);
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
  flex: 0 0 auto; z-index: 40; position: relative;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; justify-self: start; }
.topbar .tabbar { justify-self: center; }
.theme-btn {
  justify-self: end; width: 38px; height: 38px; flex: 0 0 38px; padding: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 11px; background: var(--surf-1); border: .5px solid var(--hair); color: var(--text);
  transition: background .16s, transform .14s, color .16s; -webkit-tap-highlight-color: transparent;
}
.theme-btn:hover { background: var(--surf-2); }
.theme-btn:active { transform: scale(.94); }
.theme-btn svg { width: 19px; height: 19px; }
.theme-btn .ic-sun { display: none; }
.theme-btn.is-light .ic-sun { display: block; }
.theme-btn.is-light .ic-moon { display: none; }
.logo {
  font-size: 20px; line-height: 1; width: 38px; height: 38px; flex: 0 0 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 11px; background: rgba(108,140,255,.14);
  border: .5px solid rgba(108,140,255,.28);
}
.brand-txt { min-width: 0; }
.topbar h1 { font-size: 16px; margin: 0; letter-spacing: .2px; font-weight: 600; }
.topbar h1 .lite { color: var(--brand); font-weight: 500; }
.sub { margin: 1px 0 0; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* App body + pages + bottom tabbar */
.app-body { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px; }
.page { display: none; }
.page.active { display: block; animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* 分离页：卡片与拖放区吃满可用高度，避免竖屏大片留白 */
#page-separate.active { display: flex; flex-direction: column; min-height: calc(100dvh - 96px); }
#page-separate.active > .panel { flex: 1 1 auto; display: flex; flex-direction: column; }
#page-separate .pt-body { flex: 1 1 auto; display: flex; flex-direction: column; }
#page-separate #sepDrop { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#page-separate #sepResult:not([hidden]) { flex: 1 1 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h2 { font-size: 16px; margin: 0; }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 大屏（iPad 横屏）：内容居中、限制最大宽，单卡片页垂直居中避免顶部堆叠 */
@media (min-width: 1000px) {
  .app-body { padding: 22px 26px; }
  #page-metronome.active, #page-separate.active, #page-practice.active, #page-journal.active {
    display: flex; flex-direction: column; justify-content: center;
    max-width: 1000px; margin: 0 auto; min-height: calc(100dvh - 108px);
  }
  /* 节拍器：横屏时放宽卡片，充分利用 iPad 横向空间（减留白、元素更大） */
  #page-metronome.active { max-width: min(1280px, 96vw); }
  #page-metronome .mt-panel { max-width: 100%; }
  #page-metronome .mt-sliderrow { width: min(92%, 880px); }
  #page-score.active { max-width: 1400px; margin: 0 auto; width: 100%; }
}

/* 节拍器为首页 Hero：只要竖向空间充足就居中（横竖屏均适用） */
@media (min-height: 760px) {
  #page-metronome.active {
    display: flex; flex-direction: column; justify-content: center;
    min-height: calc(100dvh - 108px);
  }
  #page-metronome .mt-panel { width: 100%; display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
}

.tabbar {
  display: flex; align-items: center; gap: 3px; flex-wrap: nowrap;
  background: var(--surf-1); border: .5px solid var(--hair);
  border-radius: 13px; padding: 3px; flex: 0 1 auto; min-width: 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; cursor: pointer; color: var(--muted);
  font-size: 13px; font-weight: 500; padding: 8px 12px; border-radius: 10px;
  white-space: nowrap; transition: background .16s, color .16s, box-shadow .16s;
  -webkit-tap-highlight-color: transparent;
}
.tab svg { width: 17px; height: 17px; opacity: .85; }
.tab:hover { color: var(--text); background: var(--surf-2); }
.tab.active { color: #fff; background: var(--brand); box-shadow: 0 1px 8px rgba(108,140,255,.42); }
.tab.active svg { opacity: 1; }

.btn {
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  padding: 8px 13px; border-radius: 10px; cursor: pointer; font-size: 13px;
  transition: .15s; white-space: nowrap;
}
.btn:hover { background: var(--btn-hover); border-color: var(--line-4); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; }
/* 导出按钮：带图标；文字在「导出 MP4」/「■ 结束录制」间切换，定宽避免整排按钮位移 */
#btnMp4 { width: 110px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
#btnMp4 .i-mp4 { display: inline-flex; align-items: center; position: relative; top: 0.5px; }
#btnMp4 .i-mp4 svg { display: block; }
#btnMp4.active { border-color: #ff6a3d; color: #ff8a5c; background: rgba(255,106,61,.12); }

.btn.ghost:hover { background: var(--ghost-hover); }
.btn.play { background: linear-gradient(180deg, #6c8cff, #4d6ee0); border-color: #5a78e6; font-weight: 600; min-width: 92px; }
.btn.play.active { background: linear-gradient(180deg, #e05a5a, #c0392b); border-color: #c0392b; }
.btn.small { padding: 5px 10px; font-size: 12px; }

/* Layout（鼓谱页：视图在上、编辑器在下） */
.layout {
  display: grid; grid-template-columns: minmax(400px, 1.1fr) minmax(380px, 1fr);
  gap: 16px; align-items: start;
}
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: .5px solid var(--hair); border-radius: 16px; overflow: hidden; box-shadow: 0 1px 2px var(--card-shadow); }
.panel + .panel, .page .panel + .panel { margin-top: 16px; }

/* 鼓谱页：鼓谱视图在上、编辑模块在下；编辑器可折叠 */
#page-score.active { display: flex; flex-direction: column; gap: 16px; overflow: hidden; }
#page-score .panel + .panel { margin-top: 0; }
.app-body.score-mode { display: flex; flex-direction: column; }
.app-body.score-mode #page-score.active { flex: 1 1 auto; min-height: 0; }
/* 鼓谱视图：占据剩余高度（编辑器收起时自动变高）；编辑器固定高度不带滚动条 */
.score-view { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.score-view .score-host { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; justify-content: center; align-items: safe center; }
/* 编辑器固定高度（内容自然高度，不参与剩余空间分配 → 不出滚动条、不抖动） */
#editorPanel { flex: 0 0 auto; display: flex; flex-direction: column; }
/* 编辑器正文：仅一行鼓件网格，固定高度 */
.editor-body { display: flex; flex-direction: column; flex: 0 0 auto; }
/* 行选择条 */
.rowpicker { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; overflow-x: auto; padding: 0; border: 0; background: none; min-width: 0; scrollbar-width: thin; }
.rowpick-label { font-size: 12px; color: var(--muted); }
.rowpick {
  border: 1px solid var(--line); background: var(--surf-3); color: var(--muted);
  padding: 5px 11px; border-radius: 999px; cursor: pointer; font-size: 12px; transition: .15s;
  font-variant-numeric: tabular-nums; flex: 0 0 auto; white-space: nowrap;
}
.rowpick:hover { border-color: var(--brand); color: var(--brand); }
.rowpick.active { background: var(--brand); border-color: var(--brand); color: #fff; }
/* 选中行高亮时给谱面预览加轻微提示边框 */
.editor-head-actions { display: flex; align-items: center; gap: 8px; }
.ed-rowlabel { font-size: 12px; color: var(--brand); font-weight: 600; font-variant-numeric: tabular-nums; min-width: 76px; text-align: center; }
.editor-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel2);
}
.editor-head h3 { font-size: 13px; margin: 0; color: var(--muted); font-weight: 600; letter-spacing: .3px; }
.editor.collapsed .editor-body { display: none; }
.editor.collapsed .editor-head { border-bottom: 0; }

/* 编辑工具栏：全部控件同一行、与「播放」等高；窄屏横向滑动不换行 */
.ed-toolbar {
  display: flex; align-items: center; gap: 3px; flex-wrap: nowrap;
  padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel2);
  flex: 0 0 auto;
  overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
}
.ed-toolbar::-webkit-scrollbar { height: 6px; }
.ed-toolbar::-webkit-scrollbar-thumb { background: var(--line-4); border-radius: 3px; }
.ed-toolbar .switch { flex: 0 0 auto; }
/* 开关式按钮（开关控件与文字融为同一个按钮，节省空间） */
.switch-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 11px;
  font-size: 12.5px; line-height: 1; white-space: nowrap; box-sizing: border-box; flex: 0 0 auto;
}
.switch-btn .switch-track { width: 36px; height: 22px; border-radius: 11px; flex: 0 0 36px; background: var(--line-3); border: 1px solid var(--line); position: relative; transition: .18s; display: inline-block; }
.switch-btn .switch-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--sw-thumb); transition: .18s; box-shadow: 0 0 0 .5px var(--thumb-ring), 0 1px 2px var(--thumb-ring); }
.switch-btn.on { border-color: var(--brand); color: var(--text); }
.switch-btn.on .switch-track { background: rgba(108,140,255,.35); border-color: var(--brand); }
.switch-btn.on .switch-thumb { left: 16px; background: var(--brand); box-shadow: 0 0 10px rgba(108,140,255,.7); }
.ed-sep { width: 1px; height: 24px; background: var(--line); flex: 0 0 1px; margin: 0; }
.ed-bpm-label { font-size: 11px; color: var(--muted); letter-spacing: .5px; flex: 0 0 auto; }
.ed-bpm-val { color: var(--brand); font-size: 19px; font-variant-numeric: tabular-nums; line-height: 1; min-width: 42px; text-align: center; flex: 0 0 auto; }
/* 内联步进钮：与「播放」等高（36px），方形圆角 */
.ed-xbtn { min-width: 32px; padding: 0 6px; height: 36px; font-size: 17px; line-height: 1; box-sizing: border-box; flex: 0 0 auto; }
.ed-inline-range { flex: 1 1 auto; min-width: 96px; height: 36px; }
/* 工具栏里的 BPM 滑条：用 #bpm 提权，避免被后面通用的 .mt-range 规则改宽/改高（iPad 上宽度塌陷导致“滑块不见了”） */
.ed-toolbar #bpm { flex: 1 1 auto; width: auto; min-width: 96px; height: 36px; }
.ed-toolbar #bpm::-webkit-slider-runnable-track { height: 9px; border-radius: 6px; background: linear-gradient(90deg, var(--brand), #8fb0ff); }
.ed-toolbar #bpm::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 22px; height: 22px; margin-top: -6.5px; border-radius: 50%; background: #fff; border: 2px solid var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.ed-toolbar #bpm::-moz-range-track { height: 9px; border-radius: 6px; background: linear-gradient(90deg, var(--brand), #8fb0ff); }
.ed-toolbar #bpm::-moz-range-thumb { width: 22px; height: 22px; border: 0; border-radius: 50%; background: #fff; }
.ed-inline-range::-webkit-slider-runnable-track { height: 9px; border-radius: 6px; background: linear-gradient(90deg, var(--brand), #8fb0ff); }
.ed-inline-range::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -6.5px; -webkit-appearance: none; appearance: none; border-radius: 50%; background: #fff; border: 2px solid var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.ed-inline-range::-moz-range-track { height: 9px; border-radius: 6px; }
.ed-inline-range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; }
/* 工具栏内的拍号：实心分段钮，与播放等高（提高特异性以胜过后面的 .mt-sig 规则） */
.ed-toolbar .ed-sig { flex: 0 0 auto; flex-wrap: nowrap; align-items: center; height: auto; box-sizing: border-box; }
.ed-toolbar .ed-sig button { min-width: 0; flex: 0 0 auto; height: 36px; box-sizing: border-box; padding: 0 6px; font-size: 11.5px; font-variant-numeric: tabular-nums; letter-spacing: -0.2px; }
#page-score .page-head { justify-content: flex-end; }

/* Grid */
.gridwrap { padding: 8px 16px 0; flex: 0 0 auto; }
/* 网格多行：每行 4 小节，与鼓谱换行同步（上下一致） */
.grid { display: flex; flex-direction: column; gap: 10px; width: 100%; position: relative; }
.gridrow { display: grid; gap: 2px; width: 100%; }
.gridrow + .gridrow { padding-top: 10px; border-top: 1px dashed var(--line); }
.grid > .cell, .gridrow > .cell { min-width: 0; }
.gridrow.playing-row { background: rgba(108,140,255,.05); }
.cell { border-radius: 5px; }
.cell.label {
  display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--muted);
  font-weight: 600; letter-spacing: .2px; padding-right: 2px;
}
.cell.label i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex: 0 0 8px; }
.corner { font-size: 10.5px; }
.ruler { text-align: center; font-size: 8px; letter-spacing: -.4px; color: var(--muted-3); height: 16px; line-height: 16px; overflow: hidden; }
.ruler.beat { color: var(--brand); font-weight: 700; }
.ruler.clickable { cursor: pointer; border-radius: 3px; }
.ruler.clickable:hover { background: var(--surf-5); }
.ruler.caret { background: rgba(255,110,30,.22); box-shadow: inset 0 0 0 1.5px rgba(255,110,30,.95); color: #ffb27a; }

/* 按拍增删条 */
.ed-timebar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 7px 16px; border-bottom: 1px solid var(--line); background: var(--panel2);
}
.ed-timebar .tb-title { font-size: 12px; font-weight: 600; color: var(--text); }
.ed-timebar .tb-label { font-size: 11px; color: var(--muted); }
.ed-timebar .tb-caret { font-size: 14px; color: var(--brand); font-variant-numeric: tabular-nums; display: inline-block; width: 8.6ch; text-align: center; }
.ed-timebar .tb-caret .c-mk { display: inline-block; width: 6px; text-align: center; font-size: 11.5px; line-height: 1; vertical-align: 1.55px; }
.ed-timebar .tb-hint { font-size: 11px; color: var(--muted); margin-left: auto; }
.ed-unit button { font-variant-numeric: tabular-nums; }

/* 网格上的游标竖线（贯穿）与鼠标悬停虚线 */
.gline { position: absolute; top: 0; pointer-events: none; z-index: 4; display: none; }
.gline.caret-line { border-left: 2px solid rgba(255,110,30,.95); box-shadow: 0 0 6px -1px rgba(255,110,30,.7); }
.gline.hover-line { border-left: 1px dashed rgba(255,150,74,.75); }

.cell.step {
  height: 20px; background: var(--surf-3); border: 1px solid var(--line-2); cursor: pointer;
  position: relative; transition: .08s;
}
.cell.step.beat { background: var(--surf-4); }
.cell.step.bar { border-left: 2px solid var(--line-4); }
.cell.step:hover { border-color: var(--brand); }
.cell.step.on { background: var(--drum, #6c8cff); border-color: transparent; box-shadow: 0 0 10px -2px var(--drum); }
.cell.step.on.accent { box-shadow: 0 0 0 2px #fff inset, 0 0 12px -1px var(--drum); }
.cell.step.on.ghost { opacity: .55; }
.cell.step.playing { outline: 2px solid #ffd166; outline-offset: -1px; z-index: 2; }
/* 唱谱行：每列一个唱字，播放光标扫过时高亮 + 弹跳动画 */
.chant-corner { font-size: 10.5px; color: var(--brand); }
.cell.chant {
  height: 20px; display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; line-height: 1; color: var(--text);
  background: var(--surf-3); border: 1px solid var(--line-2);
  text-shadow: 0 0 6px var(--drum, transparent);
}
.cell.chant.beat { background: var(--surf-4); }
.cell.chant.bar { border-left: 2px solid var(--line-4); }
.cell.chant.empty { color: var(--muted-4); font-weight: 400; }
.cell.chant.playing {
  color: #fff; background: var(--drum, var(--brand));
  border-color: #ffd166; z-index: 2;
  animation: chantPop .14s ease-out;
}
/* 空字不弹跳：只做轻微淡入，保持克制 */
.cell.chant.playing.empty {
  color: var(--muted-2); background: var(--surf-5);
  animation: chantFade .12s ease-out;
}
@keyframes chantPop {
  0% { transform: scale(.92); }
  100% { transform: scale(1); }
}
@keyframes chantFade {
  0% { background: var(--surf-3); }
  100% { background: var(--surf-5); }
}
.hint { display: none; }
.presets-tip { font-size: 11px; color: var(--muted); margin-left: auto; }

/* Presets */
.presets { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 16px 9px; border-top: 1px solid var(--line); flex: 0 0 auto; }
.presets-label { font-size: 12px; color: var(--muted); }
.chip {
  border: 1px solid var(--line); background: var(--surf-3); color: var(--text);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 12.5px; transition: .15s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }

/* Score */
.scorepanel { display: flex; flex-direction: column; }
.score-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel2); }
.score-toolbar h2 { font-size: 14px; margin: 0; flex: 0 0 auto; }
.legend { display: flex; gap: 8px; font-size: 11.5px; color: var(--muted); }
.legend .lg { display: flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; background: var(--surf-2); border: 1px solid var(--line); }
.legend .dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; flex: 0 0 auto; }
.legend .dot.normal { background: var(--muted-2); }
.legend .dot.accent { background: #fff; box-shadow: 0 0 6px rgba(255,255,255,.6); }
.legend .dot.ghost { background: var(--muted-2); opacity: .45; border: 1px dashed #aab3c4; }
.score-host { position: relative; padding: 8px; background: #fff; overflow: auto; min-height: 220px; }
.score-host canvas { display: block; margin: 0 auto; }
.score-hl { position: absolute; pointer-events: none; z-index: 2; }
.score-caret { position: absolute; pointer-events: none; z-index: 3; }
.playhead {
  position: absolute; left: 0; top: 0; width: 2px; height: 100%; background: #e05a5a;
  box-shadow: 0 0 8px #e05a5a; display: none; pointer-events: none; z-index: 3;
  will-change: transform;
}
[data-tick].hit { }
.note-hl { display: none; }

/* Journal */
.log { border-top: 1px solid var(--line); padding: 12px 16px 16px; }
.log-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.log-head h2 { font-size: 14px; margin: 0; }
.log-stats { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.log-stats b { color: var(--brand); }
.log-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.log-list li {
  display: flex; gap: 10px; align-items: center; font-size: 12px;
  background: var(--surf-3); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
.log-list .d { color: var(--brand); font-weight: 600; }
.log-list .m { color: var(--muted); }
.log-list .empty { color: var(--muted); background: transparent; border-style: dashed; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--toast-bg); color: #fff; padding: 10px 18px; border-radius: 10px;
  border: 1px solid var(--line); opacity: 0; pointer-events: none; transition: .25s; z-index: 99;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Practice (歌曲跟练) */
.pt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--panel2); flex-wrap: wrap; }
.pt-head h2 { font-size: 14px; margin: 0; }
.pt-src { display: flex; gap: 8px; flex-wrap: wrap; }
.pt-body { padding: 14px 16px 18px; }
.pt-empty { color: var(--muted); font-size: 12.5px; border: 1px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; }
.pt-name { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 8px; }
.pt-name #ptTrackName { color: var(--text); font-weight: 600; }
.muted { color: var(--muted); }
.pt-scrub { position: relative; }
.pt-scrub input[type=range] { width: 100%; accent-color: var(--brand); margin: 0; }
.pt-loopmark { position: absolute; top: 3px; height: 10px; background: rgba(108,140,255,.35); border-left: 2px solid var(--brand); border-right: 2px solid var(--brand); pointer-events: none; border-radius: 3px; }
.pt-time { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin: 2px 0 12px; }
.pt-controls, .pt-loop { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pt-loop { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.pt-controls .field input[type=range] { width: 150px; }
.pt-mix { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.mix-row { display: flex; align-items: center; gap: 12px; }
.mix-row .chk { min-width: 110px; }
.mix-row input[type=range] { flex: 1; max-width: 260px; accent-color: var(--brand2); }
.btn.light,
.pt-loop .btn.active { background: linear-gradient(180deg,#6c8cff,#4d6ee0); border-color:#5a78e6; color:#fff; }

/* Separation panel */
.tag { font-size: 10.5px; font-weight: 500; color: var(--brand2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; margin-left: 6px; vertical-align: middle; }
.sep-opts { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surf-3); }
.sep-opts .chk input:disabled { opacity: .5; }
.sep-opts select { background: var(--surf-3); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
.sep-status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.dot-on, .dot-off, .dot-run { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 8px; }
.dot-on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot-off { background: #e05a5a; }
.dot-run { background: var(--brand); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* 拖放空态 */
.sep-drop { border: 1.5px dashed var(--line); border-radius: 14px; padding: 30px 20px; text-align: center; transition: border-color .18s, background .18s; }
.sep-drop.drag { border-color: var(--brand); background: rgba(108,140,255,.06); }
.sep-drop-ico { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.sep-drop-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.sep-drop-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 16px; }
.sep-drop-sub2 { font-size: 11.5px; color: var(--muted); margin-top: 14px; }
.sep-drop .btn { display: inline-block; }

.sep-progress { height: 6px; background: var(--surf-3); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.sep-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand2), var(--brand)); transition: width .25s; }
.sep-elapsed { font-size: 11.5px; color: var(--muted); margin-bottom: 12px; }

.sep-result { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.sep-result-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 2px; }
.sep-result-name { font-size: 13px; font-weight: 600; }
.sep-row { display: flex; align-items: center; gap: 12px; }
.sep-rname { min-width: 74px; font-size: 12.5px; font-weight: 600; }
.sep-row audio { flex: 1; min-width: 0; height: 34px; }
.sep-row .sep-dl { flex: 0 0 auto; text-decoration: none; }
.sep-actions { display: flex; gap: 10px; padding-top: 14px; margin-top: 4px; border-top: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.sep-note { font-size: 11.5px; margin-top: 6px; }
.sep-more { margin-left: auto; }

/* Metronome */
/* 尺寸随视口高度缩放（iPad 上把四边空间用起来）；竖屏另有一档放大 */
#page-metronome {
  --mt-bpm: min(13vh, 190px);
  --mt-dot: min(2.4vh, 28px);
  --mt-lamp-h: min(8vh, 110px);
  --mt-chip: min(6.4vh, 92px);
  --mt-ctl: min(5vh, 74px);
  --mt-step: min(6.2vh, 96px);
  --mt-gap: min(2vh, 40px);
  --mt-pad: min(2.6vh, 38px);
  --mt-thumb: min(3.6vh, 52px);
  --mt-track: min(1.7vh, 22px);
  --mt-sw: min(4.4vh, 64px);
  --mt-fs-term: min(1.6vh, 19px);
  --mt-fs-num: min(2vh, 24px);
  --mt-fs-small: min(1.4vh, 17px);
}
@media (orientation: portrait) {
  #page-metronome {
    --mt-bpm: min(13.5vh, 190px);
    --mt-dot: min(2.8vh, 32px);
    --mt-lamp-h: min(8.5vh, 118px);
    --mt-chip: min(6.6vh, 92px);
    --mt-ctl: min(5.2vh, 78px);
    --mt-step: min(6.4vh, 100px);
    --mt-gap: min(2.2vh, 44px);
    --mt-pad: min(2.6vh, 40px);
    --mt-thumb: min(4vh, 56px);
    --mt-sw: min(5vh, 72px);
    /* 竖屏字级不放大：保证「看谱练习」7 档仍是一行（放大的是 BPM/灯/按钮/按钮高度） */
    --mt-fs-term: min(1.4vh, 17px);
    --mt-fs-num: min(2vh, 24px);
    --mt-fs-small: min(1.3vh, 15px);
  }
}
.mt-panel { max-width: 100%; margin: 0 auto; }
.mt-head { display: flex; flex-direction: column; align-items: stretch; width: 100%; gap: min(1.2vh, 16px); }
.mt-head .mt-dots { align-self: stretch; }
.mt-head .mt-head-ctls { display: inline-flex; align-items: center; justify-content: flex-end; gap: min(1.6vh, 22px); }
/* 提示灯分段控件（与「强调第一拍」同组，都在节拍器头部） */
.mt-head .mt-lamp { flex: 0 0 auto; }
/* 提示灯三档：做成与「强调第一拍」开关协调的全圆角 pill 分段（同高、同圆角、同激活色） */
.mt-head .mt-lamp {
  border: 1px solid var(--line); border-radius: 999px; overflow: hidden;
  background: var(--surf-3); display: inline-flex; align-items: center; height: calc(var(--mt-sw, 44px) * .62);
}
.mt-head .mt-lamp button {
  flex: 0 0 auto; min-width: 0; padding: 0 min(1.6vh, 20px); box-sizing: border-box;
  height: 100%; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--muted);
  font-size: var(--mt-fs-term, 12.5px); cursor: pointer; transition: .18s; white-space: nowrap;
}
.mt-head .mt-lamp button:last-child { border-right: 0; }
.mt-head .mt-lamp button:hover { color: var(--text); }
.mt-head .mt-lamp button.active { background: rgba(108,140,255,.22); color: var(--brand); font-weight: 600; }
/* 开关按钮（强调第一拍） */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: var(--mt-sw, 44px); height: calc(var(--mt-sw, 44px) * .6); border-radius: 999px; background: var(--line-3); border: 1px solid var(--line);
  position: relative; transition: .18s; flex: 0 0 auto;
}
.switch-thumb {
  position: absolute; top: calc(var(--mt-sw, 44px) * .075); left: calc(var(--mt-sw, 44px) * .075);
  width: calc(var(--mt-sw, 44px) * .45); height: calc(var(--mt-sw, 44px) * .45); border-radius: 50%;
  background: var(--sw-thumb); transition: .18s;
}
.switch input:checked + .switch-track { background: rgba(108,140,255,.35); border-color: var(--brand); }
.switch input:checked + .switch-track .switch-thumb { left: calc(100% - var(--mt-sw, 44px) * .525); background: var(--brand); box-shadow: 0 0 10px rgba(108,140,255,.7); }
.switch-label { font-size: var(--mt-fs-term, 12.5px); color: var(--muted); white-space: nowrap; }
.switch input:checked ~ .switch-label { color: var(--text); }
.mt-stage {
  display: flex; flex-direction: column; align-items: center; justify-content: space-evenly;
  flex: 1 1 auto; gap: var(--mt-gap, 18px); padding: var(--mt-pad, 28px) min(3vw, 40px) min(2.4vh, 34px);
}
.mt-dots { display: flex; gap: min(1.2vh, 14px); width: 100%; align-items: stretch; height: var(--mt-lamp-h, 110px); }
/* 灯条：横向铺满的圆角矩形，每拍一条；三档尺寸统一（都占满容器高度），只从光效强度区分 */
.mt-dot { flex: 1 1 0; min-width: 0; height: 100%; border-radius: min(1.4vh, 16px); background: var(--line-3); transition: background .12s, box-shadow .12s, opacity .12s; }
.mt-dot.down { background: var(--line-4); }
.mt-dot.on { background: var(--brand); box-shadow: 0 0 14px var(--brand); }
.mt-dot.down.on { background: #ffd166; box-shadow: 0 0 16px #ffd166; }
/* 反拍（拍内细分）：弱亮，亮度/光晕弱于正拍，一眼区分正反拍 */
.mt-dot.on.sub { background: var(--brand); opacity: .45; box-shadow: none; }
.mt-dot.down.on.sub { background: #ffd166; opacity: .45; box-shadow: none; }
/* 提示灯强度三档 —— 尺寸完全一致（都占满），仅从灯光效果强度区分 */
/* 标准：正常亮度与光晕 */
#page-metronome[data-lamp="normal"] .mt-dot { background: var(--line-3); }
#page-metronome[data-lamp="normal"] .mt-dot.down { background: var(--line-4); }
#page-metronome[data-lamp="normal"] .mt-dot.on { background: var(--brand); box-shadow: 0 0 14px var(--brand); }
#page-metronome[data-lamp="normal"] .mt-dot.down.on { background: #ffd166; box-shadow: 0 0 16px #ffd166; }
/* 大灯：更亮 + 闪烁 + 双层强光晕，熄灭态也加亮，醒目耀眼 */
#page-metronome[data-lamp="big"] .mt-dot { background: var(--line-2); }
#page-metronome[data-lamp="big"] .mt-dot.down { background: var(--line-3); }
#page-metronome[data-lamp="big"] .mt-dot.on {
  background: #fff; box-shadow: 0 0 40px var(--brand), 0 0 18px var(--brand), 0 0 6px #fff;
  animation: lampBlink .5s ease-in-out infinite alternate;
}
#page-metronome[data-lamp="big"] .mt-dot.down.on {
  background: #fff; box-shadow: 0 0 44px #ffd166, 0 0 20px #ffd166, 0 0 8px #fff;
  animation: lampBlink .5s ease-in-out infinite alternate;
}
/* 浅色主题大灯：白底上改用「暗黑核」（深色灯体）+ 品牌色光晕，最内层高亮光晕用黑色 */
[data-theme="light"] #page-metronome[data-lamp="big"] .mt-dot.on {
  background: #171b22;
  box-shadow: 0 0 40px var(--brand), 0 0 18px var(--brand), 0 0 6px #000;
  animation: lampBlink .5s ease-in-out infinite alternate;
}
[data-theme="light"] #page-metronome[data-lamp="big"] .mt-dot.down.on {
  background: #b26a00;
  box-shadow: 0 0 44px #ffd166, 0 0 20px #ffd166, 0 0 8px #000;
  animation: lampBlink .5s ease-in-out infinite alternate;
}
/* 反拍在亮色大灯下同样弱亮（蓝/金），压过上面的白核正拍 */
[data-theme="light"] #page-metronome[data-lamp="big"] .mt-dot.on.sub {
  background: var(--brand); opacity: .45; box-shadow: none; animation: none;
}
[data-theme="light"] #page-metronome[data-lamp="big"] .mt-dot.down.on.sub {
  background: #ffd166; opacity: .45; box-shadow: none; animation: none;
}
@keyframes lampBlink {
  from { opacity: .72; filter: brightness(1); }
  to   { opacity: 1; filter: brightness(1.5); }
}
/* 盲听：灯几乎无光，只留极淡轮廓呼吸，逼自己靠耳朵 */
#page-metronome[data-lamp="blind"] .mt-dot { background: transparent; box-shadow: inset 0 0 0 1px var(--line-3); }
#page-metronome[data-lamp="blind"] .mt-dot.down { background: transparent; box-shadow: inset 0 0 0 1px var(--line-4); }
#page-metronome[data-lamp="blind"] .mt-dot.on { background: var(--muted-3); box-shadow: inset 0 0 0 1px var(--muted-3); opacity: .5; }
#page-metronome[data-lamp="blind"] .mt-dot.down.on { background: var(--muted-3); box-shadow: inset 0 0 0 1px var(--muted-3); opacity: .6; }
/* 反拍（拍内细分）在任意档位都弱亮：关掉闪烁动画，降到低透明度，光晕消失 */
#page-metronome .mt-dot.on.sub {
  background: var(--brand); opacity: .45; box-shadow: none; animation: none;
}
#page-metronome .mt-dot.down.on.sub {
  background: #ffd166; opacity: .45; box-shadow: none; animation: none;
}
#page-metronome[data-lamp="blind"] .mt-dot.on.sub { opacity: .28; }
#page-metronome[data-lamp="blind"] .mt-dot.on.sub,
#page-metronome[data-lamp="blind"] .mt-dot.down.on.sub { background: var(--muted-3); }
.mt-bpm { display: flex; align-items: center; gap: 20px; }
.mt-bpm-num { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.mt-bpm-num b { font-size: var(--mt-bpm, 72px); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.mt-bpm-num small { font-size: var(--mt-fs-small, 12px); color: var(--muted); letter-spacing: 2px; margin-top: min(.6vh, 8px); }
.mt-step {
  width: var(--mt-step, 50px); height: var(--mt-step, 50px); flex: 0 0 auto; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font-size: calc(var(--mt-step, 50px) * .5); line-height: 1; cursor: pointer; transition: .15s;
}
.mt-step:hover { border-color: var(--brand); color: var(--brand); }
.mt-step:active { transform: translateY(1px); }
/* 大触区滑条：加高轨道 + 大号拇指 */
.mt-sliderrow { display: flex; align-items: center; gap: min(1.9vh, 26px); width: min(92%, 880px); }
.mt-range { flex: 1 1 auto; width: auto; height: 30px; -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; }
.mt-range::-webkit-slider-runnable-track { height: 12px; border-radius: 7px; background: linear-gradient(90deg, var(--brand), #8fb0ff); }
/* 节拍器页专用：滑条随视口放大（其它页面共用 .mt-range，保持原尺寸） */
#page-metronome .mt-range { height: max(30px, var(--mt-thumb)); }
#page-metronome .mt-range::-webkit-slider-runnable-track { height: var(--mt-track); border-radius: 999px; }
#page-metronome .mt-range::-webkit-slider-thumb { width: var(--mt-thumb); height: var(--mt-thumb); margin-top: calc((var(--mt-track) - var(--mt-thumb)) / 2); }
#page-metronome .mt-range::-moz-range-track { height: var(--mt-track); border-radius: 999px; }
#page-metronome .mt-range::-moz-range-thumb { width: var(--mt-thumb); height: var(--mt-thumb); }
.mt-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 30px; height: 30px; margin-top: -9px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 10px rgba(0,0,0,.5), 0 0 0 5px rgba(108,140,255,.22);
}
.mt-range::-moz-range-track { height: 12px; border-radius: 7px; background: linear-gradient(90deg, var(--brand), #8fb0ff); }
.mt-range::-moz-range-thumb { width: 30px; height: 30px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 3px 10px rgba(0,0,0,.5); }
/* 常用速度预设 */
.mt-preset-wrap { display: flex; flex-direction: column; align-items: stretch; gap: min(1.2vh, 18px); width: 100%; }
/* 手机版（窄屏）：隐藏快捷速度预设按钮，节拍器更简洁，速度靠滑杆/加减调节 */
@media (max-width: 600px) {
  .mt-preset-wrap { display: none; }

  /* 「强调第一拍」开关 + 提示灯（大灯）居中 */
  .mt-head .mt-head-ctls { justify-content: center; }

  /* 滑动条加宽占满整行，± 按钮换到下一行居中 */
  .mt-sliderrow {
    flex-wrap: wrap;
    justify-content: center;
    gap: min(2.5vh, 20px);
    width: min(96%, 560px);
  }
  .mt-sliderrow .mt-range { flex: 1 1 100%; order: 1; }
  .mt-sliderrow .mt-step { order: 2; }

  /* 隐藏「拍号」「细分节奏」标签文字，分段控件直接占满整行 */
  .mt-field > label { display: none; }

  /* 左上角 logo 只保留图标，隐藏文字（DrumLab Lite + 页面副标题） */
  .brand .brand-txt { display: none; }
}
/* 三套预设同时展开（分组）：左侧标签 + 右侧按钮组，整体吃满宽度 */
.mt-preset-groups { display: flex; flex-direction: column; gap: min(1.2vh, 18px); width: 100%; }
.mt-preset-group { display: flex; align-items: center; gap: min(1.4vh, 22px); }
.mt-preset-group .mt-group-label { flex: 0 0 auto; white-space: nowrap; text-align: right; font-size: var(--mt-fs-term, 12px); font-weight: 600; color: var(--muted); line-height: 1.15; }
.mt-presets { flex: 1 1 auto; display: flex; gap: min(1vh, 14px); flex-wrap: wrap; justify-content: flex-start; align-items: stretch; }
.mt-presets .mt-preset { flex: 1 1 0; min-width: 54px; }   /* 术语档按内容自适应宽度：竖屏也能 7 档一行 */
.mt-preset {
  padding: min(1.9vh, 18px) min(1.2vw, 15px); border-radius: 10px; border: 1px solid var(--line); background: var(--panel2);
  color: var(--text); font-size: var(--mt-fs-term, 13px); font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; transition: .15s;
  min-height: var(--mt-chip, 46px); display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
}
.mt-preset:hover { border-color: var(--brand); }
.mt-preset.active { background: rgba(108,140,255,.18); border-color: var(--brand); color: var(--brand); }
.mt-playrow { display: flex; gap: min(1.6vh, 24px); align-items: center; }
.btn.big { font-size: max(16px, var(--mt-fs-num, 16px)); padding: min(1.7vh, 22px) min(4.6vh, 60px); min-width: min(24vh, 260px); }
/* 底部控件：标签定宽右对齐 + 按钮组等分撑满 → 两组左右边缘严格对齐 */
.mt-controls {
  display: flex; flex-direction: column; gap: min(1.2vh, 18px); align-items: stretch;
  padding: min(2.4vh, 32px) min(3vw, 40px); border-top: 1px solid var(--line); background: var(--panel2);
}
.mt-field { display: flex; align-items: center; gap: min(1.4vh, 22px); }
.mt-field > label {
  flex: 0 0 min(7.6vh, 108px); width: min(7.6vh, 108px); text-align: right; font-size: var(--mt-fs-term, 12px); color: var(--muted);
  letter-spacing: .3px; white-space: nowrap;
}
.mt-field .segmented { flex: 1 1 auto; min-width: 0; align-self: stretch; min-height: var(--mt-ctl, 38px); }
.mt-sig, .mt-subdiv, .mt-lamp { display: flex; flex-wrap: nowrap; flex: 1 1 auto; }
.mt-sig button, .mt-subdiv button, .mt-lamp button { flex: 1 1 0; min-width: 0; padding: 0 min(.7vw, 6px); box-sizing: border-box; height: var(--mt-ctl, 38px); display: inline-flex; align-items: center; justify-content: center; }
.mt-sig button { font-size: var(--mt-fs-term, 13px); font-variant-numeric: tabular-nums; }
.mt-subdiv button { font-size: var(--mt-fs-num, 15px); }
.mt-lamp button { font-size: var(--mt-fs-term, 13px); }
.mt-preset-labeled { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; padding: min(1.2vh, 14px) min(.8vw, 12px); }
.mt-preset-labeled .mt-term { font-size: var(--mt-fs-term, 12.5px); font-weight: 600; }
.mt-presets .mt-preset-plain { font-size: var(--mt-fs-num, 15px); }   /* 与「看谱练习」术语组视觉等重 */
.mt-preset-labeled .mt-sub { display: inline-flex; align-items: baseline; gap: 4px; margin-top: 2px; }
.mt-preset-labeled .mt-cn { font-size: var(--mt-fs-small, 10.5px); color: var(--brand); opacity: .95; letter-spacing: .2px; }
.mt-preset-labeled .mt-num { font-size: var(--mt-fs-small, 10.5px); opacity: .6; font-variant-numeric: tabular-nums; }
#page-metronome .hint { text-align: center; font-size: var(--mt-fs-small, 11.5px); padding: min(1.2vh, 16px) 20px min(1.6vh, 22px); }
#page-metronome .hint.warn { color: #e0a020; font-weight: 600; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button {
  border: 0; background: var(--surf-3); color: var(--muted); padding: 6px 12px;
  cursor: pointer; font-size: 12px; border-right: 1px solid var(--line); transition: .15s;
}
.segmented button:last-child { border-right: 0; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: rgba(108,140,255,.16); color: var(--brand); font-weight: 600; }

/* 矮视口（横屏 iPad 1024×768 等）：压缩编辑器，给鼓谱预览让出高度 */
@media (max-height: 800px) {
  .editor-head { padding: 6px 16px; }
  .ed-toolbar { padding: 6px 12px; }
  .gridwrap { padding: 6px 16px 0; }
  .cell.step { height: 16px; }
  .cell.chant { height: 16px; font-size: 10.5px; }
  .presets { padding: 6px 16px 7px; }
  .chip { padding: 4px 9px; }
  .rowpicker { gap: 5px; }
  .rowpick { padding: 3px 8px; font-size: 11px; }
}

/* 增删节拍条：窄屏隐藏说明文字，保证单行不换行 */
@media (max-width: 980px) {
  .ed-timebar .tb-hint { display: none; }
}

/* 窄屏（iPad 竖屏）：压缩鼓谱工具栏，保证一行放得下。
   不放不下时工具栏是横向可滚的 → 控件会被滚出视野（用户报「BPM 滑块不见了」就是这个）*/
@media (max-width: 900px) {
  .ed-toolbar { gap: 2px; padding: 6px 8px; }
  .ed-toolbar .ed-sig button { padding: 0 3px; font-size: 10.5px; letter-spacing: -0.4px; }
  .switch-btn { padding: 0 8px; gap: 5px; font-size: 12px; }
  .ed-bpm-label { font-size: 10px; letter-spacing: 0; }
  .ed-bpm-val { font-size: 17px; min-width: 36px; }
  .ed-xbtn { min-width: 28px; }
  .ed-toolbar #bpm { min-width: 76px; }
  .ed-sep { margin: 0 1px; }
}
/* 更窄（iPad mini 竖屏等）：再挤一点，保证 10 个拍号按钮全在一行内 */
@media (max-width: 800px) {
  .ed-toolbar .ed-sig button { padding: 0 2px; font-size: 10px; }
  .ed-toolbar #bpm { min-width: 64px; }
  .switch-btn { padding: 0 7px; gap: 4px; }
}

/* 网格最右侧「末尾」列（终止线 ‖）：每行都有；末行为真正的曲末位置 */
.ruler.endcol { color: var(--muted-4); font-size: 12px; letter-spacing: 0; font-weight: 700; }
.ruler.endcol.caret { background: rgba(255,110,30,.22); box-shadow: inset 0 0 0 1.5px rgba(255,110,30,.95); color: #ffb27a; }
.cell.endcol {
  border-left: 1px dashed var(--line-4); cursor: pointer;
  background: repeating-linear-gradient(135deg, var(--stripe) 0 4px, transparent 4px 8px);
}
.cell.endcol:hover { border-color: var(--brand); background: rgba(255,110,30,.07); }
.ed-unit button:disabled { opacity: .4; cursor: default; }

/* iPad：长按 = 右键（禁用文本选择与系统长按菜单） */
#grid { touch-action: manipulation; }
#grid .step, #grid .ruler, #grid .cell, #grid .endcol {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.ed-timebar .tb-hint-touch { display: none; }
@media (hover: none) {
  .ed-timebar .tb-hint-touch { display: inline; margin-left: 8px; color: var(--brand); }
}

/* ============ 手机窄屏：鼓谱页改为文字提示，引导用大屏 ============ */
/* 默认隐藏（hidden 属性），只在手机断点内显示；基础样式不设 display，避免覆盖 hidden */
.score-mobile-hint {
  flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 6px; height: 100%; min-height: 60vh; padding: 24px;
}
.score-mobile-hint .smh-icon { font-size: 52px; line-height: 1; }
.score-mobile-hint .smh-title { font-size: 18px; font-weight: 700; margin: 12px 0 0; color: var(--text); }
.score-mobile-hint .smh-desc { font-size: 14px; line-height: 1.7; color: var(--muted); margin: 0; }

@media (max-width: 600px) {
  #page-score .score-mobile-hint { display: flex !important; }
  #page-score .page-head,
  #page-score .score-view,
  #page-score .editor { display: none !important; }
}
