:root {
  --bg: #f4f3ef;
  --panel: #ffffff;
  --line: #e3e1da;
  --line-strong: #cfccc2;
  --text: #1f1f1c;
  --text-2: #6b6860;
  --text-3: #9a968c;
  --accent: #378add;
  --accent-soft: #e6f1fb;
  --accent-text: #0c447c;
  --danger: #d92d20;
  --radius: 8px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  --mono: "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  height: 48px;
  flex: 0 0 48px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .5px;
  padding-right: 12px;
  border-right: 1px solid var(--line);
}
.tgroup { display: flex; align-items: center; gap: 6px; }
.tspacer { flex: 1; }
.thint { color: var(--text-3); font-size: 12px; max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tbtn {
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: var(--radius);
  font: inherit;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.tbtn:hover { background: #f7f6f2; }
.tbtn:active { background: #efeee9; }
.tbtn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.tbtn.primary:hover { background: #2f7bc8; }
.tbtn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.tbtn:disabled { opacity: .45; cursor: default; }

.tsel, .tnum {
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  font: inherit;
  color: var(--text);
  padding: 0 6px;
}
.tnum { width: 62px; }
.tlabel { display: flex; align-items: center; gap: 5px; color: var(--text-2); }

/* ---------- 主体 ---------- */
.main { flex: 1; display: flex; min-height: 0; }

.panel {
  flex: 0 0 auto;
  background: var(--panel);
  overflow-y: auto;
  padding: 12px;
}
.panel.left { width: 236px; border-right: 1px solid var(--line); }
.panel.right { width: 268px; border-left: 1px solid var(--line); }

.pgroup { margin-bottom: 16px; }
.ptitle {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 7px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.pkey { color: var(--text-3); font-weight: 400; font-size: 11px; }
.phint { color: var(--text-3); font-size: 11.5px; line-height: 1.5; margin-top: 6px; }

.numpad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.nbtn {
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  font: 22px/1 "Times New Roman", serif;
  color: var(--text);
  cursor: pointer;
}
.nbtn:hover { background: var(--accent-soft); border-color: var(--accent); }
.nbtn.rest { color: var(--text-2); }

.btnrow { display: flex; gap: 6px; margin-bottom: 6px; }
.dbtn {
  flex: 1;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.dbtn:hover { background: #f7f6f2; }
.dbtn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.dbtn.wide { flex: 1 1 100%; }

.lyric {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0 9px;
  font: 15px var(--font);
}
.lyric:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.keys { list-style: none; margin: 0; padding: 0; color: var(--text-2); font-size: 11.5px; line-height: 1.75; }
.keys b { color: var(--text); font-weight: 500; font-family: var(--mono); font-size: 11px; }

.field { display: block; margin-bottom: 9px; color: var(--text-2); font-size: 12px; }
.field input[type=text], .field input[type=number], .field select, .field textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  padding: 0 8px;
  font: 13px var(--font);
  color: var(--text);
}
.field textarea { height: auto; padding: 8px; font-family: var(--mono); line-height: 1.6; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.fieldrow { display: flex; gap: 8px; }
.fieldrow .field { flex: 1; }
.tsbox { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.tsbox input, .tsbox select { margin-top: 0 !important; }
.tsbox input { width: 52px; }

.vocalinfo {
  font-size: 12px;
  color: var(--text-2);
  background: #f7f6f2;
  border-radius: 6px;
  padding: 7px 9px;
  margin: 2px 0 9px;
  word-break: break-all;
}
.vocalinfo.on { background: var(--accent-soft); color: var(--accent-text); }

/* ---------- 谱面 ---------- */
.stage { flex: 1; min-width: 0; overflow: auto; padding: 20px; }
.paper {
  width: 980px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
#cv { display: block; cursor: text; }

/* ---------- 状态栏 ---------- */
.statusbar {
  flex: 0 0 28px;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  color: var(--text-2);
  font-size: 12px;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.32);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal[hidden] { display: none; }
.mbox {
  width: 640px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 60px);
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.mtitle { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.mdesc { color: var(--text-2); font-size: 12.5px; line-height: 1.7; margin-bottom: 14px; }
.mdesc code, .field code {
  font-family: var(--mono);
  font-size: 12px;
  background: #f4f3ef;
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--accent-text);
}
.merr { color: var(--danger); font-size: 12.5px; min-height: 18px; margin: 4px 0 8px; white-space: pre-wrap; }
.mfoot { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 46px;
  transform: translateX(-50%);
  background: #2b2a27;
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 80;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.toast[hidden] { display: none; }
