/* =========================================================
   PULSE — css/music-tool.css
   Phase 3: Shared music catalogue and audio trimming UI
   ========================================================= */

.mt-overlay {
  position: fixed;
  inset: 0;
  z-index: 1400;
  background: var(--bg, #0f0f12);
  color: var(--text, #fff);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overscroll-behavior: contain;
}
.mt-screen { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.mt-hidden { display: none !important; }

.mt-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(127,127,127,.18);
  background: var(--surface, rgba(20,20,24,.95));
  position: sticky; top: 0; z-index: 5;
}
.mt-title { flex: 1; min-width: 0; }
.mt-title h2 { margin: 0; font-size: 17px; font-weight: 800; line-height: 1.2; }
.mt-title p { margin: 2px 0 0; font-size: 12px; color: var(--text-2, #a1a1aa); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mt-icon-btn, .mt-chip, .mt-btn {
  border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.mt-icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--bg-2, #23232c); color: var(--text, #fff); font-size: 18px;
}
.mt-icon-btn:active, .mt-chip:active, .mt-btn:active { transform: scale(.97); }
.mt-icon-btn[disabled], .mt-btn[disabled] { opacity: .45; pointer-events: none; }

.mt-btn {
  min-height: 38px; padding: 0 14px; border-radius: 999px;
  font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--bg-2, #23232c); color: var(--text, #fff);
}
.mt-btn.primary {
  background: linear-gradient(135deg, var(--primary, #7c3aed), var(--primary-2, #a855f7));
  color: #fff; box-shadow: 0 6px 16px rgba(124,58,237,.28);
}

.mt-search-wrap { padding: 10px 12px 6px; }
.mt-search {
  width: 100%; height: 42px; border-radius: 12px; border: 1px solid rgba(127,127,127,.18);
  background: var(--bg-2, #23232c); color: var(--text, #fff);
  padding: 0 12px 0 38px; font-size: 15px; outline: none;
}
.mt-search-row { position: relative; }
.mt-search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); opacity: .6; font-size: 14px; pointer-events: none; }

.mt-tabs {
  display: flex; gap: 6px; padding: 4px 12px 10px; overflow-x: auto; scrollbar-width: none;
}
.mt-tabs::-webkit-scrollbar { display: none; }
.mt-chip {
  flex: 0 0 auto; height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--bg-2, #23232c); color: var(--text-2, #a1a1aa); font-size: 13px; font-weight: 700;
}
.mt-chip.active { background: linear-gradient(135deg, var(--primary,#7c3aed), var(--primary-2,#a855f7)); color: #fff; }

.mt-body { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; padding: 0 12px 16px; }
.mt-section-title { font-size: 12px; font-weight: 800; color: var(--text-2,#a1a1aa); text-transform: uppercase; letter-spacing: .06em; margin: 10px 2px 8px; }
.mt-status { padding: 18px 8px; text-align: center; color: var(--text-2,#a1a1aa); font-size: 14px; }
.mt-status.error { color: #ef4444; }

.mt-track {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 14px; background: var(--surface, #17171d);
  margin-bottom: 8px; border: 1px solid rgba(127,127,127,.12);
}
.mt-track.selected { border-color: rgba(124,58,237,.6); box-shadow: 0 0 0 1px rgba(124,58,237,.25) inset; }
.mt-art { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--bg-2,#23232c); flex-shrink: 0; }
.mt-meta { flex: 1; min-width: 0; }
.mt-meta strong { display: block; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-meta span { display: block; font-size: 12px; color: var(--text-2,#a1a1aa); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.mt-meta .mt-dur { font-size: 11px; color: var(--text-2,#a1a1aa); margin-top: 3px; }
.mt-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.mt-badge-preview { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 999px; background: rgba(245,158,11,.18); color: #f59e0b; display: inline-block; margin-top: 4px; }

/* Trimmer */
.mt-trim-wrap { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; padding: 12px; display: flex; flex-direction: column; gap: 14px; }
.mt-track-hero {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 16px;
  background: var(--surface,#17171d); border: 1px solid rgba(127,127,127,.12);
}
.mt-track-hero .mt-art { width: 64px; height: 64px; border-radius: 12px; }
.mt-hero-meta { flex: 1; min-width: 0; }
.mt-hero-meta strong { display: block; font-size: 16px; font-weight: 800; }
.mt-hero-meta span { display: block; font-size: 13px; color: var(--text-2,#a1a1aa); margin-top: 2px; }

.mt-wave-card {
  background: var(--surface,#17171d); border: 1px solid rgba(127,127,127,.12);
  border-radius: 16px; padding: 12px;
}
.mt-wave-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 12px; color: var(--text-2,#a1a1aa); }
.mt-wave-canvas-wrap {
  position: relative; height: 120px; border-radius: 10px; overflow: hidden;
  background: var(--bg-2,#23232c); touch-action: none;
}
.mt-wave-canvas { width: 100%; height: 100%; display: block; }
.mt-wave-dim { position: absolute; top: 0; bottom: 0; background: rgba(0,0,0,.45); pointer-events: none; }
.mt-wave-sel-border { position: absolute; top: 0; bottom: 0; border-top: 2px solid var(--primary,#7c3aed); border-bottom: 2px solid var(--primary,#7c3aed); pointer-events: none; box-shadow: inset 0 0 0 1px rgba(124,58,237,.25); }
.mt-handle {
  position: absolute; top: 0; bottom: 0; width: 18px; margin-left: -9px;
  background: #fff; border-radius: 6px; box-shadow: 0 2px 10px rgba(0,0,0,.35);
  cursor: ew-resize; touch-action: none; z-index: 3;
}
.mt-handle::after { content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 3px; height: 22px; border-radius: 2px; background: #666; }
.mt-handle.start { border-radius: 8px 4px 4px 8px; }
.mt-handle.end { border-radius: 4px 8px 8px 4px; }
.mt-playhead {
  position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px;
  background: #fff; box-shadow: 0 0 0 1px rgba(124,58,237,.8); z-index: 2; pointer-events: none;
}
.mt-time-row { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-2,#a1a1aa); margin-top: 8px; }
.mt-fallback-note { font-size: 12px; color: #f59e0b; margin-top: 8px; line-height: 1.4; }

.mt-controls {
  background: var(--surface,#17171d); border: 1px solid rgba(127,127,127,.12);
  border-radius: 16px; padding: 12px;
}
.mt-play-row { display: flex; align-items: center; gap: 12px; }
.mt-play-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--primary,#7c3aed), var(--primary-2,#a855f7)); color: #fff;
  display: grid; place-items: center; font-size: 18px; flex-shrink: 0;
}
.mt-progress { flex: 1; min-width: 0; }
.mt-progress-bar { position: relative; height: 6px; border-radius: 999px; background: var(--bg-2,#23232c); overflow: hidden; }
.mt-progress-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; background: linear-gradient(90deg, var(--primary,#7c3aed), var(--primary-2,#a855f7)); border-radius: 999px; }
.mt-times { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--text-2,#a1a1aa); }
.mt-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.mt-stat { background: var(--bg-2,#23232c); border-radius: 10px; padding: 8px; text-align: center; }
.mt-stat span { display: block; font-size: 11px; color: var(--text-2,#a1a1aa); }
.mt-stat strong { display: block; font-size: 13px; margin-top: 2px; }

.mt-nudge-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.mt-limit-note { font-size: 12px; color: var(--text-2,#a1a1aa); margin-top: 8px; line-height: 1.4; }
.mt-limit-note.warn { color: #ef4444; }

.mt-footer {
  padding: 10px 12px calc(env(safe-area-inset-bottom, 0px) + 10px);
  border-top: 1px solid rgba(127,127,127,.18);
  background: var(--surface, rgba(20,20,24,.98));
  display: flex; gap: 8px;
}
.mt-footer .mt-btn { flex: 1; }

@media (min-width: 900px) {
  .mt-overlay { align-items: center; justify-content: center; background: rgba(0,0,0,.55); padding: 20px; }
  .mt-screen { width: min(520px, 100%); height: min(92vh, 900px); border-radius: 20px; overflow: hidden; background: var(--bg,#0f0f12); box-shadow: 0 20px 60px rgba(0,0,0,.45); }
}
