/* ── Group action toolbar (shown when group is selected) ── */
.sb-image-group-toolbar {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: rgba(26, 26, 28, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 200;
  white-space: nowrap;
}
.sb-group-tool-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.sb-group-tool-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}
.sb-group-tool-btn.primary {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(139, 92, 246, 0.25));
  color: rgba(199, 210, 254, 0.95);
  border: 1px solid rgba(139, 92, 246, 0.35);
}
.sb-group-tool-btn.primary:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.4), rgba(139, 92, 246, 0.4));
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Video model picker list */
.sb-video-model-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sb-video-model-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
}
.sb-video-model-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}
.sb-video-model-item.active {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.4);
  color: white;
}
.sb-video-model-main {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
}
.sb-video-model-name {
  font-weight: 500;
}
.sb-video-model-desc {
  display: none;
}

/* Video tabs (文生视频/图生视频/首尾帧/图片参考) */
.sb-video-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.sb-video-tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.sb-video-tab:hover {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.8);
}
.sb-video-tab.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
  color: white;
}
.sb-video-tab.disabled {
  color: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.04);
}
.sb-video-tab.disabled.active {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.35);
  color: rgba(252, 165, 165, 0.9);
}

/* Connection-requirement hint bar */
.sb-video-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(239, 68, 68, 0.08);
  border-bottom: 1px solid rgba(239, 68, 68, 0.18);
  color: rgba(252, 165, 165, 0.95);
  font-size: 12px;
}
.sb-video-hint svg {
  flex-shrink: 0;
}

/* Video group styling (pink-ish accent) */
.sb-video-group {
  border: 1.5px dashed rgba(236, 72, 153, 0.2) !important;
}
.sb-video-group .sb-image-group-title {
  color: rgba(251, 207, 232, 0.8) !important;
}

/* Error-state video card */
.sb-image-card.error {
  border-color: rgba(239, 68, 68, 0.35) !important;
}

/* ── Storyboard Image Group Node ── */
.sb-image-group {
  background: rgba(255, 255, 255, 0.02) !important;
  /* 2026-06-05: 边框改为明显的白色虚线（用户要求"明显一点"） */
  border: 1.5px dashed rgba(255, 255, 255, 0.5) !important;
  border-radius: 16px !important;
  min-width: 100%;
  min-height: 100%;
  padding: 0;
}

.sb-image-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.sb-image-group-title {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.3px;
}

.sb-image-group-count {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.25);
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
}

/* ── Storyboard Image Card Node ── */
.sb-image-card {
  width: var(--card-width, 160px);
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  overflow: hidden;
  cursor: grab;
  transition: width 0.25s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  user-select: none;
}

/* Hide card/group handles until hovered/selected (prevents accidental connections) */
.react-flow__node-storyboardImageCard .react-flow__handle,
.react-flow__node-storyboardImageGroup .react-flow__handle,
.react-flow__node-storyboardVideoCard .react-flow__handle,
.react-flow__node-storyboardVideoGroup .react-flow__handle,
.react-flow__node-imageGeneration .react-flow__handle,
.react-flow__node-videoGeneration .react-flow__handle {
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.react-flow__node-storyboardImageCard:hover .react-flow__handle,
.react-flow__node-storyboardImageCard.selected .react-flow__handle,
.react-flow__node-storyboardImageGroup:hover .react-flow__handle,
.react-flow__node-storyboardImageGroup.selected .react-flow__handle,
.react-flow__node-storyboardVideoCard:hover .react-flow__handle,
.react-flow__node-storyboardVideoCard.selected .react-flow__handle,
.react-flow__node-storyboardVideoGroup:hover .react-flow__handle,
.react-flow__node-storyboardVideoGroup.selected .react-flow__handle,
.react-flow__node-imageGeneration:hover .react-flow__handle,
.react-flow__node-imageGeneration.selected .react-flow__handle,
.react-flow__node-videoGeneration:hover .react-flow__handle,
.react-flow__node-videoGeneration.selected .react-flow__handle {
  opacity: 0.7;
  pointer-events: auto;
}
.sb-image-card:active {
  cursor: grabbing;
}

.sb-image-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}

.sb-image-card.generating {
  border-color: rgba(99, 102, 241, 0.3);
}

.sb-image-card.generating .sb-image-card-placeholder {
  border-color: rgba(99, 102, 241, 0.2);
  background: rgba(99, 102, 241, 0.05);
}

.sb-image-card.has-image {
  border-color: rgba(255, 255, 255, 0.08);
}

.sb-image-card-img-wrap {
  width: 100%;
  aspect-ratio: var(--card-ratio, 9 / 16);
  overflow: hidden;
  background: #0a0a0a;
  position: relative;
}

.sb-image-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sb-image-card-placeholder {
  width: 100%;
  aspect-ratio: var(--card-ratio, 9 / 16);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: all 0.3s ease;
}

.sb-image-card-placeholder:hover {
  background: rgba(99, 102, 241, 0.06);
}

.sb-image-card-footer {
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.sb-image-card-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-image-card-dims {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.2);
  white-space: nowrap;
}

/* ── Expanded Card (Edit Mode) ── */
.sb-image-card-expand-hint {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  padding: 3px;
  color: rgba(255, 255, 255, 0.5);
  opacity: 0;
  transition: opacity 0.2s;
}
.sb-image-card:hover .sb-image-card-expand-hint {
  opacity: 1;
}

/* Card wrapper - controls floating panels position */
.sb-image-card-wrapper {
  position: relative;
  width: var(--card-width, 160px);
  transition: width 0.25s ease;
}

.sb-image-card-wrapper.expanded {
  z-index: 1000 !important;
}

/* Selected state for the small card */
.sb-image-card.selected {
  border-color: rgba(99, 102, 241, 0.6) !important;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25), 0 4px 16px rgba(99, 102, 241, 0.2) !important;
}

