:root {
  --bg: #0a0a0b;
  --bg-elev: #101013;
  --panel: #141419;
  --panel-2: #191920;
  --border: #26262e;
  --border-soft: #1e1e25;
  --text: #ececf1;
  --text-dim: #9a9aa8;
  --text-faint: #6b6b7b;
  --accent: #5e6ad2;
  --accent-hover: #7079de;
  --accent-soft: rgba(94, 106, 210, 0.14);
  --danger: #e5484d;
  --ok: #3fb950;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  --font: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ---------- 布局 ---------- */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  gap: 4px;
  position: relative;
  transition: width 0.18s ease, flex-basis 0.18s ease;
}

/* 折叠态：只留图标列 */
.sidebar.collapsed {
  width: 60px;
  flex-basis: 60px;
  padding-left: 8px;
  padding-right: 8px;
}

.sidebar.collapsed .brand {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-foot {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

/* 边缘把手：骑在侧栏与主区的交界线上，展开/收起都可用 */
.sidebar-toggle {
  position: absolute;
  right: -11px;
  top: 26px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  z-index: 30;
  display: grid;
  place-items: center;
  font-size: 12px;
  line-height: 1;
  padding: 0;
  transition: background 0.14s, color 0.14s;
}

.sidebar-toggle:hover {
  background: var(--accent-soft);
  color: #a9b1ff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex: 0 0 auto;
}

.brand-text b {
  display: block;
  font-size: 13px;
  letter-spacing: 0.2px;
}

.brand-text span {
  display: block;
  font-size: 10.5px;
  color: var(--text-faint);
  font-family: var(--mono);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.14s, color 0.14s;
  font-size: 13.5px;
}

.nav-item:hover {
  background: var(--panel);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: #a9b1ff;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  opacity: 0.9;
}

.sidebar-foot {
  margin-top: auto;
  padding: 10px 11px;
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--mono);
  border-top: 1px solid var(--border-soft);
}

/* ---- 作者署名 / 关于区块 ---- */

.sb-author {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px dashed var(--border-soft);
  font-size: 10.5px;
  line-height: 1.4;
}

.sb-author b {
  color: var(--text-dim);
  font-weight: 600;
}

.sb-author a {
  color: var(--text-faint);
  text-decoration: none;
  width: fit-content;
  transition: color 0.14s;
}

.sb-author a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.author-box {
  display: flex;
  align-items: center;
  gap: 14px;
}

.author-avatar {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.5px;
  font-family: var(--mono);
  box-shadow: 0 4px 14px rgba(94, 106, 210, 0.32);
}

.author-info {
  min-width: 0;
}

.author-name {
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: 0.2px;
}

.author-role {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--mono);
  margin-top: 2px;
}

.author-links {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.author-links a {
  font-size: 12px;
  color: #a9b1ff;
  text-decoration: none;
  font-family: var(--mono);
}

.author-links a:hover {
  text-decoration: underline;
}

.main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.view {
  display: none;
  padding: 26px 30px 60px;
  max-width: 1280px;
  margin: 0 auto;
}

.view.active {
  display: block;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
}

.page-head-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: #a9b1ff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.page-head-icon svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.page-title {
  font-size: 18px;
  font-weight: 650;
  margin: 0;
  letter-spacing: -0.2px;
}

.page-head-tip {
  color: var(--text-faint);
  cursor: help;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.page-head-tip svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}

.page-head-tip:hover {
  color: var(--text-dim);
}

/* ---------- 通用组件 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.card-icon {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: #a9b1ff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  cursor: help;
  position: relative;
}

.card-icon svg {
  width: 13px;
  height: 13px;
  pointer-events: none;
}

.card-label {
  flex-shrink: 0;
}

/* ===== 标签页 ===== */
.tab-bar {
  display: flex;
  gap: 2px;
  margin-bottom: 14px;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
}
.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all .2s ease;
}
.tab-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.tab-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}
.tab-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(74,158,255,0.3);
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* 自定义 tooltip */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--panel);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  white-space: normal;
  width: max-content;
  max-width: 280px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 100;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

/* 尺寸行：预设 select + 宽 + 高 同一行 */
.grid-size {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr;
  gap: 10px;
}

