:root {
  --bg-color: #f7f9fc;
  --grid-color: #e5e7eb;
  --node-bg: rgba(255, 255, 255, 0.85);
  --node-border: rgba(200, 200, 200, 0.5);
  --node-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  --primary-color: #3b82f6;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --port-color: #a855f7;
  --line-color: #94a3b8;
  --line-active-color: #3b82f6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #0f172a;
    --grid-color: #1e293b;
    --node-bg: rgba(30, 41, 59, 0.85);
    --node-border: rgba(255, 255, 255, 0.1);
    --node-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
  }
}

* {
  box-sizing: border-box;
  user-select: none; /* Prevent selection while dragging */
}

body,
html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    sans-serif;
  color: var(--text-main);
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------------- 顶部工具栏 ---------------- */
.toolbar {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  background: var(--node-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 16px;
  border-radius: 100px;
  box-shadow: var(--node-shadow);
  border: 1px solid var(--node-border);
  z-index: 100;
}

.toolbar-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toolbar-group:not(:last-child)::after {
  content: "";
  width: 1px;
  height: 20px;
  background: var(--node-border);
  margin-left: 8px;
}

.toolbar button {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 8px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.toolbar button:hover {
  background: rgba(128, 128, 128, 0.1);
}

.toolbar button i {
  color: var(--primary-color);
}

#zoom-level {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 45px;
  text-align: center;
}

/* ---------------- 画布容器 ---------------- */
#canvas-container {
  width: 100%;
  height: 100%;
  background-color: var(--bg-color);
  /* Use dot background pattern */
  background-image:
    radial-gradient(var(--grid-color) 1px, transparent 1px),
    radial-gradient(var(--grid-color) 1px, transparent 1px);
  background-size: 20px 20px;
  background-position:
    0 0,
    10px 10px;
  cursor: grab;
  position: relative;
  overflow: hidden;
}

#canvas-container:active {
  cursor: grabbing;
}

#canvas-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px; /* Origin point */
  height: 1px;
  transform-origin: 0 0;
}

#connections-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none; /* Let clicks pass through to canvas container */
  z-index: 10;
}

#connections-layer g {
  pointer-events: visibleStroke;
}

.connection-path {
  fill: none;
  stroke: var(--line-color);
  stroke-width: 3px;
  stroke-linecap: round;
  transition:
    stroke 0.3s,
    stroke-width 0.3s;
}

.connection-hit-path {
  fill: none;
  stroke: transparent;
  stroke-width: 20px;
  cursor: pointer;
}

#connections-layer g:hover .connection-path {
  stroke: var(--primary-color);
  stroke-width: 4px;
}

.connection-path.drawing {
  stroke-dasharray: 6;
  animation: dash 1s linear infinite;
  stroke: var(--primary-color);
}

@keyframes dash {
  to {
    stroke-dashoffset: -12;
  }
}

#nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Passes container drag through */
  z-index: 20;
}

.connection-delete-btn {
  position: absolute;
  width: 24px;
  height: 24px;
  background-color: #ef4444;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
  font-size: 12px;
  transform: translate(-50%, -50%); /* Center on coordinate */
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.connection-delete-btn:hover {
  transform: translate(-50%, -50%) scale(1.15);
  background-color: #dc2626;
}

/* ---------------- 节点样式 ---------------- */
.node {
  position: absolute;
  pointer-events: auto; /* Enable node interaction */
  background: var(--node-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--node-border);
  border-radius: 14px;
  box-shadow: var(--node-shadow);
  width: 280px;
  display: flex;
  cursor: grab; /* 整个节点显示可拖拽光标 */
  flex-direction: column;
  transition:
    box-shadow 0.2s,
    border-color 0.2s;
}

.node.active-node {
  border-color: #f97316 !important; /* orange-500 */
  box-shadow:
    0 0 0 1px #f97316,
    var(--node-shadow);
}

.node.selected-node {
  border-color: #3b82f6 !important; /* blue-500 */
  box-shadow:
    0 0 0 2px #3b82f6,
    var(--node-shadow);
}

.node.preview-node {
  width: 360px;
}

.node:hover {
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.1);
}

.node.dragging {
  opacity: 0.9;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
  cursor: grabbing !important;
  transform: scale(1.02); /* 拖拽时轻微放大 */
  transition: transform 0.1s ease;
}

.node-header {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--node-border);
  cursor: inherit; /* 继承节点的光标样式 */
}

.node-header:active {
  cursor: inherit;
}

.node-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary-color);
  border-radius: 7px;
  margin-right: 10px;
  font-size: 12px;
}

.node-title {
  font-weight: 600;
  font-size: 13px;
  flex-grow: 1;
}

.node-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px;
  border-radius: 50%;
  transition: all 0.2s;
}

.node-close:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.node-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: all 0.2s;
  margin-right: 8px;
}

.node-action:hover {
  color: var(--primary-color);
  background: rgba(59, 130, 246, 0.1);
}

