* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* === 打印样式（导出PDF时生效） === */

.print-header,
.print-footer {
  display: none;
}

@media print {
  @page {
    size: A4;
    margin: 8mm;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .toolbar {
    display: none !important;
  }

  .side-tabs,
  .side-tab {
    display: none !important;
  }

  .sidebar,
  .sidebar-overlay {
    display: none !important;
  }

  .recording-bar {
    display: none !important;
  }

  .countin-overlay {
    display: none !important;
  }

  .results-panel {
    display: none !important;
  }

  body {
    background: #fff;
  }

  body::before {
    display: none;
  }

  .sheet {
    padding: 0;
    max-width: none;
    width: 1128px;
    margin: 0;
    zoom: 0.65;
  }

  .sheet-title {
    display: none;
  }

  .sheet-table {
    page-break-inside: avoid;
  }

  .editor-add-measure {
    display: none;
  }

  .print-header {
    display: block;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 1px solid #ccc;
    margin-bottom: 12px;
  }

  .print-title {
    font-size: 18px;
    font-weight: bold;
    color: #1a1a1a;
    margin-bottom: 3px;
  }

  .print-meta {
    font-size: 10px;
    color: #555;
    display: flex;
    justify-content: center;
    gap: 8px;
  }

  .print-footer {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 9px;
    color: #555;
    padding: 4px 0;
    border-top: 1px solid #eee;
  }

  .sheet::after {
    opacity: 0.14;
  }

  .sheet-watermark {
    display: none !important;
  }
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #faf8f0;
  color: #1a1a1a;
  min-height: 100vh;
}

/* 页面全局 logo 水印 — 填满左右空白区域 */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: url('../logo.jpg') repeat center/180px;
  opacity: 0.11;
  pointer-events: none;
  z-index: 0;
}

/* === 顶部控制栏 === */

.toolbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: #f5f0e0;
  border-bottom: 1px solid #e0d8c0;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  flex-direction: column;
  margin-right: auto;
}

.brand h1 {
  font-size: 20px;
  color: #b8860b;
  margin: 0;
}

.brand h1 small {
  font-size: 20px;
  font-weight: 700;
}

.dev-credit {
  font-size: 11px;
  color: #555;
  user-select: none;
}

.dev-email {
  font-size: 10px;
  color: #888;
  user-select: none;
}

.toolbar label {
  font-size: 14px;
  color: #444;
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar input[type="number"] {
  width: 60px;
  padding: 4px 8px;
  background: #fff;
  border: 1px solid #d4c9a8;
  border-radius: 4px;
  color: #1a1a1a;
  font-size: 14px;
}

.toolbar input[type="text"] {
  width: 80px;
  padding: 4px 8px;
  background: #fff;
  border: 1px solid #d4c9a8;
  border-radius: 4px;
  color: #1a1a1a;
  font-size: 14px;
}

/* === 工具栏分组 === */

.tool-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 2px solid #e0d8c0;
  background: #fff;
}

.group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #666;
  margin-right: 2px;
  user-select: none;
}

.group-metronome {
  border-color: #d4c080;
}
.group-metronome .group-label {
  color: #b8860b;
}

.group-record {
  border-color: #d4a090;
}
.group-record .group-label {
  color: #b0725a;
}

.group-score {
  border-color: #a0c4a0;
}
.group-score .group-label {
  color: #5a8a5a;
}

.group-score button,
.group-metronome button,
.group-record button {
  padding: 4px 12px;
  font-size: 13px;
}

/* 节拍器按钮 — 金色调 */
.group-metronome button {
  background: #fefdf5;
  border-color: #d4c080;
  color: #8b6914;
}
.group-metronome button:hover {
  background: #b8860b;
  border-color: #b8860b;
  color: #fff;
}

/* 录音按钮 — 陶土色调 */
.group-record button {
  background: #fef9f7;
  border-color: #d4a090;
  color: #8b4a3a;
}
.group-record button:hover {
  background: #b0725a;
  border-color: #b0725a;
  color: #fff;
}

/* 谱面按钮 — 草绿色调 */
.group-score button {
  background: #f8faf6;
  border-color: #a0c4a0;
  color: #4a6b4a;
}
.group-score button:hover {
  background: #5a8a5a;
  border-color: #5a8a5a;
  color: #fff;
}

/* === 基础按钮 === */

