:root {
  --primary: #1a1a1a;
  --secondary: #4a4a4a;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6c757d;
  --border: #dee2e6;

  --success: #22c55e;
  --success-bg: #f0f9f0;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --error: #ef4444;
  --error-bg: #fef2f2;
  --info: #3b82f6;
  --info-bg: #eff6ff;

  --radius: 4px;
  --radius-btn: 2px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

/* HTMLの hidden 属性は常に非表示（UA差異対策） */
[hidden] { display: none !important; }

.app { height: 100vh; display: flex; flex-direction: column; }

.siteFooter {
  border-top: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.siteFooter__inner {
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.siteFooter__sep { opacity: 0.7; }

.siteFooter a {
  color: inherit;
  text-decoration: none;
}

.siteFooter a:hover {
  text-decoration: underline;
}

.topbar {
  display: grid;
  /* 左/中央/右はそれぞれ1行占有（縦積み） */
  grid-template-columns: 1fr;
  grid-template-areas:
    "left"
    "center"
    "right";
  gap: 12px;
  justify-items: stretch;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar__left { grid-area: left; }
.topbar__center { grid-area: center; }
.topbar__right { grid-area: right; }

/* 折りたたみ時は、左上タイトル＋中央(Transport)を優先して幅を確保する */
.topbar.topbar--compact {
  grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr) minmax(0, 0fr);
}

/* Grid item が縮めずにレイアウトを押し広げるのを防ぐ */
.topbar__left,
.topbar__center,
.topbar__right {
  min-width: 0;
}

.freePlanPanel {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  padding: 8px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.freePlanPanel a {
  color: inherit;
  text-decoration: none;
}

.freePlanPanel a:hover {
  text-decoration: underline;
}

.brand__title { font-weight: 650; letter-spacing: .2px; }
.brand__subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }

.brand__topRow {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.brand__compactActions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.brand__actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.brand__panels {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.topbar__center { display: flex; gap: 10px; align-items: center; justify-content: flex-start; flex-wrap: wrap; }
.topbar__right { display: flex; justify-content: flex-start; }
.fileActions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* 折りたたみボタン: 箱サイズは維持しつつ、三角マークだけ大きくする */
#topbarExtrasToggleBtn,
#layerStripToggleBtn,
#fileActionsExtrasToggleBtn {
  overflow: visible;
}

.toggleIcon {
  display: inline-block;
  transform: scale(3);
  transform-origin: center;
  line-height: 1;
}

.timeDisplay {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}

/* 右上のファイル操作エリアは1行幅を使って折り返しを安定化 */
.topbar__right .fileActions {
  width: 100%;
  justify-content: flex-start;
}

.dataMsHeader {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* 右上ツールバー内では、server/local の内側要素を横一列に並べやすくする */
.topbar__right .fileActions #serverMsBar,
.topbar__right .fileActions #localMsBar {
  display: contents;
}

.dataMsHeader__group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
  min-width: 0;
  order: 20;
}

.dataMsHeader__group .input--select {
  width: min(220px, 34vw);
  min-width: 140px;
}

/* ファイル操作バーは単独で1行分を確保（未保存マーク等で他要素が上下しないように） */
#serverMsBar,
#localMsBar {
  flex: 0 0 auto;
  width: auto;
}

/* fileActions: 並び順（左→右）
  曲をクリア / WAV生成 / WAV一覧 / ファイルドロップダウン / 新規曲作成 / 保存 / ▼
*/
#discardSongBtn { order: 10; }
#renderWavBtn { order: 11; }
#playWavBtn { order: 12; }

#newSongBtn { order: 40; }

#saveDataMsBtnHeader,
#exportMsBtn { order: 50; }

/* 保存の右に「保存以外を畳む（▼）」 */
#fileActionsExtrasToggleBtn { order: 60; }

.fileActions__extras {
  display: contents;
}

.dataMsHeader__label {
  font-size: 12px;
  color: var(--muted);
}

.dataMsHeader__name {
  font-size: 12px;
  color: var(--text);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

/* Grid children can overflow horizontally unless allowed to shrink */
.main > * { min-width: 0; }

@media (max-width: 1100px) {
  .topbar { grid-template-columns: 1fr; justify-items: stretch; }
  .topbar__right { justify-content: flex-start; }
  .main { padding: 10px; }
}

/* Mobile: 画面高さが足りずピアノロールが潰れるのを避ける */
@media (max-width: 720px) {
  /* トップバーが縦に伸びても、下が潰れないよう全体は縦スクロール可能にする */
  .app {
    height: auto;
    min-height: 100dvh;
  }

  .main {
    flex: 0 0 auto;
    overflow: visible;
    padding: 8px;
  }

  /* ピアノロールの見える高さを確保（端末差を吸収するため clamp） */
  .piano {
    flex: 0 0 auto;
    min-height: 78dvh;
  }

  .piano__scroll {
    height: clamp(480px, 62dvh, 900px);
  }

  /* 下部のヒント領域を一旦隠して可視領域を増やす */
  .piano .card__footer {
    display: none;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}

.card__header {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card__actions { display: inline-flex; align-items: center; gap: 6px; }

.card__body { display: block; }
.card__body[hidden] { display: none; }

.iconBtn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-btn);
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
}
.iconBtn:hover { border-color: #cfd6dd; background: #fbfbfb; }
.iconBtn[aria-expanded="false"] { transform: rotate(-90deg); }

.card__title { font-weight: 650; }
.card__subtitle { font-size: 12px; color: var(--muted); }

.card__footer {
  padding: 10px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.meta { color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; }
.small { font-size: 12px; color: var(--muted); }

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.controls__extras {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.pianoHeader {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pianoHeader__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.pianoHeader__bottom {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-btn);
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.btn:hover { border-color: #cfd6dd; background: #fbfbfb; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* <label class="btn ..."> のような擬似ボタン用（file input 等） */
label.btn[aria-disabled="true"] {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

/* フリープラン案内トーストを出すため、soft-lock中はクリック可能にする */
label.btn[aria-disabled="true"][data-free-locked="1"] {
  pointer-events: auto;
}

.btn[data-free-locked="1"] {
  opacity: .5;
  cursor: not-allowed;
}

.btn[data-free-locked="1"]:hover {
  border-color: var(--border);
  background: var(--surface);
}

.btn[data-free-locked="1"]:active {
  transform: none;
}

.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn--primary:hover { background: #111; border-color: #111; }

.btn--toggle[aria-pressed="true"] {
  border-color: var(--info);
  box-shadow: 0 0 0 2px rgba(59,130,246,.12);
}

/* 再生中の「停止」状態（薄青） */
.btn--stop {
  background: #dbeafe; /* blue-100 */
  border-color: #93c5fd; /* blue-300 */
  color: #1e3a8a; /* blue-900 */
}
.btn--stop:hover {
  background: #bfdbfe; /* blue-200 */
  border-color: #60a5fa; /* blue-400 */
}

.btn--danger {
  background: var(--error-bg);
  border-color: var(--error);
  color: #7f1d1d;
}

.btn--success {
  background: var(--success-bg);
  border-color: var(--success);
  color: #14532d;
  text-decoration: none;
}

/* 保存ボタン：保存済み（dirty=false）のときは白にする */
#saveDataMsBtnHeader.btn--success:not(.btn--dirty),
#saveDataMsBtn.btn--success:not(.btn--dirty),
#exportMsBtn.btn--success:not(.btn--dirty),
#compactSaveBtn.btn--success:not(.btn--dirty) {
  background: #ffffff;
  border-color: var(--border);
  color: var(--text);
}
#saveDataMsBtnHeader.btn--success:not(.btn--dirty):hover,
#saveDataMsBtn.btn--success:not(.btn--dirty):hover,
#exportMsBtn.btn--success:not(.btn--dirty):hover,
#compactSaveBtn.btn--success:not(.btn--dirty):hover {
  background: #fbfbfb;
  border-color: #cfd6dd;
}

/* 未保存（dirty）を明確に：保存ボタンを緑で強調 */
.btn--success.btn--dirty {
  background: var(--success-bg);
  border-color: var(--success);
  color: #14532d;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.22);
}
.btn--success.btn--dirty:hover {
  background: #e7f8e7;
  border-color: #16a34a;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.28);
}

/* 未保存状態は「色だけ」に依存しない：ボタン末尾に●を付与 */
#saveDataMsBtnHeader.btn--dirty::after,
#saveDataMsBtn.btn--dirty::after,
#exportMsBtn.btn--dirty::after,
#compactSaveBtn.btn--dirty::after {
  content: ' ●';
  margin-left: 2px;
  font-size: 12px;
  line-height: 1;
  color: currentColor;
}

/* モーダル（画面外クリックで閉じない） */
.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.35);
  z-index: 9999;
}

.modal__dialog {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
}

.modal__title { font-weight: 650; }

.modal__body {
  padding: 10px 10px;
}

.modal__footer {
  padding: 10px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* PianoRoll mobile tap dialog */
.nmseTapModal__info {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.nmseTapModal__lenRow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nmseTapModal__lenButtons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.nmseTapModal__lenButtons .btn {
  padding: 6px 8px;
  font-size: 12px;
}

/* 個別保存の「書き出し」等：通常ボタンでも未保存を緑で示す */
.btn--dirty:not(.btn--success) {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.btn--file { cursor: pointer; }

.field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
}
.field__label { font-size: 12px; color: var(--muted); }
.field__suffix { font-size: 12px; color: var(--muted); }

.input {
  width: 90px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 6px 8px;
  font-size: 13px;
}
.input--select {
  width: 160px;
  background: var(--surface);
}
.input:focus { outline: none; border-color: var(--info); box-shadow: 0 0 0 2px rgba(59,130,246,.12); }

.slider {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
}
.slider__label { font-size: 12px; color: var(--muted); }
.slider input[type="range"] { width: 120px; }
.slider__value { font-size: 12px; color: var(--muted); min-width: 42px; text-align: right; }

.slider--muted {
  opacity: 0.72;
}

.mixer {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mixerRow {
  display: grid;
  grid-template-columns: 1fr 140px 52px;
  gap: 10px;
  align-items: center;
}

.mixerRow--muted {
  opacity: 0.72;
}

.mixerRow--muted .mixerRow__dot {
  filter: grayscale(1);
}

.mixerRow--muted input[type="range"] {
  accent-color: #9ca3af;
  filter: grayscale(1);
}

.mixerRow__label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
}

.mixerRow__nameWrap {
  flex: 1 1 auto;
  min-width: 0;
}

.mixerRow__nameLine {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mixerRow__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mixerRow__desc {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.25;
  white-space: normal;
}

.mixerRow__mute {
  margin-left: auto;
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1;
  min-width: 34px;
  text-align: center;
}

.mixerRow__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.10);
  flex: 0 0 auto;
}

.mixerRow__value { font-size: 12px; color: var(--muted); text-align: right; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }

.layerToneHint {
  margin: 2px 0 6px;
  line-height: 1.25;
  color: var(--muted);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  background: var(--surface);
}
.tab:hover { border-color: #cfd6dd; }
.tab[aria-selected="true"] { border-color: var(--layer-color, var(--primary)); box-shadow: 0 0 0 2px rgba(59,130,246,.08); }
.tab__dot { width: 10px; height: 10px; border-radius: 999px; border: 1px solid rgba(0,0,0,.08); }
.tab__dot--ring { background: #fff; border: 2px solid var(--layer-color, var(--primary)); }

/* 音色プリセットが不足しているレイヤー（音色パック未導入/外した等） */
.tab--missing {
  border-color: rgba(239, 68, 68, 0.85);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.10);
}
.tab--missing:hover { border-color: rgba(239, 68, 68, 0.95); }
.tab--missing[aria-selected="true"] {
  border-color: rgba(239, 68, 68, 0.95);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.14);
}

.contextMenu {
  position: fixed;
  z-index: 2000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.10);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
}

.contextMenu__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
}

.contextMenu__item:hover {
  background: rgba(59,130,246,.06);
  border-color: rgba(59,130,246,.12);
}

.tonePicker {
  position: fixed;
  z-index: 2001;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  padding: 10px;
  width: min(460px, calc(100vw - 16px));
}

.tonePicker__title {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.tonePicker__select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.tonePicker__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.layerVolPicker {
  position: fixed;
  z-index: 2001;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  padding: 10px;
  width: min(420px, calc(100vw - 16px));
}

.layerVolPicker__title {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.layerVolPicker__hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.layerVolPicker__row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.layerVolPicker__range {
  flex: 1;
}

.layerVolPicker__num {
  width: 76px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.layerVolPicker__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.piano { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.piano__scroll {
  flex: 1;
  overflow: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(#fff, #fff);
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  position: relative;
}

.piano__scroll.pianoDropHover {
  box-shadow: inset 0 0 0 3px rgba(34, 197, 94, 0.22);
}
.piano__canvas { display: block; background: #fff; }

.pianoTimeline {
  position: sticky;
  top: 0;
  height: 52px;
  background: rgba(248, 249, 250, 0.92);
  backdrop-filter: blur(2px);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}

.cursorRail {
  position: absolute;
  left: 0;
  right: 0;
  height: 22px;
  cursor: pointer;
  user-select: none;
  z-index: 0;
}

.cursorRail::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  background: rgba(17, 24, 39, 0.10);
}

.cursorRail--record { top: 2px; }
.cursorRail--record::after { background: rgba(239, 68, 68, 0.18); }

.cursorRail--play { top: 26px; }
.cursorRail--play::after { background: rgba(37, 99, 235, 0.18); }

.cursorRail:hover::after {
  filter: brightness(0.9);
  box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.04);
}

.recordCursorLabel {
  position: absolute;
  top: 6px;
  padding: 2px 8px;
  border: 1px solid rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.12);
  border-radius: 999px;
  font-size: 12px;
  color: rgba(127, 29, 29, 0.95);
  cursor: grab;
  user-select: none;
  white-space: nowrap;
  z-index: 2;
}

.recordCursorLabel--bookmark {
  top: 30px;
  border-color: rgba(37, 99, 235, 0.55);
  background: rgba(37, 99, 235, 0.12);
  color: rgba(30, 64, 175, 0.95);
}

.recordCursorLabel:hover {
  border-color: rgba(239, 68, 68, 0.80);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.22);
}

.recordCursorLabel--bookmark:hover {
  border-color: rgba(37, 99, 235, 0.80);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.22);
}

.recordCursorLabel:active {
  cursor: grabbing;
}

.nmseContextMenu {
  position: fixed;
  z-index: 10000;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0,0,0,.12);
}

.nmseContextMenu__item {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}

.nmseContextMenu__item:hover {
  background: rgba(59,130,246,.08);
  border-color: rgba(59,130,246,.18);
}



.floatingPanel {
  position: fixed;
  right: 12px;
  top: 64px;
  width: 360px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 76px);
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  z-index: 9000;
}

.floatingPanel--songSettings {
  top: 116px;
}

.floatingPanel--popout {
  position: static;
  top: auto;
  left: auto;
  right: auto;
  width: auto;
  max-width: none;
  max-height: none;
  height: 100vh;
  border: 0;
  border-radius: 0;
}

.floatingPanel[hidden] {
  display: none;
}

.floatingPanel--piano {
  width: 520px;
}

.floatingPanel--wav {
  width: 520px;
}

.floatingPanel--msList {
  width: 520px;
}

.floatingPanel--pad {
  width: 520px;
}

.floatingPanel--sc {
  width: 380px;
}

.btn--panelToggle {
  background: #e5e7eb;
  border-color: #d1d5db;
  color: #111827;
}

.btn--panelToggle[aria-pressed="true"] {
  background: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
}

.panelFile {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.panelFile input[type="file"] {
  max-width: 260px;
}

.panelData {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px dashed var(--border);
}

.panelData__row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.panelData__row .field {
  margin: 0;
}

.panelData__row .input[type="text"] {
  min-width: 220px;
}

.wavList {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msList {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msRow {
  border: 1px dashed var(--border);
  border-radius: var(--radius-btn);
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.msRow__name {
  font-size: 13px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msRow__meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.msRow__actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wavRow {
  border: 1px dashed var(--border);
  border-radius: var(--radius-btn);
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.wavRow__name {
  font-size: 13px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wavRow__meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.wavRow__actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wavPlayer {
  width: 100%;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.pianoRec {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pianoRec__row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.pianoKeys {
  position: relative;
  padding: 10px;
  display: flex;
  gap: 2px;
  user-select: none;
  overflow-x: auto;
}

.pianoKey {
  position: relative;
  width: 38px;
  height: 140px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 0 0 4px 4px;
  cursor: pointer;
  touch-action: none;
}

.pianoKey.pianoKey--recent {
  box-shadow: inset 0 0 0 999px rgba(239, 68, 68, var(--recent-fill, 0.0));
  border-color: rgba(239, 68, 68, var(--recent-border, 0.0));
}

.pianoKey:active,
.pianoKey[data-active="true"] {
  background: #f3f4f6;
}

.pianoKey.pianoKey--disabled {
  cursor: not-allowed;
  opacity: 0.75;
  background: #cbd5e1;
  border-color: #94a3b8;
  box-shadow: inset 0 0 0 999px rgba(0, 0, 0, 0.05);
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(148, 163, 184, 0.55) 0px,
    rgba(148, 163, 184, 0.55) 6px,
    rgba(203, 213, 225, 0.0) 6px,
    rgba(203, 213, 225, 0.0) 12px
  );
}

.pianoKey--black {
  width: 26px;
  height: 90px;
  background: #111827;
  border-color: #0b1220;
  position: absolute;
  top: 10px;
  margin-left: -13px;
  z-index: 2;
  border-radius: 0 0 3px 3px;
}

.pianoKey--black.pianoKey--recent {
  box-shadow:
    0 0 0 2px rgba(239, 68, 68, var(--recent-border, 0.0)),
    0 0 14px rgba(239, 68, 68, var(--recent-glow, 0.0));
}

.pianoKey--black:active,
.pianoKey--black[data-active="true"] {
  background: #0b1220;
}

.pianoKey--black.pianoKey--disabled {
  opacity: 0.75;
  background: #4b5563;
  border-color: #111827;
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(17, 24, 39, 0.55) 0px,
    rgba(17, 24, 39, 0.55) 6px,
    rgba(75, 85, 99, 0.0) 6px,
    rgba(75, 85, 99, 0.0) 12px
  );
}

.pianoKeys__footer {
  padding: 0 10px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.pianoKeys__controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.floatingPanel__header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move;
  user-select: none;
}

.floatingPanel__title { font-weight: 650; font-size: 13px; }
.floatingPanel__actions { display: inline-flex; gap: 6px; align-items: center; }

.floatingPanel__body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  min-height: 0;
}

.padGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
}

.pad {
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
  padding: 10px;
  cursor: pointer;
  text-align: left;
}
.pad.pad--recent {
  box-shadow:
    inset 0 0 0 999px rgba(239, 68, 68, var(--recent-fill, 0.0)),
    0 0 14px rgba(239, 68, 68, var(--recent-glow, 0.0));
  border-color: rgba(239, 68, 68, var(--recent-border, 0.0));
}
.pad:hover { border-color: #cfd6dd; background: #fbfbfb; }
.pad:active { transform: translateY(1px); }
.pad__title { font-weight: 650; font-size: 13px; }
.pad__desc { font-size: 12px; color: var(--muted); margin-top: 4px; }

.inspector { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.inspector__row { display: grid; grid-template-columns: 80px 1fr; gap: 10px; align-items: center; }
.inspector .k { font-size: 12px; color: var(--muted); }
.inspector .v { font-size: 13px; }

.export { padding: 10px; display: flex; flex-direction: column; gap: 8px; }

.toastHost {
  position: fixed;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  width: min(420px, calc(100vw - 24px));
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 12px;
}
.toast__title { font-weight: 650; font-size: 13px; }
.toast__msg { font-size: 12px; color: var(--muted); margin-top: 4px; }

.toast--anchored {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 10000;
}

.toast__actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.toast__actionLink {
  font-size: 12px;
  color: inherit;
  text-decoration: underline;
}

.toast__actionLink:hover {
  text-decoration-thickness: 2px;
}

.toast--success { background: var(--success-bg); border-color: var(--success); color: #14532d; }
.toast--warning { background: var(--warning-bg); border-color: var(--warning); color: #92400e; }
.toast--error { background: var(--error-bg); border-color: var(--error); color: #7f1d1d; }
.toast--info { background: var(--info-bg); border-color: var(--info); color: #1e3a8a; }

.loadingOverlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 249, 250, 0.72);
  backdrop-filter: blur(2px);
  z-index: 9000;
}

.loadingOverlay__dialog {
  width: min(360px, calc(100vw - 24px));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  box-shadow: 0 12px 30px rgba(0,0,0,0.12);
}

.loadingOverlay__text {
  font-size: 13px;
  color: var(--muted);
}

.loadingSpinner {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(26, 26, 26, 0.20);
  border-top-color: rgba(26, 26, 26, 0.85);
  animation: nmse_spin 0.9s linear infinite;
  flex: 0 0 auto;
}

@keyframes nmse_spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .loadingSpinner { animation: none; }
}
