/* Modern Clean White / Light DAW Style CSS */
:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f1f5f9;
  --border-color: #e2e8f0;
  --border-color-dark: #cbd5e1;
  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --accent-gold: #d97706;
  --accent-gold-bg: rgba(217, 119, 6, 0.12);
  --accent-red: #dc2626;
  --accent-green: #059669;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --timeline-track-h: 46px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  padding: 24px;
  min-height: 100vh;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
}

.logo-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-title h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #1d4ed8, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.engine-subtitle {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.3px;
}

.lang-toggle-group {
  display: inline-flex;
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 2px;
  border-radius: 8px;
  gap: 2px;
}

.btn-lang-tab {
  background: transparent;
  border: none;
  color: #64748b;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  line-height: 1.2;
}

.btn-lang-tab:hover:not(.active) {
  color: #0f172a;
  background-color: #e2e8f0;
}

.btn-lang-tab.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.25);
}

@media (max-width: 768px) {
  .engine-subtitle {
    display: none;
  }
}

/* Top Controls Grid */
.top-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 16px;
}

@media (max-width: 860px) {
  .top-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
  width: 100%;
  box-sizing: border-box;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Card Title Bar with Top-Level Mode Selector */
.card-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-toggle-group {
  display: inline-flex;
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 3px;
  border-radius: 8px;
  gap: 4px;
}

.btn-mode-tab {
  background: transparent;
  border: none;
  color: #64748b;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

.btn-mode-tab:hover:not(.active) {
  color: #0f172a;
  background-color: #e2e8f0;
}

.btn-mode-tab.active[data-mode="original"] {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-mode-tab.active[data-mode="dissonant"] {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.param-list.disabled-mode .param-item {
  opacity: 0.45;
  pointer-events: none;
  filter: grayscale(0.6);
  transition: all 0.25s ease;
}

.mode-info-banner {
  background: #eff6ff;
  border: 1px dashed #93c5fd;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  color: #1e40af;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.45;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.06);
  transition: all 0.2s ease;
}

/* Upload Area */
.card-upload {
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
}

.upload-dropzone {
  flex: 1;
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  background-color: #f8fafc;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 220px;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--accent-primary);
  background-color: #eff6ff;
}

.upload-icon {
  font-size: 32px;
  margin-bottom: 8px;
  display: block;
}

/* FreeConvert-Style Split Choose Files Button & Dropdown */
.upload-split-btn-group {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
  margin-bottom: 4px;
  user-select: none;
  z-index: 10;
}

.btn-choose-file-main {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 18px;
  border: none;
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.btn-choose-file-main:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-choose-file-main:active {
  transform: translateY(1px);
}

.btn-choose-file-arrow {
  background: #1d4ed8;
  color: #ffffff;
  padding: 10px 12px;
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.25);
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all 0.15s ease;
}

.btn-choose-file-arrow:hover {
  background: #1e3a8a;
}

.btn-choose-file-arrow:active {
  transform: translateY(1px);
}

.upload-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14), 0 2px 6px rgba(0, 0, 0, 0.04);
  padding: 6px;
  z-index: 1000;
  text-align: left;
}

.upload-dropdown-menu.show {
  display: block;
  animation: uploadDropdownAnim 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes uploadDropdownAnim {
  from { opacity: 0; transform: translate(-50%, -6px) scale(0.97); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.upload-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 7px;
  cursor: pointer;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-main);
  text-align: left;
  transition: background 0.15s ease;
  user-select: none;
}

.upload-dropdown-item:hover {
  background-color: #eff6ff;
}

.upload-dropdown-item:hover .item-title {
  color: #2563eb;
}

.upload-dropdown-item .item-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.upload-dropdown-item .item-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}

.upload-dropdown-item .item-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  transition: color 0.15s;
}

.upload-dropdown-item .item-desc {
  font-size: 11px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-dropdown-divider {
  height: 1px;
  background-color: #e2e8f0;
  margin: 5px 8px;
}

.file-info-badge {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid #bfdbfe;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
  width: 100%;
  box-sizing: border-box;
  animation: fileBadgeFadeIn 0.25s ease-out;
}

@keyframes fileBadgeFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.file-info-badge .file-info-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

#fileName {
  font-size: 15px;
  font-weight: 700;
  color: #1d4ed8;
  letter-spacing: -0.2px;
  word-break: break-all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90%;
}

/* Parameter Grid */
.param-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Dual-Thumb Range Slider (Single bar with 2 handles) */
.dual-range-wrapper {
  position: relative;
  width: 100%;
  height: 34px;
  display: flex;
  align-items: center;
}

.dual-range-track {
  position: absolute;
  width: 100%;
  height: 6px;
  background-color: #e2e8f0;
  border-radius: 3px;
  border: 1px solid #cbd5e1;
  z-index: 1;
}

.dual-range-fill {
  position: absolute;
  height: 6px;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  border-radius: 3px;
  z-index: 2;
  left: 33.3%;
  width: 16.7%;
  pointer-events: none;
}

.dual-range-input {
  position: absolute;
  width: 100%;
  height: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  z-index: 3;
}

.dual-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #2563eb;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  cursor: grab;
  transition: transform 0.1s, border-color 0.1s;
}

