/* ============================================================
   style.css — QNPITCH
   QNAUDIO（style-core.css）/ QNTEMPOのデザイントークン・コンポーネントを
   そのまま踏襲。スマホ専用単一レイアウトのため、PC/SP分割はしない。
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400;1,500&display=swap');

:root {
  --accent-primary: #3b82f6;
  --accent-secondary: #1d4ed8;
  --accent-glow: rgba(59, 130, 246, 0.35);
  --accent-hover-1: #2563eb;
  --accent-hover-2: #1e40af;
  --good: #4ade80;
  --warn: #facc15;
  --bad: #f87171;
  --font-display: 'Instrument Sans';
  --font-body: 'Instrument Sans';

  --ease-snap: cubic-bezier(0.2, 0, 0, 1);
  --ease-glide: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-dismiss: cubic-bezier(0.4, 0, 1, 1);

  --dur-hover: 130ms;
  --dur-press: 100ms;
  --dur-open: 240ms;
  --dur-dismiss: 200ms;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  touch-action: pan-x pan-y;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  height: 100dvh;
  overflow: hidden;
  background: #0d0d0f;
  color: #f0f0f3;
  font-family: var(--font-body, 'Instrument Sans'), -apple-system, BlinkMacSystemFont, sans-serif;
  margin: 0;
  padding: 24px 24px 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  user-select: none;
}

/* ---------- Header ---------- */
#appHeader {
  width: 100%;
  max-width: 1400px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  position: relative;
  z-index: 200;
  flex-shrink: 0;
}

#appHeaderText {
  min-width: 0;
}

#appLogo {
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 1px;
  margin: 0;
  color: #f0f0f3;
  text-transform: uppercase;
}

#appLogoQN {
  color: var(--accent-primary);
}

#appVersion {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: #6b6b7b;
  text-transform: none;
  vertical-align: middle;
}

/* ---------- Pitch roll stage — the heart of the app ---------- */
.stage-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 6px;
}

.stage-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.stage-meta-label {
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #55555f;
}

.stage-meta-value {
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: #f0f0f3;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  min-width: 52px;
}

.cents-readout {
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #55555f;
  font-variant-numeric: tabular-nums;
}
.cents-readout.good { color: var(--good); }
.cents-readout.warn { color: var(--warn); }
.cents-readout.bad { color: var(--bad); }