/* 参数六项同行：步数 / 引导 / 种子 / 透明背景 / 张数 / 自动保存 */
.grid-6 {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

/* checkbox 与同行的输入框（约 37px 高）垂直对齐 */
.grid-checkline {
  height: 37px;
  white-space: nowrap;
}

/* 视口变窄时六项退化为三列两行，避免控件挤压 */
@media (max-width: 1100px) {
  .grid-6 {
    grid-template-columns: repeat(3, 1fr);
  }
  .mode-tabs {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 提示词选项卡（复用 .seg 分段控件） */
.prompt-seg {
  margin-bottom: 12px;
  width: max-content;
}

.neg-dot {
  color: var(--accent);
  font-size: 9px;
  margin-left: 4px;
  vertical-align: 1px;
}

/* 正向提示词输入框：独立选项卡后可以给更高 */
#prompt {
  min-height: 190px;
}

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

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

.field .hint {
  font-size: 10.5px;
  color: var(--text-faint);
  font-family: var(--mono);
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
  width: 100%;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
  resize: vertical;
  min-height: 78px;
  line-height: 1.55;
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.14s, opacity 0.14s;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  justify-content: center;
}

.btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

.btn-ghost {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: #22222b;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(229, 72, 77, 0.35);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(229, 72, 77, 0.12);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 11.5px;
}

/* 开始生成主按钮：显眼的大按钮 */
.btn-lg {
  padding: 14px 36px;
  font-size: 15.5px;
  min-width: 220px;
  border-radius: var(--radius);
  font-weight: 600;
}

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

/* ---------- 模式选择：一行四列，图标 + 标题 + 短描述 ---------- */
.mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.mode-tab {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.14s, background 0.14s;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.mode-tab > svg {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--text-dim);
  transition: color 0.14s;
}

.mode-tab:hover > svg {
  color: var(--text);
}

.mode-tab.active > svg {
  color: #a9b1ff;
}

.mode-tab:hover {
  border-color: #35353f;
}

.mode-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.mt-txt {
  min-width: 0;
}

.mode-tab b {
  display: block;
  font-size: 13.5px;
  margin-bottom: 3px;
}

.mode-tab .mt-txt span {
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.45;
  display: block;
}

.mode-tab.active .mt-txt span {
  color: #9aa1e0;
}

/* ---------- 上传区 ---------- */
.drop {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  color: var(--text-faint);
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
  font-size: 12.5px;
}

.drop:hover,
.drop.over {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #a9b1ff;
}

.thumbs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.thumb {
  position: relative;
  width: 86px;
  height: 86px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}

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

.thumb .del {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 19px;
  height: 19px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.thumb .tag {
  position: absolute;
  left: 3px;
  bottom: 3px;
  font-size: 9.5px;
  font-family: var(--mono);
  background: rgba(0, 0, 0, 0.7);
  padding: 1px 4px;
  border-radius: 3px;
  color: #cfcfe0;
}

/* ---------- 滑杆 ---------- */
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
}

.val {
  font-family: var(--mono);
  font-size: 11.5px;
  color: #a9b1ff;
  min-width: 42px;
  text-align: right;
}

/* ---------- 聊天（提示词优化） ---------- */
/* 右侧面板：覆盖式抽屉，默认滑出视口藏起（把手见 .chat-side-toggle）。
   fixed 定位不占布局，滑入滑出带过渡。 */
.chat-wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

.chat-side {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 340px;
  max-width: 86vw;
  z-index: 70;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  box-shadow: -18px 0 40px rgba(0, 0, 0, 0.45);
  transform: translateX(102%);
  visibility: hidden;
  transition: transform 0.24s ease, visibility 0.24s;
}

.chat-wrap.side-open .chat-side {
  transform: none;
  visibility: visible;
}

.chat-side-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.chat-side-title {
  font-size: 13px;
  font-weight: 600;
}

.chat-side-hide {
  margin-left: auto;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
  transition: background 0.14s, color 0.14s;
}

.chat-side-hide:hover {
  background: var(--accent-soft);
  color: #a9b1ff;
}

.chat-side-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* 右缘竖把手：唤出面板（仅提示词优化视图内存在，随视图显隐） */
.chat-side-toggle {
  position: fixed;
  right: 0;
  top: 45%;
  writing-mode: vertical-rl;
  padding: 16px 7px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 3px;
  cursor: pointer;
  z-index: 30;
  transition: background 0.14s, color 0.14s;
}

.chat-side-toggle:hover {
  background: var(--accent-soft);
  color: #a9b1ff;
}

.chat-wrap.side-open ~ .chat-side-toggle {
  display: none;
}

/* 对话头部：上下文状态 + 新会话 */
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: var(--radius) var(--radius) 0 0;
  flex: none;
}

.chat-scope {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-scope-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--text-faint);
  transition: background 0.2s, box-shadow 0.2s;
}

