/* ============================================
   Canvas Light · 浅色科技风（雾紫白）
   ============================================ */

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

:root {
  /* 背景 */
  --bg: #fafafb;
  --bg-elevated: #ffffff;

  /* 主色（雾紫） */
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-soft: #ede9fe;
  --primary-glow: rgba(124, 58, 237, 0.18);

  /* 辅助色（粉） */
  --accent: #ec4899;
  --accent-soft: #fce7f3;

  /* 文字 */
  --text: #1f2937;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;

  /* 边框 */
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(124, 58, 237, 0.12);
  --shadow-glow: 0 0 24px rgba(124, 58, 237, 0.25);

  /* 圆角 */
  --radius: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ===== 顶部工具栏 ===== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 50;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 700;
  font-size: 13px;
  border-radius: 8px;
  letter-spacing: -0.5px;
  box-shadow: var(--shadow-glow);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 14px;
  color: var(--text);
}

.brand-text small {
  font-size: 11px;
  color: var(--text-tertiary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.topbar-actions button {
  height: 32px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.topbar-actions button:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.topbar-actions button.danger:hover {
  background: #fee2e2;
  color: #dc2626;
}

.divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 6px;
}

.zoom-label {
  min-width: 48px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.status {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* ===== 画布视口 ===== */
.canvas-viewport {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  cursor: grab;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle, rgba(124, 58, 237, 0.12) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0;
  touch-action: none;
}

/* 独立页面模式下的视口样式 */
body:not(.app-shell-embedded) .canvas-viewport {
  position: fixed;
  top: 56px;
}

.canvas-viewport.is-space-down {
  cursor: grab;
}

.canvas-viewport.is-panning {
  cursor: grabbing;
}

/* 顶部渐变光晕 */
.canvas-viewport::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 240px;
  background: radial-gradient(
    ellipse at center top,
    rgba(124, 58, 237, 0.08),
    transparent 70%
  );
  pointer-events: none;
  z-index: 1;
}

/* ===== 画布世界 ===== */
.canvas-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 8000px;
  height: 8000px;
  transform-origin: 0 0;
  z-index: 2;
}

.wire-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 8000px;
  height: 8000px;
  pointer-events: none;
  z-index: 10;
  overflow: visible;
  transform-origin: 0 0;
}

/* 连线拖拽进行中时，禁用所有已有连线的 pointer events，避免拦截 pointermove/up */
.canvas-viewport.is-connecting .wire-layer path {
  pointer-events: none;
}

/* ===== 节点通用 ===== */
.node {
  position: absolute;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-width: 280px;
  overflow: visible;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* 给节点内容区域加裁剪来保持圆角，而不是节点本身 */
.node-head,
.node-body,
.node-footer {
  position: relative;
}

.node-head {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--bg-elevated);
}

.node-footer {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--bg-elevated);
}

.node:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.node.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow), var(--shadow-lg);
}

.node.is-dragging {
  opacity: 0.9;
  cursor: grabbing;
}

/* 节点端口（连线锚点） */
.node-port {
  position: absolute;
  top: 18px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 3px solid var(--primary);
  cursor: crosshair;
  z-index: 100;
  transition: transform 0.15s ease, background 0.15s ease;
  pointer-events: auto !important;
  /* 扩大命中区域，确保鼠标容易点到 */
  box-shadow: 0 0 0 6px transparent;
}

.node-port::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
}

.node-port:hover {
  transform: scale(1.4);
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.port-in {
  left: 2px;
}

.port-out {
  right: 2px;
}

/* 节点头部 */
.node-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border);
}

.node-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.node-title::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

.node-kind-badge {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 4px;
  font-weight: 500;
}

.node-body {
  padding: 12px 14px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.node-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  background: rgba(250, 250, 251, 0.6);
}

/* 节点操作按钮 */
.node-action {
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.node-action:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.node-action.danger:hover {
  border-color: #dc2626;
  color: #dc2626;
  background: #fef2f2;
}

/* 文本节点 */
.text-input {
  width: 100%;
  min-height: 80px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
}

.text-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* 图片/视频/素材节点 */
.media-area {
  width: 100%;
  min-height: 120px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text-tertiary);
  font-size: 12px;
}

.media-area img,
.media-area video {
  max-width: 100%;
  border-radius: 6px;
  display: block;
}

.media-empty {
  text-align: center;
  padding: 20px;
}

