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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  height: 100vh;
  overflow: hidden;
}

.header {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.header-left {
  flex: 1;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.header-buttons {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.header h1 {
  color: white;
  font-size: 24px;
  font-weight: 300;
}

.add-node-btn-header {
  background: #4caf50 !important;
  border-color: #45a049 !important;
  font-size: 16px !important;
  padding: 12px 24px !important;
  border-radius: 8px !important;
  font-weight: 500 !important;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3) !important;
}

.add-node-btn-header:hover {
  background: #45a049 !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 16px rgba(76, 175, 80, 0.4) !important;
}

.btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.btn.primary {
  background: #4caf50;
  border-color: #45a049;
}

.btn.primary:hover {
  background: #45a049;
}

.btn.disabled {
  background: #ccc !important;
  border-color: #ccc !important;
  color: #666 !important;
  cursor: not-allowed !important;
  opacity: 0.6;
}

.btn.disabled:hover {
  background: #ccc !important;
  transform: none !important;
}

.workflow-container {
  position: relative;
  height: calc(100vh - 80px);
  overflow: hidden;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.workflow-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
  cursor: default;
}

.workflow-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 10000px;
  height: 10000px;
  transform-origin: 0 0;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
    linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  z-index: 1;
}

.grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 1;
}

.minimap {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 200px;
  height: 150px;
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  overflow: hidden;
  z-index: 1000;
  cursor: crosshair;
}

.minimap-viewport {
  position: absolute;
  background: rgba(76, 175, 80, 0.3);
  border: 1px solid #4caf50;
  border-radius: 2px;
  cursor: move;
  transition: all 0.2s ease;
}

.minimap-viewport:hover {
  background: rgba(76, 175, 80, 0.4);
  border-color: #45a049;
}

.zoom-controls {
  position: fixed;
  top: 100px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.zoom-btn {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.3s ease;
}

.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.zoom-info {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  z-index: 1000;
  display: none;
}

.node {
  position: absolute;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.9) 100%);
  border-radius: 16px;
  padding: 24px;
  width: 320px; /* Fixed width instead of min-width */
  max-width: 320px; /* Ensure it doesn't grow beyond this */
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(15px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  cursor: move;
  user-select: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform; /* Optimize for animations */
  z-index: 100;
}

.node::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 16px 16px 0 0;
}

.node:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.node.selected {
  border: 2px solid #4caf50;
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.3);
  /* Disable transitions during drag for better performance */
  transition: none;
}

.node.dragging {
  /* Optimize for dragging */
  will-change: transform;
  transform: translateZ(0); /* Force hardware acceleration */
}

.node.playing {
  border: 2px solid #ff6b35;
  box-shadow: 0 0 20px rgba(255, 107, 53, 0.4);
  animation: playing-pulse 2s ease-in-out infinite;
  background: rgba(255, 255, 255, 0.98);
}

.node.playing::before {
  content: '🔊';
  position: absolute;
  top: -10px;
  right: -10px;
  background: #ff6b35;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  animation: playing-bounce 1s ease-in-out infinite;
}

/* Ensure all text content within nodes wraps properly */
.node div {
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
}

/* Ensure playing indicator is always on top */
.node.playing::before {
  z-index: 10001 !important;
}

/* Connection highlighting styles */
.node.connecting-from {
  border: 2px solid #4caf50;
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.4);
  background: rgba(255, 255, 255, 0.98);
}

.node.connecting-to {
  border: 2px solid #2196f3;
  box-shadow: 0 0 20px rgba(33, 150, 243, 0.4);
  background: rgba(255, 255, 255, 0.98);
}

/* Ensure canvas elements are properly layered */
.workflow-canvas canvas {
  z-index: 10003;
  position: relative;
}

/* Ensure physics cord canvases are visible */
#physicsCord,
[id^='permanentCord_'] {
  z-index: 1005 !important;
  position: relative;
}

@keyframes playing-pulse {
  0%,
  100% {
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.4);
  }
  50% {
    box-shadow: 0 0 30px rgba(255, 107, 53, 0.6);
  }
}

@keyframes playing-bounce {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.node-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid rgba(102, 126, 234, 0.2);
  position: relative;
}

.node-header-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.node-audio-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.node-header-buttons .play-audio-btn,
.node-header-buttons .stop-audio-btn,
.node-header-buttons .play-from-here-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #333;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
  min-width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.node-header-buttons .play-audio-btn:hover {
  background: rgba(76, 175, 80, 0.2);
  border-color: #4caf50;
}