.node-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 交互元素不显示拖拽光标 */
.node button,
.node input,
.node textarea,
.node select,
.node a,
.node .node-port,
.node .ref-image-add,
.node .ref-image-item,
.node .slider-container,
.node .dropdown-container {
  cursor: default;
}

.node button {
  cursor: pointer;
}

.node input[type="text"],
.node input[type="number"],
.node textarea {
  cursor: text;
}

.node a {
  cursor: pointer;
}

/* 输入框和表单控制 */
.prompt-input {
  width: 100%;
  height: 64px;
  resize: none;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-main);
  transition: all 0.2s;
  user-select: text;
}

@media (prefers-color-scheme: dark) {
  .prompt-input {
    background: rgba(255, 255, 255, 0.05);
  }
}

.prompt-input:focus {
  outline: none;
  border-color: var(--primary-color);
  background: transparent;
}

.node-controls {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: transparent;
  padding: 0;
  margin-bottom: 8px;
}

.generate-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 9px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.generate-btn:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.generate-btn:active {
  transform: translateY(1px);
}

/* 视频参考图区域 */
.ref-video-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ref-image-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 4px;
  align-items: flex-start;
}

.ref-image-item {
  position: relative;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--node-border);
}

.ref-image-item img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  display: block;
}

.ref-image-item-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 9px;
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 2px 0;
  pointer-events: none;
}

.ref-image-item-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.2s;
  padding: 0;
}

.ref-image-item:hover .ref-image-item-remove {
  opacity: 1;
}

.ref-image-add {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  border: 1px dashed var(--node-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  transition: all 0.2s;
  flex-shrink: 0;
  user-select: none;
}

.ref-image-add:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* 端口 */
.node-port {
  position: absolute;
  width: 18px;
  height: 18px;
  background: var(--node-bg);
  border: 4px solid var(--port-color);
  border-radius: 50%;
  top: 50%;
  transform: translateY(-50%);
  cursor: crosshair;
  z-index: 30;
  transition:
    transform 0.2s,
    box-shadow 0.2s,
    border-width 0.2s;
}

/* 扩大端口的可点击区域 */
.node-port::before {
  content: "";
  position: absolute;
  width: 40px;
  height: 40px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: transparent;
}

.node-port:hover {
  transform: translateY(-50%) scale(1.3);
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.6);
  border-width: 5px;
}

/* 拖拽连线时的高亮状态 */
.node-port.port-highlight {
  transform: translateY(-50%) scale(1.5);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.8);
  border-width: 6px;
  animation: port-pulse 0.8s ease-in-out infinite;
}

@keyframes port-pulse {
  0%,
  100% {
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.8);
  }
  50% {
    box-shadow: 0 0 30px rgba(168, 85, 247, 1);
  }
}

.output-port {
  right: -9px;
}

.input-port {
  left: -9px;
  border-color: var(--primary-color);
}

.input-port:hover {
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.6);
}

.input-port.port-highlight {
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.8);
  animation: port-pulse-input 0.8s ease-in-out infinite;
}

@keyframes port-pulse-input {
  0%,
  100% {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.8);
  }
  50% {
    box-shadow: 0 0 30px rgba(59, 130, 246, 1);
  }
}

/* 预览节点特殊样式 */
.preview-content {
  width: 100%;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.preview-content.audio-preview-content {
  min-height: 0;
}

@media (prefers-color-scheme: dark) {
  .preview-content {
    background: rgba(0, 0, 0, 0.3);
  }
}

.media-container {
  position: relative;
  width: 100%;
  height: auto;
  display: flex;
  flex-wrap: wrap; /* To support splits or grids like MJ 4 grids */
}

.media-container img,
.media-container video {
  width: 100%;
  height: auto;
  object-fit: contain;
}

.media-container.audio-media-container {
  min-height: 0;
  align-items: center;
  flex-wrap: nowrap;
}

.media-container.audio-media-container audio.media-audio {
  width: 100%;
  min-height: 0;
  flex: 0 0 auto;
  display: block;
  position: relative;
  z-index: 1;
}

.loader-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--primary-color);
  font-size: 14px;
  z-index: 10;
}

.loader-spinner i {
  font-size: 24px;
}

/* 全屏预览弹窗 */
.media-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.close-modal-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 10001;
}