button {
  padding: 6px 16px;
  background: #fff;
  border: 1px solid #d4c9a8;
  border-radius: 4px;
  color: #555;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

button:hover {
  background: #b8860b;
  color: #fff;
  border-color: #b8860b;
}

button.active {
  background: #b8860b;
  color: #fff;
  border-color: #b8860b;
}

/* === 谱面区域 === */

.sheet {
  position: relative;
  padding: 24px 0;
  max-width: 1280px;
  margin: 0 auto;
  zoom: 0.88;
}

/* 谱面歌名标题 */
.sheet-title {
  font-size: 24px;
  font-weight: bold;
  color: #5a4a3a;
  text-align: center;
  margin-bottom: 20px;
  padding: 12px 16px 4px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}

.sheet-title-text {
  font-size: 24px;
  font-weight: bold;
  color: #5a4a3a;
}

.sheet-artist-text {
  font-size: 16px;
  font-weight: normal;
  color: #8b7355;
}

/* 打印专用水印 — 屏幕用 clip 隐藏但保持图片加载 */
.sheet-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50%;
  opacity: 1;
  clip-path: inset(100%);
  pointer-events: none;
  z-index: 100;
}

/* logo 水印 — ::after 伪元素（屏幕显示） */
.sheet::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('../logo.jpg') center/65% no-repeat;
  opacity: 0.10;
  pointer-events: none;
  z-index: 100;
}

/* 编辑模式下隐藏水印 */
.sheet.editing::after {
  display: none;
}

/* 语音按钮 */
#btnMic {
  width: 38px;
  height: 34px;
  padding: 0;
  font-size: 18px;
  border-radius: 50%;
}

#btnMic.listening {
  background: #b8860b;
  color: #fff;
  border-color: #b8860b;
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(184, 134, 11, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(184, 134, 11, 0); }
}

.section-title {
  font-size: 16px;
  color: #555;
  margin: 24px 0 12px;
  padding-left: 8px;
  border-left: 3px solid #b8860b;
}

/* === 谱面表格（调试模式：带边框） === */

.sheet-table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
  margin-bottom: 16px;
}

.sheet-table td {
  padding: 4px 6px;
  vertical-align: middle;
  white-space: nowrap;
}

.sheet-table .sep {
  color: #e8c9a0;
  font-size: 18px;
  padding: 0 2px;
  user-select: none;
  font-weight: 300;
  border-left: 2px solid #e8c9a0;
  height: 100%;
  width: 0;
  text-indent: -9999px;
}

.measure .separator {
  text-align: center;
  color: #c0b890;
  font-size: 16px;
  user-select: none;
}

.measure .cell {
  text-align: center;
  padding: 2px 10px;
  white-space: nowrap;
}

/* 和弦行 */
.chord-cell {
  font-size: 16px;
  font-weight: bold;
  color: #b8860b;
  text-align: left;
}

/* 和弦行空拍 */
.chord-empty {
}

/* 拍数行 */
.beat-cell {
  font-size: 11px;
  color: #555;
  text-align: left;
}

/* 歌词行（每拍一个单元格） */
.sheet-table td.lyric-cell {
  font-size: 18px;
  color: #050007;
  font-weight: 420;
  text-align: left;
  padding: 4px 1px;
  white-space: nowrap;
}

/* === 播放状态 === */

/* 和弦静态高亮（持续到组结束） */
.chord-highlight {
  background: #f5eed8;
  border-radius: 4px;
}

/* 公共：拍位指示器容器 */
.beat-active {
  position: relative;
}

/* --- 样式1：拍手动画（默认） --- */
.rhythm-clap .beat-active::before,
.rhythm-clap .beat-active::after {
  content: '';
  position: absolute;
  top: -20px;
  width: 14px;
  height: 20px;
  border-radius: 7px 7px 3px 3px;
  pointer-events: none;
}

.rhythm-clap .beat-active::before {
  right: calc(50% + 1px);
  background: #d4a24e;
  transform-origin: right bottom;
  animation: clap-left 0.5s ease-out forwards;
}

.rhythm-clap .beat-active::after {
  left: calc(50% + 1px);
  background: #c49340;
  transform-origin: left bottom;
  animation: clap-right 0.5s ease-out forwards;
}

@keyframes clap-left {
  0% { transform: rotate(-25deg) translateX(-5px); opacity: 1; }
  35% { transform: rotate(0) translateX(0); opacity: 1; }
  45% { transform: rotate(3deg) translateX(1px); opacity: 1; }
  55% { transform: rotate(0) translateX(0); opacity: 1; }
  100% { transform: rotate(0) translateX(0); opacity: 0.3; }
}

