/* 映谱 · 简谱动态谱生成平台
   版式：夜里的声乐排练室。乌木琴漆一样的暖黑做外框，正中一张被台灯照亮的宣白谱纸。
   颜色只有三种意思：象牙白 = 主操作与激活态；朱砂 = 走谱游标、印章、当前音符；琥珀鎏金 = 小节旗标、强拍、分轨高亮。
   电脑（宽 ≥ 1100）：单屏三栏工作台，100dvh、整页不滚动，只有侧栏与谱纸内部滚动。
   手机 / 平板（宽 < 1100）：单栏，整页上下滚动；顶部三步大按钮、画布全宽、操作卡片在下方、底部固定大播放条。
   适老：正文字号 ≥ 14px、说明 ≥ 16px、主按钮 18px；深底文字对比度按 7:1 选色；按钮点按区 ≥ 44px。 */

:root {
  --bg-0: #0c0b0a;
  --bg-1: #131210;
  --bg-2: #1a1916;
  --bg-3: #23211d;
  --bg-4: #2d2a25;
  --line: rgba(255, 241, 222, 0.08);
  --line-2: rgba(255, 241, 222, 0.12);
  --line-3: rgba(255, 241, 222, 0.2);
  /* 文字色：在最浅的卡片底 --bg-3 上也 ≥ 7:1（tests 外的 contrast 脚本核算过） */
  --text-0: #f6f2ea;
  --text-1: #e8e2d8;
  --text-2: #d4ccbf;
  --text-3: #c2b9ab;
  /* 朱砂当文字用时换成亮珊瑚色（深底上 ≥ 7:1） */
  --coral: #ffb4a8;

  --ivory: #efe7d8;
  --ivory-hi: #fffaf0;
  --on-ivory: #17140f;
  --cinnabar: #c83228;
  --cinnabar-hi: #e0503f;
  --cinnabar-soft: rgba(200, 50, 40, 0.16);
  --amber: #f1b45c;
  --amber-soft: rgba(241, 180, 92, 0.14);
  --amber-line: rgba(241, 180, 92, 0.45);

  --paper: #fbf8f1;
  --paper-ink: #16140f;

  --serif: 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', 'STSong', 'SimSun', serif;
  --ui: 'Microsoft YaHei UI', 'PingFang SC', 'Noto Sans SC', system-ui, sans-serif;
  --mono: 'Cascadia Mono', 'JetBrains Mono', Consolas, monospace;

  --top-h: 64px;
  --outline-w: 272px;
  --inspector-w: 340px;
  --transport-h: 148px;
  --radius: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text-0);
  font: 15px/1.6 var(--ui);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.38; }
:focus-visible { outline: 1.5px solid var(--ivory); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--cinnabar-soft); }
[hidden] { display: none !important; }
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* 细滚动条：暖白半透明滑块、透明轨道，不出现系统原生亮白滚动条 */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 241, 222, 0.15); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 241, 222, 0.28); }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: rgba(255, 241, 222, 0.15) transparent; }
}

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); font-weight: 400; }
.eyebrow {
  margin: 0;
  font: 500 14px/1 var(--ui);
  letter-spacing: 0.24em;
  color: var(--text-2);
}

/* ---------------- 整体网格 ---------------- */
.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--outline-w) minmax(0, 1fr) var(--inspector-w);
  grid-template-rows: var(--top-h) minmax(0, 1fr) var(--transport-h);
  grid-template-areas:
    'top top top'
    'outline stage inspector'
    'transport transport transport';
}

/* ---------------- 顶部栏 ---------------- */
.topbar {
  grid-area: top;
  display: grid;
  grid-template-columns: var(--outline-w) 1fr auto;
  align-items: center;
  padding: 0 16px 0 18px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-seal {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--cinnabar);
  color: #fff4e6;
  font: 700 19px/1 var(--serif);
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px rgba(255, 238, 214, 0.55), inset 0 0 0 3px var(--cinnabar);
  transform: rotate(-3deg);
}
.brand-text { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.brand-text strong { font: 600 19px/1 var(--serif); letter-spacing: 0.12em; color: var(--ivory-hi); }
.brand-text span { font-size: 15px; letter-spacing: 0.14em; color: var(--text-2); }

.phase-switch {
  justify-self: center;
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.phase {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text-2);
  font-size: 16px;
  letter-spacing: 0.04em;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}
.phase i { font-style: normal; font-family: var(--serif); font-size: 19px; color: var(--text-3); }
.phase .ph-name { font-size: 17px; font-weight: 600; letter-spacing: 0.06em; }
.phase .ph-sub { font-size: 14px; color: var(--text-3); letter-spacing: 0.02em; }
.phase.active .ph-sub { color: var(--text-1); }
.phase:hover { color: var(--text-0); }
.phase.active { background: var(--bg-3); color: var(--ivory-hi); box-shadow: inset 0 0 0 1px var(--line-2); }
.phase.active i { color: var(--amber); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.engine-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-size: 14px;
  color: var(--text-1);
  white-space: nowrap;
}
.engine-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-2); }
.engine-badge[data-state='gpu'] { border-color: var(--amber-line); color: var(--amber); background: var(--amber-soft); }
.engine-badge[data-state='gpu'] .dot { background: #ffcf7f; box-shadow: 0 0 0 3px rgba(241, 180, 92, 0.2), 0 0 10px var(--amber); animation: glow 2.4s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px rgba(241, 180, 92, 0.08), 0 0 14px var(--amber); } }
.engine-badge[data-state='busy'] .dot { background: var(--cinnabar-hi); animation: pulse 1s ease-in-out infinite; }
.engine-badge[data-state='probing'] .dot { background: var(--text-1); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

/* ---------------- 按钮 ---------------- */
.btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 16px;
  letter-spacing: 0.03em;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease), transform 0.12s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-ivory { background: var(--ivory); color: var(--on-ivory); font-weight: 600; }
.btn-ivory:hover:not(:disabled) { background: var(--ivory-hi); }
.btn-ghost { background: var(--bg-3); border-color: var(--line); color: var(--text-1); }
.btn-ghost:hover:not(:disabled) { border-color: var(--line-3); color: var(--text-0); }
.btn-danger:hover:not(:disabled) { border-color: rgba(200, 50, 40, 0.6); color: var(--coral); }
.btn-main { min-height: 52px; font-size: 18px; }
.btn-help { min-height: 44px; padding: 0 14px; border: 1px solid var(--amber-line); background: var(--amber-soft); color: var(--amber); font-weight: 600; white-space: nowrap; }
.btn-help:hover { background: rgba(241, 180, 92, 0.24); }
.btn-block { width: 100%; }
.btn-mini { min-height: 44px; padding: 0 10px; font-size: 14px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 6px; color: var(--text-1); }
#btnExportTop { min-height: 44px; padding: 0 18px; white-space: nowrap; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row > .btn { flex: 1 1 auto; }

/* ---------------- 左侧：曲目铭牌 + 唱段导航 ---------------- */
.outline {
  grid-area: outline;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-1);
  border-right: 1px solid var(--line);
}
.plate {
  margin: 14px 14px 6px;
  padding: 16px 16px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background:
    linear-gradient(160deg, rgba(241, 180, 92, 0.07), transparent 55%),
    var(--bg-2);
}
.plate-title { margin: 8px 0 2px; font: 600 18px/1.35 var(--serif); color: var(--ivory-hi); letter-spacing: 0.04em; }
.plate-sub { margin: 0 0 12px; font-size: 14px; color: var(--text-2); }
.plate-grid { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; border-top: 1px solid var(--line); }
.plate-grid > div { padding: 10px 0 0; }
.plate-grid > div + div { border-left: 1px solid var(--line); padding-left: 10px; }
.plate-grid dt { font-size: 14px; color: var(--text-3); letter-spacing: 0.16em; }
.plate-grid dd { margin: 2px 0 0; font: 600 16px/1.2 var(--serif); color: var(--text-0); }

