/* DramaFlow 组件层（跨页面复用）。
   只引用 styles/tokens.css 的语义 token，因此浅色主题自动跟随。
   页面里不要再重复定义弹窗、按钮、输入、菜单、徽标、筛选 chips 的样式。 */

/* ---------- 空态（对标线上 CuteDesign / Element 表） ----------
   S：表格行内横排，24×23 灰盒 SVG（.el-table__empty-text:before）
   M：表格中号竖排，48 SVG（.el-table__empty-medium → not-have-m）
   L：整页/卡片居中竖排，继续用 list-empty / 业务专图
*/
.df-empty--table {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--df-color-text-faint);
  font-size: 13px;
  line-height: 24px;
}
.df-empty--table img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex: none;
}
.df-empty--medium {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 120px;
  color: var(--df-color-text-faint);
  font-size: 14px;
  line-height: 22px;
  text-align: center;
}
.df-empty--medium img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

/* ---------- 弹窗 ---------- */
.df-dialog {
  width: min(480px, 94vw);
  padding: 0;
  border: 1px solid var(--df-color-border-container, var(--df-color-divider));
  border-radius: var(--df-radius-2xl);
  background: var(--df-color-panel);
  color: var(--df-color-text);
  box-shadow: var(--df-shadow-dialog);
}
.df-dialog--sm { width: min(400px, 92vw); }
.df-dialog--md { width: min(480px, 94vw); }
.df-dialog--lg { width: min(560px, 94vw); }
.df-dialog--xl { width: min(1040px, 92vw); }
.df-dialog::backdrop { background: var(--df-color-mask); }
.df-dialog[open] { display: flex; flex-direction: column; }
.df-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--df-space-4);
  padding: var(--df-space-4) var(--df-space-6);
  border-bottom: 1px solid var(--df-color-dialog-divider, var(--df-color-divider));
}
.df-dialog__title { margin: 0; font-size: var(--df-font-size-lg); font-weight: var(--df-font-weight-medium); }
.df-dialog__close {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--df-radius-md);
  background: transparent;
  color: var(--df-color-text-secondary);
  font: inherit;
  font-size: var(--df-font-size-xl);
  line-height: 1;
  cursor: pointer;
}
.df-dialog__close:hover { background: var(--df-color-surface-hover); color: var(--df-color-text); }
.df-dialog :is(.df-btn, .df-dialog__close):focus-visible {
  outline: 2px solid var(--df-color-focus-ring);
  outline-offset: 2px;
}
.df-dialog__body {
  display: flex;
  flex-direction: column;
  gap: var(--df-space-4);
  padding: var(--df-space-5) var(--df-space-6);
  overflow-y: auto;
}
.df-dialog__text { margin: 0; color: var(--df-color-text-secondary); font-size: var(--df-font-size-sm); line-height: var(--df-line-height-base); }
.df-dialog__warning { margin: 0; color: var(--df-color-danger); font-size: var(--df-font-size-sm); }
.df-dialog__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--df-space-3);
  padding: var(--df-space-4) var(--df-space-6);
  border-top: 1px solid var(--df-color-dialog-divider, var(--df-color-divider));
}