.chat-scope-dot.on {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 类型选择器：文生图 / 编辑图片 */
.kind-seg {
  display: flex;
  flex: none;
  gap: 2px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.kind-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.kind-btn:hover {
  color: var(--text);
}

.kind-btn.active {
  background: var(--accent);
  color: #fff;
}

/* 类型相关的提示条（如编辑模式未上传参考图） */
.kind-hint {
  flex: none;
  padding: 7px 14px;
  font-size: 11.5px;
  line-height: 1.5;
  color: #f0c674;
  background: rgba(240, 198, 116, 0.08);
  border-bottom: 1px solid var(--border);
}

/* ---------- 锁定图片区（对话内） ----------
   这组图才是真正交给视觉模型"看"的，与创作台的参考图分开管理。 */
.lock-bar {
  flex: none;
  padding: 9px 14px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(94, 106, 210, 0.05);
}

.lock-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

.lock-count {
  font-size: 10.5px;
  font-family: var(--mono);
  color: var(--text-faint);
}

.lock-tip {
  font-size: 11px;
  color: var(--text-faint);
}

.lock-ops {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.lock-thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.lock-empty {
  font-size: 11px;
  color: var(--text-faint);
  padding: 2px 0;
}

.lock-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}

.lock-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.lock-thumb .del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 17px;
  height: 17px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.lock-thumb .tag {
  position: absolute;
  left: 2px;
  bottom: 2px;
  font-size: 9px;
  font-family: var(--mono);
  background: rgba(0, 0, 0, 0.7);
  padding: 1px 3px;
  border-radius: 3px;
  color: #cfcfe0;
}

.card-title-btn {
  margin-left: auto;
}

/* 对话记录列表 */
.conv-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 264px;
  overflow-y: auto;
  margin: -4px -4px 0;
  padding: 4px;
}

.conv-empty {
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  padding: 18px 0;
}

.conv-item {
  border: 1px solid var(--border-soft);
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.conv-item:hover {
  border-color: #34343f;
}

.conv-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.conv-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.conv-kind {
  flex: none;
  font-size: 10px;
  font-family: var(--mono);
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(94, 106, 210, 0.2);
  color: #a9b1ff;
}

.conv-kind.edit {
  background: rgba(63, 185, 80, 0.16);
  color: #7ee2a8;
}

.conv-title {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
}

.conv-meta {
  flex: 1;
  font-size: 10.5px;
  font-family: var(--mono);
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-op {
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-size: 10.5px;
  padding: 1px 4px;
  border-radius: 4px;
  cursor: pointer;
}

.conv-op:hover {
  color: var(--text);
  background: var(--border-soft);
}

.conv-op.del:hover {
  color: var(--danger);
}

/* 规范文件信息卡 */
.rule-info {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.7;
}

.rule-row {
  display: flex;
  gap: 8px;
}

.rule-row > span:first-child {
  flex: none;
  width: 52px;
  color: var(--text-faint);
}

.rule-row > span:last-child {
  min-width: 0;
  word-break: break-all;
  font-family: var(--mono);
  font-size: 10.5px;
}

.rule-outline {
  margin: 8px 0 0;
  padding: 8px 0 0 16px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  color: var(--text-faint);
  /* t2i 规范有 11 个章节标题，留够高度避免半行被切 */
  max-height: 248px;
  overflow-y: auto;
}

.rule-outline li {
  margin-bottom: 2px;
  line-height: 1.4;
}

.rule-missing {
  color: var(--danger);
  font-size: 11.5px;
  line-height: 1.6;
}

/* ---------- 规范原文查看器 ---------- */
.textmodal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.86);
  backdrop-filter: blur(6px);
  z-index: 998;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.textmodal.show {
  display: flex;
}

.textmodal-box {
  width: min(860px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.textmodal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 13px;
}

.textmodal-meta {
  flex: 1;
  font-size: 10.5px;
  font-family: var(--mono);
  color: var(--text-faint);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.textmodal-close {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
}

.textmodal-close:hover {
  color: #fff;
}

.textmodal-body {
  margin: 0;
  padding: 16px 18px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 190px);
  min-height: 420px;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: var(--radius);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.msg.ai {
  align-self: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}

.msg.ai.prompt {
  border-color: rgba(94, 106, 210, 0.5);
  background: rgba(94, 106, 210, 0.09);
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  width: 100%;
  max-width: 100%;
}

/* 消息悬浮删除按钮：只挂在已持久化的消息上（见 app.js msgEl / promptCardEl） */
.msg {
  position: relative;
}

.msg-del {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid transparent;
  color: var(--text-faint);
  cursor: pointer;
  opacity: 0;
  display: grid;
  place-items: center;
  padding: 0;
  transition: opacity 0.12s, color 0.12s, border-color 0.12s;
}

.msg-del svg {
  width: 12px;
  height: 12px;
}

.msg:hover .msg-del {
  opacity: 0.9;
}

.msg-del:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.msg.ai.prompt .lbl {
  display: block;
  font-family: var(--font);
  font-size: 10.5px;
  color: #a9b1ff;
  margin-bottom: 5px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.msg .meta {
  font-size: 10.5px;
  color: var(--text-faint);
  margin-top: 7px;
  display: block;
  font-family: var(--mono);
}

.chat-input {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
  gap: 9px;
  align-items: flex-end;
}

.chat-input textarea {
  min-height: 44px;
  max-height: 130px;
}

.chat-side .card {
  margin-bottom: 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* 注意：原先这里还有 .rule-list / .chip（提示词结构模板 与 官方要点 两张卡片用），
   那两张卡展示的是手写的规范摘要，会与官方规范原文漂移，已随卡片一并移除。
   规范信息现在由 .rule-info + .rule-outline 从 /api/rules 返回的真实文件元信息渲染。 */

/* ---------- 生成进度 ---------- */
.progress {
  display: none;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border: 1px solid rgba(94, 106, 210, 0.32);
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 12.5px;
  color: #b6bcff;
}

.progress.show {
  display: flex;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(169, 177, 255, 0.3);
  border-top-color: #a9b1ff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: 0 0 auto;
}

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

/* ---------- 结果预览 ---------- */
.result-area {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.result-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel-2);
  cursor: zoom-in;
  position: relative;
}

.result-item img {
  width: 100%;
  display: block;
  aspect-ratio: 1;
  object-fit: cover;
  background:
    repeating-conic-gradient(#1a1a20 0% 25%, #141418 0% 50%) 50% / 18px 18px;
}

.result-item .cap {
  padding: 7px 9px;
  font-size: 10.5px;
  font-family: var(--mono);
  color: var(--text-faint);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

/* ---------- 历史 ---------- */
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 14px;
}

.hist-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.14s, transform 0.14s;
}

.hist-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  z-index: 6;
}

.hist-thumb {
  position: relative;
  cursor: zoom-in;
  border-radius: calc(var(--radius) - 1px);
  overflow: hidden;
  background:
    repeating-conic-gradient(#1a1a20 0% 25%, #141418 0% 50%) 50% / 16px 16px;
}

.hist-thumb img {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  display: block;
}

.hist-thumb .badge {
  position: absolute;
  top: 7px;
  left: 7px;
  font-size: 10px;
  font-family: var(--mono);
  background: rgba(0, 0, 0, 0.72);
  padding: 2px 6px;
  border-radius: 4px;
  color: #d5d5e5;
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.14s;
}

.hist-card:hover .badge {
  opacity: 1;
}

/* 悬浮在卡片上方的参数条 */
.hist-tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 7px);
  transform: translateX(-50%) translateY(3px);
  white-space: nowrap;
  font-size: 10.5px;
  font-family: var(--mono);
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s, transform 0.14s;
  z-index: 7;
}

.hist-card:hover .hist-tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 悬浮才出现的 SVG 操作按钮（下载 / 复制提示词 / 删除） */
.hist-ops {
  position: absolute;
  right: 7px;
  bottom: 7px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.14s, transform 0.14s;
}

.hist-card:hover .hist-ops {
  opacity: 1;
  transform: translateY(0);
}

.hop {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(10, 10, 12, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #d5d5e5;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  backdrop-filter: blur(6px);
  transition: background 0.14s, color 0.14s;
}

.hop svg {
  width: 15px;
  height: 15px;
}

.hop:hover {
  background: var(--accent);
  color: #fff;
}

.hop.danger:hover {
  background: var(--danger);
}

/* 卡片正文（文件名 / 提示词 / 参数）已改为悬浮 tip 与查看器弹层呈现 */
.hist-missing-tip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-dim);
}

.tagm {
  font-size: 9.5px;
  font-family: var(--mono);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-dim);
}

.tagm-warn {
  color: var(--danger);
  border-color: var(--danger);
}

/* 图片文件已丢失：元数据仍保留，只是禁用图片相关操作 */
.thumb-missing {
  width: 100%;
  aspect-ratio: 9 / 16;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  padding: 10px;
}

.hist-card.is-missing .hist-thumb {
  cursor: default;
}

/* ---------- 轻量级查看器 ---------- */
.viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.86);
  backdrop-filter: blur(6px);
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.viewer.show {
  display: flex;
}

