/* ══ UNIFIED APP HEADER ══════════════════════════════════ */
.app-header {
  height: 52px;
  background: linear-gradient(180deg, var(--surface2) 0%, var(--surface) 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 4px 18px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}

.app-logo {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: var(--r-pill);
  padding: 2px 6px;
  transition: background .12s;
}
.app-logo:hover { background: rgba(255,255,255,0.05); }
.app-logo:hover .app-logo-text span { text-shadow: 0 0 18px rgba(0,232,143,.65); }

.app-logo-text {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px;
  letter-spacing: 5px;
  color: #e8edf4;
}

.app-logo-text span {
  color: var(--accent2);
  text-shadow: 0 0 14px rgba(0,232,143,.4);
}

.app-logo-version {
  font-size: 8px;
  letter-spacing: 2px;
  color: var(--label);
  padding: 1px 6px;
  border: 1px solid var(--border2);
  border-radius: var(--r-pill);
}

.header-sep { width: 1px; height: 28px; background: var(--border2); flex-shrink: 0; border-radius: var(--r-pill); }

/* ── TAB BAR inline in header ── */
.tab-bar {
  display: flex;
  align-items: stretch;
  height: 100%;
  gap: 0;
}

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 15px;
  margin: 9px 2px;
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--label);
  cursor: pointer;
  border-radius: var(--r-pill);
  transition: all var(--trans);
  user-select: none;
  white-space: nowrap;
}

.tab:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.tab.active {
  color: var(--accent2);
  background: rgba(0,232,143,0.1);
  box-shadow: 0 0 0 1px rgba(0,232,143,0.25) inset;
}
.tab-icon { font-size: 11px; }

/* ── TRANSPORT CONTROLS ── */
.transport {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.play-btn {
  width: 34px; height: 34px;
  border: 1px solid var(--border2);
  background: rgba(0,232,143,0.08);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--trans);
  flex-shrink: 0;
  padding: 0;
  border-radius: var(--r-pill);
}
.play-btn:hover {
  border-color: var(--accent2);
  background: rgba(0,232,143,0.16);
  box-shadow: 0 0 14px rgba(0,232,143,0.25);
}
.play-btn:disabled { opacity: .25; cursor: default; pointer-events: none; }
.play-btn svg { width: 14px; height: 14px; fill: var(--text2); transition: fill .15s; }
.play-btn:hover svg { fill: var(--accent2); }
.play-btn.playing {
  border-color: var(--accent2);
  background: rgba(0,232,143,0.16);
  box-shadow: 0 0 14px rgba(0,232,143,0.3);
}
.play-btn.playing svg { fill: var(--accent2); }

/* Reset + cue share the play button's green look so they read as one set. */
.reset-btn {
  width: 28px; height: 28px;
  border: 1px solid var(--border2);
  background: rgba(0,232,143,0.08);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--trans);
  flex-shrink: 0;
  padding: 0;
  border-radius: var(--r-pill);
}
.reset-btn:hover { border-color: var(--accent2); background: rgba(0,232,143,0.16); box-shadow: 0 0 12px rgba(0,232,143,0.22); }
.reset-btn:disabled { opacity: .3; cursor: default; pointer-events: none; }
/* Icon colour matches the Play button icon exactly (--text2), accent on hover */
.reset-btn svg { width: 13px; height: 13px; fill: var(--text2); transition: fill .15s; }
.reset-btn:hover svg { fill: var(--accent2); }

/* Cue-mode (play-from-marker) toggle — matches play, amber when active */
.cue-btn svg { fill: var(--text2); }
.cue-btn.active { border-color: var(--warn); background: rgba(255,178,36,0.16); box-shadow: 0 0 10px rgba(255,178,36,0.25); }
.cue-btn.active svg { fill: var(--warn); }
.cue-btn:hover svg { fill: var(--accent2); }
.cue-btn.active:hover svg { fill: var(--warn); }