.node-header-buttons .stop-audio-btn:hover {
  background: rgba(244, 67, 54, 0.2);
  border-color: #f44336;
}

.node-header-buttons .play-from-here-btn:hover {
  background: rgba(33, 150, 243, 0.2);
  border-color: #2196f3;
}

.node-header::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 30%;
  height: 2px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 1px;
}

.node-title {
  font-weight: 600;
  color: #333;
  font-size: 16px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.node-remove {
  background: #ff4757;
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.node-buttons {
  display: flex;
  gap: 5px;
}

.node-menu {
  background: #2196f3;
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.node-menu:hover {
  background: #1976d2;
  transform: scale(1.1);
}

.node-remove:hover {
  background: #ff3742;
  transform: scale(1.1);
}

.node-context-menu {
  position: fixed;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 8px 0;
  z-index: 100003;
  min-width: 150px;
  display: none;
}

.node-context-menu.show {
  display: block;
}

.node-context-menu-item {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  transition: background-color 0.2s ease;
}

.node-context-menu-item:hover {
  background-color: #f5f5f5;
}

.node-context-menu-item.danger {
  color: #ff4757;
}

.node-context-menu-item.danger:hover {
  background-color: #fff5f5;
}

.audio-files-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 10px;
  background: #f9f9f9;
}

.no-audio-files {
  color: #666;
  font-style: italic;
  text-align: center;
  padding: 20px;
}

.audio-file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  margin: 5px 0;
  background: white;
  border-radius: 4px;
  border: 1px solid #eee;
}

.audio-file-item:hover {
  background: #f0f0f0;
}

.audio-file-info {
  flex: 1;
}

.audio-file-name {
  font-weight: 500;
  color: #333;
}

.audio-file-details {
  font-size: 12px;
  color: #666;
}

.audio-file-actions {
  display: flex;
  gap: 5px;
}

.audio-file-btn {
  padding: 4px 8px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.audio-file-btn.play {
  background: #4caf50;
  color: white;
}

.audio-file-btn.play:hover {
  background: #45a049;
}

.audio-file-btn.delete {
  background: #ff4757;
  color: white;
}

.audio-file-btn.delete:hover {
  background: #ff3742;
}

.audio-file-btn.edit {
  background: #2196f3;
  color: white;
}

.audio-file-btn.edit:hover {
  background: #1976d2;
}

.generation-settings {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 15px;
  background: #f9f9f9;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.setting-row:last-child {
  margin-bottom: 0;
}

.setting-row label {
  min-width: 120px;
  font-size: 14px;
  color: #555;
}

.setting-row input[type='range'] {
  flex: 1;
}

.setting-row span {
  min-width: 30px;
  text-align: right;
  font-weight: 500;
  color: #333 !important;
}

.connection-point {
  position: absolute;
  width: 24px;
  height: 24px;
  background: #ff6b6b;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  z-index: 10001;
  pointer-events: auto;
}

.connection-point:hover {
  transform: scale(1.5);
  background: #ff5252;
}

.connection-point.left {
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
}

.connection-point.right {
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
}

.connection-point.connected {
  background: #2196f3;
}

.connection-point.connected:hover {
  background: #1976d2;
}

.connection-point.connecting {
  background: #ff9800;
  transform: scale(1.5);
  box-shadow: 0 0 20px rgba(255, 152, 0, 0.6);
  animation: pulse 1s infinite;
}

.connection-point.adjusting-delay {
  background: #ff6b35;
  transform: scale(1.5);
  box-shadow: 0 0 20px rgba(255, 107, 53, 0.6);
  animation: delay-pulse 0.5s infinite;
}

/* Delay indicator element (separate from connection points) */
.delay-indicator-element {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 6px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.3);
  min-width: 50px;
  text-align: center;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.delay-indicator-element:hover {
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

/* Delay indicator for connection points */
.connection-point.delay-indicator {
  position: relative;
  /* Ensure the connection point itself still looks like a connection point */
  background: #ff6b6b !important;
  border: 3px solid white !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
  width: 24px !important;
  height: 24px !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  z-index: 10001 !important;
  pointer-events: auto !important;
  animation: none !important;
}

.connection-point.delay-indicator:hover {
  transform: scale(1.5) !important;
  background: #ff5252 !important;
}

.connection-point.delay-indicator::after {
  content: attr(data-delay);
  position: absolute;
  top: 50%;
  left: -45px; /* Position to the left of the connection point */
  transform: translateY(-50%);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 6px 10px;
  border-radius: 20px; /* More bubble-like with rounded corners */
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.3);
  z-index: 10002;
  min-width: 50px;
  text-align: center;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
  /* Ensure this doesn't inherit connection point styles */
  width: auto !important;
  height: auto !important;
  cursor: default !important;
}

.connection-point.delay-indicator:hover::after {
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

.connection-point.delay-indicator.left::after {
  left: auto;
  right: -45px;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 20px rgba(255, 152, 0, 0.6);
  }
  50% {
    box-shadow: 0 0 30px rgba(255, 152, 0, 0.8);
  }
  100% {
    box-shadow: 0 0 20px rgba(255, 152, 0, 0.6);
  }
}

.form-group {
  margin-bottom: 20px;
  position: relative;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #2c3e50 !important;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.3s ease;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.9);
  color: #2d3748;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  background: white;
  transform: translateY(-1px);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

.form-group select {
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  padding-right: 35px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.connection-line {
  position: absolute;
  background: #4caf50;
  height: 3px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 5;
  transition: all 0.3s ease;
}

.connection-line:hover {
  background: #45a049;
  height: 4px;
}

.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 10px 20px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100000;
}

.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
}

.status-indicator.connected {
  background: #4caf50;
}

.status-indicator.disconnected {
  background: #ff4757;
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1004;
}

.modal,
.modal *,
.modal h1,
.modal h2,
.modal h3,
.modal p,
.modal span,
.modal label,
.modal div {
  color: #333 !important;
}

.modal small,
.modal .text-muted,
.modal .character-count {
  color: #666 !important;
}

.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  color: #1a202c;
  padding: 0;
  border-radius: 16px;
  min-width: 400px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
  border: 1px solid #cbd5e0;
  position: relative;
}

.modal-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #667eea 100%);
  z-index: 1;
}