.outline-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 8px; }
.outline-count { font: 14px var(--mono); color: var(--text-3); }
.outline-list { list-style: none; margin: 0; padding: 0 8px 12px; overflow-y: auto; flex: 1; min-height: 0; }
.outline-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 6px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.2s var(--ease);
}
.outline-item:hover { background: var(--bg-2); }
.outline-item.selected { border-color: var(--line-2); background: var(--bg-2); }
.outline-item.active { background: var(--bg-3); border-color: rgba(200, 50, 40, 0.45); }
.oi-no {
  grid-row: span 2;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  font: 600 15px/1 var(--serif);
  color: var(--text-1);
}
.outline-item.active .oi-no { background: var(--cinnabar); border-color: var(--cinnabar); color: #fff4e6; }
.oi-bars { font-size: 15px; color: var(--text-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.oi-time { font: 14px var(--mono); color: var(--text-2); }
.oi-density { grid-column: 2 / 4; position: relative; height: 12px; border-bottom: 1px solid var(--line); }
.oi-density i {
  position: absolute;
  bottom: 0;
  width: 2px;
  border-radius: 1px 1px 0 0;
  background: var(--text-2);
}
.oi-density i.rest { background: var(--text-3); }
.oi-density i.dash { background: var(--line-3); }
.oi-density b { position: absolute; top: -1px; bottom: -1px; width: 1px; background: var(--amber-line); }
.outline-item.active .oi-density i { background: var(--ivory); }
.outline-empty { padding: 18px 12px; font-size: 15px; color: var(--text-3); }

/* ---------------- 中央主舞台 ---------------- */
.stage {
  grid-area: stage;
  position: relative;
  display: grid;
  grid-template-rows: 50px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(ellipse 70% 60% at 50% 38%, rgba(255, 214, 150, 0.075), transparent 70%),
    var(--bg-0);
}
.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(19, 18, 16, 0.96), rgba(12, 11, 10, 0.9));
  white-space: nowrap;
  overflow: hidden;
}
.seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--bg-0); border: 1px solid var(--line); border-radius: 8px; }
.seg-btn {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-2);
  font-size: 15px;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.seg-btn:hover:not(:disabled):not(.active) { color: var(--text-0); background: var(--bg-2); }
.seg-btn.active { background: var(--ivory); color: var(--on-ivory); font-weight: 600; }
.seg-quiet .seg-btn.active { background: var(--bg-4); color: var(--ivory-hi); font-weight: 500; box-shadow: inset 0 0 0 1px var(--line-2); }
/* 禁用态不靠整体降透明度，避免象牙底变成灰底灰字 */
.seg-btn:disabled { opacity: 1; color: #857e73; background: none; }
.seg-btn.active:disabled { background: var(--bg-3); color: var(--text-1); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg-block { display: flex; }
.seg-block .seg-btn { flex: 1; min-height: 46px; font-size: 16px; }

.switch { display: inline-flex; align-items: center; gap: 8px; padding: 0 8px; font-size: 15px; color: var(--text-1); cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { width: 30px; height: 18px; border-radius: 999px; background: var(--bg-4); position: relative; transition: background 0.2s; }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--text-2); transition: transform 0.2s var(--ease), background 0.2s; }
.switch input:checked + .switch-track { background: rgba(241, 180, 92, 0.3); }
.switch input:checked + .switch-track .switch-knob { transform: translateX(12px); background: var(--amber); }
.switch input:focus-visible + .switch-track { outline: 1.5px solid var(--ivory); outline-offset: 2px; }

.stage-body { position: relative; min-height: 0; overflow: hidden; }
.editor-wrap {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px 36px 48px;
}
.paper {
  position: relative;
  max-width: 880px;
  margin: 0 auto;
  border-radius: 3px;
  background: var(--paper);
  box-shadow:
    0 0 0 1px rgba(255, 241, 222, 0.06),
    0 30px 60px -20px rgba(0, 0, 0, 0.7),
    0 0 120px rgba(255, 214, 150, 0.08);
}
.paper::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 3px;
  background: radial-gradient(ellipse 80% 55% at 50% 20%, rgba(255, 236, 200, 0.18), transparent 70%), radial-gradient(ellipse at 50% 120%, rgba(60, 40, 20, 0.12), transparent 60%);
  mix-blend-mode: multiply;
}
.paper.empty { display: none; }
#editorCanvas { display: block; width: 100%; height: auto; border-radius: 3px; }

.empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  color: var(--text-2);
  padding: 0 40px;
}
.empty-seal {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border: 2px solid var(--cinnabar);
  color: var(--cinnabar);
  font: 700 34px/1 var(--serif);
  border-radius: 6px;
  transform: rotate(-4deg);
  opacity: 0.85;
}
.empty-title { margin: 0; font: 600 26px/1.4 var(--serif); color: var(--text-0); letter-spacing: 0.06em; }
.empty-hint p { margin: 0; }
/* 空状态大卡片：第 1 步最显眼，示范曲是次要按钮 */
.empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 520px;
  padding: 30px 30px 26px;
  border: 1px solid var(--amber-line);
  border-radius: 18px;
  background: radial-gradient(120% 90% at 50% 0%, rgba(241, 180, 92, 0.1), transparent 65%), rgba(26, 25, 22, 0.92);
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.9);
}
.empty-step { font: 700 16px/1 var(--ui); letter-spacing: 0.3em; color: var(--amber); }
.empty-desc { font-size: 17px; line-height: 1.7; color: var(--text-1); }
.btn-hero { display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 60px; margin-top: 14px; padding: 0 20px; font-size: 20px; cursor: pointer; box-shadow: 0 16px 34px -16px rgba(239, 231, 216, 0.6); }
.btn-hero:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
.btn-hero-2 { width: 100%; min-height: 50px; font-size: 17px; }