.time-display {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 4px;
  color: var(--fg);
  text-shadow: 0 0 12px rgba(0,217,255,.2);
  min-width: 130px;
  text-align: center;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.time-ms {
  font-size: 13px;
  letter-spacing: 1px;
  opacity: 0.45;
  vertical-align: baseline;
  position: relative;
  top: -2px;
}

.info-pill {
  font-size: 8px;
  letter-spacing: 2px;
  color: var(--label);
  border: 1px solid var(--border);
  background: var(--surface2);
  padding: 4px 10px;
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: var(--r-pill);
}
.info-pill span { color: var(--fg); }

.hdr-file-btn {
  font-family: 'DM Mono', monospace;
  font-size: 8px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 5px 12px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text2);
  cursor: pointer;
  transition: all var(--trans);
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: var(--r-pill);
}
.hdr-file-btn:hover { border-color: var(--accent2); color: var(--accent2); background: rgba(0,232,143,0.06); }
.hdr-file-btn.loaded { border-color: var(--accent2); color: var(--accent2); background: rgba(0,232,143,.06); }
.hdr-file-btn.audio-needed { border-color: var(--warn); color: var(--warn); background: rgba(255,178,36,.07); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.project-name {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text);
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  width: 130px;
  outline: none;
  border-radius: var(--r-sm);
}
.project-name:focus { border-color: var(--accent2); }

.hbtn {
  font-family: 'DM Mono', monospace;
  font-size: 8px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 5px 12px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text2);
  cursor: pointer;
  transition: all var(--trans);
  white-space: nowrap;
  border-radius: var(--r-pill);
}
.hbtn:hover { border-color: var(--accent2); color: var(--accent2); background: rgba(0,232,143,0.06); }
.hbtn.accent { border-color: var(--accent2); color: var(--accent2); background: rgba(0,232,143,.07); }
.hbtn.active { border-color: var(--accent2); color: var(--accent2); }

/* ══ PROJECT DROPDOWN MENU ══════════════════════════════════ */
.proj-menu-name {
  color: var(--accent2);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: bottom;
}
.project-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 230px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: 10px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 950;
}
.project-menu.open { display: flex; animation: stem-bar-in 0.15s ease; }

.proj-menu-field { display: flex; flex-direction: column; gap: 4px; padding-bottom: 4px; }
.proj-menu-field > span {
  font-size: 7.5px; letter-spacing: 2px; color: var(--label);
}
.proj-menu-field .project-name { width: 100%; }

.proj-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }

.proj-menu-item {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.5px;
  text-align: left;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--trans), color var(--trans);
}
.proj-menu-item:hover { background: var(--surface3); color: var(--accent2); }
.proj-menu-kbd {
  margin-left: auto;
  font-size: 8px;
  color: var(--label);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  padding: 1px 5px;
}

/* ══ ANALYSIS PROGRESS BAR ══════════════════════════════════
   Lives IN FLOW between the header and the tab panels (body is a flex
   column), so showing it pushes tab content down instead of covering the
   Layout/Visual/Store tab headers like the old fixed overlay did. */
.stem-progress-bar {
  height: 34px;
  flex-shrink: 0;
  background: var(--surface2);
  border-bottom: 1px solid var(--border2);
  display: none;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
}
.stem-progress-bar.visible {
  display: flex;
  animation: stem-bar-in 0.22s ease;
}
@keyframes stem-bar-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Reload-audio notice: the AUDIO label is hidden unless a restored project
   is waiting for its audio file (save-load.js adds .audio-needed). */