.dual-range-input::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  border-color: #1d4ed8;
}

.dual-range-input::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.2);
  border-color: #7c3aed;
}

.dual-range-input::-moz-range-thumb {
  pointer-events: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #2563eb;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  cursor: grab;
}

/* Sound Engine Selector */
.sound-engine-select {
  background-color: #ffffff;
  color: var(--text-main);
  border: 1px solid #cbd5e1;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: all 0.15s;
}

.sound-engine-select:hover, .sound-engine-select:focus {
  border-color: #2563eb;
  background-color: #f8fafc;
}

.btn-add-sf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: var(--text-main);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-add-sf:hover {
  background-color: #2563eb;
  border-color: #2563eb;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.btn-add-sf:active {
  transform: translateY(0);
}

.sf-loading-status {
  font-size: 11px;
  color: #d97706;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.param-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.param-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.param-label {
  font-size: 13px;
  color: var(--text-muted);
}

.param-val {
  font-family: monospace;
  font-weight: 700;
  color: #2563eb;
  font-size: 13px;
}

.range-slider {
  width: 100%;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.radio-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radio-btn-label {
  flex: 1;
  min-width: 65px;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 6px 10px;
  border-radius: 6px;
  text-align: center;
  font-size: 12px;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.radio-btn-label input {
  display: none;
}

.radio-btn-label:hover {
  background-color: #f1f5f9;
  border-color: #94a3b8;
}

.radio-btn-label.active {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

/* Playback DSP & Sound Effects Panel (Collapsible) */
.play-options-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.play-options-card:hover {
  border-color: #cbd5e1;
}

.play-options-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  background-color: #f8fafc;
  border-bottom: 1px solid transparent;
  transition: background-color 0.15s ease;
}

.play-options-header:hover {
  background-color: #f1f5f9;
}

.play-options-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.play-options-heading {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.badge-opt-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background-color: rgba(5, 150, 105, 0.12);
  color: #059669;
  border: 1px solid rgba(5, 150, 105, 0.25);
}

.play-options-toggle-hint {
  display: flex;
  align-items: center;
  gap: 6px;
}

.accordion-arrow {
  font-size: 11px;
  color: #64748b;
  transition: transform 0.25s ease;
}

.accordion-arrow.rotated {
  transform: rotate(180deg);
}

.play-options-content {
  padding: 14px 16px 16px;
  border-top: 1px solid #e2e8f0;
  background-color: #f8fafc;
  display: block;
  transition: all 0.25s ease;
}

.play-options-content.collapsed {
  display: none;
}

.play-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.play-opt-label-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.play-opt-label-item:hover {
  background-color: #f0f7ff;
  border-color: #3b82f6;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.1);
}

.play-opt-checkbox {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: #2563eb;
  cursor: pointer;
}

.play-opt-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.play-opt-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.play-opt-desc {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.35;
}

/* Master Player Controller Bar */
.master-bar {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
  width: 100%;
  box-sizing: border-box;
}

/* Row 1: Primary Transport & Timeline Progress Bar */
.master-player-row {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.master-transport-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.master-timeline-integrated-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.master-vol-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Row 2: Secondary Controls (Sound Engine & Download) */
.master-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}

.sound-engine-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sound-engine-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
}

.master-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.btn-ctrl {
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.15s;
}

.btn-ctrl:hover:not(:disabled) {
  background-color: #f1f5f9;
  border-color: #94a3b8;
}

.btn-ctrl.btn-play-all {
  background-color: #2563eb;
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.btn-ctrl.btn-play-all:hover:not(:disabled) {
  background-color: #1d4ed8;
}

.time-display {
  font-family: monospace;
  font-size: 15px;
  font-weight: 700;
  color: #38bdf8;
  background-color: #0f172a;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #1e293b;
  letter-spacing: 1px;
}

.tune-boost-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: #fef2f2;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid #fecaca;
  transition: all 0.2s ease;
}

.tune-boost-wrap:hover {
  background-color: #fee2e2;
  border-color: #fca5a5;
}

.export-actions-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
}