/* TOP floating panel (above small card) */
.sb-card-top-panel {
  position: absolute;
  bottom: calc(100% + 24px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(26, 26, 28, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  z-index: 100;
  width: 760px;
}

/* BOTTOM floating panel (below small card) */
.sb-card-bottom-panel {
  position: absolute;
  top: calc(100% + 24px);
  left: 50%;
  transform: translateX(-50%);
  width: 760px;
  background: rgba(26, 26, 28, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  overflow: visible;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  z-index: 100;
  /* LibTV-parity pop-in: scale+opacity over 150ms ease-out from top-center
     so the panel feels anchored to the card above it. */
  transform-origin: top center;
  animation: sb-card-bottom-pop 0.15s cubic-bezier(0, 0, 0.2, 1);
  will-change: transform, opacity;
}
@keyframes sb-card-bottom-pop {
  0%   { transform: translateX(-50%) scale(0.85); opacity: 0; }
  100% { transform: translateX(-50%) scale(1);    opacity: 1; }
}

/* Child containers keep inner corners rounded */
.sb-card-bottom-panel .sb-card-exp-tools {
  border-radius: 18px 18px 0 0;
}
.sb-card-bottom-panel .sb-card-exp-bottom {
  border-radius: 0 0 18px 18px;
}

/* libtv parity: 展开态 — 点 ⤢ 按钮把 panel 拉成大编辑器, 给长 prompt
   留够空间. width 撑到 viewport 80% (上限 1200px), prompt 编辑区 min-height
   480px. transition + transform-origin 配合默认 pop-in 动画,展开/收起手感
   一致. */
.sb-card-bottom-panel.expanded {
  width: min(1200px, 80vw);
  transition: width 0.18s ease-out;
}
.sb-card-bottom-panel.expanded .sb-card-exp-prompt {
  min-height: 480px;
  padding: 18px 22px 12px;
  display: flex;
  flex-direction: column;
}
.sb-card-bottom-panel.expanded .sb-card-exp-prompt .mention-editor {
  flex: 1;
  min-height: 440px;
  font-size: 14px;
  line-height: 1.6;
}
.sb-card-bottom-panel.expanded .sb-card-prompt-input {
  min-height: 440px;
  font-size: 14px;
  line-height: 1.6;
}

.sb-card-bottom-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: all 0.15s;
}
.sb-card-bottom-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.8);
}

.sb-card-exp-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.sb-card-exp-title {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
}

.sb-card-exp-close {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-radius: 6px;
  padding: 4px;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: all 0.15s;
}
.sb-card-exp-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}

/* Top image toolbar (LibTV-style) */
.sb-card-top-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  gap: 4px;
  flex-wrap: nowrap;
}

.sb-card-top-toolbar-left {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.sb-card-top-toolbar-right {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.sb-card-top-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.sb-card-top-btn svg {
  width: 15px !important;
  height: 15px !important;
}
.sb-card-top-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.75);
}
.sb-card-top-btn.active {
  background: rgba(34, 197, 94, 0.14);
  color: #4ade80;
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.35);
}
.sb-card-top-btn.active:hover {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}
.sb-card-toolbar-icon.active {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.4);
  color: #4ade80;
}
.sb-card-toolbar-icon.active:hover {
  background: rgba(34, 197, 94, 0.22);
  border-color: rgba(34, 197, 94, 0.5);
  color: #4ade80;
}

.sb-card-badge-new {
  font-size: 7px;
  font-weight: 700;
  color: #22c55e;
  background: rgba(34, 197, 94, 0.12);
  padding: 1px 3px;
  border-radius: 3px;
  line-height: 1.2;
  letter-spacing: 0.5px;
}

.sb-card-top-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
}
.sb-card-top-icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.7);
}

.sb-card-exp-image {
  width: 100%;
  height: 320px;
  background: #0a0a0a;
  position: relative;
  overflow: hidden;
}

.sb-card-exp-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sb-card-exp-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.015);
}

/* Tools row */
.sb-card-exp-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.sb-card-tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 64px;
}
.sb-card-tool-btn svg {
  width: 20px !important;
  height: 20px !important;
}
.sb-card-tool-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
}

.sb-card-ref-images {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.sb-card-tools-expand {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
  flex-shrink: 0;
  /* 避让右上角的 close(✕) 按钮（absolute right:8 + 24px 宽 → 占右侧 8–32px）。
     不加的话 展开(⛶) 按钮会顶到最右、跟 ✕ 叠在一起。2026-06-07 修 */
  margin-right: 24px;
}
.sb-card-tools-expand:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.6);
}

.sb-card-ref-thumb {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  overflow: visible;
}
.sb-card-ref-thumb > img:first-of-type {
  width: 100%;
  height: 100%;
  /* contain — the badge thumb is the user's "which reference is this @N" cue,
     so it must show the full subject. cover would crop portrait sources to
     just the lower body inside the 40x40 square. */
  object-fit: contain;
  background: #0a0a0a;
  border-radius: 8px;
  display: block;
}
.sb-card-ref-thumb-hover {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%) scale(0.9);
  transform-origin: bottom center;
  width: 220px;
  max-width: 60vw;
  max-height: 60vh;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04);
  background: #0a0a1a;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  z-index: 10000;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}
.sb-card-ref-thumb:hover .sb-card-ref-thumb-hover {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s;
}
.sb-card-ref-badge {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: 8px;
  color: white;
  background: rgba(99, 102, 241, 0.8);
  border-radius: 3px;
  padding: 0 3px;
  line-height: 1.3;
}
/* libtv parity: 删除按钮居中覆盖在缩略图上, 鼠标 hover 出现.
   之前是 14px 红色小徽章贴在右上角, 视觉太弱用户找不到. 改成 22px
   居中圆形 + 半透明深色背景 + 缩略图同步压暗, 跟 liblib 视觉对齐. */
