:root {
  --bg: #121218;
  --panel: #1a1a23;
  --panel2: #23232e;
  --line: #2e2e3b;
  --text: #e8e7f0;
  --muted: #9b9bb2;
  --accent: #ffb454;
  --accent-ink: #231300;
  --blue: #6cc4ff;
  --red: #ff6464;
  --corner: #1b1b24;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.4 "PingFang SC", "Microsoft YaHei UI", "Segoe UI", system-ui, sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
  user-select: none; -webkit-user-select: none;
}
button, select, input, textarea { font: inherit; color: inherit; }
button {
  background: var(--panel2); border: 1px solid #383848; border-radius: 6px;
  padding: 4px 10px; cursor: pointer; white-space: nowrap;
}
button:hover:not(:disabled) { background: #2d2d3a; border-color: #4a4a5e; }
button.on, button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary { font-weight: 600; }
button.on:hover:not(:disabled), button.primary:hover:not(:disabled) { background: #ffc372; border-color: #ffc372; }
button:disabled { opacity: .4; cursor: default; }
button.mini { height: 20px; padding: 0 6px; font-size: 11px; border-radius: 4px; line-height: 18px; }
button.wide { width: 100%; }
select, input[type=text], input[type=number], textarea {
  background: #15151d; border: 1px solid #383848; border-radius: 6px; padding: 3px 6px; outline: none;
}
select:focus, input:focus, textarea:focus { border-color: #5a5a78; }
input[type=number] { width: 70px; }
input[type=range] { accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); margin: 0; }
label { color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
[hidden] { display: none !important; }
.flex1 { flex: 1; }

/* 顶栏 */
#top {
  background: var(--panel); border-bottom: 1px solid #000; padding: 7px 10px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; flex: none;
}
#top .grp { display: flex; align-items: center; gap: 6px; }
#top .sep { width: 1px; height: 24px; background: var(--line); }
#top .rowbreak { flex-basis: 100%; height: 0; }
#bPlay { width: 44px; font-size: 15px; }
#bRec { color: var(--red); }
#bRec.on { background: var(--red); color: #fff; border-color: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .55; } }
#posDisp {
  background: #0d0d12; border: 1px solid #2a2a36; border-radius: 6px; min-width: 96px;
  padding: 1px 10px; text-align: center; font: 15px/1.15 "Segoe UI", system-ui, sans-serif; letter-spacing: .5px;
}
#posTime { font-size: 10.5px; color: var(--muted); }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.menuWrap { position: relative; }
.menu {
  position: absolute; top: 30px; left: 0; z-index: 90; background: var(--panel2); border: 1px solid #444;
  border-radius: 8px; min-width: 210px; padding: 5px 0; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.mi { padding: 6px 14px; cursor: pointer; display: flex; justify-content: space-between; gap: 20px; }
.mi:hover { background: #34344a; }
.mi .hk { color: var(--muted); font-size: 11px; }
.msep { height: 1px; background: #383848; margin: 4px 0; }

/* 主区 */
#main { flex: 1; display: flex; min-height: 0; }
#side {
  width: 232px; flex: none; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px;
  border-right: 1px solid #000; background: var(--bg);
}
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 8px; }
.card .ttl { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.card .ttl .flex1 { flex: 1; }
.card .big { width: 100%; border-style: dashed; background: #2b2b3a; font-size: 14px; padding: 9px; margin: 4px 0; }
.hint { font-size: 11.5px; color: var(--muted); line-height: 1.55; }
.card .fname { font-weight: 600; word-break: break-all; }
.card .fname.dim { opacity: .45; }
.card .row { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.card .row > .lab { color: var(--muted); font-size: 12px; min-width: 30px; }
.card .row input[type=range] { flex: 1; min-width: 60px; }
.card select { max-width: 100%; }
.stem { display: flex; align-items: center; gap: 4px; padding: 3px 4px; border-radius: 5px; margin-top: 3px; }
.stem.shown { background: #34344a; box-shadow: inset 0 0 0 1px #5a5a78; }
.stem .sn { width: 44px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.stem input[type=range] { flex: 1; min-width: 30px; }
.sSolo.on { background: #ffd84d; color: #221; border-color: #ffd84d; }
.dirRtl { direction: rtl; }

.track {
  background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 9px;
  padding: 7px 8px; cursor: pointer;
}
.track.active { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); background: #2a2a37; }
.track .head { display: flex; align-items: center; gap: 5px; }
.track .sw { width: 12px; height: 12px; border-radius: 3px; background: var(--c); cursor: pointer; flex: none; }
.track .nm { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track .nm input { width: 100%; padding: 0 3px; }
.track .body { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.track .body select { flex: 1; min-width: 0; }
.track .body input[type=range] { width: 64px; }
.track .info { font-size: 11px; color: var(--muted); margin-top: 4px; }
.track .refRow { display: flex; gap: 6px; align-items: center; margin-top: 5px; font-size: 12px; color: var(--muted); }
.track .refRow select { flex: 1; min-width: 0; font-size: 12px; }
.tMute.on { background: #ff8a4d; border-color: #ff8a4d; color: #221; }
.tSolo.on { background: #ffd84d; border-color: #ffd84d; color: #221; }

/* 编辑区 */
#editor { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #15151c; }
.lane { display: flex; flex: none; }
.lane .corner { width: 64px; flex: none; background: var(--corner); border-right: 1px solid #000; }
.lane .corner.lbl { font-size: 11px; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.lane .pad { width: 12px; flex: none; background: var(--corner); }
.lane canvas { flex: 1; min-width: 0; display: block; }
#rulerRow { height: 30px; border-bottom: 1px solid #000; }
#chordRow { height: 26px; border-bottom: 1px solid #000; }
#lyricRow { height: 24px; border-bottom: 1px solid #000; }
#rollRow { flex: 1; min-height: 0; }
#keys { width: 64px; flex: none !important; }
#rollWrap { flex: 1; position: relative; min-width: 0; overflow: hidden; }
#rollWrap canvas { position: absolute; left: 0; top: 0; }
#overlay { touch-action: none; }
#emptyHint {
  position: absolute; left: 0; right: 0; top: 40%; transform: translateY(-50%); text-align: center;
  color: #8e8ea8; font-size: 14px; line-height: 2; pointer-events: none;
}
#emptyHint b { color: var(--accent); font-weight: 600; }
#emptyHint .small { font-size: 12px; color: #6f6f86; line-height: 1.8; }
#emptyHint .small:first-of-type { margin-top: 14px; }
.kc { display: inline-block; border: 1px solid #555; border-radius: 4px; padding: 0 5px; margin: 0 2px; line-height: 18px; font-size: 12px; background: #20202a; }
#vscroll { width: 12px; flex: none; overflow-y: scroll; overflow-x: hidden; background: #101016; }
#vscroll > div { width: 1px; }
#jpRow { height: 78px; border-top: 1px solid #000; }
.jpCorner { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); line-height: 1.35; }
#jpKeyTxt { color: var(--text); font-weight: 700; font-size: 12px; }
#jpModeTxt { color: #ffcf8a; font-size: 10px; }
#jpTrack { font-size: 10px; max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#hsRow { height: 12px; }
#hscroll { flex: 1; overflow-x: scroll; overflow-y: hidden; background: #101016; min-width: 0; }
#hscroll > div { height: 1px; }
#vscroll::-webkit-scrollbar, #hscroll::-webkit-scrollbar { width: 12px; height: 12px; }
#vscroll::-webkit-scrollbar-thumb, #hscroll::-webkit-scrollbar-thumb { background: #3a3a4c; border-radius: 6px; border: 2px solid #101016; }
#vscroll::-webkit-scrollbar-track, #hscroll::-webkit-scrollbar-track { background: #101016; }

/* 底栏 */
footer { flex: none; }
#statusBar {
  background: var(--panel); min-height: 30px; display: flex; align-items: center; gap: 14px; padding: 3px 10px;
  border-top: 1px solid #000;
}
#status { flex: 1; color: #c9c9da; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.zoom { color: var(--muted); display: inline-flex; gap: 3px; align-items: center; }
#pianoWrap { height: 86px; background: #0d0d12; }
#piano { width: 100%; height: 100%; display: block; touch-action: none; }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 80; display: flex; align-items: center; justify-content: center; }
.box {
  background: var(--panel); border: 1px solid #444; border-radius: 12px; padding: 18px 22px; width: 560px; max-width: 92vw;
  max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.6); user-select: text; -webkit-user-select: text;
}
.box.small { width: 380px; }
.box.mid { width: 460px; }
.box.wide { width: 760px; }
.box h3 { margin: 0 0 12px; font-size: 17px; }
.box .p, .box p { color: #c8c8d8; line-height: 1.7; margin: 8px 0; }
.box .row { display: flex; align-items: center; gap: 8px; margin: 8px 0; color: var(--text); }
.box textarea { width: 100%; resize: vertical; margin: 6px 0; font-size: 14px; line-height: 1.6; }
.box ul.hint { margin: 4px 0 6px; padding-left: 18px; }
.btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; align-items: center; }
.btns.list { flex-direction: column; align-items: stretch; }
.btns.list .opt { text-align: left; padding: 8px 12px; white-space: normal; }
.btns.list .opt small { display: block; color: inherit; opacity: .75; font-size: 11.5px; margin-top: 2px; }
.btns.list .cancelRow { display: flex; justify-content: flex-end; }
.bar { height: 8px; background: #2a2a36; border-radius: 4px; overflow: hidden; margin: 12px 0 4px; }
#progressFill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.checks { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 8px 4px; }
.checks label { color: var(--text); }
.checks .role { color: var(--muted); font-size: 12px; }
.helpBody h4 { color: var(--accent); font-size: 13px; margin: 16px 0 6px; }
.helpBody p, .helpBody li { color: #c8c8d8; line-height: 1.7; }
.helpBody ol { padding-left: 20px; margin: 4px 0; }
.helpBody table { border-collapse: collapse; width: 100%; }
.helpBody td { border-bottom: 1px solid #2a2a36; padding: 4px 6px; color: #c8c8d8; vertical-align: top; }
.helpBody td:first-child { color: #fff; width: 38%; }

.panel {
  position: fixed; right: 16px; top: 56px; width: 420px; z-index: 75; background: var(--panel);
  border: 1px solid #4a4a5e; border-radius: 12px; padding: 12px 14px; box-shadow: 0 16px 50px rgba(0,0,0,.6);
}
.panel .phead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 15px; }
.panel .row { display: flex; align-items: center; gap: 5px; margin: 8px 0; }
.panel .row.wrap { flex-wrap: wrap; }
.panel .hint { margin: 6px 0; }
.panel .tap { padding: 10px; margin-top: 8px; background: #2b2b3a; }
.panel .tap:active { background: var(--accent); color: var(--accent-ink); }

#chordPop {
  position: fixed; z-index: 70; width: 310px; background: var(--panel); border: 1px solid #555; border-radius: 10px;
  padding: 10px 12px; box-shadow: 0 12px 40px rgba(0,0,0,.6); user-select: text;
}
#cpTitle { font-weight: 600; margin-bottom: 4px; }
#cpAlts { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
#cpAlts button { min-width: 48px; }
#chordPop .row { display: flex; gap: 5px; margin-top: 6px; align-items: center; }
#chordPop .row input { flex: 1; min-width: 0; }
#chordPop .row button { font-size: 12px; padding: 3px 7px; }

#toasts {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 130px; z-index: 95;
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
}
.toast {
  background: rgba(40,40,54,.97); border: 1px solid #555; border-radius: 18px; padding: 8px 16px; max-width: 80vw;
  box-shadow: 0 6px 20px rgba(0,0,0,.4); transition: opacity .4s; text-align: center; line-height: 1.5;
}
.toast.out { opacity: 0; }
#mascot { position: fixed; right: 26px; bottom: 132px; z-index: 85; image-rendering: pixelated; cursor: pointer; }

.helpBody pre { font: 11px/1.5 Menlo, Consolas, monospace; color: #b3b3c4; background: #15151d; padding: 8px 10px; border-radius: 6px; white-space: pre-wrap; max-height: 240px; overflow: auto; }
.helpBody summary { cursor: pointer; color: var(--muted); }