.btn-ctrl.btn-export {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.btn-ctrl.btn-export:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
  transform: translateY(-1px);
}

.btn-ctrl.btn-export-midi:hover:not(:disabled) {
  border-color: #2563eb;
  color: #2563eb;
  background: #eff6ff;
}

.btn-ctrl.btn-export-wav:hover:not(:disabled) {
  border-color: #7c3aed;
  color: #7c3aed;
  background: #f5f3ff;
}

.btn-ctrl.btn-export-mp3:hover:not(:disabled) {
  border-color: #059669;
  color: #059669;
  background: #ecfdf5;
}

.export-status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #2563eb;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.master-vol-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.master-timeline-container {
  flex: 1;
  width: 100%;
  height: 24px;
  background-color: #f1f5f9;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  min-width: 80px;
}

.master-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  position: absolute;
  top: 0;
  left: 0;
  transition: width 0.05s linear;
}

.master-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background-color: #d97706;
  box-shadow: 0 0 6px rgba(217, 119, 6, 0.7);
  pointer-events: none;
}

/* Track Lanes Section Card & Layout */
.track-section-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  box-sizing: border-box;
}

.track-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0;
  margin-bottom: 2px;
}

.track-lanes {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.track-lane {
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: 44px 230px 1fr 104px;
  gap: 12px;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: all 0.2s;
  min-width: 0;
}

.track-lane:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}

/* Tune (Lightning) Toggle Button */
.btn-tune {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background-color: #ffffff;
  color: #64748b;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  user-select: none;
}

.btn-tune span.tune-icon {
  font-size: 16px;
  line-height: 1;
  transition: transform 0.2s, font-size 0.2s, filter 0.2s;
  display: inline-block;
  filter: grayscale(100%) opacity(0.45);
}

.btn-tune:hover {
  background-color: #f1f5f9;
  border-color: #94a3b8;
}

.btn-tune:hover span.tune-icon {
  filter: grayscale(40%) opacity(0.85);
  transform: scale(1.1);
}

/* Tune Active State: 강렬한 붉은 바탕 + 좀더 크고 강한 대비의 벼락 아이콘 */
.btn-tune.active {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  border-color: #fca5a5;
  box-shadow: 0 0 12px rgba(220, 38, 38, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.4);
  transform: scale(1.05);
}

.btn-tune.active span.tune-icon {
  font-size: 21px;
  filter: none;
  color: #ffffff;
  text-shadow: 0 0 8px #ffffff, 0 0 12px #fbbf24;
}