.sb-card-ref-remove {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.85);
  width: 22px;
  height: 22px;
  background: rgba(15, 15, 18, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  line-height: 1;
  font-weight: 400;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease-out, transform 0.12s ease-out, background 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.sb-card-ref-thumb:hover .sb-card-ref-remove {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}
.sb-card-ref-remove:hover {
  background: rgba(239, 68, 68, 0.85);
  border-color: rgba(239, 68, 68, 0.9);
}
/* hover 时缩略图本身轻微压暗, 让中间的 X 视觉更突出 */
.sb-card-ref-thumb:hover > img:first-of-type {
  filter: brightness(0.6);
  transition: filter 0.12s ease-out;
}

.sb-card-ref-add {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  background: transparent;
  color: rgba(255, 255, 255, 0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.sb-card-ref-add:hover {
  border-color: rgba(99, 102, 241, 0.3);
  color: rgba(99, 102, 241, 0.6);
  background: rgba(99, 102, 241, 0.05);
}

/* Prompt area */
.sb-card-exp-prompt {
  padding: 14px 18px 8px;
}

.sb-card-prompt-input {
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 4px 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  line-height: 1.75;
  resize: none;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.sb-card-prompt-input:focus {
  border-color: rgba(99, 102, 241, 0.3);
}

/* contenteditable variant: placeholder + inline @-mention chips */
.mention-editor:empty::before {
  content: attr(data-placeholder);
  color: rgba(255, 255, 255, 0.32);
  pointer-events: none;
}
.mention-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 7px 1px 2px;
  margin: 0 2px;
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(129, 140, 248, 0.35);
  border-radius: 999px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.92);
  vertical-align: middle;
  line-height: 1.3;
  user-select: none;
  /* clickable: clicking removes the chip (matches the JS handler in
     MentionPromptInput / StoryboardVideoCard editor). */
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.mention-chip:hover {
  background: rgba(244, 63, 94, 0.28);
  border-color: rgba(244, 63, 94, 0.55);
}
.mention-chip-thumb {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  /* contain (not cover) so portrait references show the full subject in this
     small inline chip — cover would crop a 9:16 source to just the waist. */
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: rgba(255, 255, 255, 0.08);
  flex: 0 0 18px;
}
.mention-chip-label {
  font-size: 12px;
  letter-spacing: 0.2px;
}

/* Bottom controls */
.sb-card-exp-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 14px;
  gap: 8px;
}

.sb-card-exp-selectors {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Aspect ratio picker (custom popup) */
.sb-card-ratio-wrap {
  position: relative;
  display: inline-flex;
}

.sb-card-ratio-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.sb-card-ratio-trigger:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}

.sb-card-ratio-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 320px;
  background: rgba(30, 30, 32, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  padding: 14px;
  z-index: 200;
}

.sb-card-ratio-section-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 8px;
  font-weight: 500;
}

.sb-card-res-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.sb-card-res-btn {
  padding: 10px 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.sb-card-res-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}
.sb-card-res-btn.active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: white;
}

.sb-card-ratio-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.sb-card-ratio-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 10px 4px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 62px;
}
.sb-card-ratio-opt:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.85);
}
.sb-card-ratio-opt.active {
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.sb-card-ratio-icon {
  border: 1.5px solid currentColor;
  border-radius: 2px;
  opacity: 0.85;
  flex-shrink: 0;
}

.sb-card-select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 7px 12px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.sb-card-select:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.sb-card-generate-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}
.sb-card-generate-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}
.sb-card-generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Image expand button overlay */
.sb-card-img-expand {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.2s;
}
.sb-card-exp-image:hover .sb-card-img-expand {
  opacity: 1;
}
.sb-card-img-expand:hover {
  background: rgba(0, 0, 0, 0.75);
  color: white;
}

/* Toolbar icon-only buttons */
.sb-card-toolbar-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
}
.sb-card-toolbar-icon:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.25);
  color: rgba(99, 102, 241, 0.8);
}

/* Mini select for image count */
.sb-card-select-mini {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 3px 6px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 10px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  min-width: 44px;
  text-align: center;
}
.sb-card-select-mini:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

/* Bottom right group (image count + generate btn) */
.sb-card-bottom-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.sb-card-error {
  padding: 4px 10px 6px;
  font-size: 10px;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.06);
}

/* Hide default node styling for card/group nodes + imageGeneration + videoGeneration */
.react-flow__node-storyboardImageCard .modern-node,
.react-flow__node-storyboardImageGroup .modern-node,
.react-flow__node-storyboardVideoCard .modern-node,
.react-flow__node-storyboardVideoGroup .modern-node,
.react-flow__node-imageGeneration .modern-node,
.react-flow__node-videoGeneration .modern-node {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  min-width: auto !important;
  max-width: none !important;
  padding: 0 !important;
  overflow: visible !important;
}

.react-flow__node-storyboardImageCard,
.react-flow__node-storyboardVideoCard,
.react-flow__node-imageGeneration,
.react-flow__node-videoGeneration {
  z-index: 10 !important;
  overflow: visible !important;
  background: transparent !important;
  border: none !important;
}

.react-flow__node-storyboardImageGroup,
.react-flow__node-storyboardVideoGroup {
  z-index: 0 !important;
  overflow: visible !important;
}

.react-flow__node-storyboardImageCard:has(.sb-image-card-wrapper.expanded),
.react-flow__node-storyboardVideoCard:has(.sb-image-card-wrapper.expanded),
.react-flow__node-imageGeneration:has(.sb-image-card-wrapper.expanded),
.react-flow__node-videoGeneration:has(.sb-image-card-wrapper.expanded) {
  z-index: 9999 !important;
}

.react-flow__node-storyboardImageGroup {
  z-index: 0 !important;
  overflow: visible !important;
}

.react-flow__node-storyboardImageGroup > div {
  overflow: visible !important;
}

/* ── Edge / Connection Line Styles ── */
.react-flow__edge-path {
  stroke-dasharray: none !important;
  animation: none !important;
}