@keyframes clap-right {
  0% { transform: rotate(25deg) translateX(5px); opacity: 1; }
  35% { transform: rotate(0) translateX(0); opacity: 1; }
  45% { transform: rotate(-3deg) translateX(-1px); opacity: 1; }
  55% { transform: rotate(0) translateX(0); opacity: 1; }
  100% { transform: rotate(0) translateX(0); opacity: 0.3; }
}

/* --- 样式2：下划线 --- */
.rhythm-dot .beat-active::before {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 50%;
  height: 3px;
  background: #b8860b;
  border-radius: 2px;
  pointer-events: none;
  animation: line-pulse 0.5s ease-in-out infinite alternate;
}

@keyframes line-pulse {
  from { opacity: 1; }
  to { opacity: 0.3; }
}

/* --- 样式3：拍手 emoji --- */
.rhythm-emoji .beat-active::before {
  content: '👏';
  position: absolute;
  left: 50%;
  top: -22px;
  font-size: 22px;
  pointer-events: none;
  line-height: 1;
  filter: brightness(1.1) saturate(1.3);
  animation: emoji-clap 0.5s ease-out forwards;
}

@keyframes emoji-clap {
  0% { opacity: 1; transform: translateX(-50%) translateY(-6px) scale(0.6); }
  30% { opacity: 1; transform: translateX(-50%) translateY(2px) scale(1.2); }
  50% { opacity: 1; transform: translateX(-50%) translateY(0) scale(0.95); }
  100% { opacity: 0.4; transform: translateX(-50%) translateY(0) scale(1); }
}

/* === 节奏样式选择器 === */

.style-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.style-label {
  font-size: 14px;
  color: #444;
}

.style-btns {
  display: flex;
  gap: 4px;
  background: #dcd8d0;
  padding: 3px;
  border-radius: 4px;
}

.style-btn {
  width: 32px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border-radius: 4px;
  border: 1px solid #d4c9a8;
  background: #fff;
  color: #555;
}

.style-btn.active {
  background: #b8860b;
  color: #fff;
  border-color: #b8860b;
}

/* 视图模式按钮 */
.view-btn {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
  border: 1px solid #d4c9a8;
  background: #fff;
  color: #555;
  cursor: pointer;
  border-radius: 3px;
}

.view-btn.active {
  background: #4a8c3f;
  color: #fff;
  border-color: #4a8c3f;
}

.view-btn:hover:not(.active) {
  background: #f5eed8;
}

/* 背景色触发按钮 */
.bg-trigger-btn {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
  border: 1px solid #d4c9a8;
  background: #fff;
  color: #555;
  cursor: pointer;
  border-radius: 3px;
  white-space: nowrap;
}

.bg-trigger-btn:hover {
  background: #f5eed8;
}

/* 背景下拉菜单 */
.bg-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid #d4c9a8;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 300;
  min-width: 140px;
  padding: 4px;
}

.bg-drop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  border-radius: 4px;
}

.bg-drop-item:hover {
  background: #f5eed8;
}

.bg-drop-item.active {
  background: #f5eed8;
  font-weight: bold;
  color: #b8860b;
}

.bg-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #d4c9a8;
  flex: none;
}

/* 背景主题 */
body.bg-warm {
  background: #faf8f0;
}

body.bg-green {
  background: #e8f0e3;
}

body.bg-white {
  background: #f5f5f5;
}

body.bg-dark {
  background: #2a2a2a;
}

body.bg-dark .sheet {
  background: #333;
}

body.bg-dark .sheet-title {
  color: #ddd;
}

body.bg-dark .sheet-title-text {
  color: #e0c878;
}

body.bg-dark .sheet-artist-text {
  color: #aaa;
}

body.bg-dark .simple-lyric {
  color: #ddd;
}

body.bg-dark .simple-chord {
  color: #e0c878;
}

body.bg-dark .chord-cell {
  color: #d4a030;
}

body.bg-dark .lyric-cell {
  color: #ddd;
}

body.bg-dark .beat-cell {
  color: #888;
}

body.bg-dark .toolbar {
  background: #3a3a3a;
  border-bottom-color: #555;
}

body.bg-dark .brand h1 {
  color: #e0c878;
}

body.bg-dark .brand small {
  color: #aaa;
}

body.bg-dark .toolbar button {
  background: #444;
  color: #ccc;
  border-color: #555;
}