.btn-tune.active:hover {
  background: linear-gradient(135deg, #b91c1c 0%, #f87171 100%);
  box-shadow: 0 0 16px rgba(220, 38, 38, 0.7);
}

/* Melody Highlight */
.track-lane.is-melody {
  border: 2px solid var(--accent-gold);
  background-color: #fffbeb;
  box-shadow: 0 2px 12px rgba(217, 119, 6, 0.12);
}

.track-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.track-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.track-num {
  font-weight: 700;
  font-size: 13px;
  color: #2563eb;
}

.track-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
}

.melody-badge {
  font-size: 10px;
  font-weight: 700;
  background-color: #d97706;
  color: #ffffff;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* Track Canvas */
.track-canvas-wrap {
  width: 100%;
  height: var(--timeline-track-h);
  background-color: #f1f5f9;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.track-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.track-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background-color: #d97706;
  box-shadow: 0 0 4px rgba(217, 119, 6, 0.6);
  pointer-events: none;
  display: none;
}

/* Melody Mode Selector */
.melody-toggle-wrap {
  display: flex;
  background-color: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 3px;
  gap: 2px;
}

.melody-toggle-btn {
  flex: 1;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  white-space: nowrap;
}

.melody-toggle-btn.active {
  background-color: #2563eb;
  color: #fff;
}

.melody-toggle-btn.active.dissonant {
  background-color: #dc2626;
  color: #fff;
}

/* Track Control Buttons */
.track-btns {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.btn-mini {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 5px;
  border: 1px solid #cbd5e1;
  background-color: #ffffff;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.15s;
}

.btn-mini:hover {
  background-color: #f1f5f9;
  color: var(--text-main);
  border-color: #94a3b8;
}

.btn-mini.active-mute {
  background-color: var(--accent-red);
  border-color: var(--accent-red);
  color: #fff;
  box-shadow: 0 1px 4px rgba(220, 38, 38, 0.3);
}

.btn-mini.active-solo {
  background-color: var(--accent-gold);
  border-color: var(--accent-gold);
  color: #fff;
  box-shadow: 0 1px 4px rgba(217, 119, 6, 0.3);
}

.btn-play-single {
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  color: #059669;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.15s;
}

.btn-play-single:hover {
  background-color: #059669;
  color: #fff;
  border-color: #059669;
}

.btn-play-single.playing {
  background-color: var(--accent-red);
  color: #fff;
  border-color: var(--accent-red);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  background-color: #ffffff;
  border-radius: 8px;
  border: 1px dashed #cbd5e1;
}

/* SoundFont Loading & Alert Modal Layer */
.sf-modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
  animation: sfFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 16px;
}

@keyframes sfFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.sf-modal-card {
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  width: 100%;
  max-width: 440px;
  padding: 24px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.15), 0 4px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sf-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sf-modal-icon {
  font-size: 26px;
  line-height: 1;
}

.sf-modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.sf-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sf-modal-message {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  word-break: break-all;
  white-space: pre-wrap;
}

.sf-modal-progress-wrap {
  width: 100%;
  height: 8px;
  background-color: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
}

.sf-modal-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  width: 0%;
  border-radius: 999px;
  transition: width 0.15s ease-out;
}

.sf-modal-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

.btn-modal-close {
  background-color: var(--accent-primary);
  color: #fff;
  border: none;
  font-weight: 600;
  padding: 8px 22px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
  transition: background-color 0.15s, transform 0.1s;
}

.btn-modal-close:hover {
  background-color: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.btn-modal-close:active {
  transform: translateY(0);
}

/* Modal Inputs & Actions */
.modal-text-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-main);
  background-color: #ffffff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.modal-text-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.modal-inline-error {
  font-size: 12px;
  color: #dc2626;
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 6px;
}

