/* ── FX Chain Panel ─────────────────────────────────────────────────────────── */

.fxp-panel {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  z-index: 47;
  width: min(680px, calc(100vw - 36px));
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid rgba(132, 205, 255, 0.22);
  border-radius: 20px;
  background: rgba(6, 11, 26, 0.88);
  backdrop-filter: blur(20px);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(132, 205, 255, 0.06);
  overflow: hidden;
  transition: opacity 180ms ease, transform 180ms ease;
}

.fxp-panel.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-12px) scale(0.97);
}

/* ── Header ── */
.fxp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  cursor: grab;
  user-select: none;
}

.fxp-head:active { cursor: grabbing; }

.fxp-head-left .moon-editor-kicker {
  display: block;
  font: 700 0.58rem/1 "IBM Plex Mono", monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(100, 200, 255, 0.7);
  margin-bottom: 3px;
}

.fxp-head-left strong {
  font: 700 0.9rem/1 "Syne", sans-serif;
  color: rgba(244, 248, 255, 0.94);
}

.fxp-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fxp-monitor-btn {
  padding: 6px 12px;
  border: 1px solid rgba(157, 243, 196, 0.3);
  border-radius: 10px;
  background: rgba(157, 243, 196, 0.06);
  color: rgba(157, 243, 196, 0.7);
  font: 700 0.6rem/1 "IBM Plex Mono", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
  white-space: nowrap;
}

.fxp-monitor-btn:hover,
.fxp-monitor-btn.is-active {
  background: rgba(157, 243, 196, 0.18);
  color: rgba(157, 243, 196, 0.96);
  border-color: rgba(157, 243, 196, 0.5);
}

.fxp-monitor-btn.is-active::before { content: "● "; }

.fxp-add-wrap { position: relative; }

.fxp-add-btn {
  padding: 6px 12px;
  border: 1px solid rgba(132, 205, 255, 0.28);
  border-radius: 10px;
  background: rgba(132, 205, 255, 0.06);
  color: rgba(132, 205, 255, 0.85);
  font: 700 0.6rem/1 "IBM Plex Mono", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 120ms;
  white-space: nowrap;
}

.fxp-add-btn:hover {
  background: rgba(132, 205, 255, 0.14);
}

.fxp-add-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 10;
  min-width: 160px;
  padding: 6px;
  display: grid;
  gap: 3px;
  border: 1px solid rgba(132, 205, 255, 0.2);
  border-radius: 13px;
  background: rgba(8, 14, 32, 0.96);
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.fxp-add-menu[hidden] { display: none; }

.fxp-add-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: rgba(214, 235, 246, 0.84);
  font: 600 0.68rem/1 "IBM Plex Mono", monospace;
  cursor: pointer;
  text-align: left;
  transition: background 100ms;
}

.fxp-add-menu-item:hover {
  background: rgba(255, 255, 255, 0.07);
}

.fxp-add-menu-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.fxp-close-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(244, 248, 255, 0.6);
  font: 700 0.82rem/1 "IBM Plex Mono", monospace;
  cursor: pointer;
  transition: background 120ms, color 120ms;
  flex-shrink: 0;
}

.fxp-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(244, 248, 255, 0.96);
}

/* ── Chain scroll area ── */
.fxp-chain-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 16px 12px;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
  scrollbar-color: rgba(132, 205, 255, 0.2) transparent;
  background: rgba(0, 0, 0, 0.18);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.fxp-chain-wrap::-webkit-scrollbar { height: 4px; }
.fxp-chain-wrap::-webkit-scrollbar-track { background: transparent; }
.fxp-chain-wrap::-webkit-scrollbar-thumb { background: rgba(132, 205, 255, 0.2); border-radius: 2px; }

/* IN / OUT endpoints */
.fxp-endpoint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 8px 10px;
}

.fxp-endpoint-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(132, 205, 255, 0.4);
  background: rgba(132, 205, 255, 0.1);
  display: grid; place-items: center;
  font: 700 0.54rem/1 "IBM Plex Mono", monospace;
  color: rgba(132, 205, 255, 0.8);
  letter-spacing: 0.04em;
}

.fxp-connector {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: rgba(132, 205, 255, 0.3);
  font: 700 1rem/1 monospace;
  padding: 0 2px;
  user-select: none;
  align-self: flex-start;
  margin-top: 20px;
}

.fxp-nodes-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.fxp-empty-state {
  padding: 18px 24px;
  font: 400 0.68rem/1.4 "IBM Plex Mono", monospace;
  color: rgba(198, 225, 242, 0.35);
  text-align: center;
  align-self: center;
}

/* ── Node card ── */
.fxp-node-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 140px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-top: 3px solid var(--node-color, #64c8ff);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 140ms, background 140ms, opacity 140ms, transform 140ms;
  touch-action: none;
}