.viewer-frame {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  cursor: default;
}

.viewer-frame img {
  max-width: 92vw;
  max-height: 76vh;
  object-fit: contain;
  display: block;
  transition: transform 0.12s ease;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none; /* 禁用图片原生拖拽（拖影），平移用 Pointer Events 实现 */
  background:
    repeating-conic-gradient(#1a1a20 0% 25%, #141418 0% 50%) 50% / 20px 20px;
}

.viewer-info {
  padding: 9px 13px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-faint);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  flex-wrap: wrap;
}

/* 右侧竖排工具按钮：关闭 / 提示词 / 参数 */
.viewer-tools {
  position: absolute;
  top: 20px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 3;
}

.vtool {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: color 0.14s, border-color 0.14s, background 0.14s;
}

.vtool svg {
  width: 17px;
  height: 17px;
}

.vtool:hover {
  color: #fff;
  border-color: #3a3a45;
}

.vtool.on {
  color: #a9b1ff;
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* 工具左侧的弹层：提示词 / 参数。Esc 逐层关闭，见 app.js */
.viewer-pop {
  position: absolute;
  top: 20px;
  right: 72px;
  width: 400px;
  max-width: calc(100vw - 120px);
  max-height: 80vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  z-index: 2;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.7;
}

.viewer-pop h4 {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.viewer-pop h4 .vp-closer {
  margin-left: auto;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
}

.viewer-pop h4 .vp-closer:hover {
  color: #fff;
}

.vp-prompt {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  font-size: 12.5px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px 12px;
  max-height: 46vh;
  overflow-y: auto;
}

.vp-kv {
  display: flex;
  gap: 10px;
  border-bottom: 1px dashed var(--border-soft);
  padding: 5px 0;
}

.vp-kv:last-child {
  border-bottom: none;
}

.vp-kv b {
  flex: 0 0 118px;
  font-weight: 500;
  color: var(--text-faint);
}

.vp-kv span {
  font-family: var(--mono);
  color: var(--text);
  word-break: break-all;
}

.vp-kv span a {
  color: #a9b1ff;
}

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.toast {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12.5px;
  min-width: 230px;
  max-width: 380px;
  box-shadow: var(--shadow);
  animation: slideIn 0.22s ease;
}

.toast.err {
  border-left-color: var(--danger);
}

.toast.ok {
  border-left-color: var(--ok);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
}

/* ---------- 个人信息 ---------- */
.balance {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.bal-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px;
  text-align: center;
}

.bal-item .num {
  font-size: 22px;
  font-weight: 650;
  font-family: var(--mono);
  color: #a9b1ff;
  line-height: 1.2;
}

.bal-item .lbl {
  font-size: 10.5px;
  color: var(--text-faint);
  margin-top: 3px;
}

.meter {
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
  margin-top: 10px;
}

.meter > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  transition: width 0.4s;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 7px;
}

.dot-ok {
  background: var(--ok);
}

.dot-err {
  background: var(--danger);
}

.dot-idle {
  background: var(--text-faint);
}

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
  font-size: 13px;
}