.btn-modal-cancel {
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-weight: 600;
  padding: 8px 18px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-modal-cancel:hover {
  background-color: #e2e8f0;
  color: #0f172a;
}

.btn-modal-confirm {
  background-color: #2563eb;
  border: 1px solid #2563eb;
  color: #ffffff;
  font-weight: 600;
  padding: 8px 22px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
  transition: all 0.15s;
}

.btn-modal-confirm:hover {
  background-color: #1d4ed8;
}

.btn-modal-x {
  background: transparent;
  border: none;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.15s;
}

.btn-modal-x:hover {
  color: #0f172a;
  background-color: #f1f5f9;
}

/* Sample MIDI Library Modal */
.sample-modal-card {
  max-width: 620px;
  max-height: 85vh;
}

.sample-search-wrap {
  margin-bottom: 8px;
}

.sample-list-container {
  max-height: 380px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
  padding-right: 4px;
}

.sample-list-container::-webkit-scrollbar {
  width: 6px;
}

.sample-list-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.sample-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background-color: #ffffff;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sample-item-card:hover {
  border-color: #2563eb;
  background-color: #eff6ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.sample-item-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.sample-item-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.sample-item-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sample-item-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sample-item-meta {
  font-size: 11px;
  color: #64748b;
}

.btn-sample-load {
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #2563eb;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.sample-item-card:hover .btn-sample-load {
  background-color: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.sample-list-loading, .sample-list-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 30px;
  color: #64748b;
  font-size: 13px;
}

/* ========================================================
   FreeConvert-Style Download Single Button & Choices Modal
   ======================================================== */
.btn-download-single {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s ease;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.2);
  line-height: 1.2;
  user-select: none;
}

.btn-download-single:hover:not(:disabled) {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.btn-download-single:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-download-single:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
}

.download-split-btn-group {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.2);
  user-select: none;
}

.btn-download-main {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  border: none;
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.btn-download-main:hover:not(:disabled) {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-download-main:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-download-main:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-download-arrow {
  background: #047857;
  color: #ffffff;
  padding: 8px 10px;
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-download-arrow:hover:not(:disabled) {
  background: #065f46;
}

.btn-download-arrow:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
  border-left-color: rgba(255, 255, 255, 0.4);
}

.download-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 270px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14), 0 2px 6px rgba(0, 0, 0, 0.04);
  padding: 6px;
  z-index: 1000;
  text-align: left;
}

.download-dropdown-menu.show {
  display: block;
  animation: uploadDropdownAnim 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.download-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 7px;
  cursor: pointer;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-main);
  text-align: left;
  transition: background 0.15s ease;
  user-select: none;
}

.download-dropdown-item:hover {
  background-color: #ecfdf5;
}

.download-dropdown-item:hover .item-title {
  color: #059669;
}

/* Download Choices Modal Card */
.download-modal-card {
  max-width: 680px;
  width: 95vw;
}

.download-filename-wrap {
  margin-bottom: 16px;
  background: #f8fafc;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.download-field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  margin-bottom: 6px;
}

.download-filename-input-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.download-filename-ext-hint {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  white-space: nowrap;
}

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

@media (max-width: 640px) {
  .download-options-grid {
    grid-template-columns: 1fr;
  }
}

.download-option-card {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.download-option-card:hover {
  border-color: #059669;
  box-shadow: 0 6px 18px rgba(5, 150, 105, 0.12);
  transform: translateY(-2px);
}

.download-card-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.download-card-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.download-card-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.download-card-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #64748b;
  margin-top: 3px;
}

.download-card-badge.highlight-fast {
  background: #ecfdf5;
  color: #059669;
}

.download-card-desc {
  font-size: 11px;
  color: #64748b;
  line-height: 1.45;
  margin-bottom: 14px;
  flex: 1;
}