.fxp-node-card.is-dragging {
  opacity: 0.35;
}

.fxp-node-card.is-drag-over {
  border-color: rgba(132, 205, 255, 0.5);
  background: rgba(132, 205, 255, 0.06);
}

.fxp-node-card.is-bypassed {
  opacity: 0.45;
  filter: saturate(0.3);
}

/* Ghost clone while dragging */
.fxp-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 999;
  opacity: 0.88;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  border-radius: 13px;
  transform: rotate(2deg) scale(1.04);
  transition: none;
}

.fxp-node-head {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 8px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.fxp-drag-handle {
  cursor: grab;
  color: rgba(255, 255, 255, 0.25);
  font: 700 0.8rem/1 monospace;
  letter-spacing: -1px;
  padding: 2px 0;
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
}

.fxp-drag-handle:active { cursor: grabbing; }

.fxp-node-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 700 0.6rem/1 "IBM Plex Mono", monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--node-color, rgba(214, 235, 246, 0.84));
}

/* Inline enable toggle on node card */
.fxp-node-enable {
  flex-shrink: 0;
  width: 22px; height: 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  position: relative;
  cursor: pointer;
}

.fxp-node-enable::after {
  content: "";
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  top: 1px; left: 1px;
  background: rgba(255, 255, 255, 0.4);
  transition: left 140ms, background 140ms;
}

.fxp-node-enable.is-on {
  background: rgba(157, 243, 196, 0.24);
  border-color: rgba(157, 243, 196, 0.5);
}

.fxp-node-enable.is-on::after {
  left: 11px;
  background: #9df3c4;
}

.fxp-node-delete {
  flex-shrink: 0;
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: rgba(255, 255, 255, 0.25);
  font: 700 0.62rem/1 monospace;
  cursor: pointer;
  transition: background 100ms, color 100ms;
}

.fxp-node-delete:hover {
  background: rgba(255, 80, 80, 0.18);
  color: rgba(255, 120, 120, 0.9);
}

/* ── Knobs area ── */
.fxp-node-knobs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px 10px;
}

/* ── Single knob ── */
.fxp-knob {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  cursor: ns-resize;
  user-select: none;
}

.fxp-knob svg {
  display: block;
  overflow: visible;
  touch-action: none;
}

.fxp-knob-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 3;
  stroke-linecap: round;
}

.fxp-knob-arc {
  fill: none;
  stroke: var(--node-color, #64c8ff);
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 0 3px var(--node-color, #64c8ff));
}

.fxp-knob-dot {
  fill: rgba(255, 255, 255, 0.12);
}

.fxp-knob-pointer {
  stroke: rgba(255, 255, 255, 0.7);
  stroke-width: 2.5;
  stroke-linecap: round;
}

.fxp-knob-label {
  font: 700 0.52rem/1 "IBM Plex Mono", monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(198, 225, 242, 0.55);
  text-align: center;
  margin-top: 2px;
}

.fxp-knob-value {
  font: 700 0.56rem/1 "IBM Plex Mono", monospace;
  color: rgba(244, 248, 255, 0.85);
  text-align: center;
  min-width: 36px;
}

/* ── Meters ── */
.fxp-meters {
  display: flex;
  gap: 16px;
  padding: 10px 16px 12px;
}

.fxp-meter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.fxp-meter-label {
  font: 700 0.58rem/1 "IBM Plex Mono", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(198, 225, 242, 0.5);
  white-space: nowrap;
  flex-shrink: 0;
  width: 38px;
}

.fxp-meter-track {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.fxp-meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(to right, #9df3c4, #64c8ff);
  transition: width 60ms linear;
}

.fxp-meter-fill.fxp-meter-output {
  background: linear-gradient(to right, #64c8ff, #c88fff);
}

/* ── Monitor warning tooltip ── */
.fxp-monitor-note {
  padding: 8px 16px 10px;
  font: 400 0.6rem/1.4 "IBM Plex Mono", monospace;
  color: rgba(244, 220, 120, 0.65);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: none;
}

.fxp-panel.monitoring-active .fxp-monitor-note { display: block; }

/* ── FX Chain button in audio reactive overlay ── */
.aro-fx-chain-btn {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid rgba(100, 200, 255, 0.24);
  border-radius: 11px;
  background: rgba(100, 200, 255, 0.06);
  color: rgba(100, 200, 255, 0.82);
  font: 700 0.66rem/1 "IBM Plex Mono", monospace;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.aro-fx-chain-btn:hover {
  background: rgba(100, 200, 255, 0.14);
  border-color: rgba(100, 200, 255, 0.4);
  color: rgba(100, 200, 255, 0.96);
}

@media (max-width: 600px) {
  .fxp-panel {
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    right: 12px;
    left: 12px;
    width: auto;
  }
}