.empty b {
  display: block;
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 6px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.divider {
  height: 1px;
  background: var(--border-soft);
  margin: 16px 0;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

@media (max-width: 1080px) {
  /* .chat-wrap 恒为单列（面板已抽屉化），这里只保留聊天框高度约束 */
  .chat-box {
    height: 520px;
  }
}

/* ---------- 局部重绘：蒙版画笔 ---------- */

.mask-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;
}

/* 画笔 / 橡皮 分段控件 */
.seg {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
  height: 34px;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12.5px;
  padding: 0 14px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn.active {
  background: var(--accent);
  color: #fff;
}

.mask-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  /* 工具按钮从 2 个增加到 4 个后，这一组会被挤到行尾的一小撮位置，
     所以让它独占一行并右对齐，与被挤扁相比更易读 */
  flex: 1 1 100%;
  justify-content: flex-end;
}

/* 圈选清单：哪种颜色画了几处。提示词就照这个写 —— 一种颜色一条指令。 */
.mark-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

.mark-bar-label {
  font-size: 11.5px;
  color: var(--text-faint);
  letter-spacing: 0.3px;
}

.mark-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.mark-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px 2px 5px;
  white-space: nowrap;
}

/* 色块必须显示真实颜色，不能套主题色：这抹颜色就是提示词里要写的那把钥匙，
   显示成别的颜色会让人照着写错 */