.react-flow__connection-line {
  stroke-dasharray: none !important;
}

.react-flow__edge.animated path {
  stroke-dasharray: none !important;
  animation: none !important;
}

.modern-node {
  background: rgba(255, 255, 255, 0.08) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 20px !important;
  box-shadow: none !important;
  transition: all 0.2s ease !important;
  overflow: visible;
  min-width: 500px !important;
  max-width: 600px !important;
}

.modern-node:hover {
  border-color: rgba(255, 255, 255, 0.15) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2) !important;
}

.modern-node.selected {
  border-color: rgba(255, 255, 255, 0.25) !important;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15) !important;
}

.modern-node .nodrag,
.modern-node .nowheel {
  overscroll-behavior: contain;
}

.modern-node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 20px 20px 0 0;
}

.modern-node-upload-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modern-node-upload-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
}

.modern-node-content-area {
  position: relative;
  min-height: 160px;
  max-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.modern-node-content-area.has-content {
  background: transparent;
}

.modern-node-content-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.3);
}

.modern-node-content-placeholder-icon {
  width: 48px;
  height: 48px;
  opacity: 0.5;
}

.modern-node-content-placeholder-text {
  font-size: 14px;
  font-weight: 500;
}

/* Reference image thumbnails inside ImageInputNode (and similar):
   use `contain` so the user sees the WHOLE picture inside the 1:1 grid cell
   instead of having portraits cropped to the centre crop (head + feet
   missing). The original file uploaded to TOS / sent to Volcengine is still
   the unmodified source — this rule only affects how the local thumbnail
   is rendered. The dark background fills the letterbox so the empty space
   reads as designed rather than broken. */
.modern-node-content-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.35);
}

/* Videos still use `cover` because tiny letterboxed video previews tend to
   look broken; a slight crop is preferable to a mostly-black thumbnail. */
.modern-node-content-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modern-node-content-separator {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0;
}

.modern-node-input-section {
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
  transition: all 0.2s ease;
}

.modern-node-input-section.collapsed {
  max-height: 48px;
}

.modern-node-input-section.expanded {
  max-height: 400px;
}

.modern-node-config-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.modern-node-config-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modern-node-config-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  font-weight: 500;
}

.modern-node-config-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 6px;
}

.modern-node-config-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
}

.modern-node-config-toggle svg {
  transition: transform 0.3s ease;
}

.modern-node-config-section.expanded .modern-node-config-toggle svg {
  transform: rotate(180deg);
}

.modern-node-config-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modern-node-config-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modern-node-config-field label {
  font-size: 10px;
  color: #ffffff;
  font-weight: 500;
}

.modern-node-config-select {
  width: 100%;
  padding: 7px 10px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 11px;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
  appearance: none;
}

.modern-node-config-select:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.5);
}

.modern-node-config-select:focus {
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.5);
}

.modern-node-config-lora {
  grid-column: 1 / -1;
  margin-top: 4px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}

.modern-node-config-lora-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.modern-node-config-lora-header span {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
}

.modern-node-config-lora-toggle {
  position: relative;
  width: 36px;
  height: 18px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.modern-node-config-lora-toggle.active {
  background: rgba(255, 255, 255, 0.3);
}

.modern-node-config-lora-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.modern-node-config-lora-toggle.active .modern-node-config-lora-knob {
  transform: translateX(18px);
}

.modern-node-config-lora-desc {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1.4;
}

.modern-node-input-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: background 0.2s ease;
}

.modern-node-input-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.modern-node-input-header-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  font-weight: 500;
}

.modern-node-input-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 6px;
}

.modern-node-input-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
}

.modern-node-input-toggle svg {
  transition: transform 0.3s ease;
}

.modern-node-input-section.expanded .modern-node-input-toggle svg {
  transform: rotate(180deg);
}

.modern-node-input-content {
  padding: 12px;
  overflow-y: auto;
  resize: vertical;
  min-height: 60px;
  max-height: 180px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modern-node-input-content::-webkit-resizer {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.modern-node-input-content::-webkit-scrollbar {
  width: 6px;
}

.modern-node-input-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.modern-node-input-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.modern-node-input-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.modern-node-prompt-area {
  position: relative;
  margin-bottom: 12px;
}

.modern-node-prompt-input {
  width: 100%;
  min-height: 50px;
  padding: 10px 14px;
  padding-right: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: all 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe', Roboto, sans-serif;
}

.modern-node-prompt-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.modern-node-prompt-input:focus {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.modern-node-footer {
  background: rgba(0, 0, 0, 0.1);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 10px 12px;
}

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

.modern-node-control-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 9999px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.modern-node-control-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
}

.modern-node-control-btn.primary {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
}

.modern-node-control-btn.primary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}

.modern-node-control-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 4px;
}

.modern-node-generate-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: none;
}

.modern-node-generate-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: none;
  transform: translateY(-1px);
}

.modern-node-generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.react-flow__handle.modern-handle {
  width: 12px !important;
  height: 12px !important;
  background: rgba(20, 20, 20, 0.95) !important;
  border: 2px solid rgba(255, 255, 255, 0.3) !important;
  border-radius: 50% !important;
  transition: all 0.2s ease;
  z-index: 100 !important;
  pointer-events: auto !important;
  cursor: crosshair !important;
}

.react-flow__handle.modern-handle:hover {
  transform: scale(1.2) !important;
  border-color: rgba(255, 255, 255, 0.6) !important;
  background: rgba(255, 255, 255, 0.1) !important;
  box-shadow: none !important;
  z-index: 101 !important;
}

.react-flow__handle.modern-handle::before {
  content: '' !important;
  position: absolute !important;
  top: -8px !important;
  left: -8px !important;
  right: -8px !important;
  bottom: -8px !important;
  border-radius: 50% !important;
}

.react-flow__handle.modern-handle::after {
  display: none !important;
}

