/* ============ AI 创作工作台 ============ */
:root {
  /* 狸猫暖色主题（深色） */
  --bg: #141110;
  --bg2: #1a1614;
  --panel: #201a16;
  --panel2: #282019;
  --border: #3a2f24;
  --text: #f3ede4;
  --text-dim: #a39483;
  --accent: #f59e0b;
  --accent2: #ef6c3d;
  --green: #4ade80;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, .25);
  --glow: rgba(245, 158, 11, .18);
  --edge: #dbe1ec;
  --edge-glow: rgba(199, 210, 254, .6);
}
/* 浅色主题 */
html[data-theme="light"] {
  --bg: #f7f1e7;
  --bg2: #fffcf5;
  --panel: #fffdf7;
  --panel2: #f4ead9;
  --border: #e4d6bf;
  --text: #2c2418;
  --text-dim: #97876f;
  --shadow: 0 10px 30px rgba(120, 90, 40, .12);
  --shadow-sm: 0 4px 14px rgba(120, 90, 40, .10);
  --glow: rgba(245, 158, 11, .22);
  --edge: #43536e;
  --edge-glow: rgba(99, 102, 241, .3);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
[hidden] { display: none !important; }  /* 修复：hidden 属性不被 flex/grid 覆盖 */
body {
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); overflow: hidden;
}

.app { display: flex; height: 100vh; }

/* ---------- 启动加载屏 ---------- */
.splash {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; transition: opacity .4s ease;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash img {
  width: 84px; height: 84px; border-radius: 20px;
  animation: splashPulse 1.6s ease-in-out infinite;
  box-shadow: 0 8px 40px rgba(99, 102, 241, .3);
}
.splash-name { color: var(--text); font-size: 17px; font-weight: 700; letter-spacing: 3px; }
.splash-bar {
  width: 140px; height: 3px; border-radius: 2px;
  background: var(--border); overflow: hidden;
}
.splash-bar span {
  display: block; width: 40%; height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  animation: splashSlide 1.1s ease-in-out infinite;
}
@keyframes splashPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
@keyframes splashSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 190px; flex-shrink: 0; background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px;
  transition: width .2s ease, padding .2s ease; overflow: hidden;
}
/* 折叠态：只显示狸猫图标和导航图标，点 logo 展开 */
.sidebar.collapsed { width: 66px; padding: 18px 8px; }
.sidebar.collapsed .logo { justify-content: center; padding: 4px 0 14px; cursor: pointer; }
.sidebar.collapsed .logo span, .sidebar.collapsed .collapse-btn,
.sidebar.collapsed .nav-btn span, .sidebar.collapsed .price-tag,
.sidebar.collapsed .credits-row { display: none; }
.sidebar.collapsed .nav-btn { justify-content: center; padding: 11px 8px; }
.sidebar.collapsed .nav-btn svg { flex-shrink: 0; }
.sidebar.collapsed .user-box { display: flex; justify-content: center; padding: 8px 2px; }
.sidebar.collapsed .side-avatar { width: 34px; height: 34px; }
.sidebar.collapsed .user-top { justify-content: center; }
.sidebar.collapsed .logo-img { cursor: pointer; }
/* 侧边栏版本号：logo 下方特小字 */
.side-version {
  text-align: center; font-size: 9px; color: var(--text-dim);
  opacity: .65; padding: 3px 0 8px; letter-spacing: .4px;
  user-select: none; flex-shrink: 0;
}
.sidebar.collapsed .side-version { font-size: 8px; padding: 2px 0 6px; }
.collapse-btn {
  margin-left: auto; background: none; border: 1px solid var(--border);
  color: var(--text-dim); width: 22px; height: 22px; border-radius: 6px;
  cursor: pointer; font-size: 13px; line-height: 1; flex-shrink: 0;
}
.collapse-btn:hover { color: var(--text); border-color: var(--accent); }
.logo {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px 18px;
  font-weight: 700; font-size: 14px; color: var(--text);
  white-space: nowrap; overflow: hidden;
}
.logo-img { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.logo span { white-space: nowrap; }
.auth-logo .auth-logo-img { width: 72px; height: 72px; border-radius: 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-btn {
  display: flex; align-items: center; gap: 9px; padding: 7px 11px;
  background: none; border: none; color: var(--text-dim); font-size: 13px;
  border-radius: 9px; cursor: pointer; transition: all .15s; text-align: left;
}
.nav-btn svg { width: 17px; height: 17px; }
.nav-btn:hover { background: var(--panel); color: var(--text); }
.nav-btn.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.mode-badge {
  display: flex; align-items: center; gap: 7px; padding: 9px 12px;
  background: var(--panel); border-radius: 9px; font-size: 12px; color: var(--text-dim);
}
.mode-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

/* ---------- 主区域 ---------- */
.main { flex: 1; overflow-y: auto; }
.view { display: none; padding: 28px 32px; min-height: 100vh; }
.view.active { display: block; }
.view-head { margin-bottom: 22px; }
.view-head h1 { font-size: 22px; font-weight: 700; }
.view-head .sub { color: var(--text-dim); font-size: 13px; margin-top: 6px; }

/* ---------- 面板 ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow-sm);
}
.image-layout { display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: stretch; }
@media (max-width: 900px) { .image-layout { grid-template-columns: 1fr; } }
/* 结果面板与左侧操作面板等高；显示区高度恒定且缩略图条始终可见 */
.result-panel { display: flex; flex-direction: column; }
.img-scroll { flex: 1 1 auto; min-height: 360px; overflow: visible; }
.recent-wrap { flex-shrink: 0; }
.img-grid { min-height: 360px; align-content: start; }

label { display: block; font-size: 13px; color: var(--text-dim); margin: 14px 0 6px; }
label:first-child { margin-top: 0; }
textarea, input[type="text"], input[type="password"], select {
  width: 100%; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 9px; padding: 10px 12px; color: var(--text);
  font-size: 13px; font-family: inherit; resize: vertical; outline: none;
}
textarea:focus, input:focus, select:focus { border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 0; }
.row2 label { margin-top: 14px; }

.btn {
  border: none; border-radius: 9px; padding: 11px 16px; font-size: 14px;
  cursor: pointer; font-family: inherit; transition: all .15s; margin-top: 16px;
}
.btn.primary {
  width: 100%; background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.12); }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--border); width: 100%; }
.btn.ghost:hover { border-color: var(--accent); }
.btn.small { width: auto; padding: 6px 12px; font-size: 12px; margin-top: 0; }
.hint { font-size: 12px; color: var(--text-dim); margin-top: 10px; line-height: 1.6; }
.hint.ok { color: var(--green); }
.hint.err { color: #f87171; }

/* ---------- 结果区 ---------- */
.result-panel { min-height: 420px; }
.result-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; font-size: 14px; color: var(--text-dim); }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.img-card { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); cursor: pointer; }
.img-card img { width: 100%; display: block; }
.img-card .add-tag {
  position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.65);
  color: #fff; font-size: 11px; padding: 4px 9px; border-radius: 6px; opacity: 0; transition: opacity .15s;
}
.img-card:hover .add-tag { opacity: 1; }
.placeholder {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: center;
  min-height: 320px; border: 1px dashed var(--border); border-radius: 10px; color: var(--text-dim); font-size: 13px;
}
.video-box { display: flex; justify-content: center; }
.video-box video, .video-box img { max-width: 100%; border-radius: 10px; border: 1px solid var(--border); }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-box { grid-column: 1 / -1; text-align: center; padding: 60px 0; color: var(--text-dim); font-size: 13px; }
.loading-box .spinner { margin-bottom: 14px; }