.media-empty .empty-icon {
  font-size: 28px;
  margin-bottom: 6px;
  color: var(--text-tertiary);
}

/* 提示词节点 */
.prompt-input {
  width: 100%;
  min-height: 60px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
}

.prompt-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.15);
}

/* 三视图节点 */
.three-view-area {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  min-height: 120px;
}

.three-view-cell {
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ===== 连线 ===== */
.wire-layer path {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0.6;
  pointer-events: stroke;
  cursor: pointer;
  transition: opacity 0.15s ease, stroke-width 0.15s ease;
}

.wire-layer path:hover {
  opacity: 1;
  stroke-width: 3;
}

.wire-layer path.is-selected {
  opacity: 1;
  stroke-width: 3;
  stroke: var(--accent);
}

.wire-layer path.is-temp {
  stroke-dasharray: 6 4;
  opacity: 0.8;
  pointer-events: none !important;
}

/* ===== 底部 + 节点创建器 ===== */
.node-creator {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.add-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-size: 28px;
  cursor: pointer;
  box-shadow: var(--shadow-glow), var(--shadow-lg);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.add-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 32px rgba(124, 58, 237, 0.4), var(--shadow-lg);
}

.add-btn:active {
  transform: scale(0.95);
}

.add-btn.is-open .add-icon {
  transform: rotate(45deg);
}

.add-icon {
  transition: transform 0.25s ease;
  display: inline-block;
  line-height: 1;
}

/* 节点选择面板 */
.node-panel {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: panelRise 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes panelRise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.node-panel[hidden] {
  display: none;
}

.node-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 64px;
}

.node-option:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.option-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 18px;
  color: var(--primary);
  transition: all 0.15s ease;
}

.node-option:hover .option-icon {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.option-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.node-option:hover .option-label {
  color: var(--primary);
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ===== 节点 Tab 切换（文本节点） ===== */
.node-tabs {
  display: flex;
  gap: 0;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  background: rgba(250, 250, 251, 0.6);
}

.node-tab {
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  white-space: nowrap;
}

.node-tab:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.node-tab.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ===== 系统提示词特殊样式 ===== */
.field[data-field="systemPrompt"],
.field[data-field="instruction"] {
  background: var(--primary-soft);
  margin: -2px -2px 0;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(124, 58, 237, 0.15);
}

.field[data-field="systemPrompt"] label,
.field[data-field="instruction"] label {
  color: var(--primary);
  font-weight: 600;
}

.field[data-field="systemPrompt"] .field-input,
.field[data-field="instruction"] .field-input {
  background: var(--bg-elevated);
  font-size: 11px;
  line-height: 1.6;
  min-height: 80px;
}

/* ===== 节点 Loading 态 ===== */
.node.is-loading {
  pointer-events: none;
  opacity: 0.7;
}

.node.is-loading .node-head::after {
  content: "";
  position: absolute;
  top: 16px;
  right: 14px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.node-head {
  position: relative;
}

/* ===== 分类引导 ===== */
.category-guide {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-title {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  padding: 4px 0;
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.category-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.category-item:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateX(2px);
}

.cat-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.category-item:hover .cat-name {
  color: var(--primary);
}

.cat-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.4;
}

/* ===== 分类表单 ===== */
.category-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-header {
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}

.form-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 2px;
}

.form-desc {
  display: block;
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.4;
}

.form-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.field label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

textarea.field-input {
  min-height: 60px;
  resize: vertical;
  line-height: 1.5;
}

/* textarea 外层容器：承载右上角放大按钮 */
.textarea-wrap {
  position: relative;
}
.textarea-wrap .field-input {
  padding-right: 28px;
}
.textarea-expand-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface, #fff);
  color: var(--text-secondary);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  z-index: 2;
}
.textarea-wrap:hover .textarea-expand-btn,
.textarea-expand-btn:focus {
  opacity: 1;
}
.textarea-expand-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* 放大编辑器弹层（类似飞书/微信的全屏输入） */
.textarea-expander-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  animation: textarea-expander-fade 0.15s ease;
}
@keyframes textarea-expander-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.textarea-expander {
  width: min(860px, 100%);
  height: min(70vh, 640px);
  background: var(--surface, #fff);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: textarea-expander-pop 0.18s ease;
}
@keyframes textarea-expander-pop {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.textarea-expander-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.textarea-expander-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.textarea-expander-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.textarea-expander-btn {
  border: 1px solid var(--border);
  background: var(--surface, #fff);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.textarea-expander-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.textarea-expander-btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border-color: transparent;
  font-weight: 500;
}
.textarea-expander-btn.primary:hover {
  opacity: 0.92;
  color: #fff;
}
.textarea-expander-btn.ghost {
  color: var(--text-tertiary);
}
.textarea-expander-btn.icon {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}
.textarea-expander-input {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  padding: 18px 20px;
  font-size: 14px;
  line-height: 1.7;
  font-family: inherit;
  color: var(--text);
  background: var(--surface, #fff);
}
.textarea-expander-foot {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  justify-content: flex-end;
}
.textarea-expander-hint {
  font-size: 11px;
  color: var(--text-tertiary);
}

select.field-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%237c3aed' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

/* ===== @ 引用素材下拉 ===== */
.mention-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  overflow-y: auto;
  max-height: 200px;
  animation: mentionPop 0.12s ease;
}

@keyframes mentionPop {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  text-align: left;
  transition: background 0.12s ease;
}

.mention-item:hover {
  background: var(--primary-soft);
}

.mention-label {
  font-weight: 600;
  color: var(--primary);
}

.mention-desc {
  color: var(--text-tertiary);
  font-size: 11px;
}

/* ===== 文件上传 ===== */
.field-upload {
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--bg);
}

.field-upload:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.upload-placeholder {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 6px 4px;
  line-height: 1.5;
}

.upload-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: center;
  position: relative;
}

.upload-preview img {
  max-width: 60px;
  max-height: 60px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.upload-count {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--primary);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 600;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

.file-item {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 2px 0;
}

/* ===== 表单操作按钮 ===== */
.form-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

.node-action.primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border-color: transparent;
  font-weight: 500;
}

.node-action.primary:hover {
  opacity: 0.9;
  color: white;
}

/* ===== 输出区 ===== */
.form-output {
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.6;
}

.form-output.is-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.04), rgba(236, 72, 153, 0.03));
  border-color: rgba(124, 58, 237, 0.2);
}