/* ---------- 按钮 ---------- */
.df-btn {
  min-width: 88px;
  padding: 8px 18px;
  border: 1px solid var(--df-color-border);
  border-radius: var(--df-radius-lg);
  background: transparent;
  color: var(--df-color-text);
  font: inherit;
  cursor: pointer;
}
html[data-theme="light"] .df-btn:where(:not(.df-btn--primary, .df-btn--danger, .df-btn--outline-danger, :disabled, [aria-disabled="true"], :hover, :active, :focus-visible)) {
  border-color: var(--df-color-border-button);
}
.df-btn:hover { background: var(--df-color-surface-hover); }
.df-btn--primary { border-color: transparent; background: var(--df-color-primary-fill); color: var(--df-color-primary-text); }
.df-btn--primary:hover { background: var(--df-color-primary-fill-hover); }
.df-btn--danger { border-color: transparent; background: var(--df-color-danger); color: var(--df-color-primary-text); }
.df-btn--danger:hover { background: var(--df-color-danger-hover); }
.df-btn--outline-danger { border-color: var(--df-color-danger); color: var(--df-color-danger); }
.df-btn--sm { min-width: 0; padding: 4px 10px; font-size: var(--df-font-size-xs); border-radius: var(--df-radius-md); }
.df-btn[disabled] { cursor: not-allowed; color: var(--df-color-text-faint); }
.df-btn--primary[disabled] { background: var(--df-color-surface-active); color: var(--df-color-text-faint); }
html[data-theme="light"] .df-btn:disabled:not(.df-btn--primary,.df-btn--danger,.df-btn--outline-danger) {
  color: var(--df-color-button-disabled-text);
  background-color: var(--df-color-surface-sunken);
  border-color: var(--df-color-border-button);
  cursor: not-allowed;
}
html[data-theme="light"] .df-btn:hover:not(.df-btn--primary,.df-btn--danger,.df-btn--outline-danger,.hero-actions__btn,:disabled,[aria-disabled="true"]) {
  color: var(--df-color-primary);
  background-color: var(--df-color-surface);
  border-color: var(--df-color-primary);
}
html[data-theme="light"] .df-btn:active:not(.df-btn--primary,.df-btn--danger,.df-btn--outline-danger,.hero-actions__btn,:disabled,[aria-disabled="true"]) {
  color: var(--df-color-primary-active);
  background-color: var(--df-color-primary-soft);
  border-color: var(--df-color-primary-active);
}

/* ---------- 表单字段 ---------- */
.df-field { display: flex; flex-direction: column; gap: var(--df-space-2); color: var(--df-color-text-faint); font-size: var(--df-font-size-xs); }
.df-input,
.df-textarea,
.df-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--df-color-border-field, var(--df-color-border));
  border-radius: var(--df-radius-lg);
  background: var(--df-color-surface);
  color: var(--df-color-text);
  font: inherit;
}
.df-textarea { min-height: 88px; resize: vertical; }
.df-input:focus,
.df-textarea:focus,
.df-select:focus { border-color: var(--df-color-focus-ring); outline: none; }

/* ---------- 浮层菜单 ---------- */
.df-menu {
  position: absolute;
  z-index: var(--df-z-dropdown);
  display: flex;
  flex-direction: column;
  min-width: 120px;
  padding: var(--df-space-1);
  border: 1px solid var(--df-color-popover-border, var(--df-color-border-container, var(--df-color-divider)));
  border-radius: var(--df-radius-lg);
  background: var(--df-color-panel);
  box-shadow: var(--df-shadow-popover);
}
.df-menu[hidden] { display: none; }
.df-menu > button {
  display: flex;
  align-items: center;
  gap: var(--df-space-2);
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--df-radius-sm);
  background: transparent;
  color: var(--df-color-text);
  font: inherit;
  font-size: var(--df-font-size-sm);
  text-align: left;
  cursor: pointer;
}
.df-menu > button:is(:hover, :focus-visible) { background: var(--df-color-surface-hover); }
.df-menu > button[aria-pressed="true"] { color: var(--df-color-accent); }
.df-menu button.is-danger { color: var(--df-color-danger); }
.df-menu button[disabled] { color: var(--df-color-text-faint); cursor: not-allowed; }

/* 下拉/菜单浮层变体（线上 .el-popper.search-popover / .history-popover-no-padding + .popover-item：
   底色 #191919、阴影 0 0 15px rgba(0,0,0,.2)、行 41px 通栏、hover 与选中同为 #3b404880 且字重 600） */
.df-menu--dropdown,
.df-menu--card {
  padding: 0;
  border: 0;
  background: var(--df-color-surface-media);
  box-shadow: var(--df-shadow-popover-list);
}
.df-menu--dropdown { border-radius: var(--df-radius-lg); }
.df-menu--card { width: 84px; min-width: 84px; border-radius: var(--df-radius-popover); }
.df-menu--dropdown > button,
.df-menu--card > button {
  height: 41px;
  gap: 6px;
  padding: 0 var(--df-space-3);
  border-radius: 0;
  font-size: var(--df-font-size-xs);
  color: var(--df-color-text);
  transition: background-color 0.2s ease;
}
/* 浮层行（线上 .popover-item）：41px 通栏、padding 0 12px、gap 6、hover 与选中同为 #3b404880 且字重 600 */
.df-popover-row {
  display: flex;
  align-items: center;
  width: 100%;
  height: 41px;
  min-height: 41px;
  gap: 6px;
  padding: 0 var(--df-space-3);
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--df-color-text);
  font: inherit;
  font-size: var(--df-font-size-xs);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.df-popover-row:is(:hover, :focus-visible),
