:root {
  /* Interspace color system */
  --bg: #070814;
  --bg-elevated: #101426;
  --panel: rgba(16, 20, 38, 0.72);
  --panel-strong: rgba(21, 26, 49, 0.9);
  --panel-2: rgba(21, 26, 49, 0.9); /* alias kept for legacy selectors */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f7ff;
  --muted: #9aa4c7;

  --accent: #8b5cf6;
  --accent-purple: #8b5cf6;
  --accent-cyan: #22d3ee;
  --accent-pink: #ec4899;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --accent-line: rgba(139, 92, 246, 0.55);

  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* Source color-coding (semantic) */
  --library: #22c55e;
  --stems: #22d3ee;
  --references: #f59e0b;

  /* Track lane tints */
  --track-a: rgba(255, 255, 255, 0.015);
  --track-b: rgba(255, 255, 255, 0.045);

  /* Geometry */
  --header-w: 220px;
  --px-per-beat: 26px;
  --total-beats: 64;
  --row-h: 72px;
  --ruler-h: 32px;
  --lane-w: calc(var(--px-per-beat) * var(--total-beats));
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 48px rgba(2, 4, 14, 0.55);
  --shadow-soft: 0 8px 24px rgba(2, 4, 14, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  background:
    radial-gradient(1px 1px at 18% 22%, rgba(255, 255, 255, 0.35), transparent),
    radial-gradient(1px 1px at 62% 14%, rgba(255, 255, 255, 0.22), transparent),
    radial-gradient(1px 1px at 82% 42%, rgba(255, 255, 255, 0.25), transparent),
    radial-gradient(1px 1px at 35% 68%, rgba(255, 255, 255, 0.18), transparent),
    radial-gradient(1px 1px at 90% 78%, rgba(255, 255, 255, 0.22), transparent),
    radial-gradient(1px 1px at 8% 84%, rgba(255, 255, 255, 0.16), transparent),
    var(--bg);
}

/* Animated, performance-safe nebula glow behind everything */
body::before {
  content: "";
  position: fixed;
  inset: -25%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(440px 440px at 18% 28%, rgba(139, 92, 246, 0.22), transparent 62%),
    radial-gradient(520px 520px at 82% 18%, rgba(34, 211, 238, 0.16), transparent 60%),
    radial-gradient(560px 560px at 60% 92%, rgba(236, 72, 153, 0.15), transparent 60%);
  animation: nebula 30s ease-in-out infinite alternate;
  will-change: transform, opacity;
}
@keyframes nebula {
  0%   { transform: translate3d(0, 0, 0) scale(1);      opacity: 0.8; }
  50%  { transform: translate3d(2%, -1.6%, 0) scale(1.08); opacity: 1; }
  100% { transform: translate3d(-1.6%, 1.4%, 0) scale(1.04); opacity: 0.78; }
}
@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
}

/* ---------- BUTTONS ---------- */
.btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 13px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.08s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); background: rgba(255, 255, 255, 0.08); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple), #6d3fe0);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.35);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 10px 26px rgba(139, 92, 246, 0.5); border-color: transparent; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }
.btn-mini { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

.mapi-presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 4px; }
.mapi-preset {
  appearance: none;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--accent-soft);
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.mapi-preset:hover { border-color: var(--accent-line); background: rgba(139, 92, 246, 0.26); }
.mapi-preset:active { transform: translateY(1px); }
.mapi-preset:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Stem-separation ("split a song") control in the Stems library section */
.split-box { margin: 2px 0 10px; }
.btn-block { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; cursor: pointer; text-align: center; }
.btn-block.is-busy { opacity: 0.65; pointer-events: none; }
.split-status { font-size: 11px; line-height: 1.4; color: var(--muted); margin-top: 6px; min-height: 14px; }
.split-status.error { color: var(--danger); }