.preview-wrap { position: absolute; inset: 0; display: grid; place-items: center; padding: 22px 24px; }
.preview-frame {
  position: relative;
  height: 100%;
  aspect-ratio: 9 / 16;
  max-width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 1px var(--line-2), 0 0 0 7px #080706, 0 0 0 8px var(--line), 0 40px 80px -24px rgba(0, 0, 0, 0.85);
}
/* 画布的 CSS 尺寸与位置由 app.js 按「后备尺寸 ÷ 设备像素比」写死：一个画布像素正好对一个屏幕像素，在框里居中 */
#previewCanvas { position: absolute; left: 0; top: 0; display: block; width: 100%; height: 100%; }
.hud {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 11px;
  background: rgba(12, 11, 10, 0.72);
  border: 1px solid rgba(255, 241, 222, 0.12);
  border-radius: 8px;
  pointer-events: none;
}
.hud-right { top: auto; bottom: 12px; left: auto; right: 12px; flex-direction: row; font-size: 14px; color: var(--amber); } /* 右上角让给印章 */
.hud-bar { font: 600 15px/1.3 var(--serif); color: var(--ivory-hi); letter-spacing: 0.06em; }
.hud-note { font-size: 14px; color: var(--coral); }

/* ---------------- 右侧检查器 ---------------- */
.inspector {
  grid-area: inspector;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg-1);
  border-left: 1px solid var(--line);
}
.panel { padding: 18px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.panel-head { margin-bottom: 2px; }
.panel-head h3 { margin: 6px 0 0; font: 600 21px/1.3 var(--serif); letter-spacing: 0.06em; color: var(--ivory-hi); }
.panel-lead { margin: 6px 0 0; font-size: 16px; line-height: 1.55; color: var(--text-1); }
.hint { margin: 0; font-size: 16px; line-height: 1.65; color: var(--text-2); }
.group-title { margin: 6px 0 0; font-size: 14px; font-weight: 600; letter-spacing: 0.12em; color: var(--text-1); }
.field-group { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }

/* 上传卡片：暗金微光的拖放区，原生文件控件隐藏 */
.drop-card {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 72px;
  padding: 12px 14px;
  border: 1px dashed rgba(241, 180, 92, 0.28);
  border-radius: 10px;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(241, 180, 92, 0.09), transparent 60%),
    var(--bg-2);
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.drop-card:hover, .drop-card.dragover { border-color: var(--amber-line); box-shadow: 0 0 0 3px rgba(241, 180, 92, 0.07), 0 10px 26px -14px rgba(241, 180, 92, 0.45); }
.drop-card.dragover { border-style: solid; background: radial-gradient(120% 140% at 0% 0%, rgba(241, 180, 92, 0.16), transparent 60%), var(--bg-3); }
.drop-card:focus-within { outline: 1.5px solid var(--ivory); outline-offset: 2px; }
.drop-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  border: 1px solid rgba(241, 180, 92, 0.3);
  background: linear-gradient(160deg, rgba(241, 180, 92, 0.16), rgba(241, 180, 92, 0.03));
  color: var(--amber);
}
.drop-icon svg { width: 22px; height: 22px; }
.drop-body { display: grid; gap: 2px; min-width: 0; }
.drop-title { font-size: 18px; font-weight: 600; color: var(--text-0); letter-spacing: 0.03em; }
.drop-sub { font-size: 16px; line-height: 1.55; color: var(--text-2); }
.drop-chip {
  justify-self: start;
  max-width: 100%;
  margin-top: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--bg-0);
  font-size: 14px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drop-chip.ok { border-color: rgba(241, 180, 92, 0.4); background: var(--amber-soft); color: var(--amber); }
.drop-chip.bad { border-color: rgba(255, 180, 168, 0.5); background: rgba(200, 50, 40, 0.16); color: #ffb4a8; }
.drop-chip.loading { border-color: var(--line-2); background: var(--bg-2); color: var(--text-1); }
.drop-chip.loading::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; border: 1.5px solid var(--amber); border-right-color: transparent; vertical-align: -1px; animation: chip-spin 0.9s linear infinite; }
@keyframes chip-spin { to { transform: rotate(360deg); } }
.drop-card-sm { min-height: 56px; margin-top: 8px; grid-template-columns: 32px minmax(0, 1fr); padding: 9px 12px; }
.drop-card-sm .drop-icon { width: 32px; height: 32px; border-radius: 7px; }
.drop-card-sm .drop-icon svg { width: 18px; height: 18px; }
.drop-card-sm .drop-chip { margin-top: 2px; }
.file-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; }
.file-btn:focus-within { outline: 1.5px solid var(--ivory); outline-offset: 2px; }

/* 本机 GPU 深度分析按钮：就绪时琥珀描边 */
.btn-gpu {
  display: grid;
  gap: 1px;
  justify-items: center;
  align-content: center;
  min-height: 52px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text-1);
}
.btn-gpu .gpu-title { font-size: 16px; font-weight: 600; }
.btn-gpu .gpu-sub { font: 14px var(--ui); color: var(--text-3); letter-spacing: 0.02em; }
.btn-gpu:not(:disabled) { border-color: var(--amber-line); background: linear-gradient(180deg, rgba(241, 180, 92, 0.14), rgba(241, 180, 92, 0.04)); color: var(--ivory-hi); }
.btn-gpu:not(:disabled) .gpu-sub { color: var(--amber); }
.btn-gpu:hover:not(:disabled) { background: linear-gradient(180deg, rgba(241, 180, 92, 0.22), rgba(241, 180, 92, 0.07)); }
.slice-info, .omr-summary, .analysis, .tap-status, .bpm-duration, .export-status {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-2);
  white-space: pre-line;
}
.omr-summary b, .analysis b { color: var(--amber); font-weight: 600; font-family: var(--mono); }

.field { display: grid; gap: 4px; margin-top: 8px; }
.field label { display: flex; justify-content: space-between; font-size: 15px; color: var(--text-1); }
.field output { font-family: var(--mono); color: var(--amber); font-size: 14px; }
input[type='range'] { width: 100%; accent-color: var(--amber); }
.inline-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.inline-fields label { display: grid; gap: 3px; font-size: 15px; color: var(--text-2); }
.inline-fields input, .inline-fields select, .row-table input {
  min-height: 44px;
  padding: 0 8px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--mono);
  font-size: 15px;
}
.inline-fields input[type='number'] { width: 70px; }
.inline-fields input[type='text'] { width: 96px; }
fieldset { margin: 0; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 8px; }
legend { padding: 0 6px; font-size: 14px; color: var(--text-1); }

.tabs { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-0); }
.tab { flex: 1; min-height: 44px; border: 0; border-radius: 6px; background: none; color: var(--text-2); font-size: 15px; }
.tab.active { background: var(--bg-3); color: var(--ivory-hi); box-shadow: inset 0 0 0 1px var(--line-2); }
.tab-panel { display: flex; flex-direction: column; gap: 10px; }