body.bg-dark .toolbar button:hover {
  background: #555;
}

body.bg-dark .style-label {
  color: #aaa;
}

body.bg-dark .style-btns {
  background: #3a3a3a;
}

body.bg-dark .view-btn,
body.bg-dark .bg-btn {
  background: #444;
  color: #ccc;
  border-color: #555;
}

body.bg-dark .view-btn.active {
  background: #4a8c3f;
}

body.bg-dark .bg-btn.active {
  background: #b8860b;
}

body.bg-dark .simple-table td {
  border-color: #444;
}

body.bg-dark .sep {
  color: #666;
}

/* 淡蓝主题 */
body.bg-blue {
  background: #e8edf5;
}

/* 淡紫主题 */
body.bg-lavender {
  background: #efe8f5;
}

/* 兔子耳朵图标 */
.style-icon-clap {
  display: inline-flex;
  gap: 2px;
  align-items: flex-end;
  height: 16px;
}

.style-icon-clap::before,
.style-icon-clap::after {
  content: '';
  width: 5px;
  height: 16px;
  background: currentColor;
  border-radius: 3px 3px 1px 1px;
  opacity: 0.85;
}

.style-icon-clap::before {
  transform: rotate(-10deg);
}

.style-icon-clap::after {
  transform: rotate(10deg);
}

/* === 简洁模式 === */

.simple-chord-line,
.simple-lyric-line {
  display: flex;
}

/* 一行：两个half中间有间距 */
.simple-row {
  display: flex;
  justify-content: center;
  gap: 3em;
  margin-bottom: 6px;
}

.simple-half {
  flex: none;
  overflow: visible;
}

.simple-chord {
  font-size: 16px;
  font-weight: bold;
  color: #b8860b;
  text-align: left;
  white-space: nowrap;
  padding: 0 2px;
  overflow: visible;
}

.simple-lyric {
  font-size: 17px;
  color: #000;
  font-weight: 400;
  padding: 0 2px;
  white-space: nowrap;
  overflow: visible;
}

.sl-placeholder {
  color: #c0b890;
}

/* 一行：两个half中间有间距 */
.simple-row {
  display: flex;
  justify-content: center;
  gap: 3em;
  margin-bottom: 6px;
}

.simple-half {
  display: flex;
  flex-direction: column;
}

.simple-half .simple-chord-line,
.simple-half .simple-lyric-line {
  max-width: 360px;
}

/* 简洁模式高亮 */
.simple-mode .beat-active {
  background: rgba(184, 134, 11, 0.2);
  border-radius: 2px;
}

.simple-mode .chord-highlight {
  color: #d42424;
}

/* === 编辑器 === */

.editor-table .edit-chord,
.editor-table .edit-beat {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 2px 4px;
  font-size: inherit;
  color: inherit;
  background: transparent;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.editor-table .edit-lyric {
  display: block;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 2px 0;
  color: inherit;
  background: transparent;
  outline: none;
  transition: border-color 0.2s;
  font-size: 16px;
  text-align: center;
}

.editor-table .edit-chord:focus,
.editor-table .edit-beat:focus,
.editor-table .edit-lyric:focus {
  border-color: #b8860b;
  background: #fff;
}

.editor-table .edit-chord {
  font-size: 16px;
  font-weight: bold;
  color: #b8860b;
}

.editor-table .edit-beat {
  font-size: 12px;
  color: #555;
  width: 36px;
}

.editor-table td.lyric-cell {
  text-align: center;
}

.editor-table td {
  border: 1px solid #e8e2d0;
}

.editor-add-measure {
  display: block;
  width: 100%;
  max-width: 960px;
  margin: 16px auto 0;
  padding: 10px;
  font-size: 14px;
  color: #b8860b;
  border: 1px dashed #d4c9a8;
  background: transparent;
  border-radius: 6px;
}

.editor-add-measure:hover {
  background: #f5eed8;
  border-color: #b8860b;
}

/* 歌名输入行 */
.editor-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: #f5eed8;
  border-radius: 6px;
  border: 1px solid #e8e2d0;
}

.editor-title-label {
  font-size: 16px;
  font-weight: bold;
  color: #b8860b;
  white-space: nowrap;
}

.editor-title-input {
  flex: 1;
  max-width: 600px;
  padding: 8px 12px;
  font-size: 16px;
  border: 1px solid #d4c9a8;
  border-radius: 4px;
  background: #fff;
  color: #1a1a1a;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.editor-title-input:focus {
  border-color: #b8860b;
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.1);
}