.form-output.is-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.output-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(124, 58, 237, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.output-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
}

.output-text {
  margin: 0;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow-y: auto;
  /* 内部滚动不再冒泡为画布平移 */
  overscroll-behavior: contain;
  /* 可选中复制长文 */
  user-select: text;
  cursor: auto;
  padding-right: 4px;
}

/* 输出长文滚动条：加宽并提高对比度，便于拖拽 */
.output-text::-webkit-scrollbar {
  width: 10px;
}

.output-text::-webkit-scrollbar-track {
  background: rgba(124, 58, 237, 0.06);
  border-radius: 5px;
}

.output-text::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, 0.35);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.output-text::-webkit-scrollbar-thumb:hover {
  background: rgba(124, 58, 237, 0.6);
  background-clip: content-box;
}

.output-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.output-actions .node-action {
  flex: 1;
  justify-content: center;
}

.output-result img,
.output-result video {
  max-width: 100%;
  border-radius: 4px;
  display: block;
}

/* ===== 高级参数折叠 ===== */
.form-advanced {
  border-top: 1px dashed var(--border);
  padding-top: 0;
}

.advanced-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0 0;
  background: none;
  border: none;
  font-size: 11px;
  color: var(--text-tertiary);
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s;
}

.advanced-toggle:hover {
  color: var(--primary);
}

.advanced-arrow {
  font-size: 10px;
  transition: transform 0.15s ease;
  color: var(--primary);
  display: inline-block;
  width: 10px;
}

.form-advanced.is-open .advanced-arrow {
  transform: rotate(90deg);
}

.advanced-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease, padding 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-advanced.is-open .advanced-body {
  max-height: 400px;
  padding-top: 8px;
}

/* 高级参数字段使用更紧凑的样式 */
.advanced-body .field label {
  font-size: 10px;
  color: var(--text-tertiary);
}

.advanced-body .field-input {
  font-size: 11px;
  padding: 4px 6px;
}

/* btn spinner */
.btn-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 4px;
  vertical-align: middle;
}

/* 输出提示 */
.output-hint {
  font-weight: 400;
  color: var(--text-tertiary);
}

