* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: monospace;
  font-size: 13px;
  color: #222;
  background: #fafafa;
  overflow: hidden;
}
body { display: flex; flex-direction: column; }

.toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px;
  background: #fff;
  border-bottom: 1px solid #ddd;
  flex-wrap: wrap;
  z-index: 10;
}
.tb-group { display: flex; gap: 5px; align-items: center; }
.tb-sep { width: 1px; height: 22px; background: #ddd; margin: 0 3px; }
.spacer { flex: 1; }
.meta {
  font-size: 11px; color: #888; white-space: nowrap;
  padding: 4px 8px; background: #f5f5f5; border-radius: 6px;
  border: 1px solid #e0e0e0;
}

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 8px 14px; min-height: 40px;
  border: 1px solid #888;
  background: #fff;
  border-radius: 8px;
  font-family: monospace;
  font-size: 13px;
  color: #222;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
  user-select: none;
}
button:active, .btn:active { background: #e0e0e0; }
button.primary, .btn.primary { background: #333; color: #fff; border-color: #333; }
button.primary:active, .btn.primary:active { background: #111; }
button.danger, .btn.danger { color: #a33; border-color: #c99; }
button.danger:active, .btn.danger:active { background: #f5e0e0; }
button:disabled, .btn:disabled { opacity: 0.4; cursor: not-allowed; }

.zoom-group {
  display: flex; align-items: center; gap: 2px;
  border: 1px solid #ccc; border-radius: 8px; padding: 2px; background: #fff;
}
.zoom-group button { border: none; min-height: 32px; padding: 4px 10px; background: transparent; }
.zoom-group button:active { background: #eee; }
.zoom-label { font-size: 11px; color: #888; min-width: 36px; text-align: center; }

.main { flex: 1; display: flex; min-height: 0; }

.roll-wrap {
  flex: 1; min-width: 0;
  overflow: auto;
  background: #fff;
  position: relative;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
  border-right: 1px solid #ddd;
}
.roll-wrap.panning { cursor: grabbing; }
.roll-wrap.panning #rollCanvas { cursor: grabbing !important; }
.roll-sizer { position: relative; }
.trackbar { display:flex; gap:6px; align-items:center; padding:6px 10px; overflow-x:auto; background:#fff;
  border-bottom:1px solid #ddd; flex-shrink:0; -webkit-overflow-scrolling:touch; }
.trk { display:flex; align-items:center; gap:5px; border:1px solid #bbb; border-radius:8px; padding:2px 4px 2px 9px;
  min-height:36px; cursor:pointer; white-space:nowrap; background:#fff; font-size:13px; flex-shrink:0; }
.trk.active { border-color:#222; background:#efefef; font-weight:600; }
.trk.dim .nm { opacity:.45; }
.trk .dot { width:10px; height:10px; border-radius:50%; flex-shrink:0; }
.trk .mini { min-height:28px; min-width:28px; padding:0 6px; font-size:11px; border:1px solid #ccc; border-radius:6px;
  background:#fff; cursor:pointer; font-family:monospace; }
.trk .mini.on { background:#333; color:#fff; border-color:#333; }
.trackbar .btn { flex-shrink:0; }
#rollCanvas {
  display: block;
  position: sticky; left: 0; top: 0;
  touch-action: none;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

.inspector {
  width: 240px; flex-shrink: 0;
  background: #fff;
  padding: 10px 12px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
}
.ins-title {
  font-size: 0.8rem; color: #888;
  border-bottom: 1px solid #eee;
  padding-bottom: 4px;
  margin-top: 4px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 0.8rem; color: #444; }
.field input, .field select {
  width: 100%;
  font-family: monospace;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  color: #222;
  min-height: 36px;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: #888;
}
.field input:disabled, .field select:disabled { opacity: 0.45; cursor: not-allowed; background: #f5f5f5; }
.field input[type="number"] { text-align: center; }

.ins-btns { display: flex; gap: 6px; }
.ins-btns button { flex: 1; min-height: 40px; }

.empty-hint {
  font-size: 0.75rem; color: #999; text-align: center;
  padding: 12px 8px; line-height: 1.6;
  background: #f5f5f5; border-radius: 6px;
  border: 1px solid #eee;
}

.synth-panel {
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px;
}
.synth-panel .sp-title { font-size: 0.75rem; color: #888; margin-bottom: 6px; }
.synth-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.synth-row label { font-size: 0.8rem; color: #444; width: 48px; flex-shrink: 0; }
.synth-row input[type=range] {
  flex: 1; -webkit-appearance: none; height: 6px;
  background: #ddd; border-radius: 3px; outline: none;
}
.synth-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #666; cursor: pointer; border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.synth-row .val { font-size: 0.8rem; color: #888; width: 28px; text-align: right; }

.help-tip {
  font-size: 0.72rem; color: #999; line-height: 1.55;
  padding: 8px; background: #f5f5f5; border-radius: 6px;
}
.help-tip kbd {
  display: inline-block; padding: 0 4px; border-radius: 3px;
  background: #fff; border: 1px solid #ccc;
  font-family: monospace; font-size: 10px; color: #444;
}

.statusbar {
  height: 28px; flex-shrink: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px;
  background: #fff;
  border-top: 1px solid #ddd;
  font-size: 11px; color: #888;
  white-space: nowrap; overflow: hidden;
}
.statusbar .sb-item { display: flex; align-items: center; gap: 4px; }
.statusbar .sb-item b { color: #333; font-weight: 600; }
.sb-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #6a6; margin-right: 2px;
}

.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  display: none; align-items: center; justify-content: center;
  padding: 16px; z-index: 100;
}
.modal.show { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #ccc;
  padding: 14px;
  width: 100%; max-width: 520px; max-height: 82vh;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.modal-box.wide { max-width: 600px; }
.modal-box h3 { margin: 0; font-size: 1rem; font-weight: 600; font-family: monospace; }
.modal-box textarea {
  width: 100%; min-height: 200px;
  font-family: monospace; font-size: 13px; line-height: 1.5;
  padding: 10px; border: 1px solid #ccc; border-radius: 6px;
  resize: vertical; background: #fafafa; color: #222;
}
.modal-box textarea:focus { outline: none; border-color: #888; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions button { flex: 1; min-height: 42px; }

.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.icon-btn {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 6px;
  border: 1px solid #ccc; background: #fff;
  color: #666; font-size: 18px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
  font-family: monospace;
}
.icon-btn:active { background: #e0e0e0; }

.ex-status { font-size: 12px; color: #888; line-height: 1.5; }
.ex-list {
  display: flex; flex-direction: column; gap: 6px;
  overflow-y: auto; flex: 1 1 auto; min-height: 120px;
}
.ex-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name count" "desc count";
  gap: 2px 10px; align-items: center;
  padding: 10px 12px;
  border: 1px solid #ddd; border-radius: 8px;
  background: #fafafa; cursor: pointer; text-align: left;
  font-family: monospace;
}
.ex-item:active { background: #eee; }
.ex-item.loading { opacity: 0.5; pointer-events: none; }
.ex-name { grid-area: name; font-size: 13px; font-weight: 600; color: #222;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-desc { grid-area: desc; font-size: 11px; color: #888;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-count { grid-area: count; font-size: 11px; color: #555;
  background: #eee; padding: 3px 8px; border-radius: 10px; white-space: nowrap; }
.ex-loading { padding: 18px 10px; text-align: center; color: #999; font-size: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 44px;
  transform: translateX(-50%) translateY(10px);
  background: #333; color: #fff;
  padding: 8px 16px; border-radius: 6px; font-size: 13px;
  font-family: monospace;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 200;
  white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 720px) {
  .main { flex-direction: column; }
  .inspector {
    width: 100%; max-height: 36vh;
    border-top: 1px solid #ddd;
    flex-direction: row; flex-wrap: wrap;
    align-items: flex-end; padding: 8px; gap: 8px;
  }
  .ins-title { display: none; }
  .field { flex: 1 1 90px; min-width: 80px; }
  .ins-btns { flex: 1 1 100%; }
  .empty-hint { flex: 1 1 100%; padding: 8px; }
  .synth-panel { flex: 1 1 100%; }
  .meta { display: none; }
  .help-tip { display: none; }
  button, .btn { padding: 6px 10px; font-size: 12px; min-height: 32px; }
  .toolbar { padding: 6px 8px; }
  .tb-sep { display: none; }
  .roll-wrap { border-right: none; }
}

/* ===== 专业 DAW / UTAU 风格覆写 ===== */
:root {
  --bg-dark: #18181a;
  --bg-panel: #222225;
  --bg-toolbar: #2a2a2e;
  --border-color: #3e3e42;
  --text-main: #e0e0e0;
  --text-muted: #888;
  --accent: #007acc;
  --btn-bg: #333338;
  --btn-border: #555;
  --input-bg: #1e1e1e;
}

html, body {
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.toolbar, .trackbar, .statusbar {
  background: var(--bg-toolbar);
  border-color: var(--border-color);
}

button, .btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  color: var(--text-main);
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12px;
}
button:active, .btn:active { background: #444; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger, .btn.danger { color: #e74c3c; border-color: #c0392b; }

.zoom-group { background: var(--bg-panel); border-color: var(--border-color); }
.meta { background: var(--bg-panel); border-color: var(--border-color); color: var(--text-muted); }

/* 轨道与属性面板 */
.roll-wrap { background: var(--bg-dark); border-right: 1px solid var(--border-color); cursor: default; min-height: 0; }
.roll-wrap.panning { cursor: grabbing; }
.roll-sizer { min-height: 100%; }
#rollCanvas { background: #1e1e1e; }
.trk { background: var(--bg-panel); border-color: var(--border-color); color: var(--text-main); border-radius: 4px; }
.trk.active { border-color: var(--accent); background: #2a3a4a; }
.trk .mini { background: var(--btn-bg); border-color: var(--border-color); color: var(--text-main); }
.trk .mini.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.inspector { background: var(--bg-panel); border-left: 1px solid var(--border-color); width: 260px; }
.ins-title { border-bottom-color: var(--border-color); }
.field input, .field select {
  background: var(--input-bg); border: 1px solid var(--border-color); color: var(--text-main);
  border-radius: 4px; min-height: 30px;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.synth-panel { background: var(--bg-dark); border-color: var(--border-color); }

.help-tip, .empty-hint { background: var(--bg-dark); border-color: var(--border-color); color: var(--text-muted); }
.help-tip kbd { background: var(--btn-bg); border-color: var(--border-color); color: var(--text-main); }
.modal-box { background: var(--bg-panel); border-color: var(--border-color); color: var(--text-main); }
.modal-box textarea { background: var(--input-bg); border-color: var(--border-color); color: var(--text-main); }
.ex-item { background: var(--bg-dark); border-color: var(--border-color); color: var(--text-main); }
.ex-item:active { background: #333; }
.ex-name { color: var(--text-main); }
.ex-desc { color: var(--text-muted); }
.ex-count { background: #333; color: var(--text-muted); }
.icon-btn { background: var(--btn-bg); border-color: var(--border-color); color: var(--text-muted); }
.toast { background: #111; }
.statusbar { color: var(--text-muted); }
.statusbar .sb-item b { color: var(--text-main); }
.field label { color: var(--text-muted); }
.ins-title { color: var(--text-muted); }
.sp-title { color: var(--text-muted); }
.synth-row label { color: var(--text-muted); }
.synth-row .val { color: var(--text-muted); }
.modal-box h3 { color: var(--text-main); }

/* ===== 启动载入页 / 存档 ===== */
.start-screen {
  position: fixed; inset: 0; z-index: 300;
  background: var(--bg-dark);
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px 16px; gap: 16px;
  overflow-y: auto;
}
.start-screen.show { display: flex; }
.start-brand {
  text-align: center; margin-bottom: 8px;
}
.start-brand h1 {
  margin: 0; font-size: 1.4rem; font-weight: 600;
  color: var(--text-main); letter-spacing: 0.02em;
}
.start-brand p {
  margin: 6px 0 0; font-size: 0.85rem; color: var(--text-muted);
}
.start-list {
  width: 100%; max-width: 440px;
  display: flex; flex-direction: column; gap: 8px;
  max-height: min(52vh, 420px); overflow-y: auto;
}
.start-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name actions" "meta actions";
  gap: 2px 12px; align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-panel);
  cursor: pointer; text-align: left;
  color: var(--text-main);
}
.start-item:active, .start-item:hover { border-color: var(--accent); background: #2a3a4a; }
.start-item .si-name { grid-area: name; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.start-item .si-meta { grid-area: meta; font-size: 11px; color: var(--text-muted); }
.start-item .si-actions { grid-area: actions; display: flex; gap: 6px; }
.start-item .si-actions .btn { min-height: 28px; padding: 4px 8px; font-size: 11px; }
.start-actions {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  width: 100%; max-width: 440px;
}
.start-actions .btn { min-width: 140px; min-height: 40px; }
.start-empty {
  font-size: 13px; color: var(--text-muted); text-align: center; padding: 20px;
}