.mark-chip i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex: none;
}

/* 落坑体检：只提醒，绝不替用户改提示词 */
.mark-advice {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

.mark-advisory {
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--text-dim);
  background: rgba(210, 153, 34, 0.1);
  border-left: 2px solid #d29922;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 6px 9px;
}

.mark-advisory .w {
  color: #d29922;
  margin-right: 5px;
}

/* 画布区：棋盘格底衬，便于看清透明区域与标记边界 */
.paint-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--bg);
  background-image: linear-gradient(45deg, #17171c 25%, transparent 25%),
    linear-gradient(-45deg, #17171c 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #17171c 75%),
    linear-gradient(-45deg, transparent 75%, #17171c 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  overflow: hidden;
  margin-bottom: 10px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 双层结构：底层是原图 <img>，上层是透明画布只画标记。
   这样涂抹时无需重绘底图，2048² 下也不会卡顿。 */
.paint-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  max-width: 100%;
}

#paintBase {
  display: block;
  max-width: 100%;
  height: auto;
}

#paintCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none; /* 触屏涂抹时不触发页面滚动 */
}

#paintCanvas.is-hidden {
  visibility: hidden;
}

.paint-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 12.5px;
  pointer-events: none;
  padding: 20px;
  text-align: center;
  line-height: 1.6;
  white-space: nowrap; /* 提示文字保持横排一行，不在窄画布里逐字折行 */
}

/* ---------- LoRA 适配器 ---------- */

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

.lora-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lora-row input[type="text"] {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12.5px;
}

.lora-row input[type="number"] {
  width: 78px;
  font-family: var(--mono);
  font-size: 12.5px;
}

.lora-row .lora-del {
  flex: none;
}

.lora-empty {
  color: var(--text-faint);
  font-size: 12.5px;
  padding: 2px 0 4px;
}

.lora-sum-ok {
  color: var(--ok);
}

.lora-sum-bad {
  color: var(--danger);
}

/* 最近用过的 LoRA：点一下就填进输入框，省得每次回社区翻仓库 */
.lora-recent {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.lora-chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 100px;
  cursor: pointer;
  transition: border-color 0.14s, color 0.14s;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lora-chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* ---------- 提示词优化：附加规则开关 ---------- */

.extra-toggle {
  flex: none;
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
  height: 30px;
  font-size: 12px;
  white-space: nowrap;
}

/* ================= 创作台两列：左主区 + 右任务列表 =================
   任务由服务端后台推进，右栏只是"观察窗口"。默认收起给主区让位，
   右缘的「任务列表 ‹」把手唤出，面板头部的 › 收回 —— 轮询不受显隐影响。 */

.studio-layout {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

/* 默认收起：抽屉滑出视口藏起、把手可见；.jobs-open 滑入 */
.studio-layout:not(.jobs-open) .jobs-col {
  transform: translateX(102%);
  visibility: hidden;
}

.studio-layout.jobs-open .jobs-toggle {
  display: none;
}

/* 右缘竖把手：唤出任务列表 */
.jobs-toggle {
  position: fixed;
  right: 0;
  top: 45%;
  writing-mode: vertical-rl;
  padding: 16px 7px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 3px;
  cursor: pointer;
  z-index: 30;
  transition: background 0.14s, color 0.14s;
}

.jobs-toggle:hover {
  background: var(--accent-soft);
  color: #a9b1ff;
}

/* 面板头部的收起按钮 */
.jobs-hide {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
  flex: 0 0 auto;
  transition: background 0.14s, color 0.14s;
}

.jobs-hide:hover {
  background: var(--accent-soft);
  color: #a9b1ff;
}

/* 创作台比其它视图宽，否则右栏没地方站 */
#view-studio.view {
  max-width: 1760px;
}

.studio-col {
  flex: 1 1 auto;
  min-width: 0; /* 让内部 grid 可收缩，否则会撑破 */
  padding-bottom: 96px; /* 给底部悬浮的生成 dock 让位，避免遮住最后一张结果卡 */
}

/* 生成 / 重置按钮：悬浮在视口底部居中，长页面滚动时也随时可点。
   位于创作台视图内部，切到其它视图时随 section 一起隐藏。 */
.gen-dock {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(18, 18, 24, 0.88);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.gen-dock .btn svg {
  width: 16px;
  height: 16px;
}

.jobs-col {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 86vw;
  z-index: 70;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
  box-shadow: -18px 0 40px rgba(0, 0, 0, 0.45);
  transform: none;
  visibility: visible;
  transition: transform 0.24s ease, visibility 0.24s;
}

.jobs-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border-soft);
}