.meta-div-toggle {
  display: flex;
  margin-left: auto;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.meta-div-btn {
  padding: 6px 12px;
  background: #1c1c24;
  color: #6b6b7b;
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  border: none;
}
.meta-div-btn:active { transform: scale(0.95); background: var(--accent-glow); color: var(--accent-primary); }
.meta-div-btn + .meta-div-btn { border-left: 1px solid rgba(255, 255, 255, 0.08); }
.meta-div-btn.active { color: var(--accent-primary); background: var(--accent-glow); }

/* ---------- Pitch roll canvas panel ---------- */
/* 左：固定の音階ラベル列（縦スクロール可、横スクロールしても常に見える）
   右：ピッチ軌跡キャンバス（横=時間・縦=音高、縦スクロールは左列とJSで同期） */
.pitch-roll-panel {
  flex: 1;
  min-height: 0;
  border-radius: 16px;
  background: #16161b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  display: flex;
}

.pitch-roll-keys {
  flex-shrink: 0;
  width: 44px;
  overflow-y: hidden;
  overflow-x: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: #18181f;
  position: relative;
  /* JS側でscrollTopを操作して.pitch-roll-scrollと同期させるための隠しスクロール領域。
     ユーザーが直接ここを操作することは想定していないためoverflow-yはhiddenのままでよいが、
     scrollTopの代入自体はhiddenでも有効に働く。 */
}

.pitch-roll-key-label {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 10px;
  font-weight: 600;
  color: #c8c8d0;
  box-sizing: border-box;
}
.pitch-roll-key-label.sharp { color: #4a4a56; }
.pitch-roll-key-label.is-c { color: var(--accent-primary); font-weight: 800; }
.pitch-roll-key-label { cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; transition: color 0.08s ease; }
.pitch-roll-key-label.pressed { color: var(--accent-primary); font-weight: 800; background: rgba(236, 72, 153, 0.16); }

.pitch-roll-scroll {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}

/* canvasとカーソル線を両方内包するラッパー。canvasの実サイズ(=スクロール
   コンテンツの全高・全幅)に合わせて広がるので、position:relativeの基準に
   することでカーソル線がスクロール量に関わらず全高きちんと伸びる。 */
.pitch-roll-content {
  position: relative;
  display: inline-block;
}

.pitch-roll-scroll canvas {
  display: block;
}

/* プレイバックのカーソル線（再生位置と軌跡を連動させる） */
.playback-cursor {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 8px rgba(255,255,255,0.8);
  pointer-events: none;
  display: none;
}
.playback-cursor.active { display: block; }

.stage-hint {
  text-align: center;
  font-family: var(--font-body, 'Instrument Sans'), sans-serif;
  font-size: 11px;
  color: #55555f;
  margin-top: 8px;
  margin-bottom: 0;
  letter-spacing: 0.1px;
  flex-shrink: 0;
}
.stage-hint.live { color: var(--good); }

/* ---------- Volume panel (RMS音量ライン、ピッチロールの下に固定高さで表示) ---------- */
.volume-panel {
  flex-shrink: 0;
  height: 84px;
  margin-top: 6px;
  border-radius: 12px;
  background: #16161b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  display: flex;
}

.volume-panel-label {
  flex-shrink: 0;
  width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: #18181f;
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #55555f;
}

.volume-scroll {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}

.volume-scroll canvas {
  display: block;
}

/* ---------- Recordings list modal (LIST button opens this) ---------- */
.rec-list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rec-list-empty {
  text-align: center;
  padding: 20px 0;
  color: #55555f;
  font-family: var(--font-body, 'Instrument Sans'), sans-serif;
  font-size: 13px;
  margin: 0;
}

.rec-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  border-radius: 12px;
  background: #1c1c24;
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: background var(--dur-hover) var(--ease-snap), border-color var(--dur-hover) var(--ease-snap);
}
.rec-row.playing {
  border-color: var(--accent-primary);
  background: var(--accent-glow);
}
.rec-row-icon {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
}
.rec-row-icon svg { width: 14px; height: 14px; fill: currentColor; }
.rec-row-info {
  flex: 1;
  min-width: 0;
}
.rec-row-name {
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #f0f0f3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rec-row-meta {
  font-family: var(--font-body, 'Instrument Sans'), sans-serif;
  font-size: 10px;
  color: #6b6b7b;
  margin-top: 2px;
}
.rec-row-edit {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: #55555f;
  cursor: pointer;
}
.rec-row-edit svg { width: 14px; height: 14px; fill: currentColor; }
.rec-row-edit:active { background: var(--accent-glow); color: var(--accent-primary); }

.rec-row-delete {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: #55555f;
  cursor: pointer;
  font-size: 16px;
}
.rec-row-delete:active { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

/* ---------- Save / Rename dialogs ---------- */
.preset-name-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  background: #1c1c24;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f0f0f3;
  font-family: var(--font-body, 'Instrument Sans'), sans-serif;
  font-size: 14px;
  box-sizing: border-box;
}
.preset-name-input:focus { outline: none; border-color: var(--accent-primary); }

.save-btn-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.save-cancel-btn {
  flex: 1;
  padding: 14px;
  border-radius: 14px;
  background: #1c1c24;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #c8c8d0;
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  box-sizing: border-box;
}
.save-cancel-btn:active { transform: scale(0.97); background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.save-ok-btn { flex: 1; margin-top: 0; }

/* ---------- Settings modal ---------- */
/* 設定画面は上半分に効果範囲（ピッチロール/音量ライン）を見せたいので、
   高さを画面の半分程度に抑える（背景は不透過） */
.settings-popup {
  max-height: 50vh;
  overflow-y: auto;
}

/* ---------- Key & Drone modal ---------- */
.key-popup {
  max-height: 80vh;
  overflow-y: auto;
}
.key-select-row {
  display: flex;
  gap: 8px;
  margin: 12px 0 4px;
}
.key-select {
  flex: 1;
  padding: 10px 12px;
  border-radius: 12px;
  background: #1c1c24;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f0f0f3;
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 14px;
  font-weight: 600;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236b6b7b'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
}
.key-select:focus { outline: none; border-color: var(--accent-primary); }

/* ---------- Metronome modal ---------- */
.tempo-popup {
  max-height: 80vh;
  overflow-y: auto;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.settings-row-label {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-row-title {
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #f0f0f3;
}
.settings-row-desc {
  font-family: var(--font-body, 'Instrument Sans'), sans-serif;
  font-size: 11px;
  color: #6b6b7b;
  line-height: 1.4;
}

/* SET内の他画面（Key & Drone等）への遷移用の行 */
.settings-row-link {
  cursor: pointer;
  margin: -4px -4px 10px;
  padding: 8px 4px;
  border-radius: 10px;
  transition: background 0.12s ease;
}
.settings-row-link:hover,
.settings-row-link:active {
  background: rgba(255, 255, 255, 0.05);
}
.settings-row-link .settings-row-title { color: var(--accent-primary); }
.settings-row-chevron {
  flex-shrink: 0;
  font-size: 20px;
  color: var(--accent-primary);
  line-height: 1;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}
.settings-field-label {
  font-family: var(--font-body, 'Instrument Sans'), sans-serif;
  font-size: 12px;
  color: #8b8b9e;
}
.settings-field-value {
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-primary);
  font-variant-numeric: tabular-nums;
}

.settings-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #1c1c24;
  outline: none;
  margin: 0;
}
.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 2px 8px var(--accent-glow);
  cursor: pointer;
  border: none;
}
.settings-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 2px 8px var(--accent-glow);
  cursor: pointer;
  border: none;
}
.settings-slider::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: #1c1c24;
}