.modal h2 {
  margin: 0 0 25px 0;
  padding: 25px 30px 20px 30px;
  color: white;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  font-size: 24px;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal {
  color: #2d3748;
}

.modal * {
  color: inherit;
}

/* Modal content wrapper */
.modal-content > *:not(.modal-buttons):not(h2) {
  padding-left: 30px;
  padding-right: 30px;
}

.modal-content > :first-child:not(h2) {
  padding-top: 20px;
}

.modal-content > :last-child:not(.modal-buttons) {
  padding-bottom: 20px;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin: 25px -30px -25px -30px;
  padding: 20px 30px;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-top: 1px solid #cbd5e0;
  border-radius: 0 0 16px 16px;
  flex-wrap: wrap;
}

.btn.secondary {
  background: #6c757d;
  border-color: #5a6268;
}

.btn.secondary:hover {
  background: #5a6268;
}

.modal .btn,
.modal .btn.primary,
.modal .btn.secondary {
  color: white !important;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  transition: all 0.3s ease;
}

.modal .btn:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6b5b95 100%);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
  transform: translateY(-2px);
}

.modal .btn.secondary {
  background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
  box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.modal .btn.secondary:hover {
  background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
  box-shadow: 0 6px 20px rgba(108, 117, 125, 0.4);
}

/* Responsive modal styling */
@media (max-width: 768px) {
  .modal-content {
    min-width: 95vw;
    max-width: 95vw;
    padding: 20px;
    margin: 10px;
  }

  .form-group {
    margin-bottom: 15px;
  }

  .form-group label {
    font-size: 12px;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 13px;
    padding: 10px 12px;
  }

  .modal-buttons {
    flex-direction: column;
    gap: 8px;
  }

  .modal-buttons .btn {
    width: 100%;
    padding: 12px;
  }
}

@media (max-width: 480px) {
  .modal-content {
    min-width: 98vw;
    max-width: 98vw;
    padding: 15px;
  }

  .modal h2 {
    font-size: 18px;
    margin-bottom: 15px;
  }

  .form-group textarea {
    min-height: 60px;
  }
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.play-audio-btn {
  background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
  color: white;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
  font-weight: 500;
}

.play-audio-btn:hover {
  background: linear-gradient(135deg, #45a049 0%, #388e3c 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(76, 175, 80, 0.4);
}

.stop-audio-btn {
  background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
  color: white;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(244, 67, 54, 0.3);
  font-weight: 500;
}

.stop-audio-btn:hover {
  background: linear-gradient(135deg, #d32f2f 0%, #c62828 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(244, 67, 54, 0.4);
}

.audio-controls {
  display: flex;
  align-items: center;
  margin-top: 4px;
}

.audio-controls-top {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.play-from-here-btn {
  background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
  color: white;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
  font-weight: 500;
}

.play-from-here-btn:hover {
  background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(33, 150, 243, 0.4);
}

.node-audio-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #eee;
}

.audio-file-select {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease;
}

.audio-file-select:hover {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(0, 0, 0, 0.3);
}

.audio-file-select:focus {
  outline: none;
  border-color: #4caf50;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

/* Delay bubble styles */
.delay-bubble {
  position: fixed;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  padding: 16px 20px;
  min-width: 140px;
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.4);
  z-index: 10001;
  pointer-events: auto;
  backdrop-filter: blur(15px);
  font-size: 14px;
  color: white;
  text-align: center;
  transition: all 0.3s ease;
  cursor: ns-resize;
}

.delay-bubble.active {
  background: linear-gradient(135deg, rgba(255, 107, 53, 0.95) 0%, rgba(255, 87, 34, 0.95) 100%);
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 8px 32px rgba(255, 107, 53, 0.4);
  animation: delay-pulse 1s ease-in-out infinite;
}

.delay-progress {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.delay-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #45a049);
  border-radius: 2px;
  transition: width 0.1s ease;
  width: 0%;
}

.delay-progress-bar.active {
  background: linear-gradient(90deg, #ff6b35, #ff5722);
  animation: progress-pulse 0.5s ease-in-out infinite;
}

@keyframes delay-pulse {
  0%,
  100% {
    box-shadow: 0 8px 32px rgba(255, 107, 53, 0.4);
  }
  50% {
    box-shadow: 0 8px 32px rgba(255, 107, 53, 0.6);
  }
}

@keyframes progress-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.delay-bubble .delay-label {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 13px;
  opacity: 0.9;
}

.delay-bubble .delay-value {
  color: #ffffff;
  font-weight: bold;
  font-size: 18px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 12px;
  border-radius: 12px;
  display: inline-block;
  margin: 0 4px;
}

.delay-bubble .delay-instructions {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  font-style: italic;
  margin-top: 8px;
}

.waveform-container {
  margin-top: 12px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 10002;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.waveform-container:hover {
  background: rgba(0, 0, 0, 0.08);
}

.waveform-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.8) 100%);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 10003;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.waveform-overlay:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%);
  transform: scale(1.02);
}

.waveform-overlay-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
}

.waveform-overlay-content {
  text-align: center;
  color: #666;
}

.waveform-overlay-icon {
  font-size: 24px;
  margin-bottom: 8px;
  opacity: 0.7;
}

.waveform-overlay-text {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.8;
}

.waveform-placeholder {
  font-size: 11px;
  color: #888;
  text-align: center;
  font-style: italic;
}

.node.playing {
  border: 2px solid #ff6b35;
  box-shadow: 0 0 20px rgba(255, 107, 53, 0.4);
  animation: playing-pulse 2s ease-in-out infinite;
  background: rgba(255, 255, 255, 0.98);
}

.node.playing::before {
  content: '🔊';
  position: absolute;
  top: -10px;
  right: -10px;
  background: #ff6b35;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  animation: playing-bounce 1s ease-in-out infinite;
}

@keyframes playing-pulse {
  0%,
  100% {
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.4);
  }
  50% {
    box-shadow: 0 0 30px rgba(255, 107, 53, 0.6);
  }
}