.btn-download-card-action {
  width: 100%;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  background: linear-gradient(135deg, #059669, #047857);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-download-card-action:hover {
  background: linear-gradient(135deg, #047857, #065f46);
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
}

.btn-download-card-action:active {
  transform: translateY(1px);
}

/* Download Dropdown Section Header */
.download-dropdown-section-header {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  padding: 6px 12px 2px;
  letter-spacing: 0.3px;
}

/* Save Destination Selector Tabs in Central Download Modal */
.download-dest-wrap {
  margin-bottom: 14px;
  background: #f8fafc;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.download-dest-tabs {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.btn-dest-tab {
  flex: 1;
  min-width: 110px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.btn-dest-tab:hover:not(.active) {
  border-color: #94a3b8;
  background: #f1f5f9;
}

.btn-dest-tab.active {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1d4ed8;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.15);
}

.btn-dest-tab[data-dest="drive"].active {
  background: #f0fdf4;
  border-color: #16a34a;
  color: #15803d;
}

.btn-dest-tab[data-dest="dropbox"].active {
  background: #f0f9ff;
  border-color: #0284c7;
  color: #0369a1;
}

.btn-dest-tab[data-dest="onedrive"].active {
  background: #eff6ff;
  border-color: #0078d4;
  color: #0078d4;
}

.cloud-dest-notice {
  margin-top: 10px;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px dashed #93c5fd;
  border-radius: 6px;
  font-size: 11.5px;
  color: #1e40af;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  line-height: 1.4;
  animation: uploadDropdownAnim 0.15s ease;
}

.btn-cloud-config-trigger {
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-cloud-config-trigger:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
}

/* Cloud API Configuration Modal */
.cloud-config-card {
  max-width: 520px;
  width: 92%;
}

.cloud-config-field {
  margin-bottom: 14px;
}

.cloud-field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 5px;
}

.cloud-help-link {
  font-size: 11px;
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
}

.cloud-help-link:hover {
  text-decoration: underline;
}

.cloud-field-hint {
  display: block;
  font-size: 10.5px;
  color: #64748b;
  margin-top: 4px;
  line-height: 1.35;
}

.oauth-redirect-uri-display {
  font-family: monospace;
  background: #f1f5f9;
  padding: 1px 4px;
  border-radius: 3px;
  color: #0f172a;
}

.btn-modal-cloud-link {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff !important;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
  transition: all 0.15s ease;
}

.btn-modal-cloud-link:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(37, 99, 235, 0.35);
}

/* ==========================================================================
   Custom Instrument Library Section & Sampler Modal
   ========================================================================== */
.custom-inst-section {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 0;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
  width: 100%;
  box-sizing: border-box;
}

.custom-inst-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.custom-inst-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.custom-inst-icon {
  font-size: 22px;
}

.custom-inst-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
}

.custom-inst-sub {
  font-size: 11.5px;
  color: #64748b;
  display: block;
  margin-top: 2px;
}

.btn-add-custom-inst {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(124, 58, 237, 0.25);
  transition: all 0.15s ease;
}

.btn-add-custom-inst:hover {
  background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(124, 58, 237, 0.35);
}

.custom-inst-bank-container {
  margin-top: 12px;
}

.custom-inst-empty-hint {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 12.5px;
  color: #64748b;
  text-align: center;
}

.custom-inst-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.custom-inst-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid #ddd6fe;
  border-radius: 9px;
  padding: 5px 8px 5px 8px;
  box-shadow: 0 1px 3px rgba(124, 58, 237, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.custom-inst-chip:hover {
  background: #fdfcff;
  border-color: #a78bfa;
  box-shadow: 0 3px 8px rgba(124, 58, 237, 0.15);
}

.custom-inst-chip-index {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.custom-inst-chip-play {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid #c4b5fd;
  background: #f5f3ff;
  color: #6d28d9;
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  outline: none;
}

.custom-inst-chip-play:hover {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #ffffff;
  transform: scale(1.08);
}

.custom-inst-chip-play.playing {
  background: #059669;
  border-color: #059669;
  color: #ffffff;
}

.custom-inst-chip-name-wrap {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 4px;
  min-width: 0;
}

.custom-inst-chip-name {
  font-size: 12.5px;
  font-weight: 700;
  color: #1e1b4b;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-inst-chip-pitch {
  font-size: 10.5px;
  font-weight: 600;
  color: #7c3aed;
  font-family: monospace;
  letter-spacing: -0.2px;
}

/* Modern Pill "Edit / Replace" Button */
.custom-inst-chip-edit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  outline: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  white-space: nowrap;
}

.custom-inst-chip-edit:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(37, 99, 235, 0.15);
}