.btn-tap {
  min-height: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(200, 50, 40, 0.55);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(200, 50, 40, 0.22), rgba(200, 50, 40, 0.1));
  color: var(--ivory-hi);
  font-size: 15px;
  letter-spacing: 0.08em;
  transition: transform 0.1s, background 0.2s;
}
.btn-tap kbd {
  padding: 3px 22px;
  border-radius: 6px;
  border: 1px solid rgba(255, 241, 222, 0.35);
  border-bottom-width: 3px;
  font: 600 14px var(--mono);
  color: var(--ivory);
}
.btn-tap:hover { background: linear-gradient(180deg, rgba(200, 50, 40, 0.32), rgba(200, 50, 40, 0.14)); }
.btn-tap.flash { transform: scale(0.98); background: rgba(200, 50, 40, 0.55); }
.tap-status { color: var(--amber); }

.row-table-wrap { max-height: 260px; overflow-y: auto; overflow-x: hidden; border: 1px solid var(--line); border-radius: 8px; }
.row-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.row-table th { position: sticky; top: 0; background: var(--bg-2); color: var(--text-3); font-weight: 500; padding: 6px 4px; text-align: left; }
.row-table td { padding: 3px; border-top: 1px solid var(--line); color: var(--text-1); }
.row-table td:first-child { text-align: center; font-family: var(--serif); color: var(--text-2); }
.row-table input { width: 72px; min-height: 44px; padding: 0 5px; font-size: 14px; }
.row-table tr.selected td { background: var(--bg-2); }
.row-table tr.active td { background: var(--cinnabar-soft); }
.row-table tr.cursor td:first-child { color: var(--amber); }
.row-table .btn-mini { min-height: 44px; min-width: 44px; padding: 0 10px; }