.jobs-title {
  font-size: 13px;
  font-weight: 600;
}

.jobs-meta {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
}

.jobs-body {
  flex: 1; /* 抽屉全高：列表撑满，底部提示贴底 */
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 90px;
}

.jobs-foot {
  padding: 8px 13px;
  border-top: 1px solid var(--border-soft);
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.5;
}

.jobs-empty {
  padding: 24px 10px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.7;
}

.job-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--panel);
}

/* 任务卡片的删除按钮：垃圾桶 SVG，悬浮卡片时浮现 */
.job-del {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-faint);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  opacity: 0.55;
  transition: opacity 0.14s, color 0.14s, border-color 0.14s;
}

.job-del svg {
  width: 13px;
  height: 13px;
}

.job-item:hover .job-del {
  opacity: 1;
}

.job-del:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.job-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.job-item.clickable {
  cursor: pointer;
}

.job-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.job-badge {
  font-size: 11px;
  line-height: 1.5;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid currentColor;
  color: var(--text-dim);
}

.job-badge.run { color: #7f8cff; }
.job-badge.done { color: var(--ok); }
.job-badge.partial { color: #d8a657; }
.job-badge.failed { color: var(--danger); }
.job-badge.cancelled { color: var(--text-faint); }

.job-when {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
}

.job-prompt {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.job-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--border-soft);
  overflow: hidden;
}

.job-progress > i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}

.job-thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.job-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  background: var(--bg);
  cursor: pointer;
}

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

.job-thumb .mini {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.3;
  padding: 2px;
}

.job-thumb.failed {
  border-color: rgba(229, 72, 77, 0.45);
}

.job-thumb.failed .mini {
  color: var(--danger);
}

.job-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.job-actions .btn {
  padding: 3px 9px;
  font-size: 11.5px;
}

.job-err {
  font-size: 11px;
  color: var(--danger);
  line-height: 1.5;
  word-break: break-all;
}

/* 批内相似度结论：正常情况是一行淡淡的说明，发现真的同图才变警示色 */
.job-sim {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.5;
}

.job-sim-bad {
  color: var(--danger);
  font-weight: 500;
}

@media (max-width: 1200px) {
  /* 任务列表已是视口右侧的覆盖抽屉，窄屏无需再堆叠让位 */
}

/* 结果区占位（生成中 / 失败）：结果区是等宽网格，占位也要占一格，
   否则未完成的张数会"看不见"，用户以为漏了一张。 */
.result-item.result-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  padding: 16px;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-faint);
  background: var(--bg);
  border-style: dashed;
  cursor: default;
}

.result-item.result-ph.err {
  color: var(--danger);
  border-color: rgba(229, 72, 77, 0.4);
}

.job-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}

.job-info {
  font-size: 11px;
  color: var(--text-faint);
  margin-right: auto;
}


/* ---------- 滚动条美化 ----------
   默认白色滚动条在深色主题里非常扎眼；统一成深色圆角细条。
   WebKit 走 ::-webkit-*；Firefox 走 scrollbar-width / scrollbar-color。 */
* {
  scrollbar-width: thin;
  scrollbar-color: #33333f transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #33333f;
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: #454555;
  background-clip: padding-box;
}

::-webkit-scrollbar-corner {
  background: transparent;
}