/* ===== Storyboard Modal Title Bar ===== */
.storyboard-modal-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: #141414;
}

.storyboard-view-tabs {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.storyboard-view-tab {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.4);
  border-radius: 6px;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  background: transparent;
}

.storyboard-view-tab:hover {
  color: rgba(255, 255, 255, 0.6);
}

.storyboard-view-tab.active {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
}

.storyboard-save-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.storyboard-save-btn:hover {
  background: rgba(99, 102, 241, 0.25);
}

.storyboard-ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: all 0.15s ease;
}

.storyboard-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.6);
}

/* Sub-tabs row */
.storyboard-subtabs {
  display: flex;
  align-items: center;
  padding: 8px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: #121212;
  gap: 4px;
}

.storyboard-subtab {
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.storyboard-subtab:hover {
  color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.04);
}

.storyboard-subtab.active {
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.06);
}

/* Table wrapper */
.storyboard-table-wrap {
  background: #0f0f0f;
}

/* ===== Script Storyboard Table ===== */
.script-storyboard-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  table-layout: fixed;
}

.script-storyboard-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.script-storyboard-table th {
  background: #161616;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 500;
  font-size: 12px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.script-storyboard-table th:first-child {
  border-left: none;
  position: sticky;
  left: 0;
  z-index: 11;
  background: #161616;
  text-align: center;
}

.script-storyboard-table th:last-child {
  border-right: none;
}

.script-storyboard-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  border-right: 1px solid rgba(255, 255, 255, 0.03);
  vertical-align: top;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.65;
  background: #0f0f0f;
}

.script-storyboard-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 5;
  background: #111111;
  text-align: center;
  vertical-align: middle;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.script-storyboard-table td:last-child {
  border-right: none;
}

.script-storyboard-table tbody tr {
  transition: background 0.12s ease;
}

.script-storyboard-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.script-storyboard-table tbody tr:hover td:first-child {
  background: rgba(255, 255, 255, 0.04);
}

.script-storyboard-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.01);
}

.script-storyboard-table tbody tr:nth-child(even) td:first-child {
  background: rgba(255, 255, 255, 0.025);
}

/* Editable text cell */
.storyboard-cell-text {
  width: 100%;
  min-height: 40px;
  padding: 4px 6px;
  border-radius: 4px;
  outline: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  transition: background 0.15s ease;
  cursor: text;
}

.storyboard-cell-text:hover {
  background: rgba(255, 255, 255, 0.03);
}

.storyboard-cell-text:focus {
  background: rgba(99, 102, 241, 0.06);
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.3);
}

.storyboard-cell-text:empty::before {
  content: '-';
  color: rgba(255, 255, 255, 0.15);
}

/* Long text cell (shotPrompt / videoPrompt) - scrollable textarea */
.storyboard-cell-longtext {
  width: 100%;
  min-height: 88px;
  max-height: 140px;
  padding: 6px 8px;
  border-radius: 4px;
  outline: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12.5px;
  line-height: 1.55;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.06);
  resize: vertical;
  font-family: inherit;
  overflow-y: auto;
  transition: all 0.15s ease;
  word-break: break-word;
}

.storyboard-cell-longtext:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.12);
}

.storyboard-cell-longtext:focus {
  background: rgba(99, 102, 241, 0.06);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.storyboard-cell-longtext::placeholder {
  color: rgba(255, 255, 255, 0.2);
  font-size: 11.5px;
  line-height: 1.5;
}

/* Custom scrollbar for longtext cells */
.storyboard-cell-longtext::-webkit-scrollbar {
  width: 6px;
}
.storyboard-cell-longtext::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
.storyboard-cell-longtext::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
.storyboard-cell-longtext::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Image cell */
.storyboard-img-cell {
  text-align: center;
  vertical-align: middle !important;
}

.storyboard-img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.02);
  color: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 0 auto;
}

.storyboard-img-placeholder:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.3);
}

.storyboard-img-placeholder.has-image {
  border: none;
  background: transparent;
  padding: 0;
  position: relative;
  overflow: hidden;
}

.storyboard-img-placeholder.uploading {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.08);
  color: rgba(99, 102, 241, 0.6);
}

.storyboard-cell-img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.storyboard-img-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  color: rgba(255, 255, 255, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.storyboard-img-placeholder.has-image:hover .storyboard-img-remove {
  display: flex;
}

.storyboard-img-remove:hover {
  background: rgba(239, 68, 68, 0.8);
  color: white;
}

/* Row number badge */
.storyboard-row-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.5);
  font-weight: 600;
  font-size: 13px;
}

/* ===== Script Storyboard Node (LibTV style) ===== */
.script-storyboard-node {
  width: 480px;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.ssb-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
}

.ssb-header-title {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.45);
}

.ssb-generate-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: rgba(165, 180, 252, 0.9);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.ssb-generate-btn:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(99, 102, 241, 0.5);
  color: #c7d2fe;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.15);
}

.ssb-view-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ssb-view-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
}

/* Content area */
.ssb-content-area {
  flex: 1;
  min-height: 280px;
  padding: 0 16px;
  overflow-y: auto;
}

/* Placeholder (empty state) */
.ssb-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 280px;
}

.ssb-placeholder-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  margin-bottom: 28px;
  width: 200px;
}

.ssb-placeholder-line {
  height: 5px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* Quick actions */
.ssb-quick-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ssb-quick-label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.3);
  padding: 0 4px;
  margin-bottom: 8px;
}

.ssb-quick-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px;
  border-radius: 10px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  width: 100%;
}

.ssb-quick-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.9);
}

/* Result list (after generation) */
.ssb-result-list {
  padding: 8px 0;
}

.ssb-result-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.ssb-result-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.ssb-result-num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
  font-weight: 700;
  margin-top: 1px;
}

.ssb-result-text {
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.6);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Error */
.ssb-error {
  padding: 8px 16px;
  margin: 0 16px 8px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.15);
}