.custom-inst-chip-edit:active {
  transform: translateY(0);
  box-shadow: none;
}

.custom-inst-chip-edit .chip-edit-icon {
  font-size: 11px;
  line-height: 1;
}

.custom-inst-chip-edit .chip-edit-text {
  font-size: 11.5px;
  line-height: 1.2;
}

/* Delete Button */
.custom-inst-chip-delete {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  outline: none;
  flex-shrink: 0;
}

.custom-inst-chip-delete:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
  transform: scale(1.08);
}

/* Custom Instrument Modal */
.custom-inst-modal-card {
  max-width: 520px;
  width: 94%;
}

.inst-preset-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 12px;
}

.btn-preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 14px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  font-size: 11.5px;
  font-weight: 600;
  color: #0284c7;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-preset-chip:hover {
  background: #f0f9ff;
  border-color: #38bdf8;
  color: #0369a1;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(2, 132, 199, 0.12);
}

.btn-preset-chip:active {
  transform: translateY(0);
}

.inst-source-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 8px;
}

.btn-source-tab {
  flex: 1;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-source-tab.active {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1d4ed8;
}

.mic-record-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.mic-record-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12.5px;
  color: #475569;
  margin-bottom: 8px;
}

.mic-pulse-indicator {
  width: 10px;
  height: 10px;
  background: #ef4444;
  border-radius: 50%;
  animation: pulseRecording 1s infinite alternate;
}

@keyframes pulseRecording {
  from { transform: scale(0.8); opacity: 0.5; }
  to { transform: scale(1.3); opacity: 1; }
}

.mic-timer {
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
  font-family: monospace;
  margin-bottom: 12px;
}

.btn-mic-record {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ef4444;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 24px;
  border: none;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(239, 68, 68, 0.35);
  transition: all 0.15s ease;
}

.btn-mic-record.recording {
  background: #0f172a;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.35);
}

.inst-dropzone {
  border: 2px dashed #cbd5e1;
  background: #f8fafc;
  border-radius: 8px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.inst-dropzone:hover, .inst-dropzone.dragover {
  border-color: #7c3aed;
  background: #f5f3ff;
}

.sample-analysis-panel {
  margin-top: 16px;
  background: #fbfbfe;
  border: 1px solid #e0e7ff;
  border-radius: 8px;
  padding: 14px;
}

.sample-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sample-info-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sample-loaded-icon {
  font-size: 16px;
}

.sample-duration-badge {
  font-size: 11px;
  font-weight: 700;
  background: #ede9fe;
  color: #6d28d9;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 4px;
}

.sample-state-text {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}

.btn-mini-preview {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: #334155;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-mini-preview:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.pitch-detect-box {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.pitch-detect-label {
  font-size: 12px;
  font-weight: 600;
  color: #065f46;
}

.pitch-detect-value {
  font-size: 13px;
  color: #047857;
}

.root-note-row {
  margin-bottom: 14px;
}

.root-note-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 5px;
}

.root-key-select {
  width: 100%;
  padding: 7px 10px;
  font-size: 12.5px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #0f172a;
}


/* Mini Piano Preview Keyboard */
.mini-piano-wrap {
  margin-top: 10px;
}

.mini-piano-keys {
  display: flex;
  height: 54px;
  position: relative;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  user-select: none;
  margin-top: 6px;
}