.close-modal-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.modal-content {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#media-modal .modal-content img,
#media-modal .modal-content video {
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  cursor: grab;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.media-container img {
  cursor: zoom-in;
  transition: transform 0.2s;
}

/* ---------------- 节点输出端口上下文菜单 ---------------- */
.port-context-menu {
  position: fixed;
  background: var(--node-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--node-border);
  border-radius: 16px;
  box-shadow: var(--node-shadow);
  width: 200px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10002;
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}

.port-context-menu.show {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.port-context-menu .menu-item {
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  position: relative;
}

.port-context-menu .menu-item:not(.disabled):hover {
  background: rgba(128, 128, 128, 0.1);
}

.port-context-menu .menu-icon {
  width: 32px;
  height: 32px;
  background: rgba(128, 128, 128, 0.1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  color: inherit;
  font-size: 16px;
  transition:
    background 0.2s,
    color 0.2s;
}

/* 特定图标的颜色可以根据需要定制 */
.port-context-menu .menu-item:hover .menu-icon {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary-color);
}

.port-context-menu .menu-text {
  flex-grow: 1;
}

.port-context-menu .menu-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 深色模式下的微调 */
@media (prefers-color-scheme: dark) {
  .port-context-menu .menu-icon {
    background: rgba(255, 255, 255, 0.05);
  }
}

/* ---------------- 右下角布局与小地图 ---------------- */
.bottom-controls {
  position: absolute;
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  z-index: 15;
  pointer-events: none;
}

.minimap-container {
  width: 200px;
  height: 120px;
  background: var(--node-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  pointer-events: auto;
  border: 1px solid var(--node-border);
  border-radius: 12px;
  box-shadow: var(--node-shadow);
  position: relative;
  overflow: hidden;
  cursor: crosshair;
}

#minimap-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.mini-node {
  position: absolute;
  background: var(--text-muted);
  border-radius: 2px;
  opacity: 0.6;
}

#minimap-viewport {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid var(--primary-color);
  background: rgba(59, 130, 246, 0.1);
  cursor: move;
  border-radius: 4px;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--node-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  pointer-events: auto;
  border: 1px solid var(--node-border);
  padding: 8px 16px;
  border-radius: 16px;
  box-shadow: var(--node-shadow);
}

.zoom-controls button {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.zoom-controls button:hover {
  background: rgba(128, 128, 128, 0.1);
  color: var(--primary-color);
}

.zoom-controls .divider {
  width: 1px;
  height: 14px;
  background: var(--node-border);
  margin: 0 4px;
}

.zoom-controls span {
  font-size: 13px;
  color: var(--text-main);
  font-weight: 500;
  min-width: 45px;
  text-align: center;
}

/* ---------------- 表单辅助样式 ---------------- */
.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  margin-top: 8px;
}
.form-row > label {
  color: var(--text-muted);
  min-width: 60px;
}
.radio-group {
  display: flex;
  gap: 12px;
  color: var(--text-main);
}
.radio-label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

/* ---------------- 提取视频帧时间轴 ---------------- */
.clip-timeline-wrap {
  position: relative;
  margin-bottom: 8px;
}
.clip-timeline-bar {
  position: relative;
  height: 36px;
  background: rgba(24, 144, 255, 0.1);
  border-radius: 4px;
  overflow: visible;
  cursor: crosshair;
  user-select: none;
  border: 1px solid rgba(24, 144, 255, 0.2);
}
.clip-playhead {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: #1890ff;
  z-index: 10;
  pointer-events: none;
  transition: left 0.1s linear;
}
.clip-playhead::after {
  content: "";
  position: absolute;
  top: -4px;
  left: -4px;
  width: 10px;
  height: 10px;
  background: #1890ff;
  border-radius: 50%;
}
.clip-timeline-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 2px;
}
.clip-keep-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.clip-keep-tag {
  display: inline-block;
  padding: 2px 6px;
  background: rgba(82, 196, 26, 0.1);
  border: 1px solid rgba(82, 196, 26, 0.3);
  border-radius: 4px;
  font-size: 11px;
  color: #52c41a;
}
.frame-point-marker {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: #fa8c16;
  z-index: 12;
  cursor: grab;
  transform: translateX(-1px);
}
.frame-point-marker:active {
  cursor: grabbing;
}
.frame-point-marker::before {
  content: "";
  position: absolute;
  top: -4px;
  left: -4px;
  width: 10px;
  height: 10px;
  background: #fa8c16;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.frame-point-marker .frame-point-label {
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #fa8c16;
  white-space: nowrap;
  pointer-events: none;
}
.frame-point-marker .frame-point-close {
  position: absolute;
  top: -8px;
  right: -12px;
  width: 14px;
  height: 14px;
  background: #ff4d4f;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 50%;
  font-size: 10px;
  line-height: 10px;
  text-align: center;
  cursor: pointer;
  z-index: 13;
  display: none;
}
.frame-point-marker:hover .frame-point-close {
  display: block;
}

#framePointItems {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 12px;
  padding: 4px 0;
}

.frame-point-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.02);
  padding: 4px 8px;
  border-radius: 6px;
}

.dark-theme .frame-point-item {
  background: rgba(255, 255, 255, 0.04);
}
.frame-point-item input {
  width: 60px;
  padding: 4px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  font-size: 12px;
  outline: none;
  background: rgba(255, 255, 255, 0.5);
}
.btn-remove-seg {
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  color: #ff4d4f;
  cursor: pointer;
  border-radius: 4px;
}
.btn-remove-seg:hover {
  background: rgba(255, 77, 79, 0.1);
}