#audioBtn { display: none; }
#audioBtn.audio-needed { display: inline-block; }
/* Phase badge: "SEPARATION" / "MIDI" */
.stem-prog-phase {
  font-size: 8px;
  letter-spacing: 2px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  text-transform: uppercase;
}
/* Descriptive label */
.stem-prog-label {
  font-size: 9px;
  letter-spacing: 0.5px;
  color: var(--text2);
  flex-shrink: 0;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 340px;
}
/* Track (the grey rail) */
.stem-prog-track {
  flex: 1;
  height: 3px;
  background: var(--surface3);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
/* Deterministic fill */
.stem-prog-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 2px;
  transition: width 0.4s ease;
  position: relative;
}
/* Shimmer on the fill */
.stem-prog-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    transparent 0%, rgba(255,255,255,0.25) 50%, transparent 100%);
  animation: stem-shimmer 1.4s linear infinite;
}
@keyframes stem-shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%);  }
}
/* Indeterminate mode — animating pulse when progress is unknown */
.stem-progress-bar.indeterminate .stem-prog-fill {
  width: 28% !important;
  transition: none;
  animation: stem-indeterminate 1.5s ease-in-out infinite;
}
@keyframes stem-indeterminate {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(460%);  }
}
/* Right-hand counter / pct */
.stem-prog-right {
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--label);
  flex-shrink: 0;
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Analysis stage chips: ① SEPARATE → ② TRANSCRIBE ─────── */
.stem-prog-stages {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.stem-prog-stage {
  font-size: 8px;
  letter-spacing: 1.5px;
  color: var(--label);
  border: 1px solid var(--border2);
  border-radius: var(--r-pill);
  padding: 3px 10px;
  white-space: nowrap;
  transition: all var(--trans);
}
.stem-prog-stage.active {
  color: var(--accent);
  border-color: rgba(0,217,255,0.5);
  background: rgba(0,217,255,0.08);
  animation: stage-pulse 1.6s ease-in-out infinite;
}
.stem-prog-stage.done {
  color: var(--accent2);
  border-color: rgba(0,232,143,0.4);
  background: rgba(0,232,143,0.06);
}
.stem-prog-stage-arrow { font-size: 9px; color: var(--border2); }
@keyframes stage-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,217,255,0.25); }
  50%      { box-shadow: 0 0 10px 1px rgba(0,217,255,0.18); }
}

/* ── "Analyze this track?" post-upload prompt ─────────────── */
.ap-overlay {
  position: fixed; inset: 0;
  background: rgba(4,6,10,0.6);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 950;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.ap-overlay.visible { opacity: 1; pointer-events: auto; }

.ap-modal {
  width: min(420px, calc(100vw - 48px));
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-float);
  padding: 26px 26px 20px;
  text-align: center;
  transform: translateY(8px);
  transition: transform 0.2s ease;
}
.ap-overlay.visible .ap-modal { transform: translateY(0); }

.ap-icon {
  font-size: 26px;
  color: var(--accent);
  margin-bottom: 8px;
}
.ap-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 3px;
  color: var(--fg);
  margin-bottom: 10px;
}
.ap-body {
  font-size: 11px;
  line-height: 1.65;
  letter-spacing: 0.4px;
  color: var(--text);
  margin-bottom: 18px;
}
.ap-note {
  display: block;
  margin-top: 8px;
  font-size: 9px;
  color: var(--label);
}
.ap-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.ap-btn {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  padding: 10px 22px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--trans);
  text-transform: uppercase;
}
.ap-btn.ghost {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text2);
}
.ap-btn.ghost:hover { border-color: var(--label); color: var(--text); }
.ap-btn.primary {
  background: rgba(0,217,255,0.1);
  border: 1.5px solid var(--accent);
  color: var(--accent);
}
.ap-btn.primary:hover {
  background: rgba(0,217,255,0.18);
  box-shadow: 0 0 16px rgba(0,217,255,0.25);
}

/* ── Auto-Group review modal (extends .ap-modal) ──────────── */
.ag-modal { width: min(520px, calc(100vw - 48px)); text-align: left; }
.ag-modal .ap-title, .ag-modal .ap-body { text-align: center; }

.ag-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.ag-sel-btn {
  font-size: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px 9px;
  cursor: pointer;
  transition: color .12s, border-color .12s;
}
.ag-sel-btn:hover { color: var(--accent2); border-color: var(--accent2); }
.ag-role-link {
  font-size: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
  background: none;
  border: 1px solid transparent;
  padding: 4px 6px;
  cursor: pointer;
  transition: color .12s;
}
.ag-role-link:hover { color: var(--accent2); text-decoration: underline; }

.ag-list {
  max-height: 46vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
}
.ag-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.ag-row:last-child { border-bottom: none; }
.ag-row.exists { opacity: 0.45; }
.ag-row input[type="checkbox"] { accent-color: var(--accent2); flex-shrink: 0; }