.settings-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 14px 0;
}

.settings-toggle {
  flex-shrink: 0;
  width: 46px;
  height: 26px;
  border-radius: 13px;
  background: #1c1c24;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  position: relative;
  padding: 0;
  transition: background var(--dur-hover) var(--ease-snap), border-color var(--dur-hover) var(--ease-snap);
}
.settings-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #6b6b7b;
  transition: transform var(--dur-hover) var(--ease-snap), background var(--dur-hover) var(--ease-snap);
}
.settings-toggle[aria-checked="true"] {
  background: var(--accent-glow);
  border-color: var(--accent-primary);
}
.settings-toggle[aria-checked="true"] .settings-toggle-knob {
  background: var(--accent-primary);
  transform: translateX(20px);
}

.settings-btn-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-top: 16px;
}

/* ---------- Playback info row (inside top-controls, above the button row) ---------- */
.pb-info-row {
  display: none;
  align-items: center;
  gap: 10px;
}
.pb-info-row.open { display: flex; }

.pb-name {
  flex-shrink: 0;
  max-width: 40%;
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: #f0f0f3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pb-score {
  flex-shrink: 0;
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-primary);
  white-space: nowrap;
}
.pb-progress-track {
  flex: 1;
  min-width: 0;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.pb-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-primary);
  border-radius: 2px;
}
.pb-close-btn {
  flex-shrink: 0;
  width: 22px; height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: #55555f;
  cursor: pointer;
}
.pb-close-btn svg { width: 12px; height: 12px; fill: currentColor; }
.pb-close-btn:active { background: rgba(255,255,255,0.08); }

/* ---------- Popups (Vocal range picker) ---------- */
.av-popup {
  display: none;
  position: fixed;
  left: 20px;
  right: 20px;
  bottom: 0;
  z-index: 350;
  background: #16161b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(100%);
  transition: opacity var(--dur-open) var(--ease-dismiss), transform var(--dur-open) var(--ease-dismiss);
}
.av-popup.open {
  display: block;
  opacity: 1;
  transform: translateY(0);
  transition: opacity var(--dur-open) var(--ease-pop), transform var(--dur-open) var(--ease-pop);
}

/* 録音一覧モーダルは中身をスクロールさせたいのでblockではなくflexで開く。
   .av-popup.openと同じ詳細度だが、こちらを後方に置くことで確実に上書きする。 */
.rec-list-popup {
  max-height: 70vh;
}
.rec-list-popup.open {
  display: flex;
  flex-direction: column;
}