/* 视频上传预览 */
.upload-preview video {
  max-width: 100px;
  max-height: 80px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.upload-preview audio {
  width: 100%;
  height: 28px;
}

.upload-item {
  position: relative;
  display: inline-flex;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.media-source-bar {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.media-source-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
  line-height: 1.5;
  font-family: inherit;
  transition: all 0.15s ease;
}

.media-source-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.media-source-btn.active {
  background: var(--primary, #2563eb);
  color: #fff;
  border-color: var(--primary, #2563eb);
}

.media-url-input {
  min-height: 56px;
  font-size: 11px;
}

.field-mini-actions {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
}

.field-mini-btn {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 10px;
  padding: 2px 8px;
  cursor: pointer;
  line-height: 1.4;
}

.field-mini-btn:hover {
  border-color: var(--primary, #2563eb);
  color: var(--primary, #2563eb);
}

.upload-item-audio {
  display: flex;
  width: 100%;
}

/* 字段提示 */
.field-hint {
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Skill 选择器信息卡 */
.skill-info {
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

.skill-info-desc {
  font-size: 11px;
  color: var(--text-primary);
  line-height: 1.6;
  max-height: 72px;
  overflow-y: auto;
}

.skill-info-meta {
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-secondary);
}

/* 单视频上传态 */
/* 反推拆解：已上传视频预览 */
.video-preview {
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  overflow: hidden;
  background: #000;
  margin-bottom: 6px;
}

.video-preview-player {
  display: block;
  width: 100%;
  max-height: 220px;
  background: #000;
}

.video-preview-info {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.video-preview-name {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-preview-meta {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-secondary);
}

.video-preview-clear {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

.video-preview-clear:hover {
  border-color: #ef4444;
  color: #ef4444;
}

/* 抽帧缩略图条 */
.frame-strip {
  display: flex;
  gap: 4px;
  padding: 6px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  overflow-x: auto;
  overscroll-behavior: contain;
}

.frame-strip::-webkit-scrollbar {
  height: 6px;
}

.frame-strip::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, 0.35);
  border-radius: 3px;
}

.frame-thumb {
  position: relative;
  flex-shrink: 0;
  width: 52px;
  height: 34px;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.frame-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.frame-thumb span {
  position: absolute;
  right: 1px;
  bottom: 1px;
  padding: 0 3px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 9px;
  line-height: 1.4;
}

.field-hint.is-extracting {
  padding: 6px 8px;
  background: var(--primary-soft);
  border-top: 1px solid var(--border);
  color: var(--primary);
  font-size: 11px;
}

/* 已有视频后，上传区收窄为「更换」入口 */
.field-upload.is-compact {
  padding: 7px;
}

.field-upload.is-compact .upload-placeholder {
  font-size: 11px;
}

/* 反推拆解结果面板 */
.rv-section-title {
  margin: 10px 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.rv-section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rv-subject-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rv-subject {
  display: flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.rv-subject-media {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-elevated, rgba(0, 0, 0, 0.04));
}

.rv-subject-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rv-subject-noimg {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-secondary);
}

.rv-img-clear {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.rv-subject-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.rv-subject-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rv-tag-input {
  width: 96px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-input, transparent);
  color: var(--text-primary);
  font-size: 11px;
  font-family: inherit;
  padding: 3px 6px;
}

.rv-tag-input:focus {
  outline: none;
  border-color: var(--primary, #2563eb);
}

.rv-subject-type {
  font-size: 10px;
  color: var(--text-secondary);
}

.rv-subject-appearance {
  font-size: 11px;
  color: var(--text-primary);
  line-height: 1.6;
  max-height: 60px;
  overflow-y: auto;
}

.rv-subject-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.rv-img-name {
  font-size: 10px;
  color: var(--text-secondary);
  word-break: break-all;
}

.rv-full-prompt {
  max-height: 320px;
}

.rv-empty {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 8px;
}

/* 批量生成 */
.batch-task-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  width: 100%;
}

.batch-task {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--panel, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
}

.batch-task.is-ok {
  flex-direction: column;
  align-items: stretch;
}

.batch-task.is-ok video {
  width: 100%;
  border-radius: 6px;
  display: block;
}

.batch-task.is-fail {
  border-color: rgba(239, 68, 68, 0.4);
}

.batch-task-err {
  color: #ef4444;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-task-tag {
  flex-shrink: 0;
}

.output-spinner.small {
  width: 14px;
  height: 14px;
  border-width: 2px;
  flex-shrink: 0;
}

.batch-video-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.batch-video-cell {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel, rgba(255, 255, 255, 0.03));
}

.batch-video-cell video {
  width: 100%;
  display: block;
}

.batch-video-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  font-size: 10px;
  color: var(--text-secondary);
}

.batch-save-btn {
  font-size: 10px;
  padding: 2px 8px;
}

.batch-partial-hint {
  margin-top: 6px;
  color: #f59e0b;
}

.upload-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  z-index: 2;
}

.upload-remove:hover {
  background: #fee2e2;
  border-color: #ef4444;
  color: #ef4444;
}

.upload-item-audio .upload-remove {
  top: 4px;
  right: 4px;
}

.upload-file-name {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  word-break: break-all;
  max-width: 100%;
}

/* ===== 占位节点（素材库/灵感库/成片库） ===== */
.placeholder-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 14px;
  text-align: center;
  gap: 6px;
}

.placeholder-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft));
  border-radius: 16px;
  font-size: 28px;
  color: var(--primary);
  margin-bottom: 4px;
}

.placeholder-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.placeholder-desc {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ===== 资源库节点（人像库 / 素材库）预览 ===== */
.lib-node-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 2px 2px;
}

.lib-node-media {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 10px;
  background: #0f172a;
  display: block;
}

.lib-node-media-fallback {
  width: 100%;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft));
  color: var(--primary);
}

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