.ssb-error span {
  font-size: 11px;
  color: rgba(248, 113, 113, 0.9);
  line-height: 1.5;
}

/* Bottom input bar */
.ssb-input-bar {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 0 0 16px 16px;
}

.ssb-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  padding: 0;
  margin-bottom: 8px;
}

.ssb-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.ssb-input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ssb-model-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
  font-weight: 500;
}

.ssb-send-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all 0.2s ease;
}

.ssb-send-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
}

.ssb-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── ImageInputNode "上传参考图" 主图 + 缩略图条样式 ──────────────────
   只用于 ImageInputNode（A2 主图模式 + B2 按图片比例自适应）；与共享的
   .modern-node-content-area / .modern-node-content-image 区分，避免影响
   videoInput / imageGeneration / storyboardImageCard 等共用 content-area
   的节点。主图容器宽高用 inline style 写（动态计算），这里只控制视觉。 */
.image-input-main-area {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
  /* 不要给 height/min-height —— 内层 wrap 用 inline style 决定高度 */
}

.image-input-main-wrap {
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.45);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  /* 切换图时宽度过渡，aspect-ratio 自动决定高度 */
  transition: width 0.18s ease;
  display: block;
  /* 高度由 aspect-ratio (inline style) + max-height: 500px 决定，
     不再固定 height —— 宽度永远等于 width，比例永远等于自然比例，
     杜绝因 mainSize 计算误差导致的黑边/letterbox。 */
}

.image-input-main-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  /* cover：图片填满 wrap，跟图1视觉一致（节点 == 图片，无黑边）。
     wrap 已由 aspect-ratio 锁定为图片自然比例，cover 不会真的裁切，
     即使有亚像素差也比 contain 留下的可见黑边好。 */
}

.image-input-thumbs {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 0 0 20px 20px;
  /* 紧贴节点底部圆角，否则缩略图条溢出 modern-node 的 border-radius */
}

.image-input-thumbs::-webkit-scrollbar {
  height: 4px;
}
.image-input-thumbs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.image-input-thumb {
  position: relative;
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s ease;
  background: rgba(0, 0, 0, 0.4);
}

.image-input-thumb:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.image-input-thumb.active {
  border-color: rgba(99, 102, 241, 0.7);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.4);
}

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

.image-input-thumb-x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  padding: 0;
  background: rgba(0, 0, 0, 0.65);
  border: none;
  border-radius: 9999px;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.image-input-thumb:hover .image-input-thumb-x {
  opacity: 1;
}

.image-input-thumb-x:hover {
  background: rgba(239, 68, 68, 0.9);
}

.image-input-thumb-add {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 2px dashed rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.02);
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.image-input-thumb-add:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.75);
}

/* "Bare" 模式：有图时去掉外层卡片框 / header 背景 / padding，让图片像
   悬浮在工作流点阵背景上（图1 风格）。覆盖 .modern-node 的 min-width /
   bg / border 等共享样式。仅作用于带 .image-input-bare 的实例，不影响
   videoInput / imageGeneration 等共用 .modern-node 的节点。 */
.modern-node.image-input-bare {
  background: transparent !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  border-color: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  /* min-width / max-width 由 inline style 接管（width = mainSize.w）*/
  min-width: 0 !important;
  max-width: none !important;
}

.modern-node.image-input-bare:hover {
  border-color: transparent !important;
  box-shadow: none !important;
  transform: none !important;
}

.modern-node.image-input-bare.selected {
  /* 选中态保留一点蓝色高亮在主图上：靠 main-wrap 的 outline 实现 */
  border-color: transparent !important;
  box-shadow: none !important;
}

.modern-node.image-input-bare .modern-node-header {
  background: transparent !important;
  border-bottom: none !important;
  border-radius: 0 !important;
  padding: 4px 4px 8px 4px !important;
}

.modern-node.image-input-bare .image-input-main-area {
  background: transparent !important;
  padding: 0 !important;
}

.modern-node.image-input-bare .image-input-main-wrap {
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.5);
  /* 主图四周一道极细的浅边，跟图1视觉一致 */
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 4px 24px rgba(0, 0, 0, 0.35);
}

.modern-node.image-input-bare.selected .image-input-main-wrap {
  /* 选中时换成淡紫色 outline，方便识别 */
  box-shadow:
    0 0 0 1.5px rgba(99, 102, 241, 0.55),
    0 4px 24px rgba(0, 0, 0, 0.35);
}

.modern-node.image-input-bare .image-input-thumbs {
  background: transparent !important;
  border-top: none !important;
  border-radius: 0 !important;
  padding: 8px 0 0 0 !important;
}

/* "上传"按钮：bare 模式下做成圆形小图标按钮，跟图1右上角一致 */
.modern-node.image-input-bare .modern-node-upload-btn {
  width: 32px;
  height: 32px;
  padding: 0 !important;
  border-radius: 50% !important;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

.modern-node.image-input-bare .modern-node-upload-btn:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
}

/* "Bare" 模式 — VideoInputNode 版：跟 image-input-bare 同款写法。
   有视频时去掉 modern-node 的卡片框 / 背景 / 共享 min-width 死锁，节点
   外尺寸完全按视频自然比例（inline style.width 接管）。
   修复 9:16 等竖屏视频在 500px 节点里被 max-height: 520 截断后导致的
   左右两侧黑色 letterbox。仅作用于 .video-input-bare 类，不影响其它共用
   .modern-node 的节点。 */
.modern-node.video-input-bare {
  background: transparent !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  border-color: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  /* min-width / max-width 由 inline style 接管（width = outerSize.w）*/
  min-width: 0 !important;
  max-width: none !important;
}

.modern-node.video-input-bare:hover {
  border-color: transparent !important;
  box-shadow: none !important;
  transform: none !important;
}

.modern-node.video-input-bare.selected {
  border-color: transparent !important;
  box-shadow: none !important;
}