.df-popover-row[aria-selected="true"] {
  background: var(--df-color-option-hover);
  font-weight: var(--df-font-weight-semibold);
}

.df-menu--dropdown > button:is(:hover, :focus-visible),
.df-menu--card > button:is(:hover, :focus-visible),
.df-menu--dropdown > button[aria-selected="true"],
.df-menu--card > button[aria-selected="true"],
.df-menu--card > button[aria-pressed="true"] {
  background: var(--df-color-option-hover);
  font-weight: var(--df-font-weight-semibold);
}

/* ---------- 徽标 ---------- */
.df-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--df-space-1);
  padding: 2px 8px;
  border-radius: var(--df-radius-pill);
  background: var(--df-color-surface-raised);
  color: var(--df-color-text-secondary);
  font-size: var(--df-font-size-xs);
}
.df-badge--success { color: var(--df-color-success); }
.df-badge--accent { color: var(--df-color-accent); }
.df-badge--danger { color: var(--df-color-danger-hover); }
.df-badge--warn { color: var(--df-color-warning); }
.df-badge--muted { color: var(--df-color-text-muted); }
.df-badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- 筛选 chips ---------- */
.df-chips { display: flex; flex-wrap: wrap; gap: var(--df-space-2); }
.df-chip {
  padding: 5px 12px;
  border: 1px solid var(--df-color-border);
  border-radius: var(--df-radius-pill);
  background: var(--df-color-surface);
  color: var(--df-color-text-secondary);
  font: inherit;
  font-size: var(--df-font-size-xs);
  cursor: pointer;
}
.df-chip[aria-pressed="true"] { border-color: var(--df-color-accent); color: var(--df-color-accent); }

/* ---------- 空态 ---------- */
.df-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--df-space-2);
  padding: var(--df-space-8) var(--df-space-4);
  color: var(--df-color-text-faint);
  font-size: var(--df-font-size-sm);
  text-align: center;
}
.df-empty img { width: 80px; height: 80px; object-fit: contain; }

/* ---------- 账户菜单项与账户弹窗内容 ---------- */
.home-account-menu li.is-clickable { cursor: pointer; }
.home-account-menu li.is-clickable:hover { background: var(--df-color-option-hover-bg); }
.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--df-space-4);
  padding: var(--df-space-2) 0;
  border-bottom: 1px solid var(--df-color-border-subtle);
  font-size: var(--df-font-size-sm);
}
.account-row:last-child { border-bottom: 0; }
.account-row span { color: var(--df-color-text-faint); }
.account-row strong { color: var(--df-color-text); font-weight: var(--df-font-weight-medium); text-align: right; }
.account-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  z-index: var(--df-z-toast);
  padding: 10px 18px;
  border: 1px solid var(--df-color-divider);
  border-radius: var(--df-radius-pill);
  background: var(--df-color-panel);
  color: var(--df-color-text);
  font-size: var(--df-font-size-sm);
  box-shadow: var(--df-shadow-popover);
  transform: translateX(-50%);
}

/* ---------- 画布节点 / 参数侧栏 / 标注（画布专属组件域） ---------- */
/* 从 canvas-editor-features.css 收编；只引用语义 token。页面壳（工具条/缩略图/菜单定位）仍留在页面 CSS。 */

/* -- 节点外壳与端口 / 媒体 / 生成态 -- */
/* ---------- 节点外壳（沿用 .canvas-reference-node 的原始视觉） ---------- */
.editor-nodes .canvas-reference-node { pointer-events: auto; }
.canvas-node[data-selected="true"] { box-shadow: 0 0 0 1px var(--df-color-accent); }
.canvas-node__name { cursor: text; }

.canvas-node > .node-port {
  top: 82px;
  z-index: 1;
  display: grid;
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--df-color-text-secondary);
  border-radius: 50%;
  background: var(--df-color-surface-raised);
  color: var(--df-color-text-secondary);
  font: inherit;
  font-size: 12px;
  transform: none;
  cursor: crosshair;
}
.canvas-node > .node-port .df-icon { width: 16px; height: 16px; color: var(--df-color-text-strong); }
.canvas-node > .node-port--in { left: -20px; }
.canvas-node > .node-port--out { left: auto; right: -20px; }
.canvas-node > .node-port[aria-pressed="true"] { background: var(--df-color-primary-fill); color: var(--df-color-primary-text); }
.canvas-node > .node-port[aria-pressed="true"] .df-icon { color: inherit; }