/* --- Manual Theme Overrides --- */
html.dark-theme {
  --bg-color: #0f172a;
  --grid-color: #1e293b;
  --node-bg: rgba(30, 41, 59, 0.85);
  --node-border: rgba(255, 255, 255, 0.1);
  --node-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}
html.dark-theme .prompt-input {
  background: rgba(255, 255, 255, 0.05) !important;
}
html.dark-theme .prompt-expand-textarea {
  background: rgba(255, 255, 255, 0.05) !important;
}
html.dark-theme .preview-content {
  background: rgba(0, 0, 0, 0.3) !important;
}
html.dark-theme .port-context-menu .menu-icon {
  background: rgba(255, 255, 255, 0.05) !important;
}

html.light-theme {
  --bg-color: #f7f9fc;
  --grid-color: #e5e7eb;
  --node-bg: rgba(255, 255, 255, 0.85);
  --node-border: rgba(200, 200, 200, 0.5);
  --node-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  --text-main: #1f2937;
  --text-muted: #6b7280;
}
html.light-theme .prompt-input {
  background: rgba(0, 0, 0, 0.05) !important;
}
html.light-theme .preview-content {
  background: transparent !important;
}
html.light-theme .port-context-menu .menu-icon {
  background: rgba(128, 128, 128, 0.1) !important;
}

/* ---------------- 提示词展开编辑 ---------------- */
.prompt-input-wrap {
  position: relative;
}

.prompt-expand-btn {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  padding: 0;
  background: rgba(0, 0, 0, 0.08);
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition:
    opacity 0.15s,
    background 0.15s,
    color 0.15s;
  user-select: none;
}

.prompt-input-wrap:hover .prompt-expand-btn,
.prompt-input-wrap:focus-within .prompt-expand-btn {
  opacity: 1;
}

.prompt-expand-btn:hover {
  background: var(--primary-color);
  color: #fff;
}

.prompt-expand-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.prompt-expand-dialog {
  width: 600px;
  max-width: 90vw;
  height: 500px;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--node-border);
  animation: slideIn 0.15s ease-out;
}

.prompt-expand-dialog.fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  border-radius: 0;
}

.prompt-expand-dialog.fullscreen .prompt-expand-textarea {
  flex: 1;
  height: auto;
}
html.light-theme .prompt-expand-dialog,
html.light-theme .modal-dialog-opaque {
  background: #fff;
}
html.dark-theme .prompt-expand-dialog,
html.dark-theme .modal-dialog-opaque {
  background: #1e293b;
}

.prompt-expand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--node-border);
}

.prompt-expand-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prompt-expand-header button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}

.prompt-expand-header button:hover {
  color: #ef4444;
}

#prompt-expand-translate,
#prompt-expand-markdown {
  font-size: 13px !important;
  padding: 5px 12px !important;
  border-radius: 6px !important;
  background: rgba(59, 130, 246, 0.1) !important;
  color: var(--primary-color) !important;
  border: 1px solid rgba(59, 130, 246, 0.25) !important;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
}

#prompt-expand-translate:hover:not(:disabled),
#prompt-expand-markdown:hover {
  background: var(--primary-color) !important;
  color: #fff !important;
}

#prompt-expand-translate:disabled,
#prompt-expand-markdown:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.prompt-expand-textarea {
  width: 100%;
  height: 100%;
  resize: none;
  background: rgba(0, 0, 0, 0.04);
  border: none;
  padding: 16px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-main);
  outline: none;
  line-height: 1.6;
  user-select: text;
  overflow-y: auto;
}

.prompt-expand-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
}

.prompt-expand-content.preview-mode {
  flex-direction: row;
  gap: 1px;
}

.prompt-expand-content.preview-mode .prompt-expand-textarea {
  width: 50% !important;
  height: 100% !important;
  flex: 1;
}

.prompt-expand-preview {
  width: 50%;
  padding: 16px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.02);
  font-size: 14px;
  line-height: 1.6;
  flex: 1;
}

/* ---------------- 视频合成节点 ---------------- */
.compose-node .node-icon {
  background: rgba(139, 92, 246, 0.12);
  color: #8b5cf6;
}

.compose-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.compose-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.compose-section-label i {
  font-size: 11px;
}

.compose-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--primary-color);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  margin-left: auto;
}

.compose-media-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 44px;
  border: 1px dashed var(--node-border);
  border-radius: 10px;
  padding: 6px;
  transition:
    border-color 0.2s,
    background 0.2s;
}

.compose-media-list.drag-over {
  border-color: var(--primary-color);
  background: rgba(59, 130, 246, 0.04);
}

.compose-empty-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
  padding: 8px;
  opacity: 0.7;
}

.compose-empty-hint i {
  font-size: 11px;
}