.modern-node.video-input-bare .modern-node-header {
  background: transparent !important;
  border-bottom: none !important;
  border-radius: 0 !important;
  padding: 4px 4px 8px 4px !important;
}

/* content-area 在 bare 模式下：不再固定 min/max-height，由 inline
   aspect-ratio + 节点外宽度共同决定真实高度，**严格匹配视频比例**。
   背景透明，让视频自己的圆角 + box-shadow 当视觉边界。 */
.modern-node.video-input-bare .modern-node-content-area {
  background: transparent !important;
  padding: 0 !important;
  min-height: unset !important;
  max-height: unset !important;
  overflow: hidden;
}

/* 视频元素四周一道极细浅边 + 投影，作为节点的视觉边界 */
.modern-node.video-input-bare .modern-node-content-area video {
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 4px 24px rgba(0, 0, 0, 0.35);
}

.modern-node.video-input-bare.selected .modern-node-content-area video {
  /* 选中时换成淡紫色 outline */
  box-shadow:
    0 0 0 1.5px rgba(99, 102, 241, 0.55),
    0 4px 24px rgba(0, 0, 0, 0.35);
}

/* 上传按钮：bare 模式下圆形小图标 */
.modern-node.video-input-bare .modern-node-upload-btn {
  width: 32px;
  height: 32px;
  padding: 0 !important;
  border-radius: 50% !important;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

.modern-node.video-input-bare .modern-node-upload-btn:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
}

/* ── Credit cost badge ─────────────────────────────────────────────
   Pinned next to every generation button so the user always sees how
   many credits a click will deduct. Numbers are sourced from
   src/utils/credits.js (which mirrors backend/server/config/pricing.js).
   ───────────────────────────────────────────────────────────────── */
.credit-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 8px 3px 6px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  color: rgba(252, 211, 77, 0.95);
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: 999px;
  white-space: nowrap;
  user-select: none;
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
  pointer-events: auto;
  transition: background 0.15s, border-color 0.15s;
}
.credit-badge:hover {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.45);
}
.credit-badge-icon {
  flex-shrink: 0;
  color: rgba(252, 211, 77, 0.95);
}
.credit-badge-num {
  font-weight: 700;
  letter-spacing: 0.2px;
}
.credit-badge-list {
  margin-left: 2px;
  text-decoration: line-through;
  opacity: 0.55;
  font-weight: 500;
}
.credit-badge-compact {
  padding: 2px 6px 2px 5px;
  font-size: 10px;
  gap: 1px;
}
.credit-badge-compact .credit-badge-icon {
  width: 9px;
  height: 9px;
}

/* ── LibTV-parity 编辑节点（多角度 / 打光 / 宫格切分）通用样式 ───── */
.libtv-edit-node {
  background: #1c1c1e;
  border: 1px solid #2c2c2e;
  border-radius: 12px;
}
.libtv-preset-btn {
  padding: 4px 6px;
  font-size: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
  text-align: center;
  min-height: 24px;
}
.libtv-preset-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
}
.libtv-preset-btn.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.5);
  color: rgba(199, 210, 254, 1);
}
.libtv-preset-btn.active-amber {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.5);
  color: rgba(252, 211, 77, 1);
}

.libtv-slider-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 10px;
}
.libtv-slider-label {
  color: rgba(255, 255, 255, 0.45);
  flex-shrink: 0;
  width: 56px;
}
.libtv-slider {
  flex: 1;
  height: 4px;
  accent-color: rgba(165, 180, 252, 0.9);
  cursor: pointer;
}
.libtv-slider-amber { accent-color: rgba(252, 211, 77, 0.9); }
.libtv-slider-val {
  color: rgba(255, 255, 255, 0.7);
  font-variant-numeric: tabular-nums;
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}
.libtv-mini-select {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 10px;
  padding: 2px 4px;
  outline: none;
}
.libtv-color-swatch {
  width: 28px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.12s;
  padding: 0;
}
.libtv-color-swatch:hover { transform: scale(1.05); }
.libtv-color-swatch.active {
  border-color: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
}

/* 宫格切分 — 网格单元格交互 */
.libtv-grid-cell {
  border: 1px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.libtv-grid-cell:hover {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.55);
}
.libtv-grid-cell.selected {
  background: rgba(99, 102, 241, 0.35);
  border: 2px solid rgba(165, 180, 252, 0.95);
  box-shadow: inset 0 0 12px rgba(99, 102, 241, 0.45);
}

/* ── LibTV toolbar 编辑器浮动层 (多角度 / 打光 / 宫格切分) ───────── */
.libtv-editor-overlay {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(28, 28, 30, 0.92);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 1px 0 rgba(255, 255, 255, 0.08) inset;
  z-index: 1100;
  /* LibTV-parity 缩放弹出：延长到 0.22s + 轻微 overshoot，更有质感 */
  animation: libtv-editor-pop 0.22s cubic-bezier(0.34, 1.32, 0.64, 1);
  transform-origin: top center;
  display: flex;
  flex-direction: column;
}
@keyframes libtv-editor-pop {
  0%   { transform: translateX(-50%) scale(0.78) translateY(-8px); opacity: 0; }
  60%  { transform: translateX(-50%) scale(1.015) translateY(0);   opacity: 1; }
  100% { transform: translateX(-50%) scale(1)     translateY(0);   opacity: 1; }
}
.libtv-editor-header {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.libtv-editor-title {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  flex: 1;
}
.libtv-editor-close {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}
.libtv-editor-close:hover {
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.9);
}
.libtv-editor-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.libtv-editor-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 14px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.libtv-editor-footer-dual {
  justify-content: space-between;
}
.libtv-editor-submit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.libtv-editor-submit:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}
.libtv-editor-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── 九宫格菜单 (popover 7 列表) ────────────────────────────────── */
.libtv-popover-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(28, 28, 30, 0.92);
  backdrop-filter: blur(20px) saturate(1.15);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 1px 0 rgba(255, 255, 255, 0.08) inset;
  z-index: 1100;
  animation: libtv-editor-pop 0.22s cubic-bezier(0.34, 1.32, 0.64, 1);
  transform-origin: top center;
  padding: 6px;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.libtv-popover-item {
  display: flex;
  align-items: center;
  padding: 7px 12px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.16s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  white-space: nowrap;
  position: relative;
}
.libtv-popover-item:hover {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.22), rgba(139, 92, 246, 0.16));
  color: white;
  transform: translateX(2px);
}
.libtv-popover-item:active {
  transform: translateX(2px) scale(0.98);
}