/* ---------- 画布 ---------- */
#view-canvas { padding: 0; display: none; flex-direction: column; }
#view-canvas.active { display: flex; }
#canvas-editor { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#canvas-editor[hidden] { display: none !important; }
#canvas-home { flex: 1; min-height: 0; }
#canvas-home[hidden] { display: none !important; }
.canvas-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  background: var(--bg2); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.tool-btn {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 7px 13px; border-radius: 8px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.tool-btn:hover { border-color: var(--accent); }
.tool-btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: #fff; }
.tool-btn.danger { color: #f87171; border-color: rgba(248,113,113,.4); }
.tool-btn.danger:hover { background: rgba(248,113,113,.12); }
.sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }
.tool-select {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 6px 8px; border-radius: 8px; font-size: 12px; font-family: inherit; max-width: 190px;
}
.flex-sp { flex: 1; }
#zoom-label { font-size: 12px; color: var(--text-dim); min-width: 44px; text-align: center; }
.canvas-tip { font-size: 11px; color: var(--text-dim); margin-left: auto; }
#canvas-save-state { font-size: 11px; color: var(--text-dim); margin-left: auto; }
.canvas-wrap {
  flex: 1; position: relative; overflow: hidden; cursor: grab;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 32px 32px;
}
.canvas-wrap.dragging { cursor: grabbing; }
/* 世界层 */
.canvas-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; z-index: 2; }
.canvas-edges { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 1; }
/* 连线：底层粗光晕 + 上层实线（不用 filter —— 0 尺寸 SVG 上 drop-shadow 会被整体裁剪导致连线不可见） */
.canvas-edges .edge-glow {
  fill: none; stroke: var(--edge-glow); stroke-width: 10; opacity: .55; stroke-linecap: round; pointer-events: none;
}
.canvas-edges .edge-line {
  fill: none; stroke: var(--edge); stroke-width: 3.5; opacity: 1; stroke-linecap: round; pointer-events: none;
}
.canvas-edges .edge-dot { fill: var(--edge); stroke: var(--bg2); stroke-width: 1.5; }
.canvas-edges .edge-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.canvas-edges .edge-hit:hover ~ .edge-line { stroke: #f87171; stroke-width: 4.5; }
.canvas-edges .edge-draft { fill: none; stroke: var(--accent2); stroke-width: 2.5; stroke-dasharray: 6 4; }
.canvas-select-box {
  position: absolute; border: 1px dashed var(--accent);
  background: rgba(99, 102, 241, .08); z-index: 30; pointer-events: none;
}
/* ---------- 画布项目列表（首页） ---------- */
.cv-home { padding: 24px 32px; overflow-y: auto; height: 100%; }
.cv-home-ops { display: flex; gap: 10px; margin-bottom: 18px; }
.cv-projects {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px;
}
.cv-proj-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; transition: transform .15s, border-color .15s;
}
.cv-proj-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.cv-proj-card.expiring { border-color: rgba(251, 146, 60, .5); }
.cv-p-name { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-p-meta { font-size: 11px; color: var(--text-dim); margin: 8px 0 12px; line-height: 1.7; }
.cv-p-meta .warn { color: #fb923c; }
.cv-p-ops { display: flex; gap: 6px; flex-wrap: wrap; }
.cv-p-ops .tool-btn { padding: 5px 11px; font-size: 12px; }
/* 编辑器左上项目名 */
.cv-proj-name { font-size: 13px; font-weight: 700; color: var(--text); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* ---------- 节点卡片 ---------- */
.cv-node {
  position: absolute; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 4px 18px rgba(0, 0, 0, .25);
  font-size: 12px; color: var(--text); user-select: none;
}
.cv-node.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--glow), 0 6px 22px rgba(0, 0, 0, .3); }
.cv-head {
  display: flex; align-items: center; gap: 7px; padding: 7px 10px;
  border-bottom: 1px solid var(--border); cursor: move;
}
.cv-tag {
  font-size: 10px; padding: 1px 7px; border-radius: 6px; flex-shrink: 0;
  background: var(--panel2); color: var(--text-dim);
}
.cv-tag.t-shot { background: rgba(99, 102, 241, .18); color: #818cf8; }
.cv-tag.t-character { background: rgba(245, 158, 11, .16); color: var(--accent); }
.cv-tag.t-scene { background: rgba(52, 211, 153, .14); color: #34d399; }
.cv-tag.t-doc { background: rgba(56, 189, 248, .14); color: #38bdf8; }
.cv-title {
  flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: text; min-width: 0;
}
.cv-x {
  background: none; border: none; color: var(--text-dim); font-size: 15px;
  cursor: pointer; padding: 0 2px; line-height: 1; flex-shrink: 0;
}
.cv-x:hover { color: #f87171; }
.cv-body { padding: 8px 10px 9px; }
.cv-ops { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.cv-ops .tool-btn { padding: 4px 10px; font-size: 11px; }
.cv-status { margin-top: 6px; font-size: 10.5px; color: var(--text-dim); }
.cv-status.generating { color: var(--accent); }
.cv-status.failed { color: #f87171; }
.cv-status.done { color: var(--green); }
.cv-dot {
  position: absolute; top: 50%; width: 11px; height: 11px; border-radius: 50%;
  background: var(--panel2); border: 2px solid var(--accent); cursor: crosshair;
  transform: translateY(-50%) scale(0); transition: transform .15s; z-index: 3;
}
.cv-node:hover .cv-dot { transform: translateY(-50%) scale(1); }
.cv-dot.dot-l { left: -7px; } .cv-dot.dot-r { right: -7px; }
/* 右下角缩放手柄（传统画布自由调整节点大小） */
.cv-resize {
  position: absolute; right: -5px; bottom: -5px; width: 14px; height: 14px;
  background: var(--panel2); border: 2px solid var(--accent); border-radius: 4px;
  cursor: nwse-resize; z-index: 4; opacity: .4;
}
.cv-node:hover .cv-resize { opacity: 1; }
/* 便签 / 备注 / 提示词 */
.cv-note, .cv-shot-prompt {
  width: 100%; background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 6px 8px; font-size: 11.5px; font-family: inherit;
  resize: vertical; min-height: 0; line-height: 1.5;
}
.cv-note:focus, .cv-shot-prompt:focus { outline: none; border-color: var(--accent); }
/* 剧本文档卡 */
.cv-doc-text {
  max-height: 280px; overflow-y: auto; white-space: pre-wrap; line-height: 1.7;
  font-size: 11.5px; color: var(--text); user-select: text;
}
/* 分镜卡 */
.cv-shot-img {
  height: 130px; border-radius: 8px; overflow: hidden; background: var(--panel2);
  display: flex; align-items: center; justify-content: center; cursor: zoom-in; margin-bottom: 7px;
}
.cv-shot-img img { width: 100%; height: 100%; object-fit: cover; }
.cv-empty { color: var(--text-dim); font-size: 11px; text-align: center; line-height: 1.8; }
.cv-empty small { opacity: .7; }
.cv-meta { display: flex; justify-content: space-between; align-items: center; font-size: 10.5px; color: var(--text-dim); }
.cv-refs { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-ratio {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; font-size: 10.5px; padding: 2px 4px; font-family: inherit;
}
/* 分镜卡内嵌模型/参数（每卡独立，互不影响） */
.cv-models { display: flex; gap: 5px; margin-top: 6px; }
.cv-models select {
  flex: 1; min-width: 0; background: var(--panel2); border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 6px; font-size: 10px; font-family: inherit;
  padding: 2px 3px; max-width: 50%; cursor: pointer;
}
.cv-models select:focus { outline: none; border-color: var(--accent); color: var(--text); }
/* 角色 / 场景卡 */
.cv-imggrid { display: flex; flex-wrap: wrap; gap: 6px; }
.cv-imgcell { position: relative; width: 60px; height: 60px; border-radius: 8px; overflow: hidden; }
.cv-imgcell img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.cv-imgdel {
  position: absolute; right: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff; border: none; font-size: 11px;
  cursor: pointer; line-height: 1; display: none;
}
.cv-imgcell:hover .cv-imgdel { display: block; }
.cv-imgadd {
  width: 60px; height: 60px; border: 1px dashed var(--border); border-radius: 8px;
  background: none; color: var(--text-dim); cursor: pointer; font-size: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-family: inherit;
}
.cv-imgadd:hover { border-color: var(--accent); color: var(--accent); }
.cv-imgadd small { font-size: 9px; }
.cv-img { width: 100%; border-radius: 8px; display: block; cursor: zoom-in; }
.cv-node.cv-video video { width: 100%; border-radius: 8px; display: block; }
/* ---------- 工具栏下拉 ---------- */
.tb-dd { position: relative; }
.tb-dd-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 10px;
  padding: 5px; min-width: 210px; box-shadow: var(--shadow-sm);
}
.tb-dd-menu button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--text); font-size: 12.5px; font-family: inherit; padding: 8px 10px;
  border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.tb-dd-menu button:hover { background: var(--panel); color: var(--accent); }
/* ---------- 小地图 ---------- */
.cv-minimap {
  position: absolute; left: 14px; bottom: 14px; z-index: 35;
  border: 1px solid var(--border); border-radius: 10px;
  background: rgba(10, 13, 20, .82); cursor: crosshair;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .35);
}
/* ---------- 节点搜索 ---------- */
.cv-search { position: relative; }
.cv-search input {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 6px 10px; border-radius: 8px; font-size: 12px; font-family: inherit; width: 150px;
}
.cv-search input:focus { outline: none; border-color: var(--accent); width: 190px; }
.cv-search-list {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 70;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 10px;
  min-width: 230px; max-height: 280px; overflow-y: auto; box-shadow: var(--shadow-sm); padding: 4px;
}
.cv-search-list [data-id] {
  display: flex; align-items: center; gap: 7px; padding: 7px 9px;
  border-radius: 7px; cursor: pointer; font-size: 12px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cv-search-list [data-id]:hover { background: var(--panel); color: var(--accent); }
.cv-search-list .st {
  font-size: 10px; padding: 1px 6px; border-radius: 5px; flex-shrink: 0;
  background: var(--panel); color: var(--text-dim);
}
.cv-search-list .st.t-shot { color: #818cf8; } .cv-search-list .st.t-character { color: var(--accent); }
.cv-search-list .st.t-scene { color: #34d399; } .cv-search-list .st.t-doc { color: #38bdf8; }
.cv-search-list .empty { padding: 8px 10px; font-size: 11px; color: var(--text-dim); }
/* ---------- 多选对齐工具条 ---------- */
.cv-align-bar {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 45; display: flex; align-items: center; gap: 2px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 12px;
  padding: 5px 8px; box-shadow: var(--shadow-sm);
}
.cv-align-bar button {
  background: none; border: none; color: var(--text); font-size: 15px;
  cursor: pointer; padding: 4px 8px; border-radius: 7px; font-family: inherit;
}
.cv-align-bar button:hover { background: var(--panel); color: var(--accent); }
.cv-align-bar span { width: 1px; height: 16px; background: var(--border); margin: 0 4px; }
/* ---------- 右键菜单 ---------- */
.cv-ctx-menu {
  position: absolute; z-index: 80; min-width: 170px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 10px;
  padding: 5px; box-shadow: var(--shadow-sm);
}
.cv-ctx-menu button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--text); font-size: 12.5px; font-family: inherit; padding: 7px 10px;
  border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.cv-ctx-menu button:hover { background: var(--panel); color: var(--accent); }
.cv-ctx-menu button.danger { color: #f87171; }
.cv-ctx-menu button.danger:hover { color: #f87171; background: rgba(248,113,113,.1); }
/* 搜索定位闪烁动效 */
@keyframes cvFlash { 0%, 60% { box-shadow: 0 0 0 3px var(--accent), 0 0 24px var(--glow); } 100% { box-shadow: 0 4px 18px rgba(0,0,0,.25); } }
.cv-node.flash { animation: cvFlash 1.2s ease; border-color: var(--accent); }
/* 分镜图加载骨架 */
.cv-shot-img { position: relative; }
.cv-shot-img img { background: linear-gradient(100deg, var(--panel2) 40%, var(--panel) 50%, var(--panel2) 60%); background-size: 200% 100%; animation: cvShimmer 1.4s infinite; }
@keyframes cvShimmer { to { background-position: -200% 0; } }

/* ---------- 剧本助手（右侧折叠抽屉） ---------- */
.canvas-agent { position: absolute; right: 0; top: 0; bottom: 0; z-index: 40; display: flex; }
.agent-tab {
  writing-mode: vertical-lr; letter-spacing: 4px; padding: 14px 7px;
  background: var(--panel2); border: 1px solid var(--border); border-right: none;
  border-radius: 10px 0 0 10px; color: var(--accent); font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; height: fit-content; margin-top: 18px;
}
.agent-tab:hover { background: var(--panel); }
.agent-panel {
  width: 300px; background: var(--bg2); border-left: 1px solid var(--border);
  display: none; flex-direction: column;
}
.canvas-agent.open .agent-panel { display: flex; }
.agent-head { padding: 12px 14px 8px; }
.agent-head b { font-size: 14px; }
.agent-sub { font-size: 10.5px; color: var(--text-dim); margin-left: 8px; }
.agent-ops { display: flex; flex-direction: column; gap: 6px; padding: 4px 14px 10px; border-bottom: 1px solid var(--border); }
.agent-ops .tool-btn { text-align: left; }
.agent-chat { flex: 1; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.agent-msg {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; font-size: 12px; line-height: 1.6; white-space: pre-wrap;
  word-break: break-word; max-width: 95%;
}
.agent-msg.me { align-self: flex-end; background: rgba(99, 102, 241, .15); border-color: rgba(99, 102, 241, .3); }
.agent-msg.bot.err { color: #f87171; }
.agent-copy {
  margin-top: 6px; background: var(--panel2); border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 6px; font-size: 10.5px; padding: 2px 8px;
  cursor: pointer; font-family: inherit;
}
.agent-copy:hover { color: var(--accent); border-color: var(--accent); }
.agent-input-row { display: flex; gap: 6px; padding: 10px 14px 14px; border-top: 1px solid var(--border); }
.agent-input-row textarea {
  flex: 1; background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 7px 9px; font-size: 12px; font-family: inherit; resize: none;
}
.agent-input-row textarea:focus { outline: none; border-color: var(--accent); }
.agent-input-row .tool-btn { align-self: flex-end; }

/* ---------- 设置 ---------- */
.settings-panel { max-width: 640px; }
/* 纯表格面板铺满全宽（实时状态/用户资产/兑换码/用户管理） */
#pane-status .settings-panel, #pane-assets .settings-panel,
#pane-codes .settings-panel, #pane-users .settings-panel { max-width: none; }
.settings-panel h2 {
  font-size: 14px; margin: 22px 0 4px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border); color: var(--accent);
}
.settings-panel h2:first-child { margin-top: 0; }
.settings-panel .row2 { margin-top: 16px; }
.settings-panel .btn { width: auto; margin-top: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 20px; border-radius: 10px; font-size: 13px; opacity: 0;
  pointer-events: none; transition: all .25s; z-index: 99; max-width: 70vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 退出动效 ---------- */
.logout-fx {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(12, 15, 22, .92); backdrop-filter: blur(6px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; animation: fxIn .35s ease;
}
.logout-fx img {
  width: 88px; height: 88px; border-radius: 22px;
  box-shadow: 0 8px 40px rgba(99, 102, 241, .35);
  animation: catBounce .8s cubic-bezier(.34, 1.56, .64, 1);
}
.logout-fx p { color: var(--text-dim); font-size: 14px; letter-spacing: 2px; animation: fxText .6s ease .15s both; }
@keyframes fxIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes catBounce {
  0% { transform: scale(.2) rotate(-20deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
@keyframes fxText { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ============ 用户区 / 鉴权 / 管理后台 ============ */

/* 侧边栏用户盒 */
.user-box {
  background: none; border: none;
  border-radius: 10px; padding: 10px 6px; margin-top: 8px;
}
.user-main { background: none; border: none; padding: 6px 8px; }
.user-top { display: flex; align-items: center; gap: 10px; }
.side-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover; border: 1px solid var(--border); flex-shrink: 0;
}
.credits-row { display: flex; align-items: baseline; gap: 6px; }
.credits-num { font-size: 20px; font-weight: 700; color: var(--green); }
.credits-label { font-size: 12px; color: var(--text-dim); }
.user-account { font-size: 12px; color: var(--text-dim); margin: 2px 0 10px; word-break: break-all; }
.user-top + .user-actions { margin-top: 4px; }
.user-actions { display: flex; gap: 6px; }
.user-actions .tool-btn { flex: 1; padding: 6px 4px; font-size: 12px; text-align: center; }

/* 个人资料弹窗 */
.profile-head { display: flex; align-items: center; gap: 16px; margin-top: 14px; }
.profile-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  object-fit: cover; border: 1px solid var(--border);
}
.modal-sub {
  font-size: 13px; color: var(--accent);
  margin: 20px 0 2px; padding-top: 12px; border-top: 1px solid var(--border);
}

/* 头像裁剪器（1:1） */
.cropper-frame {
  position: relative; width: 260px; height: 260px; margin: 10px auto 0;
  border-radius: 10px; overflow: hidden; background: var(--bg2);
  touch-action: none; user-select: none;
}
.cropper-frame canvas { position: absolute; inset: 0; cursor: move; }
.crop-mask {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at center, transparent 128px, rgba(0,0,0,.55) 129px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15);
}

/* 导航积分标签 */
.price-tag {
  margin-left: auto; font-style: normal; font-size: 11px; color: var(--text-dim);
  background: var(--panel2); border-radius: 6px; padding: 1px 6px;
}
.nav-btn.active .price-tag { color: #fff; background: rgba(255,255,255,.18); }

/* 登录 / 注册 */
.auth-overlay {
  position: fixed; inset: 0; background: var(--bg); z-index: 50;
  display: flex; align-items: center; justify-content: center;
  gap: clamp(40px, 8vw, 140px);
  overflow: hidden;
  padding: 40px 6vw;
}
.auth-overlay::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(640px 440px at 14% 20%, var(--glow), transparent 70%),
    radial-gradient(520px 420px at 88% 46%, rgba(239, 108, 61, .16), transparent 70%),
    radial-gradient(400px 300px at 55% 96%, rgba(245, 158, 11, .08), transparent 70%);
  pointer-events: none;
}
/* 左：品牌区（垂直居中） */
.auth-overlay .brand-slogan {
  position: relative; max-width: 400px;
  animation: sloganIn .8s ease both;
}
.auth-overlay .brand-slogan img {
  width: 128px; height: 128px; border-radius: 30px; margin-bottom: 24px;
  box-shadow: 0 16px 60px var(--glow);
}
.auth-overlay .brand-slogan h2 {
  font-size: 36px; line-height: 1.3; color: var(--text); font-weight: 800; letter-spacing: 1px;
}
.brand-slogan-main {
  margin-top: 12px; font-size: 17px; font-weight: 600;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  letter-spacing: 1px;
}
.brand-feats { list-style: none; margin-top: 26px; display: flex; flex-direction: column; gap: 14px; }
.brand-feats li {
  position: relative; padding-left: 16px; line-height: 1.5;
}
.brand-feats li::before {
  content: ""; position: absolute; left: 0; top: 5px; bottom: 5px; width: 3px;
  border-radius: 2px; background: linear-gradient(180deg, var(--accent), var(--accent2));
}
.brand-feats b { display: block; font-size: 14px; color: var(--text); }
.brand-feats span { font-size: 12px; color: var(--text-dim); }
/* 右：卡片列（卡片 + 底部版权，整体居中不空旷） */
.auth-right {
  position: relative; display: flex; flex-direction: column;
  align-items: center; gap: 16px;
  animation: cardUp .45s cubic-bezier(.22, 1, .36, 1);
}
@keyframes sloganIn { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@media (max-width: 1100px) {
  .auth-overlay .brand-slogan { display: none; }
  .auth-overlay { padding: 20px; }
}
.auth-card {
  width: 400px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px 32px 24px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .45), 0 0 0 6px var(--glow);
}
.auth-copy { font-size: 11px; color: var(--text-dim); letter-spacing: 1px; }
.auth-foot {
  margin-top: 14px; font-size: 11px; color: var(--text-dim);
  text-align: center; line-height: 1.6;
}
@keyframes cardUp {
  from { opacity: 0; transform: translateY(28px) scale(.96); }
  to { opacity: 1; transform: none; }
}
.auth-logo { text-align: center; margin-bottom: 22px; }
.auth-logo svg { color: var(--accent); }
.auth-logo h1 { font-size: 20px; margin-top: 8px; }
.auth-logo p { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.auth-tabs { display: flex; background: var(--bg2); border-radius: 9px; padding: 4px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; border: none; background: none; color: var(--text-dim);
  padding: 8px; font-size: 13px; border-radius: 7px; cursor: pointer; font-family: inherit;
}
.auth-tab.active { background: var(--accent); color: #fff; }
.auth-card .btn { width: 100%; margin-top: 18px; }
.auth-card .hint.err { margin-top: 12px; }

/* 按钮加载动效 */
.btn-spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  border-radius: 50%; margin-right: 8px; vertical-align: -2px;
  animation: spin 0.7s linear infinite;
}
.success-banner {
  display: block; background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.4);
  border-radius: 9px; padding: 10px 12px; font-size: 13px; color: var(--green);
}

/* 验证码行（grid 布局，避免输入框被压缩成细缝） */
.code-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.code-row .code-input { min-width: 0; }
.code-row .code-input input { width: 100%; }
.code-send { width: auto; margin: 0; white-space: nowrap; padding: 10px 12px; font-size: 12px; }
.code-send:disabled { opacity: .5; cursor: not-allowed; }
.mock-code-tip { font-size: 12px; color: #fbbf24; margin-top: 8px; line-height: 1.6; }

/* 图形人机验证 */
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row input { flex: 1; }
.captcha-img {
  height: 42px; border-radius: 9px; border: 1px solid var(--border);
  cursor: pointer; flex-shrink: 0; display: block;
}

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 60;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  width: 360px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 24px;
}
.modal h3 { font-size: 16px; }
.modal .sub { font-size: 12px; color: var(--text-dim); margin-top: 6px; }

/* 充值界面 */
.recharge-balance-panel { margin-bottom: 18px; }
.recharge-balance { font-size: 14px; }
.recharge-balance b { color: var(--green); font-size: 22px; margin: 0 4px; }
.recharge-panel { margin-bottom: 18px; }
.panel-h {
  font-size: 14px; color: var(--accent); margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.price-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
}
.price-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 16px 12px;
  text-align: center; background: var(--bg2); transition: border-color .15s, transform .15s;
}
.price-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.price-card .n { font-size: 13px; color: var(--text); margin-bottom: 8px; word-break: break-all; }
.price-card .p { font-size: 20px; font-weight: 700; color: var(--green); }
.price-card .p small { font-size: 11px; font-weight: 400; color: var(--text-dim); margin-left: 3px; }
.redeem-row { max-width: 520px; }
.redeem-row input { margin: 0; }
.redeem-row .btn { margin: 0; }

/* 充值弹窗（已改独立界面，保留通用样式） */
.recharge-modal { width: 420px; max-height: 82vh; overflow-y: auto; }
.recharge-balance { font-size: 13px; margin-top: 10px; }
.recharge-balance b { color: var(--green); font-size: 18px; }
.price-list { border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.price-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 14px; font-size: 13px; border-bottom: 1px solid var(--border);
}
.price-row:last-child { border-bottom: none; }
.price-row b { color: var(--green); font-weight: 600; }

/* 管理后台 */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.stat-card .v { font-size: 20px; font-weight: 700; }
.stat-card .k { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.admin-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.admin-tab {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text-dim);
  padding: 8px 18px; border-radius: 8px; cursor: pointer; font-size: 13px; font-family: inherit;
}
.admin-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.table-wrap { max-height: 380px; overflow: auto; border: 1px solid var(--border); border-radius: 9px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 500; position: sticky; top: 0; background: var(--panel2); }
td.mono { font-family: ui-monospace, monospace; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; }
.tag.ok { background: rgba(34,197,94,.15); color: var(--green); }
.tag.no { background: rgba(148,163,184,.15); color: var(--text-dim); }
.code-result { margin-top: 14px; }
.code-result textarea { font-family: ui-monospace, monospace; font-size: 12px; }

/* 最近生成缩略图条 */
.recent-wrap { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.recent-title { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.recent-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.recent-thumb {
  position: relative; width: 72px; height: 72px; flex-shrink: 0;
  border-radius: 8px; overflow: hidden; cursor: pointer;
  border: 2px solid var(--border); transition: border-color .15s;
}
.recent-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recent-thumb.sel { border-color: #facc15; box-shadow: 0 0 0 2px rgba(250, 204, 21, .35); }   /* 黄框：标出当前展示的一条 */
.recent-thumb .sel-tag {
  position: absolute; top: 2px; right: 2px; width: 16px; height: 16px;
  background: #facc15; color: #1c2333; border-radius: 50%;
  font-size: 11px; line-height: 16px; text-align: center; display: none;
}
.recent-thumb.sel .sel-tag { display: block; }
.recent-empty { color: var(--text-dim); font-size: 12px; padding: 4px 0; }

/* 参考图 */
.prompt-wrap { position: relative; }
.mention-menu {
  position: absolute; left: 10px; right: 10px; top: calc(100% - 6px);
  background: var(--panel2); border: 1px solid var(--accent); border-radius: 10px;
  max-height: 200px; overflow-y: auto; z-index: 30;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.mention-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 12px;
  cursor: pointer; font-size: 13px; color: var(--text);
}
.mention-item img { width: 30px; height: 30px; border-radius: 6px; object-fit: cover; }
.mention-item.active, .mention-item:hover { background: rgba(99,102,241,.25); }
.mention-empty { padding: 10px 12px; font-size: 12px; color: var(--text-dim); }

.ref-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.ref-cell { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.ref-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref-label {
  position: absolute; left: 0; bottom: 0; right: 0;
  background: rgba(0,0,0,.6); color: #fff; font-size: 10px;
  text-align: center; padding: 1px 0;
}
.ref-del {
  position: absolute; top: 0; right: 0; width: 18px; height: 18px;
  background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 0 0 0 6px;
  cursor: pointer; font-size: 12px; line-height: 16px; padding: 0;
}
.ref-add {
  width: 64px; height: 64px; border: 1px dashed var(--border); border-radius: 8px;
  background: none; color: var(--text-dim); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 16px; gap: 0; font-family: inherit;
}
.ref-add span { font-size: 10px; }
.ref-add:hover { border-color: var(--accent); color: var(--text); }
.ref-full {
  width: 64px; height: 64px; border: 1px dashed var(--border); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 10px; text-align: center;
}

/* 生成结果附加 */
.cost-tag { font-size: 12px; color: var(--green); margin-top: 10px; }

/* 单张大图占满结果区；「加入画布」缩小固定在右上角（预留其他功能位） */
.img-card.single {
  position: relative; grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: center;
  min-height: 360px; padding: 44px 12px 12px;
}
.img-card.single img { width: auto; max-width: 92%; max-height: 320px; min-height: 180px; object-fit: contain; }
.img-card.single .add-tag {
  position: absolute; top: 10px; right: 12px; bottom: auto; opacity: 1;
  padding: 5px 12px; font-size: 12px; border-radius: 8px;
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
}

/* ============ 移动端适配 ============ */
.mobile-user-menu { display: none; }

@media (max-width: 720px) {
  /* 手机端禁用无限画布入口 */
  .nav-btn[data-view="canvas"] { display: none !important; }
  /* 手机端头像下拉菜单 */
  .mobile-user-menu {
    display: flex; flex-direction: column; position: absolute; top: 100%; right: 8px;
    z-index: 95; min-width: 150px; background: var(--panel2);
    border: 1px solid var(--border); border-radius: 12px; padding: 5px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  }
  .mobile-user-menu button {
    background: none; border: none; color: var(--text); text-align: left;
    font-size: 13px; font-family: inherit; padding: 10px 12px; border-radius: 8px; cursor: pointer;
  }
  .mobile-user-menu button:hover, .mobile-user-menu button:active { background: var(--panel); color: var(--accent); }
  .mobile-user-menu button.danger { color: #f87171; }
  .mobile-user-menu[hidden] { display: none; }
  .user-panel { position: relative; }
  .app { flex-direction: column; }
  .admin-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .admin-tab { white-space: nowrap; flex-shrink: 0; }
  .modal { width: 92vw; }
  .view { padding: 14px; }
  .chat-dd-panel { left: 8px; right: 8px; }
  .table-wrap { font-size: 11px; }
  /* 一屏显示：应用锁定视口高度，仅内容区内部滚动；横向溢出一律禁掉 */
  html, body { height: 100%; overflow: hidden; }
  .app { height: 100vh; display: flex; }
  .main { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
  .sidebar {
    width: 100%; flex-direction: row; align-items: center;
    padding: 6px 8px; border-right: none; border-bottom: 1px solid var(--border);
    gap: 3px; flex-shrink: 0;
    position: relative; z-index: 100;   /* 盖过 .main，头像菜单不被内容区遮挡 */
    overflow: visible;                  /* 桌面规则 overflow:hidden 会裁掉下拉菜单 */
  }
  /* 手机端中和桌面折叠态（localStorage 残留 .collapsed 会把顶栏压成 66px 小方块） */
  .sidebar.collapsed { width: 100%; padding: 8px 10px; }
  .sidebar.collapsed .logo { justify-content: flex-start; padding: 0 6px 0 0; }
  .sidebar.collapsed .nav-btn { justify-content: center; padding: 6px 8px; }
  .sidebar.collapsed .nav-btn span { display: block; }
  .sidebar.collapsed .user-box { display: flex; justify-content: center; padding: 2px 4px; }
  .sidebar.collapsed .side-avatar, .sidebar.collapsed .flower-fallback { width: 32px; height: 32px; }
  .collapse-btn { display: none; }  /* 手机端无竖向折叠概念，隐藏 « 按钮 */
  .logo { padding: 0 4px 0 0; font-size: 14px; }
  .logo .logo-img { width: 30px; height: 30px; }
  .logo span { display: none; }
  .nav { flex-direction: row; flex: 1; gap: 0; justify-content: space-between; overflow-x: visible; }
  .nav-btn {
    flex: 1 1 0; min-width: 0; flex-direction: column; gap: 2px;
    padding: 5px 2px; font-size: 9.5px; border-radius: 8px;
  }
  .nav-btn svg { width: 17px; height: 17px; flex-shrink: 0; }
  .nav-btn span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .price-tag { display: none; }
  .user-box { padding: 2px 4px; margin: 0; border: none; background: none; }
  .user-panel { flex-direction: row; align-items: center; gap: 2px; }
  .user-main { background: none; border: none; padding: 0; gap: 6px; }
  .side-avatar, .flower-fallback { width: 32px; height: 32px; }
  /* 主规则 .u-btn/.user-meta 定义在媒体查询之后，必须 !important 才能生效（修复手机端按钮列表遮挡导航的 bug） */
  .user-meta, .u-btn, .side-version, .side-beian { display: none !important; }
  .ub-account { max-width: 60px; font-size: 11px; }
  .ub-credits { font-size: 10px !important; }
  .ub-credits b { font-size: 12px !important; }
  .credits-num { font-size: 14px; }
  .credits-label { display: none; }
  .view-head h1 { font-size: 18px; }
  .view-head .sub { font-size: 11px; }
  .panel, .control-panel { padding: 12px !important; }
  .gal-batch-bar { width: 96vw; justify-content: center; flex-wrap: wrap; gap: 6px; }
  /* 生成结果展示区：完整显示在手机屏幕内，不再固定 360px 高 / 92% 宽 */
  .result-panel { padding: 10px !important; min-width: 0 !important; }  /* 网格项不被内容最小宽度撑破 */
  .recent-thumb { flex-shrink: 1; min-width: 0; }  /* 缩略图可收缩，避免最小内容宽度撑破面板 */
  .img-scroll, .img-grid { min-height: 0 !important; }
  .img-scroll { overflow: hidden; }
  .img-grid { grid-template-columns: 1fr; }   /* 单列：防 minmax(200px) 撑破容器 */
  .img-card { min-width: 0; max-width: 100%; }
  .img-card.single { min-height: 0; padding: 40px 8px 8px; }
  .img-card.single img { max-width: 100% !important; max-height: 58vw; min-height: 0; }
  .result-ops { right: 8px; top: 8px; gap: 5px; }
  .op-btn { padding: 4px 8px; font-size: 11px; }
  /* 最近生成缩略图：手机端只展示最近 5 张 */
  #recent-strip .recent-thumb:nth-child(n+6) { display: none; }
  .recent-strip { overflow-x: hidden; justify-content: flex-start; }
  .recent-thumb { width: 60px; height: 60px; }
  .recent-title { font-size: 10.5px; }
  .table-wrap { overflow-x: auto; max-width: 100%; }
  .view, .panel, .control-panel, .gallery-grid, .prompt-list { max-width: 100%; }
  .view-head, .image-layout, .gallery-grid { min-width: 0; }
  img, video { max-width: 100%; }
  .main { flex: 1; overflow-y: auto; }
  .view { padding: 16px 14px; }
  .image-layout { grid-template-columns: 1fr; }
  .auth-card { width: 92vw; max-width: 380px; padding: 24px 20px; }
  .canvas-tip { display: none; }
}

/* ============ 剧本创作 ============ */
.script-layout {
  display: grid; grid-template-columns: 230px 1fr 340px; gap: 16px;
  align-items: stretch; height: calc(100vh - 150px); min-height: 520px;
}
@media (max-width: 1100px) {
  .script-layout { grid-template-columns: 1fr; height: auto; }
  .script-docs { min-height: 420px; }
}
.script-side { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.script-side-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 14px; }
.folder-list, .skill-list { flex: 1; overflow-y: auto; margin-bottom: 10px; }
.folder-item, .skill-item {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text);
}
.folder-item:hover, .skill-item:hover { background: var(--panel2); }
.folder-item.active { background: rgba(99,102,241,.22); }
.folder-item .fi-del, .skill-item .fi-del {
  margin-left: auto; background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 14px; padding: 0 2px;
}
.folder-item .fi-del:hover, .skill-item .fi-del:hover { color: #f87171; }
.skill-item .own-tag { font-size: 10px; color: var(--text-dim); margin-left: auto; }
.skill-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.script-docs { display: flex; flex-direction: column; min-height: 0; padding: 14px; }
.doc-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.doc-tab {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text-dim);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 12px; font-family: inherit;
}
.doc-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.doc-actions { display: flex; gap: 8px; margin-bottom: 10px; min-height: 30px; }
.doc-viewer { flex: 1; overflow-y: auto; min-height: 0; }
.doc-content {
  white-space: pre-wrap; font-size: 13px; line-height: 1.8; color: var(--text);
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 16px;
}
.doc-file-row {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.doc-file-row .open { color: var(--accent); cursor: pointer; margin-left: auto; }
.doc-file-row .del { color: var(--text-dim); cursor: pointer; }
.doc-file-row .del:hover { color: #f87171; }
.doc-img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.doc-img-grid img { width: 100%; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; }
.doc-img-name { font-size: 11px; color: var(--text-dim); margin-top: 3px; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.script-chat { display: flex; flex-direction: column; min-height: 0; padding: 14px; }
.chat-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  font-size: 14px; font-weight: 600; margin-bottom: 10px;
}
.chat-title { min-width: 0; margin-right: 8px; }
.chat-sub {
  font-weight: 400; font-size: 12px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; margin: -4px 0 8px;
}
.chat-dd-group { display: flex; gap: 6px; flex-shrink: 0; margin-top: -3px; }
.chat-skill-select {
  max-width: 200px; background: var(--bg2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 5px 8px; font-size: 12px; outline: none;
}
.skill-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.skill-chip {
  padding: 4px 11px; border-radius: 14px; border: 1px solid var(--border);
  font-size: 11px; cursor: pointer; color: var(--text-dim); background: var(--panel2);
  transition: all .15s; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.skill-chip:hover { border-color: var(--accent); color: var(--text); }
.skill-chip.on { background: rgba(99,102,241,.22); border-color: var(--accent); color: var(--text); }
.chat-messages { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; }
.chat-msg {
  max-width: 88%; padding: 9px 12px; border-radius: 12px;
  font-size: 13px; line-height: 1.7; white-space: pre-wrap; word-break: break-word;
}
.chat-msg.user { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.chat-msg.assistant { align-self: flex-start; background: var(--panel2); border: 1px solid var(--border); }
.script-chat textarea { margin-top: 10px; flex-shrink: 0; }
.script-chat .btn.primary { margin-top: 10px; }

/* 对话区右上角下拉按钮 */
.chat-dd-btn {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 5px 10px; border-radius: 8px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.chat-dd-btn:hover { border-color: var(--accent); }
.script-chat { position: relative; }
.chat-dd-panel {
  position: absolute; top: 44px; right: 14px; left: 14px; z-index: 40;
  background: var(--panel2); border: 1px solid var(--accent); border-radius: 10px;
  max-height: 240px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.dd-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--border);
}
.dd-row:last-child { border-bottom: none; }
.dd-row:hover { background: rgba(99,102,241,.18); }
.dd-row input { accent-color: var(--accent); }

/* 作品画廊 */
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px;
}
.gallery-item {
  position: relative;
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background: var(--bg2); transition: transform .15s, border-color .15s;
}
.gallery-item:hover { transform: translateY(-3px); border-color: var(--accent); }
.gallery-item img { width: 100%; height: 130px; object-fit: cover; display: block; cursor: zoom-in; }
.gallery-item.expired img { opacity: .3; filter: grayscale(1); }
.g-meta {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  gap: 2px 8px; padding: 7px 10px; font-size: 11px; color: var(--text-dim);
}
.g-dl { color: var(--accent); text-decoration: none; }
.g-dewm {
  color: var(--green); text-decoration: none; cursor: pointer;
  background: none; border: none; font-family: inherit; font-size: 11px; padding: 0;
}
.g-dewm:disabled { color: var(--text-dim); cursor: wait; }
.cv-vid-ops { display: flex; gap: 6px; margin-top: 6px; }
.cv-vid-ops .tool-btn { flex: 1; padding: 4px 8px; font-size: 11px; }
.g-expired { color: #f87171; }
/* 即将过期（剩余不足 24 小时）：标红倒计时 + 卡片橙红描边 */
.g-expiring { color: #fb923c; font-weight: 600; }
.gallery-item.expiring { border-color: rgba(251,146,60,.55); }
/* 画廊删除按钮：二次确认后删除 */
.g-del {
  background: none; border: none; color: #f87171; cursor: pointer;
  font-size: 11px; font-family: inherit; padding: 0; opacity: .75;
}
.g-del:hover { opacity: 1; text-decoration: underline; }
/* 画廊 24 小时过期提醒横幅 */
.gal-expire-banner {
  background: rgba(251,146,60,.1); border: 1px solid rgba(251,146,60,.45);
  color: var(--text); border-radius: 12px; padding: 10px 14px;
  font-size: 13px; margin-bottom: 14px;
}
.gal-expire-banner b { color: #fb923c; }
.gal-expire-banner a { color: var(--accent); }
.cat-tag {
  font-size: 10px; padding: 1px 7px; border-radius: 6px;
  background: rgba(245,158,11,.15); color: var(--accent); flex-shrink: 0;
}
.shot-gen-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px;
}
.gen-status { font-size: 11px; color: var(--text-dim); min-width: 90px; }

/* 画廊批量管理 */
#gal-manage-btn.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: #fff; }
.gal-check-wrap { position: absolute; left: 8px; top: 8px; z-index: 3; }
.gal-check-wrap input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.prompt-card .gal-check-wrap { position: static; margin-right: 4px; }
.gal-batch-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  z-index: 90; display: flex; align-items: center; gap: 10px;
  background: var(--panel2); border: 1px solid var(--border); border-bottom: none;
  border-radius: 14px 14px 0 0; padding: 10px 18px; box-shadow: var(--shadow-sm);
}
.gal-batch-bar .tool-btn { padding: 6px 12px; font-size: 12px; }
.gal-selall { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text); cursor: pointer; }
.gal-selall input { accent-color: var(--accent); }
#gal-sel-count { font-size: 12px; color: var(--accent); font-weight: 600; }
/* 画廊分类标签页 */
.gal-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.gal-tab {
  background: var(--panel); border: 1px solid var(--border); color: var(--text-dim);
  padding: 8px 16px; border-radius: 10px; cursor: pointer; font-size: 13px; font-family: inherit;
  transition: all .15s;
}
.gal-tab:hover { border-color: var(--accent); color: var(--text); }
.gal-tab.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: #fff; }
.gal-tab span { font-size: 11px; opacity: .85; }

/* 视频卡片 */
.gallery-item video { width: 100%; height: 130px; object-fit: cover; display: block; background: #000; cursor: zoom-in; }
.gallery-item.expired video { opacity: .3; filter: grayscale(1); }

/* 历史提示词列表 */
.prompt-list { display: flex; flex-direction: column; gap: 10px; }
.prompt-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; box-shadow: var(--shadow-sm);
}
.p-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.p-type { font-size: 11px; padding: 2px 9px; border-radius: 6px; flex-shrink: 0; }
.p-type.img { background: rgba(245, 158, 11, .15); color: var(--accent); }
.p-type.vid { background: rgba(239, 108, 61, .18); color: var(--accent2); }
.p-detail { font-size: 11px; color: var(--text-dim); }
.p-cost { font-size: 11px; color: var(--text-dim); }
.p-time { font-size: 11px; color: var(--text-dim); margin-left: auto; }
.p-copy { flex-shrink: 0; padding: 4px 10px; font-size: 11px; }
.p-text { font-size: 13px; line-height: 1.7; color: var(--text); word-break: break-word;
  background: var(--bg2); border-radius: 8px; padding: 10px 12px; }

/* 资产分组 / 视频资产 / Skill 引用 */
.group-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.group-chip {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text-dim);
  padding: 4px 12px; border-radius: 16px; cursor: pointer; font-size: 12px; font-family: inherit;
}
.group-chip:hover { border-color: var(--accent); color: var(--text); }
.group-chip.on { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: #fff; }
.group-chip.add { border-style: dashed; }
.group-chip.del { color: #f87171; }
.move-sel {
  background: var(--bg2); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 6px; padding: 3px 6px; font-size: 11px; outline: none; max-width: 110px;
}
.doc-img-move { margin-top: 4px; display: flex; justify-content: center; }
.video-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; margin-bottom: 10px;
}
.video-card video { width: 100%; max-height: 260px; border-radius: 8px; background: #000; }
.v-meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12px; }
.v-meta .del { color: var(--text-dim); cursor: pointer; }
.v-meta .del:hover { color: #f87171; }
.skill-refs { min-height: 4px; font-size: 11px; color: var(--text-dim); margin-bottom: 6px; }
.skill-ref {
  display: inline-flex; align-items: center; gap: 4px; margin: 2px 6px 2px 0;
  background: rgba(245, 158, 11, .14); color: var(--accent);
  padding: 2px 9px; border-radius: 12px;
}
.skill-ref i { cursor: pointer; font-style: normal; opacity: .7; }
.skill-ref i:hover { opacity: 1; }
/* 加入剧本按钮排在加入画布之下，同尺寸 */
.result-actions { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.result-actions .btn.small { width: 100%; }
.to-script-wrap { position: relative; }

/* ---------- 自定义编辑弹窗（替代系统 prompt/confirm） ---------- */
#pop-dialog { position: fixed; inset: 0; z-index: 300; }
.pop-box {
  position: fixed; width: 280px;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 14px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, .5), 0 0 0 4px var(--glow);
  padding: 16px;
  animation: popIn .16s ease;
}
@keyframes popIn { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }
.pop-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 10px; line-height: 1.5; }
.pop-msg { font-size: 12px; color: var(--text-dim); line-height: 1.7; margin-bottom: 4px; white-space: pre-wrap; }
.pop-input {
  width: 100%; background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 8px 10px; font-size: 13px; outline: none; margin-bottom: 4px;
}
.pop-input:focus { border-color: var(--accent); }
.pop-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.pop-btn {
  padding: 7px 18px; border-radius: 9px; font-size: 12px; cursor: pointer; font-family: inherit;
  border: 1px solid var(--border); background: var(--panel2); color: var(--text);
}
.pop-btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; color: #fff; }
.pop-btn.ghost:hover { border-color: var(--accent); }

/* 资产平铺小方块 + 放大查看 */
.doc-img-grid .asset-cell { position: relative; }
.asset-ops {
  position: absolute; top: 6px; right: 6px; display: none; gap: 4px; z-index: 5;
}
.asset-cell:hover .asset-ops { display: flex; }
.asset-ops .tool-btn { padding: 3px 8px; font-size: 10px; }
.asset-cell .doc-img-name { cursor: zoom-in; }
.asset-lightbox-img { max-width: 82vw; max-height: 70vh; border-radius: 12px; display: block; margin: 0 auto; }
.asset-lightbox video { max-width: 82vw; max-height: 70vh; border-radius: 12px; display: block; margin: 0 auto; background: #000; }
.lightbox-ops { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }

/* 聊天标题两行 */
.chat-title { display: flex; flex-direction: column; min-width: 0; }
.chat-title .t1 { font-size: 14px; font-weight: 700; color: var(--text); }
.chat-title .t2 { font-size: 11px; color: var(--text-dim); font-weight: 400; margin-top: 2px; }

/* 加入剧本下拉菜单 */
.to-script-wrap { position: relative; display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.to-script-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  width: 220px; max-height: 260px; overflow-y: auto;
  background: var(--panel2); border: 1px solid var(--accent); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.to-script-item {
  display: block; width: 100%; text-align: left; padding: 9px 14px; font-size: 13px;
  color: var(--text); background: none; border: none; border-bottom: 1px solid var(--border);
  cursor: pointer; font-family: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.to-script-item:hover { background: rgba(245, 158, 11, .16); color: var(--accent); }
.to-script-item:last-child { border-bottom: none; }
.to-script-empty { padding: 12px 14px; font-size: 12px; color: var(--text-dim); }

/* 服务条款 */
.agree-row {
  display: flex !important; align-items: flex-start; gap: 8px;
  margin-top: 4px; cursor: pointer; line-height: 1.6;
}
.agree-row input { width: auto; margin-top: 3px; accent-color: var(--accent); flex-shrink: 0; }
.agree-row span { font-size: 12px; color: var(--text-dim); }
.agree-row a, #link-terms {
  color: var(--accent); cursor: pointer; text-decoration: underline; font-size: 12px;
}
.terms-body { margin-top: 12px; }
.terms-body p {
  font-size: 12px; line-height: 1.9; color: var(--text-dim);
  margin-bottom: 12px; text-align: justify;
}
.terms-body b { color: var(--text); }

/* ---------- 全局滚动条（与主题一致，窄圆条） ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--panel2) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
::-webkit-scrollbar-corner { background: transparent; }

/* ---------- 剧本库 ＋ 按钮：无底色 + 点击旋转动效 ---------- */
.folder-item .fi-add {
  background: none !important; border: none !important; box-shadow: none;
  color: var(--text-dim); font-size: 15px; font-weight: 600;
  padding: 0 4px; cursor: pointer; line-height: 1;
  border-radius: 50%; transition: transform .4s cubic-bezier(.34, 1.56, .64, 1), color .15s;
}
.folder-item .fi-add:hover { color: var(--accent); transform: scale(1.25); }
.folder-item .fi-add:active { transform: rotate(180deg) scale(1.1); }
.folder-item .fi-add.spin { animation: fiSpin .45s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes fiSpin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* ---------- 引用剧本下拉 ---------- */
.dd-script-upload { padding: 8px 12px 10px; }

/* ---------- 生视频能力卡：参考槽位 / 计费预估 ---------- */
.vid-caps {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; font-size: 12px; color: var(--text-dim); margin-bottom: 10px;
}
.vid-caps b, .vid-cost b { color: var(--accent); }
.ref-note { font-size: 11px; color: var(--text-dim); font-weight: 400; }
.vid-refs { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.ref-group-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-dim); margin-bottom: 5px;
}
.ref-group-head .tool-btn { padding: 2px 10px; font-size: 11px; }
.ref-thumbs { display: flex; flex-wrap: wrap; gap: 6px; }
.ref-thumb {
  position: relative; width: 54px; height: 54px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: var(--panel2);
}
.ref-thumb img, .ref-thumb video { width: 100%; height: 100%; object-fit: cover; }
.ref-thumb .ref-audio {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.ref-del {
  position: absolute; right: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff; border: none; font-size: 11px;
  cursor: pointer; line-height: 1;
}
.vid-cost {
  background: rgba(245, 158, 11, .08); border: 1px solid rgba(245, 158, 11, .3);
  border-radius: 8px; padding: 7px 10px; font-size: 12px; color: var(--text-dim); margin-bottom: 4px;
}
.row3 { display: flex; gap: 4px; }
.row3 input { width: 100%; min-width: 0; }

/* ---------- 用户区（纵向列表：账号行 + 功能行） ---------- */
.user-box { display: flex; justify-content: center; padding: 4px 0 10px; }
.user-panel { display: flex; flex-direction: column; gap: 3px; width: 100%; }
/* 第一行：头像 + 账号 + 积分 */
.user-main {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--border);
  cursor: default; transition: border-color .2s;
}
.user-main:hover { border-color: var(--accent); }
.side-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.flower-fallback {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: var(--accent); background: var(--panel2);
}
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.ub-account {
  font-size: 12px; color: var(--text); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* 积分即充值入口 */
.ub-credits {
  background: none; border: none; padding: 0; font-family: inherit; cursor: pointer;
  font-size: 11px; color: var(--text-dim); text-align: left; white-space: nowrap;
}
.ub-credits b { color: var(--green); font-size: 14px; }
.ub-credits:hover b { text-decoration: underline; }
/* 功能行按钮 */
.u-btn {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 1px solid transparent; border-radius: 10px;
  padding: 7px 10px; font-size: 13px; font-family: inherit; color: var(--text-dim);
  cursor: pointer; width: 100%; text-align: left;
  transition: background .15s, color .15s;
}
.u-btn:hover { background: var(--panel); color: var(--text); }
.u-btn span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-ico { width: 20px; height: 20px; object-fit: contain; flex-shrink: 0; }
.u-btn > span:first-child, .u-btn > svg { flex-shrink: 0; width: 20px; text-align: center; font-size: 15px; }
.u-logout:hover { color: #f87171; }
/* 折叠态：只留头像 */
.sidebar.collapsed .user-meta, .sidebar.collapsed .u-btn { display: none; }
.sidebar.collapsed .user-main { background: none; border: none; padding: 2px; justify-content: center; }
.sidebar.collapsed .side-avatar, .sidebar.collapsed .flower-fallback { width: 34px; height: 34px; }
.sidebar.collapsed .user-box { padding: 4px 0; }
/* 入场动效：逐行淡入上移 */
.user-panel > * { animation: uRowIn .35s ease backwards; }
.user-panel > :nth-child(2) { animation-delay: .04s; }
.user-panel > :nth-child(3) { animation-delay: .08s; }
.user-panel > :nth-child(4) { animation-delay: .12s; }
.user-panel > :nth-child(5) { animation-delay: .16s; }
.user-panel > :nth-child(6) { animation-delay: .20s; }
@keyframes uRowIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 生成详情 / 标注编辑器 / 文档弹窗编辑 ---------- */
.detail-list { margin-top: 14px; }
.detail-row {
  display: flex; gap: 14px; padding: 8px 0;
  border-bottom: 1px solid var(--border); font-size: 13px; align-items: baseline;
}
.detail-row.col { flex-direction: column; gap: 6px; border-bottom: none; }
.detail-row .k { color: var(--text-dim); flex-shrink: 0; width: 64px; }
.detail-row .v { color: var(--text); word-break: break-all; }
.detail-row .v.prompt {
  background: var(--bg2); border-radius: 8px; padding: 10px 12px;
  line-height: 1.7; max-height: 130px; overflow-y: auto;
}
.anno-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; margin: 12px 0;
}
.anno-color { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.anno-color.on { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.anno-toolbar .tool-btn.on { border-color: var(--accent); color: var(--accent); }
.anno-wrap {
  background: repeating-conic-gradient(#1a1a1a 0% 25%, #222 0% 50%) 50% / 24px 24px;
  border-radius: 10px; padding: 10px; display: flex; justify-content: center;
}
#anno-canvas { max-width: 100%; cursor: crosshair; border-radius: 6px; }
#doc-view-text {
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 14px; outline: none; resize: vertical;
  font-family: inherit; white-space: pre-wrap;
}
#doc-view-text:focus { border-color: var(--accent); }

/* ---------- 结果区操作按钮（图片框内右上角竖排） ---------- */
.img-card.single { position: relative; }
.result-ops {
  position: absolute; right: 12px; top: 12px; z-index: 5;
  display: flex; flex-direction: column; gap: 8px; align-items: stretch;
}
.op-btn {
  background: rgba(20, 17, 16, .82); backdrop-filter: blur(4px);
  border: 1px solid var(--border); color: var(--text);
  padding: 7px 14px; border-radius: 9px; font-size: 12px;
  cursor: pointer; font-family: inherit; white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.op-btn:hover { border-color: var(--accent); color: var(--accent); }
.result-ops .to-script-wrap { position: relative; }
.result-ops .to-script-menu { top: calc(100% + 4px); right: 0; }
/* 详情缩略图 */
.detail-thumb {
  width: 100%; max-height: 180px; object-fit: contain; border-radius: 10px;
  background: var(--bg2); border: 1px solid var(--border); margin-top: 10px;
}
/* 对话中的文档卡片 */
.chat-msg.has-docs { display: flex; flex-direction: column; gap: 8px; max-width: 92%; }
.chat-msg .msg-text { white-space: pre-wrap; }
.doc-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg2); border: 1px solid var(--accent); border-radius: 10px;
  padding: 10px 14px; cursor: pointer; transition: transform .15s, box-shadow .15s;
}
.doc-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px var(--glow); }
.dc-icon { font-size: 18px; }
.dc-name { font-size: 13px; font-weight: 600; color: var(--text); flex: 1; }
.dc-open { font-size: 11px; color: var(--accent); }
.chat-doc-body {
  margin-top: 12px; padding: 16px; background: var(--bg2); border-radius: 10px;
  font-size: 13px; line-height: 1.8; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
  max-height: 62vh; overflow-y: auto; font-family: inherit;
}


/* ================= v0.9.2 用户体验批量升级 ================= */

/* 需求5：生视频左参数区滚动、右结果区固定 */
#view-video .image-layout { align-items: start; }
#view-video .control-panel {
  position: sticky; top: 16px;
  max-height: calc(100vh - 110px);
  overflow-y: auto; overscroll-behavior: contain;
  padding-right: 6px;
}
#view-video .result-panel { position: sticky; top: 16px; max-height: calc(100vh - 110px); overflow: hidden; }
#view-video .video-scroll { overflow-y: auto; flex: 1; min-height: 220px; display: flex; flex-direction: column; justify-content: center; }
#view-video .video-box { width: 100%; }
@media (max-width: 900px) {
  #view-video .control-panel, #view-video .result-panel { position: static; max-height: none; overflow: visible; }
}

/* 需求9：剧本助手标题不换行 */
.chat-title .t1 { white-space: nowrap; flex-shrink: 0; }
.chat-head .chat-dd-group { flex-shrink: 0; }

/* 需求6：视频最近作品条 */
#vid-recent-wrap { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
#vid-recent-strip .recent-thumb { width: 86px; height: 50px; border-radius: 8px; }

/* 需求7：添加参考图菜单 + 画廊选择器 */
.ref-add-menu {
  position: absolute; z-index: 60; min-width: 150px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35); padding: 6px; font-size: 13px;
}
.ref-add-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: 0; color: var(--text); padding: 8px 10px;
  border-radius: 7px; cursor: pointer; font-size: 13px; text-align: left;
}
.ref-add-menu button:hover { background: var(--panel2); }
.galpick-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px; overflow-y: auto; padding: 4px; min-height: 200px; max-height: 52vh;
}
.galpick-cell { position: relative; border-radius: 10px; overflow: hidden; cursor: pointer; border: 2px solid transparent; aspect-ratio: 1; background: var(--panel2); }
.galpick-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.galpick-cell.sel { border-color: var(--accent); }
.galpick-cell .gp-tag {
  position: absolute; right: 5px; top: 5px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12px; line-height: 20px; text-align: center;
  display: none; font-weight: 700;
}
.galpick-cell.sel .gp-tag { display: block; }
.gp-zoom {
  position: fixed; z-index: 90; pointer-events: none; display: none;
  border-radius: 12px; overflow: hidden; box-shadow: 0 14px 44px rgba(0,0,0,.5);
  border: 1px solid var(--border); background: var(--panel);
}
.gp-zoom img { display: block; max-width: 300px; max-height: 300px; object-fit: contain; }

/* 需求8：参考图拖动排序 */
.ref-thumb, .ref-cell { transition: opacity .12s; }
.ref-thumb.dragging, .ref-cell.dragging { opacity: .35; }
.ref-thumb.drop-target, .ref-cell.drop-target { outline: 2px dashed var(--accent); outline-offset: 2px; }
.ref-thumb { cursor: grab; }

/* 需求10：模型健康状态点 */
.model-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 5px; vertical-align: middle; background: var(--dot, #6b7280);
  box-shadow: 0 0 6px var(--dot, transparent);
}

/* 需求12：任务日志表 */
#logs-table { width: 100%; font-size: 12.5px; border-collapse: collapse; }
#logs-table th, #logs-table td { padding: 7px 9px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
#logs-table .log-err { color: #f87171; word-break: break-all; }
#logs-table .log-id { color: var(--text-dim); font-family: ui-monospace, monospace; }



/* 参考已满："+" 置灰禁用 */
.ref-add.ref-full, .tool-btn.ref-full { opacity: .3; cursor: not-allowed; }
.ref-add.ref-full:hover, .tool-btn.ref-full:hover { background: none; }

/* ============ 生视频两级模型下拉（点账号展开该账号可用模型） ============ */
.mdl-dd { position: relative; }
.mdl-dd-btn {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 12px; color: var(--text); font-size: 13px; font-family: inherit;
  cursor: pointer; text-align: left;
}
.mdl-dd-btn:hover, .mdl-dd-btn:focus { border-color: var(--accent); outline: none; }
.mdl-dd-btn #vid-model-btn-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.mdl-caret { color: var(--text-dim); font-size: 11px; flex-shrink: 0; }
.mdl-dd-panel {
  margin-top: 8px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg2); max-height: 300px; overflow-y: auto; padding: 6px;
  box-shadow: 0 10px 28px rgba(0,0,0,.35);
}
.mdl-group { font-size: 11px; color: var(--text-dim); padding: 8px 8px 4px; }
.mdl-item {
  display: flex; align-items: center; gap: 7px; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text);
}
.mdl-item:hover { background: rgba(124,108,255,.12); }
.mdl-item.sel { background: rgba(124,108,255,.22); color: var(--accent); }
.mdl-item .mdl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mdl-acc {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border-radius: 8px; cursor: pointer; font-size: 13px;
}
.mdl-acc:hover { background: rgba(124,108,255,.1); }
.mdl-acc-name { font-weight: 600; flex-shrink: 0; }
.mdl-acc-badges { font-size: 11.5px; color: var(--text-dim); flex: 1; }
.mdl-acc-caret { color: var(--text-dim); font-size: 11px; }
.mdl-acc-models { padding: 2px 0 4px 16px; }

/* 需求4：生视频页锁高——整页/结果区不再产生页面级滚动
   注意：display 必须只在 active 时定义，否则 ID 选择器会压掉 .view 的 display:none（全局视图切换 bug） */
#view-video.view.active { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
#view-video .view-head { flex-shrink: 0; }
#view-video .image-layout { flex: 1; min-height: 0; }
@media (max-width: 900px) { #view-video.view.active { height: auto; overflow: visible; } }

/* 需求9：结果展示区不产生轻微滚动，视频自适应容器 */
#view-video .video-scroll { overflow: hidden; }
#view-video .video-box { max-height: 100%; display: flex; align-items: center; justify-content: center; }
#view-video .video-box video { width: auto; max-width: 100%; max-height: calc(100vh - 210px); object-fit: contain; }

/* 任务日志：单行显示，列不互相挤压穿模
   注意：th 绝不能带 overflow:hidden——会破坏 position:sticky 的粘性（表头跟着滚走=穿模） */
#logs-table { table-layout: fixed; width: 100%; }
#logs-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--bg2); }
#logs-table td.log-clip { max-width: 220px; }
#logs-table td.log-err { max-width: 340px; }
/* sticky 必须挂在 thead 上：挂在 th 上会被父级 thead 的高度框住，滚过头就失效（穿模根源） */
#logs-table thead { position: sticky; top: 0; z-index: 2; background: var(--bg2); }
#logs-table th { background: var(--bg2); box-shadow: 0 1px 0 var(--border); }

/* 管理后台实时状态表：铺满宽度 + 列宽分配 + 不透明表头 */
#status-table { width: 100%; table-layout: fixed; }
#status-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--bg2); }
#status-table th:nth-child(1) { width: 92px; }   /* 任务ID */
#status-table th:nth-child(2) { width: 84px; }   /* 用户 */
#status-table th:nth-child(3) { width: 72px; }   /* 类型 */
#status-table th:nth-child(5) { width: 130px; }  /* 模型 */
#status-table th:nth-child(6) { width: 78px; }   /* 状态 */
#status-table th:nth-child(7) { width: 78px; }   /* 开始 */
#status-table th:nth-child(8) { width: 72px; }   /* 耗时 */
#status-table th:nth-child(9) { width: 220px; }  /* 错误 */
#status-table thead { position: sticky; top: 0; z-index: 2; background: var(--bg2); }
#status-table th { background: var(--bg2); box-shadow: 0 1px 0 var(--border); }
#logs-table th { background: var(--bg2); }

/* 管理后台：表单面板也全宽 + 整页锁高（pane 内部滚动） */
#pane-models .settings-panel, #pane-vmodels .settings-panel,
#pane-captcha .settings-panel, #pane-llm .settings-panel { max-width: none; }
#view-admin.view.active { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
#view-admin .view-head, #view-admin .admin-tabs { flex-shrink: 0; }
#view-admin .admin-pane { flex: 1; min-height: 0; overflow-y: auto; }
@media (max-width: 900px) { #view-admin.view.active { height: auto; overflow: visible; } }

/* 生视频：生成等待框不缩水 */
#view-video .loading-box {
  min-height: calc(100vh - 250px); width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; text-align: center;
}

/* 豆包配置弹窗限高内滚（未装插件时引导很长，防页面显示不全） */
#doubao-modal .modal { max-height: 88vh; overflow-y: auto; overscroll-behavior: contain; }

/* ============ v0.9.2 任务中心 + 最近作品优化（2026-10-28） ============ */
/* 任务中心操作列：按钮不换行、紧凑排布 */
#logs-table td.log-ops { white-space: nowrap; overflow: visible; }
#logs-table td.log-ops .tool-btn { padding: 2px 8px; font-size: 11px; }
/* 最近作品缩略图：canvas 绘制的高清帧 */
.recent-thumb canvas { width: 100%; height: 100%; display: block; }
.recent-thumb.gen-wait.sel { border-color: #facc15; box-shadow: 0 0 0 2px rgba(250, 204, 21, .35); }
/* 生图结果操作：删除按钮悬停警示红 */
.op-btn.op-del:hover { border-color: #f87171; color: #f87171; }
/* 生图界面整页锁高：内容超出视口的轻微滚动（复用任务跳回后可见），与生视频/管理页同方案 */
#view-image.view.active { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
@media (max-width: 900px) { #view-image.view.active { height: auto; overflow: visible; } }
/* 视频最近作品条：10 条恰好平铺整行，不产生横向滚动（弹性的等分宽度） */
#vid-recent-strip .recent-thumb { width: auto; flex: 1 1 0; min-width: 0; height: 52px; border-radius: 8px; }
#vid-recent-strip { overflow-x: hidden; }
/* 任务中心 8 列列宽：任务ID/模型/状态/消耗/提交完成时间/提示词/报错/操作 */
#logs-table th:nth-child(1) { width: 96px; }   /* 任务ID */
#logs-table th:nth-child(3) { width: 56px; }   /* 状态 */
#logs-table th:nth-child(4) { width: 84px; }   /* 消耗 */
#logs-table th:nth-child(5) { width: 150px; }  /* 提交/完成时间 */
#logs-table th:nth-child(7) { min-width: 130px; } /* 报错 */
#logs-table th:nth-child(8) { width: 190px; }  /* 操作 */
#logs-table td.log-cost { color: #fbbf24; white-space: nowrap; }
#logs-table td.log-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* 任务状态四态：成功绿√ / 失败红✗ / 生成中转动的齿轮 / 排队中呼吸的沙漏 */
#logs-table .st-ok   { color: #34d399; font-weight: 700; font-size: 15px; }
#logs-table .st-fail { color: #f87171; font-weight: 700; font-size: 15px; }
#logs-table .st-run  { color: #fb923c; display: inline-block; font-size: 15px; animation: log-spin 1.6s linear infinite; }
#logs-table .st-pend { color: #fbbf24; display: inline-block; font-size: 15px; animation: log-pulse 1.2s ease-in-out infinite; }
@keyframes log-spin  { from { transform: rotate(0deg); }   to { transform: rotate(360deg); } }
@keyframes log-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
/* 剧本创作整页锁高：中间文档区与右侧剧本助手撑满右侧全部高度，下方不留空 */
#view-script.view.active { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
#view-script .script-layout { flex: 1; height: auto; min-height: 0; }
@media (max-width: 1100px) { #view-script.view.active { height: auto; overflow: visible; } }
/* 画布剧本助手：token 计费提示 */
.agent-cost { display: block; margin-top: 6px; font-size: 11px; color: #fbbf24; opacity: .9; }
/* 伴侣升级提醒：豆包管理入口绿色向上箭头（有新版时出现） */
#btn-doubao.has-update { color: var(--text); }
#btn-doubao.has-update::after {
  content: "↑"; flex-shrink: 0; margin-left: auto;
  width: 18px; height: 18px; line-height: 18px; text-align: center;
  border-radius: 50%; background: var(--green); color: #06281c;
  font-size: 13px; font-weight: 800;
  animation: upd-bounce 1.2s ease-in-out infinite;
}
@keyframes upd-bounce { 0%, 100% { transform: translateY(1px); } 50% { transform: translateY(-2px); } }
/* 备案号悬挂：登录页版权行与侧边栏，小灰字不抢视觉 */
.auth-copy a, .side-beian a { color: inherit; text-decoration: none; opacity: .85; }
.auth-copy a:hover, .side-beian a:hover { opacity: 1; text-decoration: underline; }
.side-beian {
  text-align: center; font-size: 9px; color: var(--text-dim);
  opacity: .65; padding: 0 0 6px; letter-spacing: .3px;
  user-select: none; flex-shrink: 0; line-height: 1.6;
}
.sidebar.collapsed .side-beian { font-size: 8px; padding-bottom: 6px; }
.side-version + .side-beian { padding-top: 0; }
.beian-sep { opacity: .6; margin: 0 4px; }