.ag-name {
  flex: 1;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--fg);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  padding: 4px 6px;
  outline: none;
  min-width: 0;
}
.ag-name:focus { border-color: var(--accent2); background: var(--surface); }

.ag-count {
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--text2);
  white-space: nowrap;
  flex-shrink: 0;
}
.ag-kind {
  font-size: 7.5px;
  letter-spacing: 1.5px;
  color: var(--label);
  border: 1px solid var(--border2);
  border-radius: var(--r-pill);
  padding: 2px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}
.ag-empty {
  padding: 22px;
  text-align: center;
  font-size: 10px;
  color: var(--label);
}

.auto-group-btn {
  color: var(--accent) !important;
  letter-spacing: 1px;
}

/* ── Pipeline journey chips: Audio › Layout › Analyze › Show ── */
.pipeline-chips {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.pl-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'DM Mono', monospace;
  font-size: 8px;
  letter-spacing: 1.5px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--label);
  cursor: pointer;
  transition: all var(--trans);
  white-space: nowrap;
}
.pl-chip:hover { border-color: var(--label); color: var(--text); }
.pl-chip.done {
  color: var(--accent2);
  border-color: rgba(0,232,143,0.35);
  background: rgba(0,232,143,0.05);
}
.pl-chip.next {
  color: var(--accent);
  border-color: rgba(0,217,255,0.45);
  background: rgba(0,217,255,0.06);
  animation: stage-pulse 2.4s ease-in-out infinite;
}
.pl-icon { font-size: 9px; }
.pl-arrow { font-size: 9px; color: var(--border2); margin: 0 1px; }

/* Busy state: analysis running — spinner, not clickable */
.pl-chip.busy {
  color: var(--accent);
  border-color: rgba(0,217,255,0.45);
  background: rgba(0,217,255,0.06);
  cursor: default;
  pointer-events: none;
}
.pl-chip.done-final { cursor: default; }   /* complete — click does nothing */
/* Analyze chip stays clickable after completion → re-opens the adjust mode */
.pl-chip.done-clickable { cursor: pointer; }
.pl-chip.done-clickable:hover { border-color: var(--accent2); background: rgba(0,232,143,0.12); }
.pl-chip.adjusting { color: var(--warn); border-color: rgba(255,178,36,0.5); background: rgba(255,178,36,0.10); }
.pl-spin {
  width: 9px; height: 9px;
  border: 1.5px solid rgba(0,217,255,0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: pl-spin-rot 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes pl-spin-rot { to { transform: rotate(360deg); } }

/* Narrow windows: chips collapse to icons only — they're the primary
   AUDIO/ANALYZE controls now, so they must never disappear entirely. */
@media (max-width: 1460px) {
  .pl-chip .pl-label { display: none; }
  .pl-chip { padding: 4px 7px; }
}

/* ── Onboarding tour ─────────────────────────────────────── */
#tourOverlay {
  position: fixed; inset: 0;
  background: rgba(4,6,10,0.62);
  z-index: 1200;
}
.tour-lit {
  position: relative;
  z-index: 1201 !important;
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-sm);
  box-shadow: 0 0 0 6px rgba(0,217,255,0.15), 0 0 30px rgba(0,217,255,0.25);
}
.tour-card {
  position: fixed;
  z-index: 1202;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-float);
  padding: 16px 18px 14px;
}
.tour-step-n {
  font-size: 8px;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 6px;
}
.tour-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px;
  letter-spacing: 2.5px;
  color: var(--fg);
  margin-bottom: 6px;
}
.tour-body {
  font-size: 10.5px;
  line-height: 1.6;
  letter-spacing: 0.3px;
  color: var(--text);
  margin-bottom: 12px;
}
.tour-actions { display: flex; align-items: center; gap: 8px; }
.tour-btn {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 1.5px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--trans);
}
.tour-btn.ghost { background: transparent; border: 1px solid var(--border2); color: var(--text2); }
.tour-btn.ghost:hover { border-color: var(--label); color: var(--text); }
.tour-btn.primary {
  background: rgba(0,217,255,0.1);
  border: 1.5px solid var(--accent);
  color: var(--accent);
}
.tour-btn.primary:hover { background: rgba(0,217,255,0.2); }
