* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f3f5fb;
  --panel: #ffffff;
  --panel2: #f4f6fc;
  --border: #e6e9f2;
  --text: #1d2033;
  --muted: #8b91a7;
  --primary: #5b7cfa;
  --primary2: #4a6af0;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
}
html, body { height: 100%; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
button {
  font-family: inherit; cursor: pointer; border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 13px; background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); transition: .15s;
}
button:hover { background: #eef1f8; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary2); }
button:disabled { opacity: .5; cursor: not-allowed; }
input, textarea, select {
  font-family: inherit; background: var(--panel2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 9px 11px; font-size: 13px; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }
label { font-size: 12px; color: var(--muted); display: block; margin: 10px 0 5px; }
.hidden { display: none !important; }

/* ---------- 登录页（浅色气泡风，移植自 tianyiyun）---------- */
#authView {
  --lg-pri: #5b7cfa;
  --lg-pri2: #4a6af0;
  --lg-text: #1d2033;
  --lg-muted: #8b91a7;
  --lg-line: #e4e7f0;
  position: relative;
  height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; overflow: hidden;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(91,124,250,.18), transparent 55%),
    radial-gradient(900px 500px at 88% 110%, rgba(45,70,160,.12), transparent 50%),
    linear-gradient(165deg, #eef1f8 0%, #f5f7fc 42%, #e8ecf6 100%);
}

/* 气泡感背景舞台 */
.login-stage { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.login-orb {
  position: absolute; border-radius: 50%; filter: blur(40px); opacity: .55;
  animation: loginFloat 14s ease-in-out infinite;
}
.login-orb-a { width: 320px; height: 320px; top: -80px; right: 8%; background: rgba(91,124,250,.22); }
.login-orb-b { width: 260px; height: 260px; bottom: -60px; left: 6%; background: rgba(74,106,240,.14); animation-delay: -6s; }
.login-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(29,32,51,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29,32,51,.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 75%);
}
@keyframes loginFloat {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(18px, -14px); }
}
.login-bubbles { position: absolute; inset: 0; z-index: 1; overflow: hidden; pointer-events: none; }
/* 工作区 / 管理后台复用的上浮气泡: 置于渐变背景之上、内容之下 */
#projectsView .view-bubbles, #adminView .view-bubbles { position: absolute; z-index: 0; }
.login-bubbles .bubble {
  position: absolute; bottom: -100px; display: block; border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,.95) 0 12%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(140,170,255,.45), rgba(91,124,250,.28));
  border: 1.5px solid rgba(91,124,250,.45);
  box-shadow:
    inset 0 -6px 14px rgba(74,106,240,.18),
    inset 0 4px 10px rgba(255,255,255,.55),
    0 8px 24px rgba(74,106,240,.16);
  opacity: .9;
  animation-name: bubbleRise;
  animation-timing-function: cubic-bezier(.37, .01, .63, 1);
  animation-iteration-count: infinite;
}
.login-bubbles .bubble::after {
  content: ''; position: absolute; top: 16%; left: 20%;
  width: 34%; height: 22%; border-radius: 50%; background: rgba(255,255,255,.85);
}
@keyframes bubbleRise {
  0%   { transform: translate3d(0, 0, 0) scale(.85); opacity: 0; }
  10%  { opacity: .95; }
  30%  { transform: translate3d(28px, -30vh, 0) scale(1); }
  55%  { transform: translate3d(-32px, -55vh, 0) scale(1.05); opacity: .85; }
  80%  { transform: translate3d(20px, -82vh, 0) scale(.95); opacity: .55; }
  100% { transform: translate3d(-16px, -115vh, 0) scale(1.1); opacity: 0; }
}
.b1  { left: 4%;  width: 28px; height: 28px; animation-duration: 14s; animation-delay: -1s; }
.b2  { left: 12%; width: 64px; height: 64px; animation-duration: 18s; animation-delay: -5s; }
.b3  { left: 20%; width: 20px; height: 20px; animation-duration: 12s; animation-delay: -8s; }
.b4  { left: 30%; width: 44px; height: 44px; animation-duration: 16s; animation-delay: -3s; }
.b5  { left: 42%; width: 24px; height: 24px; animation-duration: 13s; animation-delay: -10s; }
.b6  { left: 54%; width: 56px; height: 56px; animation-duration: 20s; animation-delay: -7s; }
.b7  { left: 63%; width: 16px; height: 16px; animation-duration: 11s; animation-delay: -2s; }
.b8  { left: 72%; width: 72px; height: 72px; animation-duration: 22s; animation-delay: -12s; }
.b9  { left: 82%; width: 32px; height: 32px; animation-duration: 15s; animation-delay: -4s; }
.b10 { left: 90%; width: 22px; height: 22px; animation-duration: 13s; animation-delay: -9s; }
.b11 { left: 38%; width: 40px; height: 40px; animation-duration: 17s; animation-delay: -14s; }
.b12 { left: 8%;  width: 50px; height: 50px; animation-duration: 19s; animation-delay: -16s; }
/* 即使系统开启“减弱动态效果”，仍保留气泡缓慢上升（放慢节奏、关闭光晕漂浮以降低干扰）*/
@media (prefers-reduced-motion: reduce) {
  .login-orb { animation: none; }
  .login-bubbles .bubble { animation-duration: 26s; }
}

/* 白色玻璃面板（单栏，居中）*/
.auth-shell {
  position: relative; z-index: 2;
  display: block; width: 100%; max-width: 400px; min-height: 0;
  padding: 36px 36px 28px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 20px; overflow: visible;
  box-shadow:
    0 1px 0 rgba(255,255,255,.9) inset,
    0 24px 64px rgba(30,40,90,.1),
    0 4px 16px rgba(30,40,90,.04);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  animation: loginIn .55s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes loginIn {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* 品牌头 */
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand .brand-mark {
  width: 48px; height: 48px; flex-shrink: 0; border-radius: 13px;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
  background: linear-gradient(150deg, #5b7cfa, #4a6af0);
  box-shadow: 0 6px 18px rgba(74,106,240,.32);
}
.login-brand-text h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: .02em; color: var(--lg-text); line-height: 1.2; }
.login-brand-text p { margin: 5px 0 0; font-size: 14px; color: var(--lg-muted); letter-spacing: .04em; }
.login-divider {
  height: 1px; margin: 26px 0 22px;
  background: linear-gradient(90deg, transparent, var(--lg-line) 12%, var(--lg-line) 88%, transparent);
}

/* 登录页内表单元素（浅色，覆盖全局深色样式）*/
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-field { display: flex; flex-direction: column; }
#authView label { margin: 0 0 7px; font-size: 14px; font-weight: 600; letter-spacing: .04em; color: #6b7289; }
#authView input {
  padding: 13px 15px; background: #f7f8fc; border: 1px solid #e4e7f0;
  border-radius: 11px; font-size: 16px; color: var(--lg-text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
#authView input::placeholder { color: #a7adbf; }
#authView input:hover { border-color: #d5dae8; background: #fff; }
#authView input:focus { background: #fff; border-color: var(--lg-pri); box-shadow: 0 0 0 3px rgba(91,124,250,.14); }

/* 验证码行 */
.login-captcha { display: flex; gap: 10px; align-items: stretch; }
.login-captcha input { flex: 1; }
.login-captcha img {
  width: 120px; height: 46px; object-fit: cover; flex-shrink: 0;
  border-radius: 11px; border: 1px solid #e4e7f0; background: #f7f8fc; cursor: pointer;
  transition: border-color .15s, opacity .15s;
}
.login-captcha img:hover { border-color: var(--lg-pri); opacity: .92; }

/* 登录/注册链接切换 */
.login-switch { margin: 4px 0 0; text-align: center; font-size: 14px; color: var(--lg-muted); }
.login-switch a { color: var(--lg-pri); font-weight: 600; text-decoration: none; cursor: pointer; }
.login-switch a:hover { text-decoration: underline; }

/* 提交按钮 */
#authView .auth-submit {
  width: 100%; margin-top: 8px; padding: 14px 16px; border-radius: 11px;
  font-size: 17px; letter-spacing: .12em; font-weight: 600;
  background: var(--lg-pri); border: 1px solid var(--lg-pri); color: #fff;
  box-shadow: 0 8px 20px rgba(74,106,240,.28);
  transition: transform .15s, box-shadow .15s, background .15s;
}
#authView .auth-submit:hover { background: var(--lg-pri2); border-color: var(--lg-pri2); transform: translateY(-1px); box-shadow: 0 10px 24px rgba(74,106,240,.34); }
#authView .auth-submit:active { transform: translateY(0); }

.auth-err { color: var(--err); font-size: 13px; min-height: 18px; margin-top: 12px; text-align: center; }
.login-foot { margin: 20px 0 0; text-align: center; font-size: 13px; color: #a0a6b8; letter-spacing: .04em; }

@media (max-width: 480px) {
  #authView { padding: 16px; }
  .auth-shell { padding: 28px 22px 22px; border-radius: 16px; }
  .login-brand-text h1 { font-size: 22px; }
  .login-brand .brand-mark { width: 42px; height: 42px; font-size: 22px; }
}

/* ---------- 顶栏 ---------- */
#topbar {
  height: 52px; background: rgba(255,255,255,.72); border-bottom: 1px solid rgba(230,233,242,.8);
  backdrop-filter: blur(12px);
  display: flex; align-items: center; padding: 0 16px; gap: 12px; position: relative; z-index: 20;
}
#topbar .logo { font-weight: 700; font-size: 15px; color: var(--primary2); }
#topbar .spacer { flex: 1; }
#topbar .credits { color: var(--warn); font-size: 13px; }

/* 工作区顶栏: 名称 + 画布切换 */
.ws-bar {
  display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 52vw;
}
.ws-bar.hidden { display: none !important; }
.ws-title {
  width: auto; min-width: 80px; max-width: 220px; padding: 6px 8px; font-size: 14px; font-weight: 600;
  background: transparent; border: 1px solid transparent; border-radius: 8px; color: var(--text);
}
.ws-title:hover, .ws-title:focus { background: var(--panel2); border-color: var(--border); }
.ws-sep { width: 1px; height: 18px; background: var(--border); flex-shrink: 0; }
.canvas-switch { position: relative; }
.canvas-switch-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 10px;
  background: var(--panel2); border: 1px solid var(--border); font-size: 13px;
}
.canvas-switch-btn .caret { font-size: 11px; opacity: .7; }
.canvas-switch.open .canvas-switch-btn { border-color: var(--primary); }
.canvas-menu {
  position: absolute; left: 0; top: calc(100% + 8px); z-index: 80; min-width: 200px;
  background: #ffffff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 14px 36px rgba(30,40,90,.16); padding: 6px; overflow: hidden;
}
.canvas-menu.hidden { display: none !important; }
.canvas-menu-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px 8px; font-size: 12px; color: var(--muted);
}
.canvas-menu-head button {
  width: 28px; height: 28px; padding: 0; border-radius: 8px; font-size: 18px; line-height: 1;
}
.canvas-menu-item {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 8px;
  font-size: 13px; cursor: pointer; position: relative;
}
.canvas-menu-item:hover, .canvas-menu-item.active { background: rgba(0,0,0,.04); }
.canvas-menu-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.canvas-menu-item .canvas-more {
  width: 26px; height: 26px; padding: 0; border-radius: 7px; font-size: 16px; line-height: 1;
  opacity: 0; flex-shrink: 0; color: var(--muted); letter-spacing: 1px;
}
.canvas-menu-item:hover .canvas-more, .canvas-menu-item.active .canvas-more { opacity: 1; }
.canvas-menu-item .canvas-more:hover { color: var(--text); background: rgba(0,0,0,.06); }
.canvas-menu-item.renaming { background: rgba(0,0,0,.05); cursor: default; }
.canvas-inline-input {
  flex: 1; min-width: 0; width: 100%; padding: 4px 8px !important; font-size: 13px !important;
  background: #ffffff !important; border: 1px solid var(--primary) !important; border-radius: 6px !important;
  color: var(--text) !important;
}
.canvas-item-menu {
  position: fixed; z-index: 130; min-width: 160px; padding: 6px;
  background: #ffffff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(30,40,90,.16);
}
.canvas-item-menu .cim-item {
  padding: 9px 12px; border-radius: 7px; font-size: 13px; cursor: pointer; color: var(--text);
}
.canvas-item-menu .cim-item:hover { background: rgba(0,0,0,.05); }
.canvas-item-menu .cim-item.danger { color: var(--err); }
.canvas-item-menu .cim-item.danger:hover { background: rgba(231,76,60,.15); }
.ws-card-title { cursor: text; }
.ws-card-title:hover { color: var(--primary2); }
.ws-inline-input {
  width: 100%; min-width: 0; margin-bottom: 4px; padding: 2px 6px !important; font-size: 14px !important; font-weight: 700 !important;
  background: #ffffff !important; border: 1px solid var(--primary) !important; border-radius: 6px !important;
  color: var(--text) !important;
}
.save-status { font-size: 12px; color: var(--muted); white-space: nowrap; min-width: 48px; }
.save-status.pending { color: var(--muted); }
.save-status.saving { color: var(--warn); }
.save-status.err { color: var(--err); }
.save-status.ok { color: var(--ok); }