@keyframes playing-bounce {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* Queue Position Display */
.queue-position-display {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10004;
  backdrop-filter: blur(4px);
}

/* Generation Loading Display */
.generation-loading-display {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 1000000;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.generation-loading-animation {
  display: flex;
  align-items: center;
  gap: 12px;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-bars {
  display: flex;
  gap: 3px;
  align-items: end;
}

.loading-bar {
  width: 3px;
  height: 12px;
  background: white;
  border-radius: 1px;
  animation: loading-bars 1.2s ease-in-out infinite;
}

.loading-bar:nth-child(1) {
  animation-delay: 0s;
}
.loading-bar:nth-child(2) {
  animation-delay: 0.1s;
}
.loading-bar:nth-child(3) {
  animation-delay: 0.2s;
}
.loading-bar:nth-child(4) {
  animation-delay: 0.3s;
}
.loading-bar:nth-child(5) {
  animation-delay: 0.4s;
}

.generation-loading-text {
  color: white;
  text-align: center;
}

.loading-status {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}

.loading-details {
  font-size: 11px;
  opacity: 0.8;
  font-style: italic;
}

.loading-user-indicator {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 2px;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  display: inline-block;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes loading-bars {
  0%,
  40%,
  100% {
    height: 12px;
    opacity: 0.4;
  }
  20% {
    height: 18px;
    opacity: 1;
  }
}

.queue-position-icon {
  font-size: 14px;
}

.queue-position-number {
  font-weight: bold;
  color: #4a90e2;
}

.queue-position-display.updating {
  animation: queue-pulse 1.5s infinite;
}

@keyframes queue-pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
  100% {
    opacity: 1;
  }
}

/* Rate Limit Usage Tracker */
.rate-limit-tracker {
  position: fixed;
  bottom: 250px;
  right: 20px;
  width: 200px;
  height: 150px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.3);
  z-index: 1000;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  flex-direction: column;
}

.rate-limit-tracker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.8);
  border-radius: 8px 8px 0 0;
  flex-shrink: 0;
}