.compose-media-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid transparent;
  transition:
    background 0.15s,
    border-color 0.15s,
    box-shadow 0.15s,
    opacity 0.15s;
  cursor: default;
  position: relative;
}

.dark-theme .compose-media-item {
  background: rgba(255, 255, 255, 0.04);
}

.compose-media-item:hover {
  background: rgba(0, 0, 0, 0.06);
}

.dark-theme .compose-media-item:hover {
  background: rgba(255, 255, 255, 0.07);
}

.compose-media-item.dragging {
  opacity: 0.4;
  border-color: var(--primary-color);
}

.compose-media-item.drag-placeholder {
  border: 2px dashed var(--primary-color);
  background: rgba(59, 130, 246, 0.06);
}

.compose-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px;
  opacity: 0.5;
  transition:
    opacity 0.15s,
    color 0.15s;
  flex-shrink: 0;
}

.compose-drag-handle:active {
  cursor: grabbing;
}

.compose-media-item:hover .compose-drag-handle {
  opacity: 1;
  color: var(--primary-color);
}

.compose-media-thumb {
  width: 48px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.08);
}

.compose-media-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.compose-media-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compose-media-meta {
  font-size: 10px;
  color: var(--text-muted);
}

.compose-media-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 11px;
  opacity: 0;
  transition:
    opacity 0.15s,
    color 0.15s,
    background 0.15s;
  flex-shrink: 0;
}

.compose-media-item:hover .compose-media-remove {
  opacity: 1;
}

.compose-media-remove:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.compose-options {
  padding-top: 4px;
}

.compose-options .form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.compose-options .form-row label:first-child {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.compose-options .radio-group {
  display: flex;
  gap: 10px;
}

.compose-options .radio-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-main);
  cursor: pointer;
}

.compose-options .radio-label input[type="radio"] {
  margin: 0;
  width: 13px;
  height: 13px;
}

.compose-audio-icon {
  width: 48px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary-color);
  font-size: 14px;
  flex-shrink: 0;
}

/* ---------------- 功能区 ---------------- */
.preview-features {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  gap: 5px;
  padding: 12px 0;
  border-top: 1px solid var(--node-border);
  justify-content: flex-start;
  background: rgba(0, 0, 0, 0.02);
}

.dark-theme .preview-features {
  background: rgba(255, 255, 255, 0.02);
}

.preview-features .feature-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 12px;
  background: var(--node-bg);
  border: 1px solid var(--node-border);
  color: var(--text-main);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  white-space: nowrap;
}

.preview-features .feature-btn:hover {
  background: var(--primary-color);
  color: #fff !important;
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.preview-features .feature-btn i {
  transition: transform 0.2s;
}

.preview-features .feature-btn:hover i {
  transform: scale(1.1);
}

.dark-theme .preview-features .feature-btn {
  background: rgba(255, 255, 255, 0.05);
}

.cropper-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  overflow: visible;
  border-radius: 4px;
}

.clip-timeline-wrap {
  position: relative;
  flex-shrink: 0;
}