/* ── 确认气泡 (九宫格选完模板 + 高清按钮 共用) ─────────────────── */
.libtv-confirm-popup {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(28, 28, 30, 0.92);
  backdrop-filter: blur(20px) saturate(1.15);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 1px 0 rgba(255, 255, 255, 0.08) inset;
  z-index: 1100;
  animation: libtv-editor-pop 0.22s cubic-bezier(0.34, 1.32, 0.64, 1);
  transform-origin: top center;
  padding: 6px 6px 6px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.libtv-confirm-popup .libtv-editor-close {
  width: 22px;
  height: 22px;
}
.libtv-confirm-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
}
.libtv-confirm-popup .libtv-editor-submit {
  padding: 5px 10px;
  font-size: 11px;
}

/* toolbar 按钮 active 态 */
.sb-card-top-btn.active {
  background: rgba(99, 102, 241, 0.22) !important;
  color: rgba(199, 210, 254, 1) !important;
  border-color: rgba(99, 102, 241, 0.5) !important;
}
.sb-card-top-btn:disabled {
  opacity: 0.40;
  cursor: not-allowed;
}

/* ── 预设按钮带 SVG 图标（多角度 7 预设）────────────────────────── */
.libtv-preset-with-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 4px;
  min-height: 50px;
}
.libtv-preset-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.55);
  transition: color 0.12s;
}
.libtv-preset-icon svg { width: 100%; height: 100%; }
.libtv-preset-with-icon.active .libtv-preset-icon {
  color: rgba(199, 210, 254, 1);
}
.libtv-preset-label {
  font-size: 10px;
  white-space: nowrap;
}

/* ── 九宫格菜单 item 带 SVG 缩略图标 ──────────────────────────── */
.libtv-popover-item-with-icon {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}
.libtv-popover-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: rgba(199, 210, 254, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.10);
  border: 1px solid rgba(99, 102, 241, 0.22);
  border-radius: 6px;
  padding: 2px;
  transition: all 0.18s ease;
}
.libtv-popover-icon svg { width: 100%; height: 100%; }
.libtv-popover-item-with-icon:hover .libtv-popover-icon {
  color: rgba(199, 210, 254, 1);
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(165, 180, 252, 0.55);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.35);
  transform: scale(1.05);
}
.libtv-popover-text {
  font-size: 12px;
  flex: 1;
  letter-spacing: 0.2px;
  font-weight: 500;
}

/* ── 打光实时预览（CSS filter 近似 · 档 2）─────────────────────── */
.libtv-lighting-preview-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #0a0a0a;
  isolation: isolate;
}
/* 底层：原图（淡显，作为参照） */
.libtv-lighting-preview-img {
  position: absolute;
  inset: 0;
  width: 50%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}
/* 上层：CSS-filtered 副本 — 显示在右半边，左半边显示原图，
   形成 before / after 对比 */
.libtv-lighting-preview-img-filtered {
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
  /* filter 由 inline style 注入 */
  border-left: 1px dashed rgba(255, 255, 255, 0.35);
}
/* 阴影叠层：把 box-shadow 单独画在右半边，模拟主光源方向 */
.libtv-lighting-preview-overlay {
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
  border-radius: 0;
  /* box-shadow 由 inline style 注入 */
}
.libtv-lighting-preview-hint {
  position: absolute;
  bottom: 4px;
  left: 6px;
  z-index: 4;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.55);
  padding: 1px 6px;
  border-radius: 4px;
  pointer-events: none;
}
/* before/after 标签 */
.libtv-lighting-preview-wrap::before {
  content: '原图';
  position: absolute;
  top: 4px;
  left: 6px;
  z-index: 4;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.55);
  padding: 1px 6px;
  border-radius: 4px;
}
.libtv-lighting-preview-wrap::after {
  content: '调光后';
  position: absolute;
  top: 4px;
  right: 6px;
  z-index: 4;
  font-size: 9px;
  color: rgba(252, 211, 77, 0.95);
  background: rgba(0, 0, 0, 0.55);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ── 多角度编辑器实时预览（方案 C · CSS 3D 伪预览 + 方向指示器）─── */
.libtv-ma-preview-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(99, 102, 241, 0.06), rgba(139, 92, 246, 0.04)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0px, rgba(255, 255, 255, 0.025) 8px, transparent 8px, transparent 16px),
    #0a0a0a;
  isolation: isolate;
  /* perspective 由 inline style 注入（containers 决定 3D 透视强度） */
}

.libtv-ma-preview-img {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 88%;
  height: 88%;
  object-fit: cover;
  /* transform 由 inline style 注入 */
  transform-origin: center center;
  transform-style: preserve-3d;
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1), border-radius 0.18s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1;
}

.libtv-ma-preview-vignette {
  position: absolute;
  inset: 6%;
  pointer-events: none;
  z-index: 2;
  /* background + border-radius 由 inline style 注入（鱼眼效果） */
  transition: background 0.18s, border-radius 0.18s;
}

.libtv-ma-preview-widget-slot {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 5;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.libtv-ma-direction-widget {
  display: block;
}

.libtv-ma-preview-hint {
  position: absolute;
  bottom: 4px;
  left: 6px;
  z-index: 5;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.55);
  padding: 1px 6px;
  border-radius: 4px;
  pointer-events: none;
}