.piano-key {
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  padding-bottom: 4px;
  box-sizing: border-box;
  transition: background 0.08s ease;
}

.piano-key.white {
  flex: 1;
  background: #ffffff;
  color: #64748b;
  border-right: 1px solid #e2e8f0;
  z-index: 1;
}

.piano-key.white:hover, .piano-key.white:active {
  background: #ddd6fe;
  color: #5b21b6;
}

.piano-key.black {
  position: absolute;
  width: 6.5%;
  height: 60%;
  background: #1e293b;
  color: #f8fafc;
  border-radius: 0 0 3px 3px;
  z-index: 2;
  font-size: 8px;
}

.piano-key.black:hover, .piano-key.black:active {
  background: #7c3aed;
}

.btn-modal-delete {
  background: #fee2e2;
  color: #dc2626 !important;
  border: 1px solid #fca5a5;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-modal-delete:hover {
  background: #fecaca;
  color: #b91c1c !important;
}

/* Track Lane Instrument Combobox */
.track-inst-select {
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  max-width: 220px;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
}

.track-inst-select:hover, .track-inst-select:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

.track-inst-select.is-custom {
  background: #f5f3ff;
  border-color: #a78bfa;
  color: #5b21b6;
}

.custom-inst-track-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 700;
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

/* ==========================================================================
   Mobile & Responsive Layout System (Phones & Narrow Tablets)
   ========================================================================== */
@media (max-width: 768px) {
  body {
    padding: 12px 10px;
  }

  .app-container {
    gap: 12px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding-bottom: 10px;
  }

  .header-right {
    width: 100%;
    justify-content: flex-end;
  }

  .card, .master-bar, .custom-inst-section, .track-section-card {
    padding: 12px 14px;
    border-radius: 10px;
  }

  /* Master Player Bar Mobile Layout */
  .master-player-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .master-transport-group {
    display: flex;
    justify-content: space-between;
    width: 100%;
    gap: 6px;
  }

  .master-transport-group .btn-ctrl {
    flex: 1;
    justify-content: center;
    padding: 8px 10px;
    font-size: 13px;
  }

  .master-timeline-integrated-wrap {
    width: 100%;
    display: flex;
    flex-direction: column-reverse;
    gap: 6px;
  }

  .master-timeline-container {
    width: 100%;
    height: 22px;
    border-radius: 6px;
  }

  .time-display {
    width: 100%;
    text-align: center;
    font-size: 13px;
    padding: 4px 8px;
  }

  .master-vol-wrap {
    width: 100%;
    justify-content: flex-end;
    gap: 8px;
  }

  .master-vol-wrap .range-slider {
    flex: 1;
    max-width: none;
  }

  .master-sub-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .sound-engine-group {
    width: 100%;
    display: flex;
    align-items: center;
  }

  .sound-engine-select {
    flex: 1;
    min-width: 0;
  }

  .btn-download-single {
    width: 100%;
    justify-content: center;
  }

  /* Responsive Track Lane (2-Row Grid for Phones) */
  .track-lane {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    grid-template-rows: auto auto;
    gap: 8px;
    padding: 8px 10px;
  }

  .track-lane .btn-tune {
    grid-column: 1;
    grid-row: 1;
    width: 36px;
    height: 36px;
  }

  .track-lane .track-info {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }

  .track-lane .track-info .track-name {
    font-size: 12.5px;
    max-width: 140px;
  }

  .track-lane .track-btns {
    grid-column: 3;
    grid-row: 1;
    justify-content: flex-end;
  }

  .track-lane .track-canvas-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
    height: 38px;
  }

  .track-inst-select {
    max-width: 130px;
    font-size: 11px;
  }

  /* Modal Dialogs Mobile Width */
  .custom-inst-modal-card,
  .cloud-modal-card,
  .sf-modal-card {
    width: 95vw;
    max-width: 95vw;
    margin: 10px;
    padding: 14px;
    max-height: 90vh;
    overflow-y: auto;
  }
}