.canvas-node--video .reference-node__image,
.canvas-node--audio .reference-node__image { color: var(--df-color-text-muted); }

.canvas-node__media { position: relative; }
.reference-node__image.is-empty { align-items: start; padding-top: 86px; }
.canvas-open-assets .df-icon { width: 20px; height: 20px; fill: currentColor; }
.canvas-bottom-tools .df-icon { width: 16px; height: 16px; flex: none; fill: currentColor; }
.canvas-stop__square { display: inline-block; width: 12px; height: 9px; border: 1.5px solid currentColor; border-radius: 1px; }
.canvas-reference-node footer button { display: inline-flex; align-items: center; gap: 4px; }
.canvas-reference-node footer .df-icon { width: 12px; height: 12px; fill: currentColor; }
.canvas-node__media img,
.canvas-node__media video { display: block; width: 100%; height: 156px; object-fit: cover; border-radius: var(--df-radius-lg); }
.canvas-node__media audio { display: block; width: calc(100% - 24px); margin: 60px 12px; }
.canvas-node__text {
  display: block;
  width: 100%;
  height: 156px;
  padding: 10px;
  border: 1px solid var(--df-color-control-edge);
  border-radius: var(--df-radius-lg);
  background: var(--df-color-surface-sunken);
  color: var(--df-color-text);
  font: inherit;
  resize: none;
}
.canvas-node__title { display: inline-flex; align-items: center; gap: 6px; }