.lib-node-type {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  padding: 2px 8px;
  background: var(--primary-soft);
  border-radius: 999px;
}

.lib-node-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.12);
  color: #7c3aed;
  border: 1px solid rgba(124, 58, 237, 0.25);
}

.lib-node-badge.warn {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  border-color: rgba(245, 158, 11, 0.3);
}

.lib-node-name {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== 资源仓库（虚拟人像 / 灵感 / 成片）Tab 样式 ===== */
.lib-panel {
  padding: 8px;
}

.lib-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.lib-tab {
  flex: 1;
  padding: 6px 8px;
  font-size: 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  border-radius: 0;
}

.lib-tab:hover {
  color: var(--primary);
}

.lib-tab.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.vh-toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.vh-select,
.vh-input {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.vh-select:focus,
.vh-input:focus {
  border-color: var(--primary);
}

.vh-btn {
  padding: 5px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.vh-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.vh-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.vh-btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.vh-btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.vh-btn-danger:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #ef4444;
  color: #ef4444;
}

.vh-upload-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.vh-upload-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.vh-newgroup {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  align-items: center;
}

.vh-error {
  padding: 8px 10px;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 8px;
}

.vh-loading {
  padding: 8px 10px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.vh-empty {
  padding: 30px 10px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
}

.vh-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.vh-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.vh-card-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.vh-card-media img,
.vh-card-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.vh-audio-placeholder {
  font-size: 32px;
  color: var(--text-tertiary);
}

.vh-status {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 2px 6px;
  font-size: 10px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}

.vh-status-ok {
  background: #10b981;
}

.vh-status-pending {
  background: #f59e0b;
}

.vh-status-fail {
  background: #ef4444;
}

.vh-card-meta {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vh-card-name {
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vh-card-actions {
  display: flex;
  gap: 4px;
}

.vh-card-actions .vh-btn {
  flex: 1;
  padding: 3px 6px;
  font-size: 11px;
}

/* 上传预览中的虚拟人像素材标识 */
.upload-asset-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  padding: 2px 6px;
  font-size: 10px;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  z-index: 1;
}

.upload-asset-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: linear-gradient(135deg, var(--primary-soft), #f3f4f6);
  color: var(--primary);
  font-size: 22px;
}

.upload-file-sub {
  font-size: 10px;
  color: var(--text-tertiary);
}

/* 统一参考素材预览：混合图片/视频/音频 */
.upload-preview-media {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: flex-start;
  position: relative;
}

.upload-preview-media .upload-item {
  position: relative;
  display: inline-flex;
  min-width: 60px;
  min-height: 40px;
  align-items: center;
  justify-content: center;
}

/* 媒体类型小徽标（图片/视频/音频） */
.upload-media-type-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  padding: 1px 5px;
  font-size: 9px;
  border-radius: 3px;
  background: rgba(17, 24, 39, 0.6);
  color: #fff;
  z-index: 1;
  pointer-events: none;
}

/* ===== 虚拟人像素材选择弹窗 ===== */
.vh-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.vh-picker-modal {
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.vh-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.vh-picker-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.vh-picker-close {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.vh-picker-close:hover {
  background: var(--bg);
  color: var(--text);
}

.vh-picker-body {
  padding: 12px 16px 16px;
  overflow-y: auto;
  flex: 1;
}

/* 人像库选择弹窗：虚拟/真人二级切换 */
.vh-picker-subtabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.vh-picker-subtab {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.vh-picker-subtab:hover { border-color: var(--primary); color: var(--primary); }
.vh-picker-subtab.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
/* 弹窗内 tab 来源标签（与 app-shell.css 保持一致） */
.vh-picker-subtab .lib-subtab-tag {
  display: inline-block;
  margin-left: 5px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10px;
  line-height: 1.6;
  background: rgba(124, 58, 237, 0.12);
  color: var(--primary);
  vertical-align: middle;
}
.vh-picker-subtab .lib-subtab-tag.warn {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
}
.vh-picker-subtab.is-active .lib-subtab-tag,
.vh-picker-subtab.is-active .lib-subtab-tag.warn {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}
/* 卡片来源徽标 */
.vh-picker-card .vh-source-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  background: rgba(124, 58, 237, 0.92);
  color: #fff;
  z-index: 2;
}
.vh-picker-card .vh-source-badge.warn {
  background: rgba(245, 158, 11, 0.95);
}

.vh-picker-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.vh-picker-select {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text);
  background: #fff;
  min-width: 0;
}

.vh-picker-refresh {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.vh-picker-refresh:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.vh-picker-refresh:disabled,
.vh-picker-select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.vh-picker-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.vh-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.vh-picker-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.vh-picker-card:hover:not(.disabled) {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
  transform: translateY(-1px);
}

.vh-picker-card.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.vh-picker-card .media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.vh-picker-card .media img,
.vh-picker-card .media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.vh-picker-media-fallback {
  font-size: 28px;
  color: var(--text-tertiary);
}

.vh-picker-card .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 2px 6px;
  font-size: 10px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}

.vh-picker-card .meta {
  padding: 6px;
}

.vh-picker-card .meta .name {
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vh-picker-empty {
  grid-column: 1 / -1;
  padding: 32px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
}

.vh-picker-error {
  color: #ef4444;
}

@media (max-width: 480px) {
  .vh-picker-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .vh-picker-modal {
    max-height: 90vh;
  }
}

/* ===== app-shell 资源库页面样式 ===== */
.lib-page-tabs {
  display: flex;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 16px;
  width: fit-content;
}

.lib-page-tab {
  padding: 8px 20px;
  font-size: 13px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.lib-page-tab:hover {
  color: var(--primary);
}

.lib-page-tab.is-active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.lib-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  background: #fff;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.lib-toolbar label {
  font-size: 13px;
  color: var(--text-secondary);
}

.lib-toolbar select,
.lib-toolbar input[type="text"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #fff;
}

.lib-toolbar select:focus,
.lib-toolbar input[type="text"]:focus {
  border-color: var(--primary);
}

.lib-btn {
  padding: 6px 14px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.lib-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.lib-btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.lib-btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.lib-btn-danger {
  color: #ef4444;
}

.lib-btn-danger:hover {
  background: #fee2e2;
  border-color: #ef4444;
  color: #ef4444;
}

.lib-upload-label {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.lib-upload-label input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.lib-asset-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s, transform 0.15s;
}

.lib-asset-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.lib-asset-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.lib-asset-media img,
.lib-asset-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lib-asset-placeholder {
  font-size: 48px;
  color: var(--text-tertiary);
}

.lib-asset-status {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}

.lib-asset-status.active {
  background: #10b981;
}

.lib-asset-status.processing {
  background: #f59e0b;
}

.lib-asset-status.failed {
  background: #ef4444;
}

.lib-asset-type-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
}

.lib-asset-meta {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lib-asset-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lib-asset-id {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: monospace;
}

.lib-asset-actions {
  display: flex;
  gap: 6px;
}

.lib-asset-actions .lib-btn {
  flex: 1;
  padding: 5px 8px;
  font-size: 12px;
}

.lib-empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-tertiary);
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.lib-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.lib-empty-title {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 6px;
}

.lib-empty-desc {
  font-size: 13px;
}

.lib-loading-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--primary);
  font-size: 13px;
}

.lib-error-state {
  padding: 20px;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}

/* 新组创建弹层行 */
.lib-newgroup-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.lib-newgroup-row input {
  flex: 1;
}

.refresh-btn {
  margin-left: auto;
}