.bg-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bg-chip {
  display: grid;
  gap: 6px;
  padding: 6px 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 14px;
}
.bg-chip.active { border-color: var(--ivory); color: var(--ivory-hi); }
.bg-swatch { display: block; height: 52px; border-radius: 5px; }
.sw-warm { background: radial-gradient(ellipse at 50% 108%, rgba(241, 180, 92, 0.6) 0 30%, transparent 60%), linear-gradient(180deg, #171009, #2b1c12 35%, #4a311c 72%, #7a5428); }
.sw-landscape { background: radial-gradient(circle at 74% 14%, rgba(241, 180, 92, 0.75) 0 9%, transparent 11%), linear-gradient(170deg, transparent 52%, rgba(45, 48, 44, 0.55) 53%, rgba(45, 48, 44, 0.55) 70%, transparent 71%), linear-gradient(180deg, #e9e1cf, #f4eee1 60%, #2c2e2b 61%, #3a3c38); }
.sw-gold { background: linear-gradient(180deg, #e2b85c 0 9%, transparent 10%), linear-gradient(90deg, transparent 30%, rgba(255, 214, 140, 0.35) 50%, transparent 70%), linear-gradient(180deg, #120d08, #3d2712); }

.progress { display: flex; align-items: center; gap: 10px; }
.progress-bar { flex: 1; height: 4px; border-radius: 2px; background: var(--bg-4); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--cinnabar); transition: width 0.2s linear; }
#exportPercent { font-size: 14px; color: var(--text-1); min-width: 36px; text-align: right; }
.export-done { display: grid; gap: 8px; }

/* ---------------- 底部走带与旗标同步轨 ---------------- */
.transport {
  grid-area: transport;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-1);
  border-top: 1px solid var(--line);
}
.transport-bar { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 0 16px; flex: none; }
.transport-now { display: flex; flex-direction: column; justify-content: center; min-width: 150px; line-height: 1.3; }
/* 换声音、升降调、快慢、单小节反复：电脑和手机都默认收在「更多」里，主路径不露 */
.transport-tools { display: none; align-items: center; gap: 10px; min-width: 0; }
.transport.open .transport-tools { display: flex; }
.btn-more {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--bg-3);
  color: var(--text-0);
  font-size: 16px;
  white-space: nowrap;
}
.transport.open .btn-more { border-color: var(--amber-line); color: var(--amber); }
.btn-play {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--ivory);
  flex: none;
}
.btn-play:hover:not(:disabled) { background: var(--ivory-hi); }
.icon-play { width: 0; height: 0; margin-left: 3px; border-left: 12px solid var(--on-ivory); border-top: 7.5px solid transparent; border-bottom: 7.5px solid transparent; }
.btn-play.playing .icon-play { width: 12px; height: 14px; margin-left: 0; border: 0; border-left: 4px solid var(--on-ivory); border-right: 4px solid var(--on-ivory); }
.time { font-size: 14px; color: var(--text-1); white-space: nowrap; }
.now-bar { font-size: 17px; font-weight: 600; color: var(--amber); white-space: nowrap; }
.seg-sm .seg-btn { min-height: 44px; padding: 0 10px; font-size: 15px; white-space: nowrap; }
#trackSwitch .seg-btn.active { background: var(--amber); color: var(--on-ivory); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-0); }
.stepper button { min-width: 44px; height: 44px; padding: 0 10px; border: 0; background: none; color: var(--text-1); font-size: 15px; white-space: nowrap; }
.stepper button:hover:not(:disabled) { color: var(--ivory-hi); }
.stepper span { min-width: 52px; text-align: center; font-size: 15px; color: var(--text-0); white-space: nowrap; }
.stepper.unsupported button { opacity: 0.45; }
.toggle-btn { min-height: 44px; white-space: nowrap; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-0); color: var(--text-2); font-size: 14px; }
.toggle-btn[aria-pressed='true'] { border-color: rgba(200, 50, 40, 0.6); color: var(--coral); background: var(--cinnabar-soft); }
.timeline-hint { display: none; margin-left: auto; font-size: 14px; color: var(--text-3); white-space: nowrap; }
.transport.open .timeline-hint { display: block; }
.btn-more { margin-left: auto; }
.transport.open .timeline-hint + .btn-more { margin-left: 0; }
.sync-timeline { display: block; width: 100%; flex: 1; min-height: 0; touch-action: none; }

/* ---------------- 提示 ---------------- */
.toast {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 50;
  max-width: min(360px, calc(100% - 32px));
  padding: 10px 16px;
  line-height: 1.55;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: rgba(35, 33, 29, 0.97);
  color: var(--text-0);
  font-size: 15px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.toast { border-left: 3px solid var(--amber); }
.toast.error { border-color: rgba(200, 50, 40, 0.7); border-left-color: var(--cinnabar); color: #f6c3bb; }
.toast:not([hidden]) { animation: toast-in 0.28s var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---------------- v2.5：卡片、抽屉、流水线、版本卡、修音胶囊 ---------------- */
.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 14px 16px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background:
    linear-gradient(165deg, rgba(255, 241, 222, 0.035), transparent 45%),
    var(--bg-2);
}
.card-title { display: flex; align-items: center; gap: 10px; margin: 0; font: 600 18px/1.35 var(--serif); letter-spacing: 0.06em; color: var(--ivory-hi); }
.card-no {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 5px;
  background: var(--cinnabar);
  color: #fff4e6;
  font: 700 14px/1 var(--serif);
  box-shadow: inset 0 0 0 1.5px rgba(255, 238, 214, 0.45);
}
.hint b { color: var(--text-1); font-weight: 600; }
.drop-card-hero { min-height: 84px; border-color: rgba(241, 180, 92, 0.42); }
.drop-card-hero .drop-title { font-size: 19px; }
.key-row label { color: var(--text-2); }
.key-row select { width: 132px; }
.key-row input { width: 80px; }

/* 高级抽屉：默认收起，展开后才显示工程控件 */
.advanced-drawer { border: 1px solid var(--line); border-radius: 10px; background: rgba(12, 11, 10, 0.4); }
.advanced-drawer > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  cursor: pointer;
  list-style: none;
  font-size: 15px;
  color: var(--text-2);
  letter-spacing: 0.02em;
  border-radius: 10px;
}
.advanced-drawer > summary::-webkit-details-marker { display: none; }
.advanced-drawer > summary::after { content: '›'; margin-left: auto; font-size: 16px; color: var(--text-3); transition: transform 0.2s var(--ease); }
.advanced-drawer[open] > summary::after { transform: rotate(90deg); }
.advanced-drawer > summary:hover { color: var(--text-0); background: var(--bg-2); }
.advanced-drawer[open] > summary { color: var(--text-0); border-bottom: 1px solid var(--line); border-radius: 10px 10px 0 0; }
.drawer-body { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.drawer-body .drop-card-sm { margin-top: 0; }

/* 自动处理流水线 */
.pipeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pipeline li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; padding: 9px 8px; border-radius: 8px; }
.pipeline li[data-state='run'] { background: rgba(241, 180, 92, 0.07); }
.pipeline li b { display: block; font-size: 15px; font-weight: 600; color: var(--text-0); }
.pipeline li span { display: block; font-size: 14px; color: var(--text-2); margin-top: 1px; }
.pipeline li[data-state='wait'] b { color: var(--text-2); }
.pipe-ico { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--line-3); font-style: normal; font: 700 15px/1 var(--ui); }
.pipeline li[data-state='done'] .pipe-ico { border-color: var(--amber); background: var(--amber); color: var(--on-ivory); }
.pipeline li[data-state='done'] .pipe-ico::before { content: '✓'; }
.pipeline li[data-state='run'] .pipe-ico { border-color: var(--amber); border-right-color: transparent; animation: spin 0.9s linear infinite; }
.pipeline li[data-state='warn'] .pipe-ico { border-color: var(--cinnabar-hi); color: var(--cinnabar-hi); }
.pipeline li[data-state='warn'] .pipe-ico::before { content: '!'; }
/* 不影响使用的说明：灰色短横，不用红色感叹号吓人 */
.pipeline li[data-state='info'] .pipe-ico { border-color: var(--text-3); color: var(--text-2); }
.pipeline li[data-state='info'] .pipe-ico::before { content: '–'; }
.sung-fields label { display: flex; align-items: center; gap: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
#btnToStage3 { padding-inline: 10px; letter-spacing: 0; text-wrap: balance; line-height: 1.35; }
/* 「下一步」按钮贴着检查器底边，演唱范围确认条展开后也不会掉出可视区 */
.sticky-next { position: sticky; bottom: -1px; z-index: 2; margin: 2px -14px -16px; padding: 10px 14px 14px; border-radius: 0 0 12px 12px; background: linear-gradient(180deg, rgba(26, 25, 22, 0), var(--bg-2) 30%); }
.pipe-hint { padding: 8px 10px; border-radius: 8px; background: rgba(255, 241, 222, 0.04); border: 1px dashed var(--line-2); }

/* 演唱范围与调高确认条：琥珀表示已自动匹配，朱砂表示吻合度不够、需要人工指定 */
.sung-range { display: grid; gap: 8px; padding: 10px; border-radius: 8px; border: 1px solid var(--amber-line); background: var(--amber-soft); }
.sung-range[data-state='blocked'] { border-color: rgba(200, 50, 40, 0.6); background: var(--cinnabar-soft); }
.sung-text { margin: 0; font-size: 15px; line-height: 1.6; color: var(--text-0); }
.sung-text b { color: var(--amber); font-family: var(--mono); font-weight: 600; }
.sung-range[data-state='blocked'] .sung-text b { color: var(--coral); }
.sung-fields { display: grid; gap: 6px; }
.sung-ask { margin: 0; font-size: 15px; color: var(--text-1); }
.sung-fields input { width: 58px; }
.sung-fields .btn { min-height: 44px; flex: 1 1 100%; }
/* 「看细节…」：调、升降几个半音、每分钟几拍、准确度等技术信息默认收起 */
.sung-more > summary { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; color: var(--text-1); text-decoration: underline; text-underline-offset: 3px; font-size: 15px; }
.sung-detail { margin: 0 0 6px; font-size: 15px; line-height: 1.6; color: var(--text-1); }
.sung-more .sung-fields { margin-top: 4px; }

/* 待核对音符巡检 */
.review-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(200, 50, 40, 0.45); background: var(--cinnabar-soft); }
.review-text { flex: 1; font-size: 16px; color: var(--coral); }
.review-row .btn { min-height: 44px; padding: 0 14px; }

/* 未演唱的行：左侧导航半透明 */
.outline-item.unsung { opacity: 0.72; }
.outline-item.unsung .oi-time { color: var(--text-3); }

/* 导出版本二选一大卡片 */
.version-cards { display: grid; grid-template-columns: 1fr; gap: 8px; }
.ver-card {
  position: relative;
  display: grid;
  grid-template-columns: 34px 1fr;
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  justify-items: start;
  min-height: 60px;
  padding: 10px 40px 10px 12px;
  text-align: left;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--bg-1);
  color: var(--text-1);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.ver-card:hover:not(:disabled) { border-color: var(--line-3); }
.ver-card.active { border-color: var(--ivory); background: linear-gradient(170deg, rgba(239, 231, 216, 0.12), rgba(239, 231, 216, 0.03)); box-shadow: 0 0 0 3px rgba(239, 231, 216, 0.08); color: var(--ivory-hi); }
.ver-ico { grid-row: 1 / span 2; justify-self: center; font-size: 22px; line-height: 1; }
.ver-name { grid-column: 2; font: 600 17px/1.3 var(--serif); letter-spacing: 0.04em; }
.ver-desc { grid-column: 2; font-size: 15px; color: var(--text-2); }
/* 右侧单选圆点：选中时象牙实心 + 勾 */
.ver-card::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border-radius: 50%;
  border: 1.5px solid var(--line-3);
}
.ver-card.active::after { content: '✓'; display: grid; place-items: center; border-color: var(--ivory); background: var(--ivory); color: var(--on-ivory); font: 700 13px/1 var(--ui); }
.ver-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.link-btn { min-height: 44px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 999px; background: none; color: var(--text-2); font-size: 14px; }
.link-btn:hover:not(:disabled) { color: var(--text-0); border-color: var(--line-3); }
.link-btn.active { color: var(--amber); border-color: var(--amber-line); background: var(--amber-soft); }
.ver-foot .hint { flex: 1; min-width: 120px; }
.ver-card.unavailable:not(.active) { opacity: 0.55; }
.ver-card.unavailable .ver-desc::after { content: '（还没有这种声音）'; color: var(--text-3); }
.link-btn.unavailable { opacity: 0.55; }