/* ---------- 项目列表 (浅蓝气泡风, 与登录页统一) ---------- */
#projectsView {
  padding: 30px; height: calc(100vh - 52px); overflow: auto; position: relative;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(91,124,250,.16), transparent 55%),
    radial-gradient(900px 500px at 88% 110%, rgba(45,70,160,.10), transparent 50%),
    linear-gradient(165deg, #eef1f8 0%, #f5f7fc 42%, #e8ecf6 100%);
}
/* 装饰性光晕 */
#projectsView::before,
#projectsView::after {
  content: ''; position: fixed; border-radius: 50%; filter: blur(50px);
  pointer-events: none; z-index: 0;
}
#projectsView::before { width: 360px; height: 360px; top: 80px; right: 6%; background: rgba(91,124,250,.16); }
#projectsView::after { width: 300px; height: 300px; bottom: 40px; left: 4%; background: rgba(74,106,240,.12); }
#projectsView > * { position: relative; z-index: 1; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 16px; margin-top: 20px; }
.proj-card {
  background: rgba(255,255,255,.72); border: 1px solid rgba(255,255,255,.9); border-radius: 16px;
  box-shadow: 0 12px 30px rgba(30,40,90,.1); backdrop-filter: blur(10px);
  overflow: hidden; cursor: pointer; transition: .18s;
}
.proj-card:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: 0 18px 40px rgba(91,124,250,.2); }
.proj-card .thumb { height: 120px; background: linear-gradient(135deg,#eef1fb,#dfe5f5); display:flex; align-items:center; justify-content:center; color: var(--muted); font-size: 30px; }
.proj-card .meta { padding: 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.proj-card .meta-main { min-width: 0; flex: 1; }
.proj-card .meta h3 { font-size: 16px; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-card .meta p { font-size: 13px; color: var(--muted); }
.proj-card .proj-more {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 7px; border: none; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center; opacity: 0; transition: .15s;
}
.proj-card:hover .proj-more { opacity: 1; }
.proj-card .proj-more:hover { background: rgba(0,0,0,.06); color: var(--text); }

/* ---------- 画布 ---------- */
#editorView { height: calc(100vh - 52px); display: flex; position: relative; }
#toolbox {
  width: 60px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 6px; z-index: 15;
}
.tool-btn {
  width: 44px; height: 44px; border-radius: 10px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 18px; gap: 2px; padding: 0;
}
.tool-btn span { font-size: 9px; color: var(--muted); }

/* 左侧栏底部: 姓名 / 今日消耗积分 / 今日生成条数 (窄栏只显示数字, 悬停 title 显示全文) */
.toolbox-user { margin-top: auto; width: 100%; display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 8px 3px 2px; border-top: 1px solid var(--border); }
.toolbox-user .tb-user-name { max-width: 54px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11px; color: var(--text); text-align: center; cursor: default; }
.toolbox-user .tb-stat { display: flex; flex-direction: column; align-items: center; line-height: 1.15;
  color: var(--muted); cursor: default; }
.toolbox-user .tb-stat .tb-ic { font-size: 11px; opacity: .8; }
.toolbox-user .tb-stat b { font-size: 12px; color: var(--text); font-weight: 600; max-width: 54px;
  overflow: hidden; text-overflow: ellipsis; }

#canvasWrap { flex: 1; position: relative; overflow: hidden;
  background-color: #eef1f8;
  background-image: radial-gradient(circle, #cdd4e6 1px, transparent 1px);
  background-size: 22px 22px; cursor: crosshair; }
#canvasWrap.panning { cursor: grabbing; }
#canvasWrap.space { cursor: grab; }
/* 拖拽本地素材文件到画布时的高亮提示 */
#canvasWrap.drag-over::after {
  content: '松开鼠标, 添加素材到画布';
  position: absolute; inset: 0; z-index: 60; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--primary);
  background: rgba(91,124,250,.08);
  border: 2px dashed var(--primary); border-radius: 12px;
}
/* 画布层不拦截鼠标: 空白点击落到 wrap 上才能框选; 节点自行接收事件 */
#canvas { position: absolute; top: 0; left: 0; transform-origin: 0 0; z-index: 1; pointer-events: none; }
#edgeSvg { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; z-index: 0; transform-origin: 0 0; }
#edgeSvg path { stroke: #b7c0d8; stroke-width: 2; fill: none; }
#edgeSvg path.temp { stroke: var(--primary2); stroke-dasharray: 5 4; }
/* 选中节点相连的连线: 电流流动特效 */
#edgeSvg path.edge-flow {
  stroke: var(--primary); stroke-width: 2.5; stroke-dasharray: 7 7;
  filter: drop-shadow(0 0 4px rgba(91,124,250,.85));
  animation: edgeFlow .55s linear infinite;
}
@keyframes edgeFlow { to { stroke-dashoffset: -14; } }
/* 连线剪刀按钮 */
.edge-cut {
  position: fixed; z-index: 90; width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border-radius: 50%; background: #e74c3c; color: #fff; border: 2px solid #fff;
  display: none; align-items: center; justify-content: center; cursor: pointer;
  font-size: 13px; line-height: 1; box-shadow: 0 4px 12px rgba(0,0,0,.4); pointer-events: auto;
}
.edge-cut.show { display: flex; }
.edge-cut:hover { background: #d63c2c; transform: scale(1.1); }
/* 图片预览灯箱 */
.img-preview-mask {
  position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.img-preview-img { max-width: 92vw; max-height: 92vh; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.img-preview-close { position: fixed; top: 18px; right: 26px; color: #fff; font-size: 26px; cursor: pointer; line-height: 1; }
.img-preview-close:hover { opacity: .8; }

/* 视频预览播放器 (带截图) */
.video-preview-mask {
  position: fixed; inset: 0; z-index: 310; background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
}
.video-preview-box {
  display: flex; flex-direction: column; gap: 12px; align-items: center;
  max-width: 92vw; max-height: 92vh;
}
.video-preview-el { max-width: 92vw; max-height: 78vh; border-radius: 8px; background: #000; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.video-preview-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.video-preview-bar button { padding: 8px 14px; font-size: 14px; }
.video-preview-bar button:disabled { opacity: .6; cursor: default; }
.video-preview-tip { color: rgba(255,255,255,.65); font-size: 12px; }
/* 截图内联状态: 深色遮罩上要有足够对比度 */
.video-preview-tip.pending { color: #ffd479; }
.video-preview-tip.ok { color: #6fe3a5; font-weight: 600; }
.video-preview-tip.err { color: #ff8f85; font-weight: 600; }
.video-preview-close { position: fixed; top: 18px; right: 26px; color: #fff; font-size: 26px; cursor: pointer; line-height: 1; }
.video-preview-close:hover { opacity: .8; }

/* 生成日志 */
#genLogView { padding: 28px 34px 48px; height: calc(100vh - 52px); overflow: auto; position: relative; }
.gen-section { margin-top: 22px; }
.gen-section-head { display: flex; align-items: center; margin-bottom: 12px; gap: 12px; flex-wrap: wrap; }
.gen-section-title { font-size: 16px; font-weight: 600; color: var(--text); }
.gen-batch-bar {
  margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 13px; color: var(--muted);
}
.gen-batch-all { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; color: var(--text); }
.gen-batch-all input { margin: 0; cursor: pointer; }
.gen-batch-count { white-space: nowrap; min-width: 4.5em; }
.gen-batch-bar button { padding: 5px 12px; font-size: 13px; }
.gen-batch-bar button:disabled { opacity: .45; cursor: not-allowed; }
.gen-th-check, .gen-td-check { width: 36px; text-align: center; padding-left: 8px !important; padding-right: 4px !important; }
.gen-td-check .gen-row-cb { margin: 0; cursor: pointer; vertical-align: middle; }
.gen-row-cb-empty { display: inline-block; width: 14px; height: 14px; }
.gen-section .admin-pager { margin-top: 12px; }
.gen-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px; margin-top: 8px;
}
.gen-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 48px 0; font-size: 14px; }
.gen-card {
  position: relative;
  background: rgba(255,255,255,.78); border: 1px solid rgba(230,233,242,.9); border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 10px 26px rgba(30,40,90,.08); backdrop-filter: blur(8px);
  transition: .15s;
}
.gen-card:hover { border-color: var(--primary); box-shadow: 0 16px 36px rgba(91,124,250,.18); }
.gen-card-check {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px;
  background: rgba(255,255,255,.92); box-shadow: 0 1px 4px rgba(20,30,70,.18);
}
.gen-card-check .gen-row-cb { margin: 0; cursor: pointer; }
.gen-media {
  position: relative; height: 168px; background: #0d1020;
  display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden;
}
.gen-media img, .gen-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gen-media.gen-empty-media { color: var(--muted); font-size: 13px; background: var(--panel2); cursor: default; }
.gen-play {
  position: absolute; width: 46px; height: 46px; border-radius: 50%;
  background: rgba(0,0,0,.5); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 18px; padding-left: 3px; pointer-events: none;
}
.gen-info { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.gen-row1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gen-cap { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--panel2); color: var(--muted); }
.gen-cap.video { background: rgba(91,124,250,.16); color: var(--primary2); }
.gen-cap.image { background: rgba(34,197,94,.14); color: var(--ok); }
.gen-status { font-size: 12px; padding: 2px 8px; border-radius: 6px; }
.gen-status.ok { background: rgba(34,197,94,.14); color: var(--ok); }
.gen-status.err { background: rgba(239,68,68,.14); color: var(--err); }
.gen-status.run { background: rgba(245,158,11,.16); color: var(--warn); }
.gen-status.muted { background: var(--panel2); color: var(--muted); }
.gen-dur { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--panel2); color: var(--muted); white-space: nowrap; }
.gen-user { font-size: 12px; color: var(--muted); margin-left: auto; }
.gen-prompt { font-size: 13px; color: var(--text); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gen-meta { font-size: 12px; color: var(--muted); }
.gen-err { font-size: 12px; color: var(--err); word-break: break-word; }
.gen-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.gen-actions button { flex: 1; padding: 6px 8px; font-size: 13px; }
/* 右下角三点菜单 (删除日志, 仅超级管理员) */
.gen-more { position: relative; margin-left: auto; flex: 0 0 auto; }
.gen-actions .gen-more-btn {
  flex: 0 0 auto; width: 32px; height: 30px; padding: 0; font-size: 18px; line-height: 1;
  color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 8px;
}
.gen-actions .gen-more-btn:hover { background: var(--panel2); color: var(--text); }
.gen-menu {
  position: absolute; bottom: calc(100% + 6px); right: 0; min-width: 148px; white-space: nowrap; padding: 4px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(20,30,70,.22); z-index: 30;
}
.gen-menu.hidden { display: none; }
.gen-menu button {
  flex: none; width: 100%; display: flex; align-items: center; gap: 8px;
  text-align: left; padding: 8px 10px; font-size: 13px; line-height: 1.2;
  color: var(--text); background: transparent; border: none; border-radius: 6px; cursor: pointer;
}
.gen-menu button .gm-ic { flex: none; width: 16px; text-align: center; font-size: 14px; }
.gen-menu button .gm-tx { font-size: 13px; white-space: nowrap; }
.gen-menu button:hover { background: var(--panel2); }
.gen-menu button.danger { color: var(--err); }
.gen-menu button.danger:hover { background: rgba(231,76,60,.12); }

/* ---------- 生成日志: 紧凑表格 (超管·全部用户·视频日志) ---------- */
.gen-grid.gen-as-table { display: block; }
/* overflow 需 visible, 否则三点菜单(向上弹出)会被裁掉; 圆角改由四角单元格补齐 */
.gen-table-wrap { margin-top: 8px; overflow: visible; }
.gen-table { font-size: 14px; }
.gen-table th { font-size: 13px; white-space: nowrap; }
.gen-table th, .gen-table td { padding: 8px 10px; vertical-align: middle; }
.gen-table thead th:first-child { border-top-left-radius: 14px; }
.gen-table thead th:last-child { border-top-right-radius: 14px; }
.gen-table tbody tr:last-child td:first-child { border-bottom-left-radius: 14px; }
.gen-table tbody tr:last-child td:last-child { border-bottom-right-radius: 14px; }
.gen-table .gen-thumb {
  position: relative; width: 72px; height: 42px; border-radius: 8px; overflow: hidden;
  background: #0d1020; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.gen-table .gen-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gen-table .gen-thumb .gen-play { width: 22px; height: 22px; font-size: 11px; padding-left: 2px; }
.gen-table .gen-thumb-empty { cursor: default; background: var(--panel2); color: var(--muted); font-size: 11px; }
.gen-td-prompt { max-width: 340px; }
.gen-td-prompt-in { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; cursor: default; }
.gen-table .gen-err { margin-top: 2px; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gen-table .gen-actions { margin-top: 0; gap: 6px; }
.gen-table .gen-actions button { flex: none; padding: 4px 9px; font-size: 13px; }
.gen-table .gen-more { margin-left: 0; }

/* 积分记录 (生成日志内的个人流水账本) */
/* 标题/余额/筛选强制单行, 避免 flex 收缩把中文压成竖排 */
.credit-log-head { gap: 12px; flex-wrap: nowrap; }
.credit-log-head .gen-section-title,
.credit-log-balance { white-space: nowrap; flex-shrink: 0; }
.credit-log-balance { font-size: 14px; font-weight: 600; color: var(--primary); }
.credit-log-type {
  margin-left: auto; flex-shrink: 0; padding: 5px 10px; font-size: 13px; color: var(--text);
  background: rgba(255,255,255,.85); border: 1px solid rgba(230,233,242,.9); border-radius: 8px;
}
.credit-log-toolbar { margin: 0 0 12px; }
.credit-table .credit-user { white-space: nowrap; }
.credit-table .credit-uid { color: var(--muted); font-size: 12px; }
.credit-table .credit-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.credit-chg.pos { color: var(--ok); font-weight: 600; }
.credit-chg.neg { color: var(--err); font-weight: 600; }
.credit-table .credit-remark {
  max-width: 520px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 13px; color: var(--text);
}
#creditLogTable .gen-empty { display: block; }
/* 分页器左侧: 每页条数选择器 */
/* 覆盖全局 label{display:block}, 并禁止收缩换行, 保证「每页 N 条」横排一行 */
.gen-ps {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 0; flex-shrink: 0; white-space: nowrap; color: var(--muted);
}
.gen-ps select {
  padding: 4px 8px; font-size: 13px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
}

.node {
  position: absolute; width: 280px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; z-index: 2; box-shadow: 0 8px 24px rgba(30,40,90,.12); user-select: none;
  pointer-events: auto; cursor: default;
}
.node.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(91,124,250,.4); }
.node.connect-target { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(46,204,113,.45); }
.node .node-head {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px; cursor: move;
  border-bottom: 1px solid var(--border); font-size: 12px;
}
.node .node-head .type-badge { font-size: 10px; padding: 2px 6px; border-radius: 5px; background: var(--panel2); color: var(--muted); }
.node .node-head .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.node .node-head .node-rename-input {
  flex: 1; min-width: 0; font-size: 12px; padding: 1px 5px; border-radius: 5px;
  border: 1px solid var(--primary); background: var(--panel2); color: var(--text); outline: none;
  user-select: text; cursor: text;
}
.node .node-head .del { color: var(--muted); cursor: pointer; padding: 0 4px; }
.node .node-head .del:hover { color: var(--err); }
.node .node-body { padding: 10px; }
.node textarea { min-height: 64px; resize: vertical; font-size: 12px; }
.node .media { width: 100%; border-radius: 8px; background: #000; display: block; -webkit-user-drag: none; user-drag: none; }
.node img { -webkit-user-drag: none; user-drag: none; }
.node .media-ph {
  width: 100%; height: 140px; border-radius: 8px; background: var(--panel2);
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; text-align:center;
}
.node .node-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.node .node-actions button { padding: 5px 9px; font-size: 11px; }
.node .status-bar { font-size: 11px; margin-top: 6px; }
.node .status-running { color: var(--warn); }
.node .status-failed { color: var(--err); }
.node .status-success { color: var(--ok); }
/* 生成进度条 (确定/不确定两种) */
.status-bar .prog { margin-top: 4px; height: 4px; border-radius: 3px; background: rgba(0,0,0,.07); overflow: hidden; }
.status-bar .prog-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width .3s ease; }
.status-bar .prog-indet .prog-fill { width: 40%; animation: progIndet 1.1s ease-in-out infinite; }
@keyframes progIndet { 0% { margin-left: -45%; } 100% { margin-left: 105%; } }
/* 端口: 外层为放大的透明拖拽热区(28px), 中心用 ::after 画可见圆点 */
.node .port {
  position: absolute; width: 30px; height: 30px; border-radius: 50%;
  top: 50%; transform: translateY(-50%); cursor: crosshair; z-index: 6;
  background: transparent; border: none; display: flex; align-items: center; justify-content: center;
}
.node .port::after {
  content: ''; width: 14px; height: 14px; border-radius: 50%; background: var(--panel2);
  border: 2px solid var(--primary); transition: transform .12s, background .12s;
}
.node .port.in  { left: -15px; }
.node .port.out { right: -15px; }
.node .port:hover::after { background: var(--primary); transform: scale(1.35); }
/* 选中/悬停节点时端口更明显 */
.node:hover .port::after, .node.selected .port::after { box-shadow: 0 0 0 3px rgba(91,124,250,.18); }

/* 图片节点占位可点击上传 */
.node .media-ph.uploadable { cursor: pointer; }
.node .media-ph.uploadable:hover { border: 1px dashed var(--primary); color: var(--primary2); }
/* 图片生成节点占位: 点击选中打开生成浮层(非上传) */
.node .media-ph-gen { cursor: pointer; line-height: 1.7; border: 1px dashed var(--border); }
.node .media-ph-gen:hover { border-color: var(--primary); color: var(--primary2); }
/* 上传中占位: 带旋转指示器 */
.node .media-ph-upload { gap: 8px; color: var(--primary2); border: 1px dashed var(--primary); }
.node .media-ph-upload .up-spin {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,.12); border-top-color: var(--primary);
  animation: upSpin .7s linear infinite;
}
@keyframes upSpin { to { transform: rotate(360deg); } }
.audio-trim-btn {
  margin-top: 8px; width: 100%; background: rgba(0,0,0,.04); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px; font-size: 12px; cursor: pointer;
}
.audio-trim-btn:hover { background: rgba(0,0,0,.07); border-color: var(--primary); }
.video-shot-btn {
  margin-top: 8px; width: 100%; background: rgba(0,0,0,.04); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px; font-size: 12px; cursor: pointer;
}
.video-shot-btn:hover { background: rgba(0,0,0,.07); border-color: var(--primary); }

/* ---------- 管理后台 (浅蓝气泡风, 与登录页统一) ---------- */
#adminView {
  padding: 26px 30px; height: calc(100vh - 52px); overflow: auto; position: relative;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(91,124,250,.16), transparent 55%),
    radial-gradient(900px 500px at 88% 110%, rgba(45,70,160,.10), transparent 50%),
    linear-gradient(165deg, #eef1f8 0%, #f5f7fc 42%, #e8ecf6 100%);
}
/* 装饰性光晕 */
#adminView::before,
#adminView::after {
  content: ''; position: fixed; border-radius: 50%; filter: blur(50px);
  pointer-events: none; z-index: 0;
}
#adminView::before { width: 360px; height: 360px; top: 80px; right: 6%; background: rgba(91,124,250,.16); }
#adminView::after { width: 300px; height: 300px; bottom: 40px; left: 4%; background: rgba(74,106,240,.12); }
#adminView > * { position: relative; z-index: 1; }
.admin-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.admin-head h2 { font-size: 20px; }
.admin-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.admin-stats .stat {
  background: rgba(255,255,255,.72); border: 1px solid rgba(255,255,255,.9); border-radius: 14px;
  padding: 10px 16px; font-size: 13px; color: var(--muted);
  box-shadow: 0 12px 30px rgba(30,40,90,.1); backdrop-filter: blur(10px);
}
.admin-stats .stat b { display: block; font-size: 20px; color: var(--text); margin-top: 2px; }
.admin-tabs { display: flex; gap: 8px; margin-top: 18px; border-bottom: 1px solid rgba(230,233,242,.8); }
.admin-tabs button { background: transparent; border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 8px 14px; font-size: 14px; }
.admin-tabs button.active { color: var(--text); border-bottom-color: var(--primary); }
/* 工具栏输入框/下拉/按钮同步放大一号 */
#adminView .admin-toolbar input, #adminView .admin-toolbar select, #adminView .admin-toolbar button { font-size: 14px; }
.admin-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 14px 0 12px; }
.admin-table .detail-cell { max-width: 460px; font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: zoom-in; }
.admin-table .detail-cell:hover { color: var(--text); }
/* 提示词单行省略, 悬停查看(title), 双击弹层看全文 */
.log-prompt { display: inline-block; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; cursor: zoom-in; }
.log-prompt:hover { color: var(--primary2); text-decoration: underline; }
.text-modal-body { white-space: pre-wrap; word-break: break-word; max-height: 60vh; overflow: auto; font-size: 13px; line-height: 1.7; color: #1a1d24; }
.log-action { padding: 2px 8px; border-radius: 6px; font-size: 12px; background: var(--panel2); color: var(--muted); }
.log-action.credits { background: rgba(243,156,18,.18); color: var(--warn); }
.log-action.delete { background: rgba(239,68,68,.14); color: var(--err); }
.log-action.update { background: rgba(91,124,250,.18); color: var(--primary2); }
.admin-table-wrap {
  border: 1px solid rgba(255,255,255,.9); border-radius: 14px; overflow: hidden;
  background: rgba(255,255,255,.72); box-shadow: 0 12px 30px rgba(30,40,90,.1);
  backdrop-filter: blur(10px);
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 16px; }
.admin-table th, .admin-table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid rgba(230,233,242,.7); }
.admin-table th { background: rgba(244,246,252,.7); color: var(--muted); font-weight: 600; font-size: 15px; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(91,124,250,.05); }
.admin-table .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-table .row-actions button { padding: 5px 9px; font-size: 14px; }
.badge-role { padding: 2px 9px; border-radius: 6px; font-size: 14px; background: var(--panel2); color: var(--muted); }
.badge-role.admin { background: rgba(91,124,250,.2); color: var(--primary2); }
.badge-status { padding: 2px 9px; border-radius: 6px; font-size: 14px; }
.badge-status.on { background: rgba(46,204,113,.18); color: var(--ok); }
.badge-status.off { background: rgba(239,68,68,.14); color: var(--err); }
.badge-status.pending { background: rgba(245,158,11,.18); color: var(--warn); }
.admin-pager {
  display: flex; align-items: center; flex-wrap: nowrap; gap: 10px;
  margin-top: 14px; font-size: 14px; color: var(--muted); white-space: nowrap;
}
.badge-role.superadmin { background: rgba(243,156,18,.2); color: var(--warn); }

/* ---------- 系统设置: 模型开放 ---------- */
#adminSettingsPane { padding-top: 16px; }
.settings-intro { font-size: 14px; color: var(--muted); line-height: 1.6; margin-bottom: 18px; }
.settings-intro b { color: var(--text); }
.model-group { margin-bottom: 22px; }
.model-group-head {
  display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600;
  color: var(--text); margin-bottom: 10px;
}
.model-list { display: flex; flex-direction: column; gap: 8px; }
.model-item {
  display: flex; align-items: center; gap: 14px;
  background: rgba(255,255,255,.72); border: 1px solid rgba(255,255,255,.9); border-radius: 12px;
  padding: 12px 16px; box-shadow: 0 10px 26px rgba(30,40,90,.08); backdrop-filter: blur(10px);
}
.model-info { flex: 1; min-width: 0; }
.model-name { font-size: 15px; color: var(--text); font-weight: 500; }
.model-off-tag {
  font-size: 12px; font-weight: 400; color: var(--warn);
  background: rgba(243,156,18,.14); border-radius: 5px; padding: 1px 7px; margin-left: 6px;
}
.model-meta { font-size: 13px; color: var(--muted); margin-top: 3px; }
/* 系统设置: 核心参数表单 */
.sys-config-form { display: flex; flex-direction: column; gap: 16px; margin-bottom: 12px; }
.sys-config-group {
  background: rgba(255,255,255,.72); border: 1px solid rgba(255,255,255,.9); border-radius: 12px;
  padding: 14px 16px; box-shadow: 0 10px 26px rgba(30,40,90,.08);
}
.sys-config-group-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 10px; }
.sys-config-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.sys-config-field:last-child { margin-bottom: 0; }
.sys-config-label { font-size: 13px; color: var(--text); font-weight: 500; }
.sys-config-label em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 12px; }
.sys-config-desc { font-size: 12px; color: var(--muted); line-height: 1.4; }
.sys-config-field input, .sys-config-field select {
  width: 100%; max-width: 560px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 13px;
}
.sys-config-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.model-del-btn {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid rgba(231,76,60,.28); background: rgba(231,76,60,.08);
  color: var(--err); font-size: 13px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.model-del-btn:hover { background: var(--err); color: #fff; }
/* 开关 */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute; inset: 0; background: var(--panel2); border: 1px solid var(--border);
  border-radius: 26px; transition: .2s;
}
.switch-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: var(--muted); border-radius: 50%; transition: .2s;
}
.switch input:checked + .switch-slider { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); background: #fff; }

/* ---------- 系统设置: 数据库备份与还原 (复用 .model-item 卡片) ---------- */
#adminDbBackupList { display: flex; flex-direction: column; gap: 8px; }
.db-backup-action { flex-wrap: wrap; }
.db-backup-action .primary { flex-shrink: 0; }
.db-backup-intro { line-height: 1.65; margin-top: 4px; }
.db-backup-intro b { color: var(--warn); font-weight: 600; }
.db-backup-meta { margin-top: 4px; }
.db-backup-name {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.db-backup-item button { flex-shrink: 0; }
.db-restore-btn {
  border: 1px solid rgba(243,156,18,.4); background: rgba(243,156,18,.1);
  color: var(--warn); border-radius: 8px; padding: 5px 12px; font-size: 13px; cursor: pointer;
  transition: background .15s, color .15s;
}
.db-restore-btn:hover { background: var(--warn); color: #fff; }
.db-restore-warn { font-size: 13px; line-height: 1.7; color: #3a3f4d; margin-bottom: 8px; }
.db-restore-warn b { color: var(--err); }
.db-restore-file {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; margin-bottom: 10px; word-break: break-all;
}

/* ---------- 积分消耗趋势 ---------- */
#adminCreditsPane { padding-top: 16px; }
.trend-scope { font-size: 13px; color: var(--muted); margin-left: 8px; }
.trend-blocks { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 900px) { .trend-blocks { grid-template-columns: 1fr; } }
.trend-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px; box-shadow: 0 10px 26px rgba(30,40,90,.06);
}
.trend-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.trend-title { font-size: 14px; font-weight: 600; color: var(--text); }
.trend-total { font-size: 12px; color: var(--muted); }
.trend-chart { width: 100%; min-height: 260px; }
.trend-chart svg { display: block; }
.trend-legend { display: flex; align-items: center; gap: 14px; margin: 2px 0 6px; }
.trend-legend-item { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.trend-legend-item i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.trend-empty { display: flex; align-items: center; justify-content: center; height: 260px; color: var(--muted); font-size: 13px; }
/* 卡片内二级区块: 用户消耗排行饼图 */
.trend-sub { margin-top: 14px; padding-top: 12px; border-top: 1px solid #eceef5; }
.trend-sub-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.trend-sub-title { font-size: 13px; font-weight: 600; color: var(--text); }
.trend-sub-note { font-size: 12px; color: var(--muted); }
.trend-pie { width: 100%; min-height: 240px; }
.trend-pie svg { display: block; overflow: visible; }
.trend-pie .trend-empty { height: 220px; }
.pie-slice { transition: opacity .15s; }
.pie-slice:hover { opacity: .82; }

/* ---------- 属性面板 ---------- */
#inspector {
  width: 300px; background: var(--panel); border-left: 1px solid var(--border);
  padding: 16px; overflow-y: auto; z-index: 15;
}
#inspector h3 { font-size: 14px; margin-bottom: 12px; }
#inspector .empty { color: var(--muted); font-size: 13px; margin-top: 40px; text-align: center; }
.field-row { margin-bottom: 10px; }

/* ---------- 缩放控件 ---------- */
#zoomCtl {
  position: absolute; bottom: 16px; left: 76px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; display: flex; align-items: center; gap: 4px; padding: 4px; z-index: 10;
}
#zoomCtl button { padding: 4px 10px; }
#zoomCtl .z { font-size: 12px; color: var(--muted); width: 48px; text-align: center; }

/* ---------- 弹窗 & toast ---------- */
#modalMask {
  position: fixed; inset: 0; background: rgba(20,25,50,.4); display: flex; align-items: center;
  justify-content: center; z-index: 120;
}
.modal {
  background: #f4f5f7; color: #1a1d24; border: none; border-radius: 12px;
  padding: 22px 24px 18px; width: 380px; max-width: calc(100vw - 32px); max-height: 82vh; overflow: auto;
  box-shadow: 0 20px 50px rgba(30,40,90,.2);
}
.modal h2 { font-size: 16px; margin-bottom: 14px; color: #1a1d24; font-weight: 600; }
.modal .modal-body input, .modal .modal-body textarea, .modal .modal-body select {
  background: #fff; border: 1px solid #d5d8e0; color: #1a1d24;
}
  .modal .modal-body input:focus, .modal .modal-body textarea:focus {
  border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(91,124,250,.14);
}
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* 音频裁剪: 波形 + 左右手柄 */
.trim-tip { font-size: 13px; color: #6b7180; line-height: 1.7; margin-bottom: 14px; }
.trim-tip b { color: var(--primary2); }
.trim-wave { position: relative; height: 120px; background: #f4f6fc; border: 1px solid #e6e9f2; border-radius: 12px; overflow: hidden; user-select: none; }
.trim-wave canvas { position: absolute; inset: 0; display: block; }
.trim-dim { position: absolute; top: 0; bottom: 0; background: rgba(244,246,252,.7); pointer-events: none; z-index: 2; }
.trim-dim-l { left: 0; width: 0; }
.trim-dim-r { right: 0; width: 0; }
.trim-handle { position: absolute; top: 0; bottom: 0; width: 16px; margin-left: -8px; cursor: ew-resize; z-index: 3; }
.trim-handle::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; transform: translateX(-50%); background: var(--primary); }
.trim-handle span { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 12px; height: 38px; background: var(--primary); border-radius: 6px; box-shadow: 0 2px 8px rgba(91,124,250,.55); }
.trim-info { margin-top: 14px; font-size: 13px; color: #6b7180; }
.trim-info b { color: #1a1d24; font-weight: 600; margin: 0 2px; }
.trim-info .trim-sep { display: inline-block; width: 16px; }
.trim-ctrls { display: flex; gap: 10px; margin-top: 14px; }
.trim-ctrls button { padding: 8px 16px; }
.modal .actions button {
  background: #fff; color: #1a1d24; border: 1px solid #d0d4dd; min-width: 72px;
}
.modal .actions button:hover { background: #f0f1f4; }
.modal .actions button.primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.modal .actions button.primary:hover { background: var(--primary2); border-color: var(--primary2); }
.modal .actions button.danger { background: #e74c3c; border-color: #e74c3c; color: #fff; }
.modal .actions button.danger:hover { background: #d63c2c; border-color: #d63c2c; }
.modal .modal-body p { margin: 0; font-size: 13px; line-height: 1.6; color: #3a3f4d; }
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  /* 强制深色字: 编辑态 --text 近白, 绝不能用 var(--text) */
  background: #111827 !important;
  border: 1px solid #374151 !important;
  color: #f9fafb !important;
  /* z-index 高于视频预览遮罩(310)/图片灯箱(300), 否则弹层打开时提示被盖成一块阴影 */
  padding: 10px 18px; border-radius: 10px; font-size: 13px; font-weight: 600;
  z-index: 340; opacity: 0; transition: .25s; pointer-events: none;
  box-shadow: 0 12px 32px rgba(0,0,0,.45);
}
#toast.show { opacity: 1; }
#toast.err {
  background: #7f1d1d !important;
  border-color: #fca5a5 !important;
  color: #fff !important;
}
#toast.ok {
  background: #14532d !important;
  border-color: #86efac !important;
  color: #fff !important;
}

/* 生成日志批量 ZIP 打包等待遮罩 (高于预览 310 / toast 340) */
.zip-busy-mask {
  position: fixed; inset: 0; z-index: 360;
  background: rgba(15, 20, 40, .48);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.zip-busy-card {
  width: min(360px, 100%);
  background: #fff;
  border: 1px solid rgba(230, 233, 242, .95);
  border-radius: 14px;
  padding: 28px 26px 24px;
  box-shadow: 0 20px 50px rgba(20, 30, 70, .28);
  text-align: center;
}
.zip-busy-spinner {
  width: 36px; height: 36px; margin: 0 auto 16px;
  border: 3px solid rgba(91, 124, 250, .22);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: zip-busy-spin .8s linear infinite;
}
.zip-busy-spinner.hidden, .zip-busy-bar.hidden, .zip-busy-actions.hidden { display: none; }
@keyframes zip-busy-spin { to { transform: rotate(360deg); } }
.zip-busy-title {
  font-size: 17px; font-weight: 700; color: var(--text); line-height: 1.35; margin-bottom: 8px;
}
.zip-busy-detail {
  font-size: 13px; color: var(--muted); line-height: 1.55; margin-bottom: 18px;
}
.zip-busy-bar {
  position: relative; height: 6px; border-radius: 999px;
  background: rgba(91, 124, 250, .12); overflow: hidden;
}
.zip-busy-bar-ind {
  position: absolute; top: 0; bottom: 0; width: 40%;
  border-radius: 999px; background: var(--primary);
  animation: zip-busy-ind 1.2s ease-in-out infinite;
}
@keyframes zip-busy-ind {
  0% { left: -40%; }
  100% { left: 100%; }
}
.zip-busy-actions { margin-top: 18px; }
.zip-busy-actions button {
  min-width: 96px; padding: 8px 18px; font-size: 13px;
  background: var(--primary); border: 1px solid var(--primary); color: #fff; border-radius: 8px; cursor: pointer;
}
.zip-busy-actions button:hover { background: var(--primary2); border-color: var(--primary2); }
.zip-busy-mask.is-error .zip-busy-title { color: var(--err); }
.zip-busy-mask.is-ok .zip-busy-title { color: var(--ok); }

.ctx-menu {
  position: fixed; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px; z-index: 150; box-shadow: 0 10px 30px rgba(30,40,90,.16); min-width: 180px;
}
.ctx-menu .ctx-title { padding: 6px 12px 8px; font-size: 12px; color: var(--muted); cursor: default; }
.ctx-menu .ctx-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; font-size: 13px; border-radius: 7px; cursor: pointer; }
.ctx-menu .ctx-item:hover { background: var(--panel2); }
.ctx-menu .ctx-item .ic { width: 18px; text-align: center; font-size: 15px; }

/* 框选矩形 */
.marquee {
  position: absolute; z-index: 9; pointer-events: none; border-radius: 2px;
  border: 1px solid var(--primary); background: rgba(91,124,250,.12);
}
/* 选中区域框 (z-index 低于节点; 本体不拦截鼠标, 以便在选框范围内仍可框选/拖拽节点。
   整组移动通过拖拽任一选中节点完成; 工具栏与"+"单独开启点击) */
/* 选中区域框: 本体点击穿透(不拦截节点), 但层级高于节点, 使工具栏/"+"不被其他节点遮挡。
   整组移动通过拖分组边框完成; 多选整体拖动通过拖任一选中节点完成。 */
.sel-box {
  position: absolute; z-index: 20; pointer-events: none; border-radius: 14px;
  border: 1.5px dashed var(--primary); background: rgba(91,124,250,.05);
  box-shadow: 0 0 0 1px rgba(91,124,250,.1);
}
/* 选中整组时: 选框与分组边框重合, 隐藏选框自身描边/底色, 只保留分组框, 避免双层虚线 */
.sel-box.on-group { border-color: transparent; background: transparent; box-shadow: none; }
.sel-box-add {
  position: absolute; right: -15px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border-radius: 50%; pointer-events: auto; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; font-size: 20px; line-height: 1;
  box-shadow: 0 4px 12px rgba(91,124,250,.5); transition: transform .12s, background .12s;
}
.sel-box-add:hover { background: var(--primary2); transform: translateY(-50%) scale(1.12); }

/* 区域框上方工具栏 */
.sel-toolbar {
  position: absolute; left: 50%; bottom: 100%; top: auto; margin-bottom: 10px;
  transform-origin: center bottom; cursor: default; pointer-events: auto;
  display: flex; align-items: center; gap: 4px; padding: 5px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(30,40,90,.16); white-space: nowrap;
}
.sel-tool {
  position: relative; display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
  color: var(--text); user-select: none;
}
.sel-tool:hover { background: rgba(0,0,0,.05); }
.sel-tool .ic { font-size: 14px; opacity: .9; }
.sel-tool .caret { font-size: 11px; opacity: .6; margin-left: 2px; }
.sel-tool[data-role="group"] { border-left: 1px solid var(--border); border-radius: 0 8px 8px 0; }
.sel-dropdown {
  position: absolute; left: 0; bottom: calc(100% + 6px); top: auto; display: none;
  flex-direction: column; min-width: 150px; padding: 5px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(30,40,90,.16); z-index: 5;
}
.sel-tool.open .sel-dropdown { display: flex; }
.sel-opt { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; font-size: 13px; }
.sel-opt:hover { background: var(--primary); color: #fff; }
.sel-opt .ic { width: 16px; text-align: center; }
/* 音频分离下拉 */
.sep-dropdown { min-width: 148px; white-space: nowrap; }
.sel-opt.sep-disabled { color: var(--muted); cursor: not-allowed; opacity: .7; }
.sel-opt.sep-disabled:hover { background: transparent; color: var(--muted); }
.sel-opt .sep-soon { margin-left: auto; font-size: 11px; color: var(--muted); background: rgba(0,0,0,.06); border-radius: 6px; padding: 1px 6px; }
/* 已打组节点 */
.node.grouped { border-color: rgba(91,124,250,.55); }
/* 分组背景框 (留白处可点击选中整组/拖动/缩放; 节点在其上层, 仍可单独交互)。
   背景色统一, 不随是否获取焦点变化, 保证始终清晰可见。 */
.node-group {
  position: absolute; z-index: 0; pointer-events: auto; cursor: move;
  border: 1.5px dashed rgba(91,124,250,.55); border-radius: 16px;
  background: rgba(91,124,250,.12); box-shadow: inset 0 0 0 1px rgba(91,124,250,.1);
}
.node-group.selected { border-color: var(--primary); box-shadow: inset 0 0 0 1px rgba(91,124,250,.3); }
.node-group-label {
  position: absolute; top: 7px; left: 12px; pointer-events: auto; cursor: text;
  max-width: calc(100% - 24px); display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 8px; font-size: 12px; font-weight: 600;
  color: var(--primary2); background: rgba(91,124,250,.14); border: 1px solid rgba(91,124,250,.3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none;
}
.node-group-label:hover { background: rgba(91,124,250,.28); }
.node-group-input {
  font-size: 12px; font-weight: 600; padding: 1px 5px; border-radius: 5px; min-width: 80px;
  border: 1px solid var(--primary); background: var(--panel2); color: var(--text);
  outline: none; user-select: text; cursor: text;
}
/* 空格键抓手平移 */
#canvasWrap.space.panning { cursor: grabbing; }

/* 视频节点浮动生成面板 */
.node-dock {
  position: absolute; z-index: 40; width: 680px; max-width: calc(100% - 24px);
  background: rgba(255,255,255,.96); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 20px 50px rgba(30,40,90,.18); padding: 12px; cursor: default;
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
}
.node-dock.hidden { display: none; }
/* 放大态: 居中大面板 (默认居中; 拖拽调整大小后切换为左上角锚定的自由模式) */
.node-dock.expanded {
  position: fixed !important;
  left: 50%; top: 50%; right: auto; bottom: auto;
  transform: translate(-50%, -50%);
  width: min(900px, 90vw); height: min(80vh, 760px); max-width: none;
  z-index: 110;  /* 高于连线剪刀(.edge-cut z-index:90), 防止剪刀穿透弹层 */
}
/* 自由拖拽模式: 取消居中变换, 由 JS 写入 left/top/width/height 内联样式 */
.node-dock.expanded.dock-freed { transform: none; }
.node-dock.expanded .dock-prompt-wrap { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.node-dock.expanded .dock-prompt { flex: 1 1 auto; min-height: 240px; max-height: none; }
/* 右下角拖拽把手: 仅放大态显示 */
.dock-resize { display: none; }
.node-dock.expanded .dock-resize {
  display: block; position: absolute; right: 4px; bottom: 4px;
  width: 16px; height: 16px; cursor: nwse-resize; z-index: 5; opacity: .5;
  background:
    linear-gradient(135deg, transparent 0 46%, var(--muted) 46% 54%, transparent 54%),
    linear-gradient(135deg, transparent 0 72%, var(--muted) 72% 82%, transparent 82%);
}
.node-dock.expanded .dock-resize:hover { opacity: .9; }
.dock-chips { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.dock-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px;
  font-size: 12px; color: var(--text); background: rgba(0,0,0,.04);
  border: 1px solid var(--border); border-radius: 16px; cursor: pointer; user-select: none;
}
.dock-chip:hover { background: rgba(0,0,0,.07); }
.dock-expand { margin-left: auto; color: var(--muted); cursor: pointer; padding: 4px; display: inline-flex; align-items: center; }
.dock-expand:hover { color: var(--text); }
.dock-refs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.dock-warn {
  margin: -4px 0 10px; padding: 6px 10px; border-radius: 8px; font-size: 12px; line-height: 1.5;
  background: rgba(230, 90, 60, .1); border: 1px solid rgba(230, 90, 60, .35); color: #d8502e;
}
.dock-warn.info {
  background: rgba(91, 124, 250, .1); border-color: rgba(91, 124, 250, .35); color: #4a6af0;
}
body.editing .dock-warn.info { color: #93b0ff; }
.dock-thumb {
  position: relative; width: 56px; height: 56px; border-radius: 10px; overflow: hidden;
  background: rgba(0,0,0,.03); border: 1px solid var(--border);
}
.dock-thumb img { width: 100%; height: 100%; object-fit: cover; }
.dock-thumb .n {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,.6); color: #fff; font-size: 11px; display: flex;
  align-items: center; justify-content: center; z-index: 1;
}
.dock-thumb .del {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,.65); color: #fff; font-size: 11px; cursor: pointer; z-index: 2;
  display: none; align-items: center; justify-content: center;
}
.dock-thumb:hover .del { display: flex; }
.dock-thumb .del:hover { background: var(--err); }
.dock-thumb.audio {
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: linear-gradient(135deg, #7c5cff 0%, #34c6f4 100%); border-color: transparent;
}
.dock-thumb.audio .audio-ic {
  font-size: 24px; transition: opacity .12s;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)) brightness(1.15);
}
.dock-thumb.audio .audio-play {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  font-size: 20px; color: #fff; background: rgba(0,0,0,.5); z-index: 1;
}
.dock-thumb.audio:hover .audio-ic { opacity: 0; }
.dock-thumb.audio:hover .audio-play,
.dock-thumb.audio.playing .audio-play { display: flex; }
.dock-thumb.audio .audio-dur {
  position: absolute; left: 2px; bottom: 2px; z-index: 2;
  padding: 0 4px; height: 16px; border-radius: 8px;
  background: rgba(0,0,0,.65); color: #fff; font-size: 10px;
  display: flex; align-items: center; white-space: nowrap;
  font-variant-numeric: tabular-nums; pointer-events: none;
}
.dock-thumb.add {
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  color: var(--muted); cursor: pointer; border-style: dashed;
}
.dock-thumb.add:hover { color: var(--text); border-color: var(--primary); }
/* 参考视频缩略图: 直接用 video 的首帧, 角标标明类型 */
.dock-thumb.video video { width: 100%; height: 100%; object-fit: cover; }
.dock-thumb.video .video-ic {
  position: absolute; right: 2px; bottom: 2px; font-size: 12px; z-index: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.6));
}
/* 首/尾帧用途角标 */
.dock-thumb .role {
  position: absolute; left: 2px; bottom: 2px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 2;
}
.dock-thumb .role:hover { background: rgba(0,0,0,.8); }
.dock-thumb .role.role-first { background: var(--primary); }
.dock-thumb .role.role-last { background: #f0932b; }
/* 首尾帧模式下, 本次不会下发的参考素材 */
.dock-thumb.dim { opacity: .38; }
.dock-prompt {
  width: 100%; min-height: 68px; max-height: 320px; overflow-y: auto; border: none; outline: none;
  background: transparent; color: var(--text); font-size: 14px; line-height: 1.6;
  font-family: inherit; margin-bottom: 8px; white-space: pre-wrap; word-break: break-word;
}
.dock-prompt.is-empty::before {
  content: attr(data-ph); color: var(--muted); pointer-events: none;
}
/* @ 引用素材内联芯片 (缩略图 + @N) */
.mention-chip {
  display: inline-flex; align-items: center; gap: 4px; vertical-align: middle;
  padding: 1px 8px 1px 3px; margin: 0 1px; border-radius: 20px; line-height: 1.4;
  background: rgba(91,124,250,.2); border: 1px solid rgba(91,124,250,.55);
  color: var(--text); font-size: 13px; user-select: none;
}
.mention-chip .mc-img { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; display: block; }
.mention-chip .mc-ic {
  width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; border-radius: 50%; background: rgba(0,0,0,.08);
}
.mention-chip .mc-n { font-size: 12px; }
/* 参考缩略图悬停放大预览 */
.dock-thumb:not(.audio):not(.video) { cursor: zoom-in; }
.thumb-preview {
  position: fixed; z-index: 9999; padding: 4px; background: #ffffff;
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 18px 44px rgba(30,40,90,.2);
  pointer-events: none;
}
.thumb-preview.hidden { display: none; }
.thumb-preview img { display: block; max-width: 340px; max-height: 340px; border-radius: 8px; }
/* @ 引用素材候选列表 */
.dock-prompt-wrap { position: relative; }
.dock-mention {
  position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 30;
  width: 260px; max-height: 280px; overflow-y: auto;
  background: #ffffff; border: 1px solid var(--border); border-radius: 12px; padding: 6px;
  box-shadow: 0 18px 44px rgba(30,40,90,.18);
}
.dock-mention.hidden { display: none; }
.dock-mention-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px; cursor: pointer;
}
.dock-mention-item:hover, .dock-mention-item.active { background: rgba(0,0,0,.05); }
.dm-thumb {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 7px; overflow: hidden;
  background: rgba(0,0,0,.04); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.dm-thumb img { width: 100%; height: 100%; object-fit: cover; }
.dm-thumb .dm-audio { font-size: 16px; }
.dm-label { flex: 1; min-width: 0; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-key { flex-shrink: 0; font-size: 12px; color: var(--muted); }
.dock-bar { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
.dock-left { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; flex-wrap: nowrap; }
.dock-params { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.dock-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; margin-left: auto; }
.dock-model { position: relative; flex-shrink: 1; min-width: 0; }
.dock-model-btn {
  display: inline-flex; align-items: center; gap: 8px; max-width: 250px;
  background: rgba(0,0,0,.04); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 10px; font-size: 13px; cursor: pointer; outline: none;
}
.dock-model-btn:hover { background: rgba(0,0,0,.06); }
.dock-model-btn .mm-ic { color: #eab308; display: inline-flex; }
.dock-model-btn .mm-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-model-btn .mm-caret { color: var(--muted); font-size: 12px; }
.dock-model-menu {
  position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 10;
  width: 380px; max-width: 78vw; max-height: 60vh; overflow-y: auto;
  background: #ffffff; border: 1px solid var(--border); border-radius: 14px; padding: 8px;
  box-shadow: 0 18px 44px rgba(30,40,90,.18);
}
.dock-model-menu.hidden { display: none; }
.dock-model-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer;
}
.dock-model-item:hover { background: rgba(0,0,0,.04); }
.dock-model-item.active { background: rgba(0,0,0,.06); }
.mm-item-ic {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 9px; color: #eab308;
  display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.04);
}
.mm-item-main { flex: 1; min-width: 0; }
.mm-item-name { font-size: 14px; font-weight: 600; color: var(--text); }
.mm-desc { font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mm-item-price {
  flex-shrink: 0; font-size: 12px; color: var(--muted); background: rgba(0,0,0,.04);
  border-radius: 12px; padding: 3px 9px;
}
.mm-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }

/* 生成参数弹层 */
.dock-params { position: relative; flex-shrink: 0; }
.dock-params-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,.04); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 10px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.dock-params-btn:hover { background: rgba(0,0,0,.06); }
.dock-params-btn .pp-ic { color: var(--muted); }
.dock-params-btn .pp-caret { color: var(--muted); font-size: 12px; }
.dock-params-menu {
  position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 10; width: 340px; max-width: 80vw;
  background: #ffffff; border: 1px solid var(--border); border-radius: 14px; padding: 14px;
  box-shadow: 0 18px 44px rgba(30,40,90,.18);
}
.dock-params-menu.hidden { display: none; }
.pp-sec { margin-bottom: 14px; }
.pp-sec:last-child { margin-bottom: 0; }
.pp-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.pp-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.pp-grid.pp-two { grid-template-columns: repeat(2, 1fr); }
.pp-opt {
  background: rgba(0,0,0,.03); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 6px; font-size: 13px; cursor: pointer; text-align: center;
}
.pp-opt:hover { background: rgba(0,0,0,.06); }
.pp-opt.active { border-color: var(--text); background: rgba(0,0,0,.08); font-weight: 600; }
.pp-slider { display: flex; align-items: center; gap: 12px; }
.pp-slider input[type="range"] { flex: 1; accent-color: var(--primary); }
.pp-dur { font-size: 13px; color: var(--text); min-width: 34px; text-align: right; }
.pp-note { margin-top: 6px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.pp-seed { display: flex; align-items: center; gap: 8px; }
.pp-seed input {
  flex: 1; min-width: 0; background: rgba(0,0,0,.03); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 10px; font-size: 13px; outline: none;
}
.pp-seed .pp-opt { flex: 0 0 auto; padding: 9px 10px; }
.dock-p {
  background: rgba(0,0,0,.04); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 8px; font-size: 12px; outline: none; max-width: 120px; flex-shrink: 0;
}
.dock-hint { color: var(--muted); font-size: 12px; }
.dock-credits { color: var(--muted); font-size: 13px; white-space: nowrap; }
.dock-credits .sep { opacity: .5; margin: 0 2px; }
.dock-credits-note { font-size: 11px; margin-left: 2px; opacity: .75; }
.dock-gen {
  width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; transition: transform .12s, background .12s;
}
.dock-gen:hover:not(:disabled) { background: var(--primary2); transform: scale(1.08); }
.dock-gen.busy, .dock-gen:disabled { background: #c2c8d6; cursor: not-allowed; pointer-events: none; opacity: .85; }

/* 从画布选择参考模式 */
.ref-bar {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 12px; padding: 9px 12px 9px 16px;
  background: #2f6bff; color: #fff; border-radius: 14px; font-size: 14px;
  box-shadow: 0 12px 34px rgba(0,0,0,.45);
}
.ref-bar.hidden { display: none; }
.ref-bar-ic { display: inline-flex; font-size: 15px; transform: rotate(-45deg); }
.ref-bar-txt { font-weight: 600; }
.ref-bar-back {
  background: rgba(255,255,255,.22); color: #fff; border: none; border-radius: 8px;
  padding: 6px 12px; cursor: pointer; font-size: 13px;
}
.ref-bar-back:hover { background: rgba(255,255,255,.34); }
.ref-bar-x { background: transparent; border: none; color: #fff; cursor: pointer; font-size: 16px; padding: 2px 6px; line-height: 1; }
.ref-bar-x:hover { opacity: .8; }

#canvasWrap.ref-picking .node.ref-eligible { cursor: pointer; }
#canvasWrap.ref-picking .node.ref-eligible::after {
  content: '添加参考'; position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  padding: 6px 14px; background: rgba(0,0,0,.78); color: #fff; border-radius: 16px;
  font-size: 13px; font-weight: 600; white-space: nowrap; display: none; z-index: 7;
}
#canvasWrap.ref-picking .node.ref-selected::after { content: '取消选择'; }
#canvasWrap.ref-picking .node.ref-eligible:hover::after { display: block; }
#canvasWrap.ref-picking .node.ref-selected { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ============================================================
   画布编辑界面深色主题 (进入编辑器时 body.editing 生效)
   仅作用于顶栏 + 画布编辑区; 登录页 / 工作区列表保持浅色
   配色参考: 近黑画布底 + 细网点, 深色玻璃浮层, 浅灰文字
   ============================================================ */
body.editing {
  --bg: #161616;
  --panel: #1e1e1e;
  --panel2: #292929;
  --border: #343434;
  --text: #ededed;
  --muted: #8c8c8c;
  background: var(--bg);
  font-family: -apple-system, "PingFang SC", "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: .2px;
}

/* 画布底: 近黑 + 细网点 */
body.editing #canvasWrap {
  background-color: #191919;
  background-image: radial-gradient(circle, #2d2d2d 1px, transparent 1px);
}
body.editing #edgeSvg path { stroke: #4c4c4c; }

/* 顶栏在编辑器深色态: 深色实底 */
body.editing #topbar { background: rgba(26,26,26,.9); border-bottom-color: var(--border); }

/* 通用按钮 hover 浅底 -> 深底 */
body.editing button:hover { background: #333; }

/* 白底浮层 -> 深色玻璃 */
body.editing .canvas-menu,
body.editing .canvas-item-menu,
body.editing .thumb-preview,
body.editing .dock-mention,
body.editing .dock-model-menu,
body.editing .dock-params-menu { background: #202020; }
body.editing .node-dock { background: rgba(28,28,28,.94); }
body.editing .canvas-inline-input { background: #202020 !important; }

/* 深底上黑色叠层不可见 -> 改为白色叠层 (hover / active) */
body.editing .canvas-menu-item:hover,
body.editing .canvas-menu-item.active,
body.editing .canvas-item-menu .cim-item:hover,
body.editing .dock-model-item:hover,
body.editing .dock-mention-item:hover,
body.editing .dock-mention-item.active { background: rgba(255,255,255,.06); }

/* 深底上淡底控件 */
body.editing .canvas-menu-item.renaming,
body.editing .dock-chip,
body.editing .dock-thumb,
body.editing .dock-model-btn,
body.editing .dock-params-btn,
body.editing .dock-p,
body.editing .dm-thumb,
body.editing .mm-item-ic,
body.editing .mm-item-price,
body.editing .pp-opt,
body.editing .pp-seed input { background: rgba(255,255,255,.05); }

/* 深底上 hover 加深 */
body.editing .canvas-menu-item .canvas-more:hover,
body.editing .dock-chip:hover,
body.editing .dock-model-btn:hover,
body.editing .dock-model-item.active,
body.editing .dock-params-btn:hover,
body.editing .pp-opt:hover { background: rgba(255,255,255,.1); }

body.editing .pp-opt.active { background: rgba(255,255,255,.14); border-color: var(--text); }
body.editing .mention-chip .mc-ic { background: rgba(255,255,255,.14); }

/* 生成按钮禁用态 */
body.editing .dock-gen.busy,
body.editing .dock-gen:disabled { background: #3a3a3a; }

/* ---------- 浮动面板备注行: 失败原文 / 结算摘要 ---------- */
.dock-note {
  margin: -4px 0 10px; padding: 6px 10px; border-radius: 8px; font-size: 12px; line-height: 1.5;
  cursor: pointer; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.dock-note.err {
  background: rgba(230, 90, 60, .1); border: 1px solid rgba(230, 90, 60, .35); color: #d8502e;
}
.dock-note.ok {
  background: rgba(34, 197, 94, .08); border: 1px solid rgba(34, 197, 94, .3); color: #16a34a;
}
body.editing .dock-note.ok { color: #4ade80; }

/* ---------- 编辑器侧栏 (剧本 / 角色库) ---------- */
.side-panel {
  position: absolute; top: 12px; left: 72px; bottom: 12px; width: 400px; max-width: calc(100vw - 90px);
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 18px 44px rgba(0,0,0,.22); z-index: 30;
  display: flex; flex-direction: column; overflow: hidden;
}
.sp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 600; color: var(--text); flex-shrink: 0;
}
.sp-close {
  width: 28px; height: 28px; border-radius: 8px; border: none; background: transparent;
  color: var(--muted); font-size: 14px; cursor: pointer;
}
.sp-close:hover { background: rgba(128,128,128,.15); color: var(--text); }
.sp-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.sp-sec { margin-bottom: 18px; }
.sp-sec-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.sp-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.sp-row label { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.sp-row input, .sp-row select {
  flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel2); color: var(--text); font-size: 13px;
}
.sp-row input[type="number"] { flex: none; width: 72px; }
.sp-input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel2); color: var(--text); font-size: 13px; resize: vertical; margin-bottom: 8px;
}
.sp-warn { font-size: 12px; color: var(--warn); }
.sp-hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.sp-empty { font-size: 13px; color: var(--muted); line-height: 1.8; padding: 18px 6px; text-align: center; }
.sp-gen, .sp-board { flex-shrink: 0; }
.sp-board { width: 100%; padding: 9px 0; font-size: 14px; }
.sp-shots { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.sp-shot { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--panel2); }
.sp-shot-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.sp-shot-seq { font-weight: 600; color: var(--text); flex-shrink: 0; }
.sp-shot-dur { width: 52px !important; flex: none !important; }
.sp-shot-size, .sp-shot-move { width: 64px !important; flex: none !important; }
.sp-shot-head input {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--panel); color: var(--text); font-size: 12px;
}
.sp-shot-del {
  margin-left: auto; width: 24px; height: 24px; border-radius: 6px; border: none;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 12px;
}
.sp-shot-del:hover { color: var(--err); background: rgba(231,76,60,.12); }
.sp-shot textarea {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); color: var(--text); font-size: 13px; resize: vertical;
}
.sp-shot-ops { justify-content: flex-end; }

/* 角色库 */
.cp-toolbar { margin-bottom: 12px; }
.cp-form { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--panel2); }
.cp-ref-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); }
.cp-list { display: flex; flex-direction: column; gap: 10px; }
.cp-card {
  display: flex; gap: 12px; border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; background: var(--panel2);
}
.cp-thumb {
  width: 76px; height: 76px; border-radius: 10px; overflow: hidden; flex-shrink: 0;
  background: rgba(128,128,128,.12); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 26px;
}
.cp-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cp-thumb-empty { cursor: default; color: var(--muted); }
.cp-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cp-name { font-size: 14px; font-weight: 600; color: var(--text); }
.cp-desc {
  font-size: 12px; color: var(--muted); margin: 3px 0 6px; line-height: 1.5;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.cp-ops { display: flex; gap: 6px; margin-top: auto; flex-wrap: wrap; }
.cp-ops button { padding: 4px 9px; font-size: 12px; }
.cp-del { margin-left: auto; }
.cp-del:hover { color: var(--err); }

/* ---------- 管理后台: 模型按量结算标记 / 结算异常任务 ---------- */
.model-usage-tag {
  font-size: 12px; font-weight: 400; color: var(--primary);
  background: rgba(91,124,250,.12); border-radius: 5px; padding: 1px 7px; margin-left: 6px;
}
.anomaly-card { margin-top: 16px; }
.anomaly-ctl { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.anomaly-ctl select { padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); font-size: 13px; }
.anomaly-intro { font-size: 12px; color: var(--muted); margin-bottom: 10px; line-height: 1.6; }

/* 生成日志表格: 图片缩略图与视频同款 */
.gen-table .gen-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* 生成日志筛选条: 日期输入不被压瘪 */
.gen-filter-bar input[type="date"] { max-width: 140px; }