.editor-title-input::placeholder {
  color: #999;
}

/* 歌手输入框 */
.editor-artist-label {
  font-size: 14px;
  color: #b8860b;
  white-space: nowrap;
  margin-left: 8px;
}

.editor-artist-input {
  flex: 0 1 200px;
  max-width: 200px;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid #d4c9a8;
  border-radius: 4px;
  background: #fff;
  color: #1a1a1a;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.editor-artist-input:focus {
  border-color: #b8860b;
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.1);
}

.editor-artist-input::placeholder {
  color: #999;
}

/* === 源码查看弹窗 === */

.md-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.md-box {
  background: #fff;
  border-radius: 8px;
  width: 600px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

.md-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-size: 14px;
  color: #444;
  border-bottom: 1px solid #e0d8c0;
}

.md-header button {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  border: none;
  background: transparent;
}

.md-header button:hover {
  color: #1a1a1a;
  background: transparent;
}

.md-textarea {
  flex: 1;
  padding: 16px;
  border: none;
  outline: none;
  font-family: "Consolas", "Menlo", monospace;
  font-size: 14px;
  color: #1a1a1a;
  resize: none;
  min-height: 300px;
  line-height: 1.6;
}

/* === 空状态 === */

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: #555;
}

.empty-state p {
  margin: 8px 0;
  font-size: 14px;
}

/* === 录音状态栏 === */

.recording-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: #2a2a2a;
  color: #eee;
  font-size: 14px;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f44336;
  animation: rec-blink 0.8s ease-in-out infinite;
}

@keyframes rec-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.rec-text {
  font-weight: bold;
  letter-spacing: 2px;
}

.rec-timer {
  font-family: "Consolas", "Menlo", monospace;
  font-size: 16px;
  color: #fff;
  min-width: 48px;
}

.rec-wave {
  flex: 1;
  height: 36px;
  border-radius: 4px;
  background: #1a1a1a;
}

.btn-stop-record {
  padding: 6px 16px;
  background: #f44336;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}

.btn-stop-record:hover {
  background: #d32f2f;
}

/* === 倒数蒙层 === */

.countin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.countin-number {
  font-size: 120px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  user-select: none;
}

@keyframes countin-pop {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* === 对比结果面板 === */

.results-panel {
  max-width: 720px;
  margin: 16px auto;
  padding: 14px 16px 10px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
  border: 1px solid #e0d8c0;
}

.results-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 0;
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 14px;
  border-radius: 6px;
  min-width: 64px;
}

.stat-value {
  font-size: 24px;
  font-weight: bold;
  line-height: 1.1;
}

.stat-label {
  font-size: 11px;
  color: #555;
  margin-top: 2px;
}

.stat-perfect {
  background: #c8e6c9;
}

.stat-perfect .stat-value {
  color: #2e7d32;
}

.stat-good {
  background: #fff9c4;
}

.stat-good .stat-value {
  color: #f9a825;
}

.stat-warning {
  background: #ffe0b2;
}

.stat-warning .stat-value {
  color: #e65100;
}

.stat-off {
  background: #ffcdd2;
}

.stat-off .stat-value {
  color: #c62828;
}

.stat-missed {
  background: #f0eaf5;
}

.stat-missed .stat-value {
  color: #7b6f8a;
}

.stat-score {
  background: #fdf2d0;
  border: 2px solid #b8860b;
}

.stat-score .stat-value {
  color: #b8860b;
}

/* 时间轴 canvas */

.timeline-canvas {
  display: block;
  width: 100%;
  border-radius: 4px;
  cursor: crosshair;
}

/* 操作按钮 */

.results-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
}

.results-disclaimer {
  text-align: center;
  font-size: 12px;
  color: #555;
  margin-top: 4px;
}

/* 重新录制 — 灰色 */
#btnReRecord {
  background: #f5f5f5;
  border-color: #ccc;
  color: #777;
}
#btnReRecord:hover {
  background: #9e9e9e;
  border-color: #9e9e9e;
  color: #fff;
}

/* 关闭对比 — 灰色 */
#btnCloseComparison {
  background: #f5f5f5;
  border-color: #ccc;
  color: #777;
}
#btnCloseComparison:hover {
  background: #9e9e9e;
  border-color: #9e9e9e;
  color: #fff;
}

.playback-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 2px solid #d4c9a8;
  border-radius: 8px;
  background: #fdfaf0;
}