.clip-timeline-bar {
  position: relative;
  height: 56px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  overflow: visible;
  cursor: crosshair;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.clip-playhead {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: #1890ff;
  pointer-events: none;
  z-index: 3;
}

.dark-theme .clip-timeline-bar {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.clip-playhead::after {
  content: "";
  position: absolute;
  top: -4px;
  left: -4px;
  width: 10px;
  height: 10px;
  background: #1890ff;
  border-radius: 50%;
}

.clip-del-zone {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(255, 77, 79, 0.35);
  border-left: 2px solid #ff4d4f;
  border-right: 2px solid #ff4d4f;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.clip-del-zone:active {
  cursor: grabbing;
}

.clip-del-zone .del-label {
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.clip-del-zone .del-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  background: #ff4d4f;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  z-index: 4;
}

.clip-del-zone .del-close:hover {
  background: #ff1a1a;
}

.clip-del-zone .del-edge {
  position: absolute;
  top: 0;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
  z-index: 3;
}

.clip-del-zone .del-edge-left {
  left: -4px;
}

.clip-del-zone .del-edge-right {
  right: -4px;
}

.clip-timeline-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #999;
  margin-top: 4px;
  padding: 0 2px;
}

.clip-timeline-hint {
  font-size: 12px;
  color: #999;
  margin: 0;
  flex-shrink: 0;
}

.clip-preview {
  font-size: 13px;
  color: #fff;
  padding: 8px 0;
  flex-shrink: 0;
}

.clip-seg-list {
  border-top: 1px solid #444;
  padding-top: 8px;
  flex-shrink: 0;
}

.clip-seg-list .seg-title {
  font-size: 13px;
  color: #999;
  margin-bottom: 6px;
}

.clip-seg-list .seg-title span {
  color: #fff;
  font-weight: 600;
}

.clip-segments {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.clip-segment {
  margin-bottom: 4px;
}

.clip-segment .form-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.clip-segment .form-row label {
  color: #999;
  font-size: 12px;
  min-width: 50px;
}

.clip-segment .form-row input {
  width: 70px;
  flex: none;
  padding: 4px 8px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #2a2a2a;
  color: #fff;
  font-size: 12px;
}

.btn-remove-seg {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: #ff4d4f;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-remove-seg:hover {
  background: #ff1a1a;
}

/* Clip Video Node Timeline Styles */
.clip-video-node .clip-timeline-wrap {
  position: relative;
  margin-bottom: 8px;
}

.clip-video-node .clip-timeline-bar {
  position: relative;
  height: 56px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  overflow: visible;
  cursor: crosshair;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.dark-theme .clip-video-node .clip-timeline-bar {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.clip-video-node .clip-playhead {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--primary-color);
  pointer-events: none;
  z-index: 3;
}

.clip-video-node .clip-playhead::after {
  content: "";
  position: absolute;
  top: -4px;
  left: -4px;
  width: 10px;
  height: 10px;
  background: var(--primary-color);
  border-radius: 50%;
}

.clip-video-node .clip-del-zone {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(255, 77, 79, 0.35);
  border-left: 2px solid #ff4d4f;
  border-right: 2px solid #ff4d4f;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.clip-video-node .clip-del-zone:active {
  cursor: grabbing;
}

.clip-video-node .clip-del-zone .del-label {
  font-size: 11px;
  color: #cc3333;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.8);
}

.dark-theme .clip-video-node .clip-del-zone .del-label {
  color: #ff6b6b;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.clip-video-node .clip-del-zone .del-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  background: #ff4d4f;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  z-index: 4;
}

.clip-video-node .clip-del-zone .del-close:hover {
  background: #ff1a1a;
}

.clip-video-node .clip-del-zone .del-edge {
  position: absolute;
  top: 0;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
  z-index: 3;
}

.clip-video-node .clip-del-zone .del-edge-left {
  left: -4px;
}

.clip-video-node .clip-del-zone .del-edge-right {
  right: -4px;
}

/* 视频拆解节点样式 */
.split-video-node .clip-timeline-wrap {
  position: relative;
  margin-bottom: 8px;
}

.split-video-node .clip-timeline-bar {
  position: relative;
  height: 56px;
  background: #e8f5e9;
  border-radius: 8px;
  overflow: visible;
  cursor: crosshair;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.split-video-node .clip-playhead {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: #4caf50;
  pointer-events: none;
  z-index: 3;
}

.split-video-node .split-keep-zone {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(76, 175, 80, 0.3);
  border-left: 2px solid #4caf50;
  border-right: 2px solid #4caf50;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.split-video-node .split-keep-zone:active {
  cursor: grabbing;
}

.split-video-node .split-keep-zone:hover {
  background: rgba(76, 175, 80, 0.4);
}

.split-video-node .split-keep-zone .del-label {
  font-size: 11px;
  color: #2e7d32;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.8);
}

.dark-theme .split-video-node .split-keep-zone .del-label {
  color: #66bb6a;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.split-video-node .split-keep-zone .del-close {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  background: #4caf50;
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 12px;
  line-height: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.split-video-node .split-keep-zone .del-close:hover {
  opacity: 1;
}

.split-video-node .split-keep-zone .del-edge {
  position: absolute;
  top: 0;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
  z-index: 3;
}

.split-video-node .split-keep-zone .del-edge-left {
  left: -4px;
}

.split-video-node .split-keep-zone .del-edge-right {
  right: -4px;
}

/* 拆解节点片段列表样式 */
.split-video-node .clip-segments {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 150px;
  overflow-y: auto;
}

.split-video-node .clip-segment {
  margin-bottom: 4px;
}

.split-video-node .clip-segment .form-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.split-video-node .clip-segment .form-row label {
  color: var(--text-muted);
  font-size: 12px;
  min-width: 50px;
}

.split-video-node .clip-segment .form-row input {
  width: 70px;
  flex: none;
  padding: 4px 8px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  background: var(--node-bg);
  color: var(--text-main);
  font-size: 12px;
}

.dark-theme .split-video-node .clip-segment .form-row input {
  border-color: rgba(255, 255, 255, 0.2);
}

.split-video-node .btn-remove-seg {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: #ff4d4f;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.split-video-node .btn-remove-seg:hover {
  background: #ff1a1a;
}

/* 音频截取节点样式 */
.clip-audio-node .clip-timeline-wrap {
  position: relative;
  margin-bottom: 8px;
}

.clip-audio-node .clip-timeline-bar {
  position: relative;
  height: 40px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  overflow: visible;
  cursor: crosshair;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.clip-audio-node .clip-playhead {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: #4caf50;
  pointer-events: none;
  z-index: 3;
}

.clip-audio-node .split-keep-zone {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(76, 175, 80, 0.3);
  border-left: 2px solid #4caf50;
  border-right: 2px solid #4caf50;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.clip-audio-node .split-keep-zone:active {
  cursor: grabbing;
}

.clip-audio-node .split-keep-zone:hover {
  background: rgba(76, 175, 80, 0.4);
}

.clip-audio-node .split-keep-zone .del-label {
  font-size: 11px;
  color: #2e7d32;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.8);
}

.dark-theme .clip-audio-node .split-keep-zone .del-label {
  color: #66bb6a;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.clip-audio-node .split-keep-zone .del-close {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  background: #4caf50;
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 12px;
  line-height: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.clip-audio-node .split-keep-zone .del-close:hover {
  opacity: 1;
}

.clip-audio-node .split-keep-zone .del-edge {
  position: absolute;
  top: 0;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
  z-index: 3;
}

.clip-audio-node .split-keep-zone .del-edge-left {
  left: -4px;
}

.clip-audio-node .split-keep-zone .del-edge-right {
  right: -4px;
}

.clip-audio-node .clip-segments {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 150px;
  overflow-y: auto;
}

.clip-audio-node .clip-segment {
  margin-bottom: 4px;
}

.clip-audio-node .clip-segment .form-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.clip-audio-node .clip-segment .form-row label {
  color: var(--text-muted);
  font-size: 12px;
  min-width: 50px;
}

.clip-audio-node .clip-segment .form-row input {
  width: 70px;
  flex: none;
  padding: 4px 8px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  background: var(--node-bg);
  color: var(--text-main);
  font-size: 12px;
}

.dark-theme .clip-audio-node .clip-segment .form-row input {
  border-color: rgba(255, 255, 255, 0.2);
}

.clip-audio-node .btn-remove-seg {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: #ff4d4f;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.clip-audio-node .btn-remove-seg:hover {
  background: #ff1a1a;
}

.clip-audio-node .clip-seg-list {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding-top: 8px;
  margin-top: 4px;
}

.dark-theme .clip-audio-node .clip-seg-list {
  border-color: rgba(255, 255, 255, 0.1);
}

.clip-audio-node .clip-seg-list .seg-title {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.clip-audio-node .clip-seg-list .seg-title span {
  color: var(--text-main);
  font-weight: 600;
}

.clip-audio-node .clip-timeline-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 2px;
}

.clip-audio-node .clip-timeline-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 8px;
}

.split-video-node .clip-seg-list .seg-title {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.split-video-node .clip-seg-list .seg-title span {
  color: var(--text-main);
  font-weight: 600;
}

.clip-video-node .clip-timeline-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 2px;
}

.clip-video-node .clip-timeline-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 8px 0;
}

.clip-video-node .clip-preview {
  font-size: 13px;
  color: var(--text-main);
  padding: 8px 0;
  min-height: 24px;
}

.clip-video-node .clip-keep-tags,
.extract-frame-node .clip-keep-tags,
.to-gif-node .clip-keep-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.clip-video-node .clip-keep-tag,
.extract-frame-node .clip-keep-tag,
.to-gif-node .clip-keep-tag {
  display: inline-block;
  padding: 2px 10px;
  background: rgba(82, 196, 26, 0.1);
  border: 1px solid #52c41a;
  border-radius: 4px;
  font-size: 12px;
  color: #52c41a;
}

.clip-video-node .clip-seg-list {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding-top: 8px;
  margin-top: 4px;
}

.dark-theme .clip-video-node .clip-seg-list {
  border-color: rgba(255, 255, 255, 0.1);
}

.clip-video-node .clip-seg-list .seg-title {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.clip-video-node .clip-seg-list .seg-title span {
  color: var(--text-main);
  font-weight: 600;
}

.clip-video-node .clip-segments {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 150px;
  overflow-y: auto;
}

.clip-video-node .clip-segment {
  margin-bottom: 4px;
}

.clip-video-node .clip-segment .form-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.clip-video-node .clip-segment .form-row label {
  color: var(--text-muted);
  font-size: 12px;
  min-width: 50px;
}

.clip-video-node .clip-segment .form-row input {
  width: 70px;
  flex: none;
  padding: 4px 8px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  background: var(--node-bg);
  color: var(--text-main);
  font-size: 12px;
}

.dark-theme .clip-video-node .clip-segment .form-row input {
  border-color: rgba(255, 255, 255, 0.2);
}

.clip-video-node .btn-remove-seg {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: #ff4d4f;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.clip-video-node .btn-remove-seg:hover {
  background: #ff1a1a;
}

.cropper-canvas {
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.cropper-toolbar {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(20, 20, 20, 0.85);
  backdrop-filter: blur(8px);
  padding: 6px 12px;
  border-radius: 8px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.cropper-toolbar button {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 4px;
  transition: background 0.2s;
}

.cropper-toolbar button:hover {
  background: rgba(255, 255, 255, 0.15);
}

.cropper-toolbar button.btn-confirm {
  background: #fff;
  color: #141414;
  font-weight: 500;
}

.cropper-toolbar button.btn-confirm:hover {
  background: #f0f0f0;
}

/* ---------------- AI 表单：布局与字段分组 ---------------- */
.newapi-model-settings {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.newapi-model-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.newapi-parameter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  align-items: start;
}

.newapi-span-2 {
  grid-column: 1 / -1;
}

@media (max-width: 640px) {
  .newapi-parameter-grid {
    grid-template-columns: 1fr;
  }

  .newapi-span-2 {
    grid-column: auto;
  }
}

.newapi-select-field {
  width: 100%;
  min-width: 0;
}

.newapi-select-field + .newapi-select-field {
  margin-top: 0;
}

.setting-group.newapi-select-field {
  margin-bottom: 10px;
}

.setting-group.newapi-select-field > .input,
.setting-group.newapi-select-field > .node-select {
  width: 100%;
  margin-top: 3px;
}

.newapi-size-input-wrap {
  position: relative;
}

.newapi-inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.newapi-inline-field > .input,
.newapi-inline-field > .node-select {
  flex: 1;
  min-width: 0;
}

.newapi-inline-unit {
  flex-shrink: 0;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 13px;
}

.newapi-size-input-wrap .newapi-size-input {
  padding-right: 38px;
}

.newapi-size-trigger {
  position: absolute;
  top: calc(50% + 2px);
  right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transform: translateY(-50%);
}

.newapi-size-trigger svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.newapi-size-trigger.is-open svg {
  transform: rotate(180deg);
}

.newapi-size-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: max(100%, 200px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--node-border);
  border-radius: 10px;
  background: var(--select-menu-surface);
  box-shadow: var(--node-shadow);
}

.newapi-size-suggestions.hidden {
  display: none !important;
}

.newapi-size-suggestion-item {
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--select-menu-text);
  font-size: 13px;
  line-height: 1.2;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.newapi-size-suggestion-item:hover {
  background: rgba(59, 130, 246, 0.12);
}

.newapi-jsoneditor-host {
  position: relative;
  height: 100%;
}

.newapi-jsoneditor-host .jsoneditor {
  height: 100% !important;
  box-sizing: border-box;
}

.newapi-parameter-grid {
  min-height: 0;
}

/* ---------------- AI 表单：下拉框主题变量 ---------------- */
:root {
  --select-surface: rgba(0, 0, 0, 0.05);
  --select-surface-hover: rgba(0, 0, 0, 0.08);
  --select-menu-surface: #f7f9fc;
  --select-menu-text: #1f2937;
  --select-color-scheme: light;
}

html.dark-theme {
  --select-surface: rgba(255, 255, 255, 0.05);
  --select-surface-hover: rgba(255, 255, 255, 0.08);
  --select-menu-surface: #0f172a;
  --select-menu-text: #f8fafc;
  --select-color-scheme: dark;
}

html.light-theme {
  --select-surface: rgba(0, 0, 0, 0.05);
  --select-surface-hover: rgba(0, 0, 0, 0.08);
  --select-menu-surface: #f7f9fc;
  --select-menu-text: #1f2937;
  --select-color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  html:not(.dark-theme):not(.light-theme) {
    --select-surface: rgba(255, 255, 255, 0.05);
    --select-surface-hover: rgba(255, 255, 255, 0.08);
    --select-menu-surface: #0f172a;
    --select-menu-text: #f8fafc;
    --select-color-scheme: dark;
  }
}

/* ---------------- AI 表单：select / input 控件样式 ---------------- */
select.input,
select.node-select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background-color: var(--select-surface);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  color-scheme: var(--select-color-scheme);
  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 10px center;
  background-size: 14px;
  transition: all 0.2s ease;
}

select.input:hover,
select.node-select:hover {
  background-color: var(--select-surface-hover);
  border-color: transparent;
}

select.input:focus,
select.node-select:focus {
  border-color: var(--primary-color);
  box-shadow: none;
  outline: none;
  background-color: transparent;
}

select.input option,
select.node-select option,
select.input optgroup,
select.node-select optgroup {
  background-color: var(--select-menu-surface);
  color: var(--select-menu-text);
}

input.input,
input.node-select {
  width: 100%;
  min-height: 40px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background-color: var(--select-surface);
  color: var(--text-main);
  font-size: 13px;
  transition: all 0.2s ease;
}

input.input:hover,
input.node-select:hover {
  background-color: var(--select-surface-hover);
  border-color: transparent;
}

input.input:focus,
input.node-select:focus {
  border-color: var(--primary-color);
  box-shadow: none;
  outline: none;
  background-color: transparent;
}

input.input[type="number"],
input.node-select[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input.input[type="number"]::-webkit-outer-spin-button,
input.input[type="number"]::-webkit-inner-spin-button,
input.node-select[type="number"]::-webkit-outer-spin-button,
input.node-select[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

#image-parameter-settings .settings-panel .hidden,
#video-parameter-settings .settings-panel .hidden {
  display: none !important;
}