.rate-limit-tracker-title {
  font-weight: 600;
  color: #333;
  font-size: 12px;
}

.rate-limit-refresh-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
  border-radius: 4px;
  transition: all 0.2s ease;
  color: #666;
}

.rate-limit-refresh-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #333;
}

.rate-limit-tracker-content {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.rate-limit-bar {
  margin-bottom: 8px;
}

.rate-limit-bar:last-child {
  margin-bottom: 0;
}

.rate-limit-bar-label {
  font-size: 10px;
  color: #666;
  margin-bottom: 4px;
  font-weight: 500;
}

.rate-limit-bar-container {
  position: relative;
  height: 20px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  overflow: hidden;
}

.rate-limit-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #45a049);
  border-radius: 10px;
  transition: all 0.3s ease;
  width: 0%;
}

.rate-limit-bar-fill.warning {
  background: linear-gradient(90deg, #ff9800, #f57c00);
}

.rate-limit-bar-fill.danger {
  background: linear-gradient(90deg, #f44336, #d32f2f);
}

.rate-limit-bar-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: 600;
  color: #333;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Animation for usage updates */
@keyframes usage-update {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.rate-limit-tracker.updating {
  animation: usage-update 0.3s ease;
}

/* Help Modal Styles */
.help-modal-content {
  max-width: 800px;
  max-height: 80vh;
  overflow-y: auto;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  color: #1a202c;
  border: 1px solid #cbd5e0;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
  position: relative;
}

.help-modal-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #667eea 100%);
  z-index: 1;
}

.help-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px 15px 25px;
  margin: -30px -30px 20px -30px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.help-modal-header h2 {
  color: white !important;
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.help-modal-header .btn {
  background: rgba(255, 255, 255, 0.2);
  color: white !important;
  border: 1px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(10px);
  padding: 8px 12px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 6px;
  transition: all 0.3s ease;
}

.help-modal-header .btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.help-content {
  padding: 0 25px 10px 25px;
  color: #2d3748;
  max-height: calc(80vh - 120px);
  overflow-y: auto;
  /* Custom scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: #667eea #f1f1f1;
}

.help-content::-webkit-scrollbar {
  width: 8px;
}

.help-content::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.help-content::-webkit-scrollbar-thumb {
  background: #667eea;
  border-radius: 4px;
}

.help-content::-webkit-scrollbar-thumb:hover {
  background: #5a6fd8;
}

.help-section {
  margin-bottom: 25px;
  padding: 20px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(248, 250, 252, 0.9) 100%);
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

.help-section h3 {
  color: #2d3748 !important;
  margin-bottom: 15px;
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 2px solid #667eea;
}

.help-section ul {
  list-style: none;
  padding-left: 0;
}

.help-section li {
  padding: 12px 0;
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
  line-height: 1.6;
  color: #4a5568 !important;
  transition: all 0.2s ease;
}

.help-section li:last-child {
  border-bottom: none;
}

.help-section li strong {
  color: #2d3748 !important;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.help-highlight {
  background: #667eea;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
  font-size: 14px;
}

.help-modal-footer {
  margin: 20px -25px -10px -25px;
  padding: 20px 25px;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-top: 1px solid #cbd5e0;
  text-align: center;
  border-radius: 0 0 12px 12px;
}

.help-modal-footer .btn {
  padding: 12px 30px;
  font-size: 16px;
  font-weight: 600;
  color: white !important;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  transition: all 0.3s ease;
}

.help-modal-footer .btn:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6b5b95 100%);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
  transform: translateY(-2px);
}

/* Responsive help modal */
@media (max-width: 768px) {
  .help-modal-content {
    max-width: 95vw;
    margin: 20px auto;
  }

  .help-modal-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .help-section {
    padding: 10px;
  }

  .help-section h3 {
    font-size: 16px;
  }
}