/* 印章字 */
.seal-row { display: flex; align-items: center; gap: 12px; }
.seal-preview {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 6px;
  background: #b42a20;
  color: #fff4e6;
  font: 700 20px/1 var(--serif);
  box-shadow: inset 0 0 0 2px rgba(255, 238, 214, 0.5), inset 0 0 0 3.5px #b42a20;
  transform: rotate(-3deg);
}
.seal-preview[data-len="2"] { font-size: 15px; }
.seal-preview[data-len="3"], .seal-preview[data-len="4"] { font-size: 14px; line-height: 1.05; padding: 3px; text-align: center; }
.seal-preview.empty { background: var(--bg-3); color: var(--text-3); box-shadow: inset 0 0 0 1px var(--line-2); }
.seal-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--bg-0);
  color: var(--text-0);
  font: 600 18px var(--serif);
  letter-spacing: 0.2em;
}
.btn-export { min-height: 60px; padding-inline: 8px; font-size: 20px; letter-spacing: 0; white-space: nowrap; box-shadow: 0 14px 30px -14px rgba(239, 231, 216, 0.55); }

/* 单击音符修音小胶囊 */
.note-pop {
  position: absolute;
  z-index: 40;
  width: 432px;
  padding: 10px 10px 11px;
  border: 1px solid rgba(241, 180, 92, 0.45);
  border-radius: 14px;
  background:
    linear-gradient(170deg, rgba(241, 180, 92, 0.1), transparent 55%),
    rgba(19, 18, 16, 0.98);
  box-shadow: 0 22px 48px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(0, 0, 0, 0.6);
  animation: toast-in 0.2s var(--ease);
}
.note-pop::after {
  content: '';
  position: absolute;
  left: var(--arrow-x, 50%);
  bottom: -7px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  transform: rotate(45deg);
  background: rgba(19, 18, 16, 0.98);
  border-right: 1px solid rgba(241, 180, 92, 0.45);
  border-bottom: 1px solid rgba(241, 180, 92, 0.45);
}
.note-pop.below::after { bottom: auto; top: -7px; transform: rotate(225deg); }
.np-head { display: flex; align-items: center; gap: 8px; margin: 0 2px 8px; }
.np-now {
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--cinnabar);
  color: #fff4e6;
  font: 700 17px/1 var(--serif);
}
.np-title { flex: 1 1 auto; font: 600 15px var(--serif); color: var(--ivory-hi); letter-spacing: 0.04em; }
.np-kbd { margin-left: auto; font-size: 14px; color: var(--text-3); }
.np-close { width: 44px; height: 44px; flex: none; border: 0; border-radius: 6px; background: none; color: var(--text-2); font-size: 22px; line-height: 1; }
.np-close:hover { background: var(--bg-3); color: var(--text-0); }
.np-row { display: flex; gap: 4px; }
.np-pitch button {
  flex: 1;
  min-height: 48px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--bg-2);
  color: var(--text-0);
  font: 700 17px/1 var(--serif);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.np-pitch button small { font: 500 12px/1.2 var(--ui); color: var(--text-3); }
.np-pitch button:hover { border-color: var(--amber-line); background: var(--bg-3); }
.np-pitch button.active { background: var(--amber); border-color: var(--amber); color: var(--on-ivory); }
.np-pitch button.active small { color: rgba(23, 20, 15, 0.6); }
.np-attr { margin-top: 6px; align-items: stretch; }
.np-seg { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-0); }
.np-seg button { min-height: 44px; padding: 0 8px; border: 0; border-radius: 6px; background: none; color: var(--text-2); font-size: 14px; white-space: nowrap; }
.np-seg button:hover { color: var(--text-0); background: var(--bg-2); }
.np-seg button.active { background: var(--ivory); color: var(--on-ivory); font-weight: 600; }
.np-sep { width: 1px; margin: 4px 2px; background: var(--line-2); }

/* 听谱核对卡里的「看识别细节」：专业统计默认收起 */
.omr-more { margin-top: 4px; white-space: pre-line; color: var(--text-2); }
.omr-more > summary { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; color: var(--text-1); text-decoration: underline; text-underline-offset: 3px; white-space: normal; }
.np-ask { margin: 0 2px 8px; font-size: 15px; color: var(--text-1); }
.np-attr { flex-wrap: wrap; row-gap: 6px; }
.toast { max-width: min(420px, calc(100% - 32px)); font-size: 16px; padding: 12px 18px; }
.toast.error { color: var(--coral); }
/* 手指在谱面上可以上下左右滑、两指放大；按在能拖的线上时由 app.js 在 touchstart 里拦住滑屏 */
#editorCanvas { touch-action: manipulation; }
.zoom-btn { display: none; }
.note-pop { width: 480px; }