/* ---------- TOP BAR ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  flex-shrink: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  font-size: 20px;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.5));
}
.brand-name {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 1.5px;
}
.brand-name span {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
  padding-left: 12px;
  margin-left: 2px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

.analyzer {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  max-width: 720px;
}
.analyzer-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}
.analyzer-input {
  flex: 1;
  background: rgba(7, 8, 20, 0.6);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.analyzer-input::placeholder { color: rgba(154, 164, 199, 0.6); }
.analyzer-input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.analyzer-status { font-size: 12px; color: var(--muted); min-width: 90px; }

/* ---------- WORKSPACE ---------- */
.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
}

.panel-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: var(--muted);
  margin: 0 0 14px;
}

/* ---------- LIBRARY ---------- */
.library-panel {
  width: 286px;
  flex-shrink: 0;
  background: var(--panel);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}
.lib-section { margin-bottom: 22px; }
.lib-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.lib-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.dot {
  width: 9px; height: 9px; border-radius: 50%; display: inline-block;
  box-shadow: 0 0 8px currentColor;
}
.dot-library { background: var(--library); color: var(--library); }
.dot-stems { background: var(--stems); color: var(--stems); }
.dot-references { background: var(--references); color: var(--references); }
.ref-only-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--references);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 6px;
  padding: 3px 6px;
}
.lib-list { display: flex; flex-direction: column; gap: 9px; }
.lib-empty {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  padding: 12px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.015);
}

.file-card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 11px;
  padding: 9px 10px;
  cursor: grab;
  transition: border-color 0.16s ease, transform 0.1s ease, box-shadow 0.16s ease, background 0.16s ease;
  position: relative;
}
.file-card:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}
.file-card:active { cursor: grabbing; }
.file-card.type-library { border-left-color: var(--library); }
.file-card.type-stems { border-left-color: var(--stems); }
.file-card.type-references { border-left-color: var(--references); }
.file-card .fc-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 16px;
}
.file-card .fc-wave { height: 28px; margin: 7px 0 3px; }
.file-card .fc-meta { font-size: 10px; color: var(--muted); display: flex; justify-content: space-between; }
.file-card .fc-ref { color: var(--references); font-weight: 700; letter-spacing: 0.4px; }
.file-card .fc-del {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 16px;
  height: 16px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  transition: color 0.15s ease;
}
.file-card .fc-del:hover { color: var(--danger); }

/* ---------- TIMELINE ---------- */
.timeline-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: transparent;
}
.timeline-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tl-title { font-weight: 700; font-size: 14px; letter-spacing: 0.3px; }
.tl-actions { display: flex; align-items: center; gap: 18px; }
.tl-field { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.tl-select {
  background: rgba(7, 8, 20, 0.6);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
}
.tl-select:focus { outline: none; border-color: var(--accent-line); }
.tl-zoom { width: 110px; accent-color: var(--accent); }

.timeline-scroll {
  flex: 1;
  overflow: auto;
  position: relative;
}
.timeline-grid {
  position: relative;
  width: max-content;
  min-width: 100%;
}

.tl-ruler-row {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--ruler-h);
  width: max-content;
}
.tl-track-row {
  display: flex;
  height: var(--row-h);
  width: max-content;
}