.av-popup-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 340;
  background: rgba(5, 5, 7, 0);
  transition: background var(--dur-open) var(--ease-dismiss);
}
.av-popup-backdrop.open {
  display: block;
  background: rgba(5, 5, 7, 0.6);
  transition: background var(--dur-open) var(--ease-pop);
}

.popup-title {
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #6b6b7b;
  margin: 0 0 14px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 6px;
}

.choice-cell {
  padding: 13px 4px;
  text-align: center;
  border-radius: 12px;
  background: #1c1c24;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #c8c8d0;
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur-hover) var(--ease-snap), border-color var(--dur-hover) var(--ease-snap), color var(--dur-hover) var(--ease-snap);
}
.choice-cell.selected {
  background: var(--accent-glow);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.popup-close-btn {
  width: 100%;
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border: none;
  color: #fff;
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 6px 20px var(--accent-glow);
  transition: transform var(--dur-press) var(--ease-snap);
  box-sizing: border-box;
}
.popup-close-btn:active { transform: scale(0.97); }

/* .settings-btn-row / .key-select-row 等、Reset/Doneを横並びにする箇所では
   .popup-close-btn の width:100% を上書きし、Resetボタンと同じ幅に揃える。
   .popup-close-btnより後方に置くことで確実に上書きする。 */
.popup-close-btn.save-ok-btn {
  width: auto;
  flex: 1;
  margin-top: 0;
}

/* ---------- クリア確認ダイアログ ---------- */
.clear-confirm-desc {
  font-family: var(--font-body, 'Instrument Sans'), sans-serif;
  font-size: 12px;
  color: #8b8b9e;
  line-height: 1.5;
  margin: 0 0 16px;
}
.clear-confirm-ok-btn.popup-close-btn {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}

/* ---------- Bottom fixed transport (mirrors QNAUDIO / QNTEMPO top-controls) ---------- */
.top-controls-spacer { flex-shrink: 0; }

.top-controls {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(13, 13, 15, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
}

.top-controls-row { display: flex; gap: 8px; align-items: center; }

.loopbtn {
  flex: 1;
  padding: 14px 0 12px;
  font-size: 20px;
  text-align: center;
  background: #16161b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  cursor: pointer;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: background var(--dur-hover) var(--ease-snap), border-color var(--dur-hover) var(--ease-snap), transform var(--dur-press) var(--ease-snap), box-shadow var(--dur-press) var(--ease-snap);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.loopbtn svg { width: 22px; height: 22px; fill: currentColor; }
.loopbtn:active { transform: translateY(0) scale(0.96); box-shadow: 0 2px 8px rgba(0,0,0,0.4); }

.loopbtn-rec {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border: none;
  box-shadow: 0 6px 20px var(--accent-glow);
}
.loopbtn-rec.recording {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}
.loopbtn-rec.recording svg { animation: recPulse 1.1s ease-in-out infinite; }
@keyframes recPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.loopbtn-play {
  color: #c8c8d0;
}
.loopbtn-play:disabled {
  cursor: default;
  opacity: 0.4;
}
.loopbtn-play:disabled:active { transform: none; }
.loopbtn-play.playing {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  background: var(--accent-glow);
}

.loopbtn-square {
  flex: 0 0 auto;
  width: 56px;
  color: #c8c8d0;
}
.loopbtn-square svg { width: 18px; height: 18px; }
.loopbtn-square .top-controls-btn-label { font-size: 8px; }
.loopbtn-square.active {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  background: var(--accent-glow);
}

.top-controls-btn-label {
  font-family: var(--font-display, 'Instrument Sans'), sans-serif;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: inherit;
  opacity: 0.7;
  line-height: 1;
}

/* 2段目：SAVE / CLEAR / TEMPO / SET。1段目より項目数が多いので個々のボタンをやや小さくし、
   fill:1 1 0 で4等分に揃える（1段目のREC/PLAYはloopbtn-rec/loopbtn-playでflex:1のまま）。 */
.top-controls-row-secondary .loopbtn-square {
  flex: 1 1 0;
  width: auto;
  padding: 10px 0 9px;
}
.top-controls-row-secondary .loopbtn svg { width: 16px; height: 16px; }

.loopbtn-square:disabled {
  cursor: default;
  opacity: 0.35;
}
.loopbtn-square:disabled:active { transform: none; }