/* ---------------- 新手引导：遮罩聚光灯 + 纸色说明卡 + 琥珀粗箭头 ---------------- */
.guide { position: fixed; inset: 0; z-index: 1000; pointer-events: none; }
.guide-shade { position: fixed; background: rgba(6, 5, 4, 0.74); pointer-events: auto; }
.guide-ring {
  position: fixed;
  border: 3px solid var(--amber);
  border-radius: 12px;
  box-shadow: 0 0 0 5px rgba(241, 180, 92, 0.22), 0 0 34px rgba(241, 180, 92, 0.55);
  pointer-events: none;
  animation: guide-pulse 1.6s ease-in-out infinite;
}
@keyframes guide-pulse { 50% { box-shadow: 0 0 0 9px rgba(241, 180, 92, 0.1), 0 0 44px rgba(241, 180, 92, 0.75); } }
.guide-arrow { position: fixed; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.guide-arrow-back { fill: none; stroke: rgba(23, 20, 15, 0.9); stroke-width: 12; stroke-linecap: round; }
.guide-arrow-line { fill: none; stroke: var(--amber); stroke-width: 7; stroke-linecap: round; }
.guide-card {
  position: fixed;
  max-height: calc(100dvh - 20px);
  overflow-y: auto;
  padding: 18px 20px 18px;
  border-radius: 16px;
  background: var(--paper);
  color: var(--paper-ink);
  box-shadow: 0 24px 60px -10px rgba(0, 0, 0, 0.85), 0 0 0 3px rgba(241, 180, 92, 0.65);
  pointer-events: auto;
  animation: toast-in 0.25s var(--ease);
}
.guide-count { margin: 0 0 6px; font: 700 15px/1.2 var(--ui); letter-spacing: 0.12em; color: #8c2119; }
.guide-title { margin: 0 0 8px; font: 700 22px/1.35 var(--serif); letter-spacing: 0.04em; color: var(--paper-ink); }
.guide-text { margin: 0; font-size: 18px; line-height: 1.7; color: #2a251d; }
.guide-wait { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: rgba(241, 180, 92, 0.22); font-size: 16px; line-height: 1.5; color: #4a3410; }
.guide-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.guide-actions .btn { flex: 1 1 auto; min-height: 52px; font-size: 18px; }
.guide-next { background: #17140f; color: var(--ivory-hi); }
.guide-next:hover:not(:disabled) { background: #2d2a25; }
.guide-skip.btn-ghost { flex: 0 1 auto; background: transparent; border-color: rgba(22, 20, 15, 0.35); color: #3b352c; }
.guide-skip.btn-ghost:hover:not(:disabled) { border-color: #16140f; color: #16140f; }
.guide-card :focus-visible { outline: 2px solid #8c2119; outline-offset: 2px; }
.guide-card.docked { padding: 14px 16px 14px; }
.guide-card.docked .guide-title { font-size: 20px; }
.guide-card.docked .guide-text { font-size: 17px; line-height: 1.6; }

/* ---------------- 电脑：1100 ~ 1360 收窄侧栏 ---------------- */
@media (max-width: 1360px) {
  :root { --outline-w: 224px; --inspector-w: 320px; }
  .timeline-hint, .transport.open .timeline-hint { display: none; }
  .brand-text span { display: none; }
  .phase .ph-sub { display: none; }
  .phase { padding: 0 14px; }
  .transport-tools { gap: 8px; }
  .seg-sm .seg-btn { padding: 0 8px; }
}
@media (min-width: 1100px) and (max-width: 1260px) {
  .engine-badge #engineText { display: none; }
  .engine-badge { padding: 0 10px; }
  #btnLoopBar { padding: 0 8px; }
}
.desk-only { display: inline; }
@media (hover: none), (max-width: 1099px) {
  .desk-only { display: none; }
}

/* ---------------- 手机与平板（宽 < 1100）：单栏、整页滚动、底部固定播放条 ---------------- */
@media (max-width: 1099px) {
  :root { --m-transport: 72px; --m-top: 118px; }
  html, body { height: auto; overflow: visible; }
  .app { overflow-x: clip; }
  body { font-size: 16px; }
  .app {
    height: auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding-bottom: calc(var(--m-transport) + env(safe-area-inset-bottom) + 8px);
  }

  /* 顶部：第一行产品标识 + 怎么用，第二行三步大按钮（贴顶，随时能切） */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    order: 0;
    grid-template-columns: 1fr auto;
    grid-template-areas: 'brand right' 'phases phases';
    gap: 6px 10px;
    padding: calc(4px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
    box-shadow: 0 8px 20px -12px rgba(0, 0, 0, 0.8);
  }
  .brand { grid-area: brand; gap: 10px; }
  .brand-seal { width: 30px; height: 30px; font-size: 17px; }
  .brand-text span { display: none; }
  .topbar-right { grid-area: right; gap: 8px; }
  .engine-badge, #btnExportTop { display: none; }
  .phase-switch { grid-area: phases; justify-self: stretch; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-radius: 14px; padding: 3px; gap: 3px; }
  .phase { justify-content: center; gap: 4px; min-height: 50px; padding: 0 4px; border-radius: 11px; white-space: nowrap; }
  .phase i { font-size: 18px; }
  .phase .ph-name { font-size: 17px; letter-spacing: 0.02em; }
  .phase .ph-sub { display: none; }

  /* 中部：当前步骤的画布全宽 */
  .stage { order: 1; display: block; min-height: 0; }
  .stage-toolbar { flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 8px 10px; white-space: normal; overflow: visible; }
  .stage-toolbar .seg { flex: 1 1 auto; }
  .stage-toolbar .seg-btn { flex: 1; font-size: 16px; }
  .switch { min-height: 44px; font-size: 15px; }
  .stage-body { position: relative; overflow: visible; }
  .editor-wrap { position: relative; inset: auto; height: min(64dvh, 760px); min-height: 280px; padding: 10px 6px 14px; overscroll-behavior: contain; }
  .zoom-btn { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; font-size: 15px; white-space: nowrap; }
  .zoom-btn[aria-pressed='true'] { border-color: var(--amber-line); color: var(--amber); }
  .paper.zoomed { width: 210%; max-width: none; margin: 0; }
  .editor-wrap:has(.paper.zoomed) { overflow-x: auto; }
  .empty-hint { position: relative; inset: auto; padding: 8px 4px 4px; }
  .empty-card { width: 100%; padding: 22px 16px 18px; }
  .empty-title { font-size: 24px; }
  .btn-hero { font-size: 19px; padding: 10px 12px; line-height: 1.35; }
  .preview-wrap { position: relative; inset: auto; padding: 4px 6px 6px; }
  .review-row { flex-wrap: wrap; }
  .review-row .btn { flex: 1 1 auto; }
  .preview-frame { height: auto; width: min(100%, calc((100dvh - var(--m-top) - var(--m-transport) - 14px) * 9 / 16)); margin: 0 auto; }
  .app[data-phase='3'] .stage-toolbar, .stage:has(.paper.empty) .stage-toolbar { display: none; }
  .stage-toolbar .seg-btn { white-space: nowrap; padding: 0 8px; }
  .hud { padding: 6px 9px; }
  .hud:not(.hud-right) { top: 8px; left: 8px; }
  .hud-right { bottom: 8px; right: 8px; }

  /* 按行跳转：横向滑动的一排大按钮 */
  .outline { order: 2; border: 0; background: none; }
  .outline:has(.outline-empty) { display: none; }
  .plate { display: none; }
  .outline-head { padding: 8px 14px 4px; }
  .outline-count { font-size: 14px; }
  .outline-list { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 4px 12px 12px; scroll-snap-type: x proximity; flex: none; }
  .outline-item { flex: 0 0 auto; width: 212px; min-height: 64px; border-color: var(--line-2); background: var(--bg-1); scroll-snap-align: start; }

  /* 当前步骤的操作卡片：画布下方 */
  .inspector { order: 3; overflow: visible; border: 0; background: none; }
  .panel { max-width: 720px; margin: 0 auto; padding: 8px 12px 24px; }
  .sticky-next { position: static; margin: 4px 0 0; padding: 0; background: none; }
  .drop-card { min-height: 84px; }
  .version-cards { gap: 10px; }
  .bg-chip { min-height: 44px; font-size: 15px; }

  /* 底部固定大播放条：播放 / 当前小节 / 时间；「更多」展开换声音、升降调、快慢与声音波形 */
  .transport {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    max-height: calc(100dvh - 60px);
    overflow-y: auto;
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-shadow: 0 -12px 30px -8px rgba(0, 0, 0, 0.75);
  }
  .transport-bar { flex-wrap: wrap; gap: 8px 12px; min-height: var(--m-transport); padding: 8px 12px; }
  .btn-play { width: 56px; height: 56px; }
  .transport-now { flex: 1 1 auto; min-width: 0; }
  .now-bar { font-size: 18px; }
  .time { font-size: 15px; }
  .btn-more { min-height: 48px; }
  .transport-tools { order: 5; width: 100%; flex-wrap: wrap; gap: 8px; padding-bottom: 4px; }
  .transport-tools > * { flex: 1 1 auto; }
  #trackSwitch { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #trackSwitch .seg-btn { padding: 0 4px; font-size: 15px; }
  .stepper { justify-content: space-between; }
  .stepper button { min-width: 72px; height: 48px; font-size: 16px; }
  #rateSwitch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .toggle-btn { min-height: 48px; font-size: 16px; }
  .shift-note { width: 100%; }
  .timeline-hint { display: none; }
  .transport.open .timeline-hint { display: block; order: 6; width: 100%; margin: 0; white-space: normal; font-size: 14px; }
  .sync-timeline { display: none; flex: none; height: 104px; }
  .transport.open .sync-timeline { display: block; }

  /* 修音面板：从底部弹出的大按钮面板 */
  .note-pop {
    position: fixed !important;
    left: 8px !important;
    right: 8px;
    top: auto !important;
    bottom: calc(8px + env(safe-area-inset-bottom)) !important;
    width: auto;
    max-width: 640px;
    margin: 0 auto;
    z-index: 60;
    padding: 14px 12px 12px;
    border-radius: 18px;
  }
  .note-pop::after { display: none; }
  .np-title { font-size: 17px; }
  .np-now { min-width: 40px; height: 40px; font-size: 22px; }
  .np-pitch { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
  .np-pitch button { min-height: 56px; font-size: 24px; }
  .np-pitch button small { font-size: 13px; }
  .np-attr { flex-direction: column; gap: 8px; margin-top: 10px; }
  .np-seg { width: 100%; }
  .np-seg button { flex: 1; min-height: 50px; font-size: 16px; padding: 0 4px; }
  .np-sep { display: none; }

  /* 提示条：停在播放条上方，整宽大字 */
  .toast {
    position: fixed;
    top: auto;
    left: 12px;
    right: 12px;
    bottom: calc(var(--m-transport) + env(safe-area-inset-bottom) + 12px);
    max-width: none;
    z-index: 45;
    font-size: 17px;
  }
}

/* 平板竖屏：三步按钮下面带一句小字说明 */
@media (min-width: 700px) and (max-width: 1099px) {
  .phase .ph-sub { display: inline; font-size: 14px; }
  .phase { gap: 6px; }
}

/* 横屏手机（矮屏）：顶栏不贴顶，画布高度按屏幕高算 */
@media (max-width: 1099px) and (max-height: 500px) {
  :root { --m-top: 0px; }
  .topbar { position: relative; }
  .editor-wrap { height: calc(100dvh - var(--m-transport) - 16px); min-height: 220px; }
  .preview-frame { width: min(100%, calc((100dvh - var(--m-transport) - 28px) * 9 / 16)); }
  /* 预览只有一百多像素宽：左上角的小节说明会盖住三分之一画面，底部播放条已写当前小节，这里收起 */
  .preview-frame .hud:not(.hud-right) { display: none; }
  .note-pop { max-height: calc(100dvh - 16px); overflow-y: auto; }
  .np-pitch { grid-template-columns: repeat(9, minmax(0, 1fr)); }
  .np-pitch button { min-height: 48px; font-size: 20px; }
  .np-attr { flex-direction: row; }
  .np-seg { width: auto; flex: 1 1 auto; }
  /* 横屏矮屏：引导说明卡收紧，给目标和箭头留地方 */
  .guide-card.docked { padding: 10px 14px; }
  .guide-card.docked .guide-count, .guide-card.docked .guide-wait { display: none; }
  .guide-card.docked .guide-title { font-size: 18px; margin-bottom: 4px; }
  .guide-card.docked .guide-text { font-size: 16px; line-height: 1.5; }
  .guide-card.docked .guide-actions { margin-top: 8px; }
  .guide-card.docked .guide-actions .btn { min-height: 44px; font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------- 默认（非专家）界面：只看视频效果 ----------------
   「检查识谱」切换、唱名小黄牌、修音、调号 / 快慢 / 听一遍歌谱、分行抽屉、谱头调拍速度都只在 ?expert=1 时出现 */
.app:not(.expert) .expert-only { display: none !important; }
.app:not(.expert) .stage { grid-template-rows: minmax(0, 1fr); }
@media (min-width: 1100px) {
  .app:not(.expert) .preview-wrap { padding: 14px 18px; }
  /* 电脑上底部平时只留播放键一排；声音波形与黄色小旗跟换声音、快慢一起收在「更多」里，舞台因此更高、预览更大 */
  .app:not(.expert) { --transport-h: 72px; }
  .app:not(.expert):has(.transport.open) { --transport-h: 148px; }
  .app:not(.expert) .transport:not(.open) .sync-timeline { display: none; }
}

/* 第 1 步认谱结果：认出来是琥珀，认不出来是朱砂，并写清楚怎么办 */
.sheet-result { display: grid; gap: 10px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--amber-line); background: var(--amber-soft); }
.sheet-result[data-state='bad'] { border-color: rgba(200, 50, 40, 0.6); background: var(--cinnabar-soft); }
.sheet-result-text { margin: 0; font-size: 17px; line-height: 1.6; color: var(--text-0); }
.sheet-result[data-state='bad'] .sheet-result-text { color: var(--coral); }

/* 歌谱样子两档：小样 + 名字 + 一句话 */
.tex-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tex-card {
  display: grid;
  gap: 4px;
  align-content: start;
  justify-items: start;
  min-height: 44px;
  padding: 8px 8px 10px;
  text-align: left;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--bg-1);
  color: var(--text-1);
}
.tex-card.active { border-color: var(--ivory); box-shadow: 0 0 0 3px rgba(239, 231, 216, 0.1); color: var(--ivory-hi); }
.tex-swatch { display: grid; place-items: center; width: 100%; height: 44px; border-radius: 6px; font: 700 20px/1 var(--serif); letter-spacing: 0.3em; }
.tex-swatch-clean { background: var(--paper); color: #16140f; }
.tex-swatch-stage { background: radial-gradient(ellipse at 50% 40%, #f9edd3, #e4c999); color: #28180c; box-shadow: inset 0 0 0 2px rgba(168, 112, 36, 0.7), 0 4px 10px rgba(0, 0, 0, 0.5); }
.tex-name { font: 600 17px/1.3 var(--serif); letter-spacing: 0.04em; }
.tex-desc { font-size: 14px; line-height: 1.45; color: var(--text-2); }
.tex-card.active .tex-desc { color: var(--text-1); }