.tl-corner {
  width: var(--header-w);
  flex-shrink: 0;
  position: sticky;
  left: 0;
  z-index: 30;
  height: var(--ruler-h);
  background: var(--panel-strong);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.tl-ruler {
  flex-shrink: 0;
  height: var(--ruler-h);
  background: var(--panel-strong);
  border-bottom: 1px solid var(--border);
  display: flex;
}
.ruler-bar {
  width: calc(var(--px-per-beat) * 4);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  font-size: 10px;
  color: var(--muted);
  padding: 5px 6px;
  position: relative;
}
.ruler-bar::after {
  content: "";
  position: absolute;
  left: 25%; right: 0; bottom: 0;
  height: 6px;
  background-image: repeating-linear-gradient(
    to right,
    var(--border) 0,
    var(--border) 1px,
    transparent 1px,
    transparent 25%
  );
}

.track-header {
  width: var(--header-w);
  flex-shrink: 0;
  height: var(--row-h);
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--panel-strong);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.th-row { display: flex; align-items: center; gap: 6px; }
.th-name {
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 600;
  font-size: 12px;
  flex: 1;
  min-width: 0;
  padding: 2px 0;
}
.th-name:focus { outline: none; border-bottom: 1px solid var(--accent-line); }
.th-mini-btn {
  width: 23px; height: 21px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
}
.th-mini-btn:hover { border-color: var(--border-strong); color: var(--text); }
.th-mini-btn.active.mute { background: var(--danger); border-color: var(--danger); color: #fff; }
.th-mini-btn.active.solo { background: var(--accent); border-color: var(--accent); color: #fff; }
.th-controls { display: flex; align-items: center; gap: 8px; }
.th-vol { flex: 1; accent-color: var(--accent); height: 4px; }
.th-pan {
  width: 54px;
  accent-color: var(--accent-cyan);
  height: 4px;
}
.th-pan-label { font-size: 9px; color: var(--muted); width: 20px; text-align: center; }

.lane {
  width: var(--lane-w);
  flex-shrink: 0;
  height: var(--row-h);
  position: relative;
  border-bottom: 1px solid var(--border);
  background:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(var(--px-per-beat) * 4 - 1px),
      var(--border) calc(var(--px-per-beat) * 4 - 1px),
      var(--border) calc(var(--px-per-beat) * 4)
    );
}
.lane.row-a { background-color: var(--track-a); }
.lane.row-b { background-color: var(--track-b); }
.lane.drag-over {
  box-shadow: inset 0 0 0 2px var(--accent-line);
  background-color: var(--accent-soft);
}

.clip {
  position: absolute;
  top: 7px;
  bottom: 7px;
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: flex;
  flex-direction: column;
  user-select: none;
  box-shadow: 0 4px 14px rgba(2, 4, 14, 0.4);
}
.clip:active { cursor: grabbing; }
.clip.type-library { background: rgba(34, 197, 94, 0.22); border-color: rgba(34, 197, 94, 0.5); }
.clip.type-stems { background: rgba(34, 211, 238, 0.2); border-color: rgba(34, 211, 238, 0.5); }
.clip.type-references {
  /* Reference-only: distinct muted-warning striping, never the master */
  background:
    repeating-linear-gradient(
      45deg,
      rgba(245, 158, 11, 0.18) 0,
      rgba(245, 158, 11, 0.18) 9px,
      rgba(245, 158, 11, 0.07) 9px,
      rgba(245, 158, 11, 0.07) 18px
    );
  border-color: rgba(245, 158, 11, 0.55);
  border-style: dashed;
}
.clip-label {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  justify-content: space-between;
  gap: 4px;
}
.clip-ref-badge { color: var(--references); font-weight: 800; flex-shrink: 0; letter-spacing: 0.4px; }
.clip-canvas { flex: 1; width: 100%; display: block; }
.clip-del {
  position: absolute;
  top: 1px; right: 3px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  z-index: 2;
}
.clip-del:hover { color: #fff; }

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent-cyan);
  z-index: 15;
  pointer-events: none;
  box-shadow: 0 0 10px var(--accent-cyan);
}
.playhead::before {
  content: "";
  position: absolute;
  top: 0;
  left: -4px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid var(--accent-cyan);
}

.drop-hint {
  margin: 0;
  padding: 9px 16px;
  font-size: 11px;
  color: var(--muted);
  background: var(--panel);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ---------- MUSICAPI ---------- */
.musicapi-panel {
  width: 326px;
  flex-shrink: 0;
  background: var(--panel);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-left: 1px solid var(--border);
  padding: 18px;
  overflow-y: auto;
  transition: margin-right 0.2s ease;
}
.musicapi-panel.collapsed { display: none; }
.field-label { display: block; font-size: 12px; font-weight: 600; margin: 14px 0 6px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12px; }
.input, .textarea {
  width: 100%;
  background: rgba(7, 8, 20, 0.6);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}
.input::placeholder, .textarea::placeholder { color: rgba(154, 164, 199, 0.55); }
.input:focus, .textarea:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 14px 0; cursor: pointer; }
.check input { accent-color: var(--accent); }
.mapi-buttons { display: flex; gap: 9px; }
.mapi-buttons .btn { flex: 1; }
.mapi-status { font-size: 12px; color: var(--muted); margin-top: 14px; min-height: 18px; }
.mapi-status.error { color: #ff9a9a; }
.mapi-status.ok { color: var(--success); }
.ref-warning {
  margin-top: 16px;
  font-size: 11px;
  color: var(--references);
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.5;
}

/* ---------- TRANSPORT ---------- */
.transport {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  row-gap: 10px;
  padding: 12px 18px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px rgba(2, 4, 14, 0.4);
  flex-shrink: 0;
  z-index: 5;
}
.transport-group { display: flex; align-items: center; gap: 9px; }
.t-master { flex: 1; justify-content: flex-end; }
.t-btn {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.t-btn:hover { border-color: var(--border-strong); background: rgba(255, 255, 255, 0.08); }
.t-btn:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
.t-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 16px rgba(139, 92, 246, 0.5); }
.t-play {
  width: 54px;
  background: var(--success);
  border-color: var(--success);
  color: #04140b;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.4);
}
.t-play:hover { background: #2fe06d; border-color: #2fe06d; }
.t-play.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 18px rgba(139, 92, 246, 0.55); }
.t-position {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent-cyan);
  margin-left: 8px;
  min-width: 56px;
}
.t-field { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.t-bpm {
  width: 64px;
  background: rgba(7, 8, 20, 0.6);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}
.t-bpm:focus { outline: none; border-color: var(--accent-line); }
.t-master-field input { width: 150px; accent-color: var(--accent); }

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-strong);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--accent-line);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 12px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 100;
  max-width: 80vw;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); }