.playback-label {
  font-size: 14px;
  font-weight: 700;
  color: #444;
  margin-right: 4px;
  user-select: none;
}

.playback-label.playing {
  color: #b8860b;
  animation: label-pulse 1s ease-in-out infinite;
}

@keyframes label-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* 回放 / 回放+节拍 — 金色统一 */
#btnPlayAudioOnly,
#btnPlaySynced {
  background: #fdf2d0;
  border-color: #e6c340;
  color: #8b6914;
  font-weight: 600;
}
#btnPlayAudioOnly:hover,
#btnPlaySynced:hover {
  background: #b8860b;
  border-color: #b8860b;
  color: #fff;
}
#btnPlayAudioOnly:disabled,
#btnPlaySynced:disabled {
  background: #f5f5f5;
  border-color: #ddd;
  color: #555;
  font-weight: 400;
}

/* 停止 — 红色 */
#btnStopPlayback {
  background: #ffebee;
  border-color: #ef9a9a;
  color: #c62828;
}
#btnStopPlayback:hover {
  background: #c62828;
  border-color: #c62828;
  color: #fff;
}

.playback-wave {
  width: 140px;
  height: 30px;
  border-radius: 4px;
  background: #f5f0e0;
  opacity: 0.5;
  transition: opacity 0.2s;
  margin-left: 4px;
}

.playback-wave.active {
  opacity: 1;
}

/* === 谱面精度染色 === */

.acc-perfect {
  background: #c8e6c9 !important;
}

.acc-good {
  background: #fff9c4 !important;
}

.acc-warning {
  background: #ffe0b2 !important;
}

.acc-off {
  background: #ffcdd2 !important;
}

.acc-missed {
  background: #f0eaf5 !important;
}

/* === 按钮禁用 === */

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button:disabled:hover {
  background: #fff;
  color: #555;
  border-color: #d4c9a8;
}

/* === 右侧触发标签 === */

.side-tabs {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 199;
}

.side-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 8px 10px 12px;
  background: #fff;
  border: 1px solid #d4c9a8;
  border-right: none;
  border-radius: 6px 0 0 6px;
  color: #888;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: -2px 2px 8px rgba(0,0,0,0.08);
  transition: background 0.15s, color 0.15s, padding 0.15s;
}

.side-tab:hover {
  background: #f5eed8;
  color: #b8860b;
  padding-right: 14px;
}

.side-tab.active {
  background: #f5eed8;
  color: #b8860b;
  border-color: #b8860b;
  box-shadow: -2px 2px 12px rgba(184, 134, 11, 0.2);
}

.side-tab-arrow {
  font-size: 10px;
}

.side-tab-text {
  writing-mode: vertical-rl;
  letter-spacing: 4px;
}

/* === 侧边栏遮罩 === */

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.3);
  z-index: 200;
}

/* === 侧边栏面板 === */

.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 90vw;
  height: 100vh;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #e0d8c0;
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-size: 18px;
  color: #b8860b;
  margin: 0;
}

.sidebar-close {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid #d4c9a8;
  background: #fff;
  border-radius: 50%;
  font-size: 14px;
  color: #888;
  cursor: pointer;
  line-height: 28px;
  text-align: center;
}

.sidebar-close:hover {
  background: #f5eed8;
  color: #555;
}

.sidebar-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.sidebar-body h3 {
  font-size: 15px;
  color: #b8860b;
  margin: 20px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #f0ead0;
}

.sidebar-body h3:first-child {
  margin-top: 0;
}

.sidebar-body p {
  font-size: 14px;
  color: #444;
  line-height: 1.7;
  margin: 6px 0;
}

.sidebar-body ol {
  padding-left: 20px;
  margin: 6px 0;
}

.sidebar-body li {
  font-size: 14px;
  color: #444;
  line-height: 1.8;
}

.sidebar-body ul {
  padding-left: 20px;
  margin: 6px 0;
}

.scoring-disclaimer {
  font-weight: 700;
  font-size: 15px;
  color: #c62828;
  margin-top: 12px;
}

.sidebar-body code {
  background: #f5eed8;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 13px;
  color: #b8860b;
}

/* 精度表格 */
.acc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 14px;
}

.acc-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0ead0;
  color: #444;
}

.acc-table td:first-child {
  font-weight: bold;
  text-align: center;
  border-radius: 4px;
}

.demo-cell {
  min-width: 48px;
}