/* 生成中 / 失败态：对齐线上 node-generate-status */
.canvas-node__status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--df-radius-2xl);
  background: var(--df-color-surface);
}
.canvas-node__status.is-running {
  background: url("../assets/loading-uzdJBgcp.gif") center/cover no-repeat;
}
.canvas-node__progress-text {
  margin-bottom: 12px;
  padding: 2px 8px;
  border-radius: var(--df-radius-sm);
  background: var(--df-color-surface);
  color: var(--df-color-text-strong);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.canvas-node__progress {
  width: 180px;
  height: 6px;
  overflow: hidden;
  border-radius: var(--df-radius-xs);
  background: var(--df-color-progress-track);
}
.canvas-node__progress i {
  display: block;
  height: 100%;
  border-radius: var(--df-radius-xs);
  background: var(--df-color-tag-text);
  transition: width .18s linear;
}
.canvas-node__status.is-failed {
  align-items: flex-start;
  justify-content: flex-start;
  padding: 40px 20px;
}
.canvas-node__failed-header {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--df-color-danger);
  font-size: 14px;
  font-weight: 600;
  line-height: 24px;
}
.canvas-node__failed-header svg { fill: currentColor; }
.canvas-node__failed-desc {
  margin: 8px 0 0;
  color: var(--df-color-text-muted);
  font-size: 12px;
  line-height: 18px;
}
.canvas-node__failed-id {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  color: var(--df-color-text-muted);
  font-size: 12px;
  line-height: 18px;
}
.canvas-node__failed-id code {
  max-width: 200px;
  overflow: hidden;
  font: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.canvas-node__failed-id button {
  display: grid;
  flex: none;
  width: 18px;
  height: 18px;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--df-color-text-strong);
  cursor: pointer;
}
.canvas-node__failed-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}
.canvas-node__failed-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--df-color-border-strong);
  border-radius: var(--df-radius-md);
  background: transparent;
  color: var(--df-color-text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.canvas-node__failed-actions button:hover { opacity: .8; }
.canvas-node__failed-actions .canvas-node__retry {
  width: 98px;
  padding: 0;
}
.canvas-node__failed-actions svg { flex: none; fill: currentColor; }

/* -- 节点参数侧栏 -- */
/* ---------- 节点参数侧栏 ---------- */
.node-detail {
  position: absolute;
  top: 68px;
  right: 20px;
  z-index: var(--df-z-dropdown);
  display: flex;
  flex-direction: column;
  gap: var(--df-space-4);
  width: 320px;
  max-height: calc(100vh - 96px);
  padding: var(--df-space-5);
  overflow-y: auto;
  border: 1px solid var(--df-color-divider);
  border-radius: var(--df-radius-2xl);
  background: var(--df-color-panel);
  color: var(--df-color-text);
  box-shadow: var(--df-shadow-popover);
}
.node-detail[hidden] { display: none; }
.node-detail > header { display: flex; align-items: center; justify-content: space-between; }
.node-detail h2 { display: flex; align-items: center; gap: var(--df-space-2); margin: 0; font-size: var(--df-font-size-md); font-weight: var(--df-font-weight-medium); }
.node-detail h2 svg { fill: currentColor; }
.node-detail header button {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: var(--df-radius-md);
  background: transparent;
  color: var(--df-color-text-secondary);
  font: inherit;
  cursor: pointer;
}
.node-detail header button:hover { background: var(--df-color-surface-hover); }
.node-field select { appearance: none; }
.node-detail__params { display: grid; grid-template-columns: 1fr 1fr; gap: var(--df-space-3); }
.node-detail__params[hidden] { display: none; }
.node-detail__runs { display: flex; flex-direction: column; gap: var(--df-space-2); margin: 0; padding: 0; list-style: none; }
.node-detail__runs li { display: flex; align-items: center; justify-content: space-between; gap: var(--df-space-2); padding: 6px 10px; border-radius: var(--df-radius-md); background: var(--df-color-surface); font-size: var(--df-font-size-xs); color: var(--df-color-text-secondary); }
.node-detail__runs .run-state--succeeded { color: var(--df-color-success); }
.node-detail__runs .run-state--failed { color: var(--df-color-danger); }
.node-detail__actions { display: flex; gap: var(--df-space-2); padding-top: var(--df-space-1); }
.node-detail__actions .df-btn {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  font-size: var(--df-font-size-sm);
}
.node-detail__actions .df-btn:not(.df-btn--primary, .df-btn--danger) {
  background: var(--df-color-surface);
}
.node-detail__actions .df-btn.is-danger { color: var(--df-color-danger); }

/* -- 多选提示 -- */
.node-detail__multi {
  margin: 0;
  padding: 6px 10px;
  border-radius: var(--df-radius-md);
  background: var(--df-color-surface);
  color: var(--df-color-accent);
  font-size: var(--df-font-size-xs);
}
.node-detail__multi[hidden] { display: none; }

/* -- 节点右键菜单增量 -- */
/* 节点右键菜单中的节点操作 */
/* 菜单外壳复用 .df-menu */
.canvas-node-menu { min-width: 130px; }
.canvas-node-menu button.is-danger { color: var(--df-color-danger); }

/* -- 标注 -- */
/* ---------- 标注 ---------- */
.editor-annotations { position: absolute; inset: 0; pointer-events: none; }
.editor-annotations:empty { display: none; }
.annotation {
  position: absolute;
  pointer-events: auto;
  border: 2px solid var(--annotation-color);
  border-radius: var(--df-radius-md);
  background: color-mix(in srgb, var(--annotation-color) 14%, transparent);
  cursor: move;
}
.annotation[data-selected="true"] { box-shadow: 0 0 0 2px var(--df-color-focus-ring); }
.annotation--arrow {
  border: 0;
  border-radius: 0;
  background: transparent;
}
.annotation--arrow svg { display: block; width: 100%; height: 100%; overflow: visible; }
.annotation--arrow line { stroke: var(--annotation-color); stroke-width: 2; stroke-dasharray: 7 5; }
.annotation--arrow polygon { fill: var(--annotation-color); }
.annotation__index {
  position: absolute;
  top: -11px;
  left: -11px;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  background: var(--annotation-color);
  color: var(--df-palette-neutral-950);
  font-size: var(--df-font-size-xs);
  font-weight: var(--df-font-weight-semibold);
}
.editor[data-tool="annotate"] { cursor: crosshair; }

/* -- 成组虚线框 -- */
.canvas-node[data-grouped="true"]::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 1px dashed var(--df-color-accent);
  border-radius: var(--df-radius-2xl);
  pointer-events: none;
}


html[data-theme="light"] .df-btn--outline-danger { color: var(--df-color-danger-text, #bd252e); }
html[data-theme="dark"] .df-btn--danger { color: var(--df-palette-neutral-950); }