/* ---------- INTRO SLIDESHOW ---------- */
.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.intro-overlay[hidden] { display: none; }
.intro-overlay.open { opacity: 1; }
.intro-overlay.revealing { opacity: 0; pointer-events: none; }

.intro-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 5, 14, 0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.intro-stage {
  position: relative;
  width: min(560px, 100%);
  background: var(--panel-strong);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 40px 40px 28px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transform: scale(0.96);
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.intro-overlay.open .intro-stage { transform: scale(1); }
.intro-overlay.revealing .intro-stage { transform: scale(1.04); }

/* soft spotlight + light sweep */
.intro-spotlight {
  position: absolute;
  top: -40%;
  left: 50%;
  width: 140%;
  height: 120%;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(139, 92, 246, 0.28), rgba(34, 211, 238, 0.1) 55%, transparent 75%);
  pointer-events: none;
  opacity: 0.85;
}
.intro-stage::after {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 50%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  pointer-events: none;
  transform: skewX(-12deg);
}
.intro-stage.sweep::after { animation: introSweep 0.9s ease; }
@keyframes introSweep {
  0% { left: -60%; }
  100% { left: 120%; }
}
@media (prefers-reduced-motion: reduce) {
  .intro-stage.sweep::after { animation: none; }
}

.intro-skip {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  z-index: 2;
  transition: color 0.15s ease, background 0.15s ease;
}
.intro-skip:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.intro-skip:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }

.intro-content { position: relative; z-index: 1; min-height: 196px; text-align: center; }
.intro-content.swap { animation: introIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes introIn {
  0% { opacity: 0; transform: translateY(10px) scale(0.99); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .intro-content.swap { animation: none; }
}

.intro-kicker {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2.4px;
  color: var(--muted);
  margin: 0 0 14px;
}
.intro-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.4px;
  margin: 0 0 12px;
  line-height: 1.1;
}
.intro-title .ta { color: var(--text); }
.intro-title .daw {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.intro-finale .intro-title {
  font-size: 44px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan) 45%, var(--accent-pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(139, 92, 246, 0.35));
}
.intro-subtitle {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-cyan);
  margin: 0 0 16px;
}
.intro-body {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  opacity: 0.92;
  margin: 0 auto;
  max-width: 420px;
  white-space: pre-line;
}

.intro-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
}
.intro-dots { display: flex; gap: 8px; }
.intro-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: all 0.2s ease;
}
.intro-dot:hover { background: rgba(255, 255, 255, 0.4); }
.intro-dot.active {
  width: 22px;
  border-radius: 5px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
}
.intro-dot:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
.intro-nav { display: flex; gap: 9px; }
.intro-back[hidden] { display: none; }

@media (max-width: 560px) {
  .intro-stage { padding: 32px 22px 22px; }
  .intro-title { font-size: 28px; }
  .intro-finale .intro-title { font-size: 34px; }
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1080px) {
  .brand-sub { display: none; }
  .library-panel { width: 240px; }
  .musicapi-panel { width: 280px; }
}
@media (max-width: 820px) {
  .analyzer-label { display: none; }
  .topbar { gap: 12px; padding: 10px 12px; }
}

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* ---- Song -> detailed prompt (reverse-prompt) ---- */
.reverse-prompt { margin-top: 4px; }
.rp-controls { display: flex; gap: 8px; align-items: center; margin-bottom: 9px; }
.rp-controls .input { flex: 1; min-width: 0; }
.rp-controls .btn-mini { white-space: nowrap; }
.rp-divider { border: none; border-top: 1px solid rgba(124, 131, 170, 0.18); margin: 16px 0 2px; }
.rp-split-btn { margin-top: 14px; }
.rp-split-note { margin: 8px 0 0; }
.rp-detail {
  white-space: pre-wrap;
  font-size: 12.5px;
  line-height: 1.55;
  color: #e7ebff;
  background: rgba(10, 13, 28, 0.6);
  border: 1px solid rgba(124, 131, 170, 0.18);
  border-radius: 10px;
  padding: 12px 13px;
  margin-top: 12px;
  max-height: 360px;
  overflow: auto;
}
.rp-detail::-webkit-scrollbar { width: 9px; }
.rp-detail::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.35); border-radius: 8px; }

/* ---------- PROJECTS ---------- */
.proj-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 6, 16, 0.66);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.proj-overlay[hidden] { display: none; }
.proj-modal {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--panel-strong);
  border: 1px solid var(--accent-line);
  border-radius: 18px;
  padding: 24px 24px 20px;
  box-shadow: var(--shadow);
}
.proj-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.proj-close:hover { color: var(--text); border-color: var(--border-strong); }
.proj-title { margin: 0 0 4px; font-size: 20px; font-weight: 800; }
.proj-sub { margin: 0 0 16px; font-size: 12.5px; color: var(--muted); }
.proj-save-row { display: flex; gap: 8px; margin-bottom: 10px; }
.proj-save-row .input { flex: 1; min-width: 0; }
.proj-save-row .btn { white-space: nowrap; }
.proj-new { margin-bottom: 18px; }
.proj-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
  margin-bottom: 10px;
}
.proj-list { display: flex; flex-direction: column; gap: 8px; }
.proj-empty { font-size: 12.5px; color: var(--muted); padding: 6px 2px; }
.proj-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(10, 13, 28, 0.55);
}
.proj-item-main { flex: 1; min-width: 0; }
.proj-item-name {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proj-item-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.proj-item .proj-open { flex-shrink: 0; }
.proj-item-del {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.proj-item-del:hover { color: var(--danger); border-color: var(--danger); }
.proj-ai-note {
  margin-top: 18px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--accent-cyan);
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
}
