/* ============================================================
   Loom · 织造所
   零依赖样式表，深/浅双主题
   ============================================================ */

:root {
  --font: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --serif: "Noto Serif SC", "Songti SC", "SimSun", "Source Han Serif SC", serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --radius: 14px;
  --radius-sm: 9px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

/* ---------- 深色（默认） ---------- */
html[data-theme="dark"] {
  --bg: #141311;
  --bg-elev: #1d1c1a;
  --panel: #1d1c1a;
  --panel-2: #242220;
  --panel-3: #2f2c28;
  --line: #2f2c28;
  --line-strong: #423e38;
  --line-input: #4a453e;
  --text: #efe9e1;
  --text-2: #a39b91;
  --text-3: #8b837a;
  --accent: #efe9e1;
  --accent-2: #fffdf9;
  --accent-fg: #141311;
  --accent-soft: rgba(239, 233, 225, .08);
  --accent-text: #efe9e1;
  --rose: #d9a294;
  --rose-ink: #e8b3a4;
  --rose-soft: #332a26;
  --danger: #e08a80;
  --danger-soft: rgba(224, 138, 128, .12);
  --ok: #9dbb8b;
  --warn: #d8b478;
  --shadow: 0 24px 48px -24px rgba(0, 0, 0, .6);
  --shadow-sm: 0 8px 20px -12px rgba(0, 0, 0, .55);
  --glass: rgba(20, 19, 17, .86);
  --grid-gap: 16px;
}

/* ---------- 浅色 ---------- */
html[data-theme="light"] {
  --bg: #f6f3ee;
  --bg-elev: #fffdf9;
  --panel: #fffdf9;
  --panel-2: #f6f3ee;
  --panel-3: #efe9df;
  --line: #e6e0d6;
  --line-strong: #d8d0c3;
  --line-input: #c7bdad;
  --text: #1d1b19;
  --text-2: #7a736b;
  --text-3: #9a9289;
  --accent: #1d1b19;
  --accent-2: #3a3430;
  --accent-fg: #fffdf9;
  --accent-soft: rgba(29, 27, 25, .055);
  --accent-text: #1d1b19;
  --rose: #c08a7d;
  --rose-ink: #96604f;
  --rose-soft: #f3e6e1;
  --danger: #b4574d;
  --danger-soft: rgba(180, 87, 77, .09);
  --ok: #5c7a4e;
  --warn: #a8792f;
  --shadow: 0 24px 48px -24px rgba(60, 40, 30, .35);
  --shadow-sm: 0 8px 20px -14px rgba(60, 40, 30, .3);
  --glass: rgba(255, 253, 249, .9);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
html[data-theme="dark"] body {
  background:
    radial-gradient(760px 560px at 96% -14%, rgba(217, 162, 148, .1), transparent 68%),
    var(--bg);
}
html[data-theme="light"] body {
  background:
    radial-gradient(760px 560px at 96% -14%, rgba(192, 138, 125, .16), transparent 68%),
    var(--bg);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* ============================================================
   布局
   ============================================================ */
#app { display: flex; height: 100vh; }

#sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 12px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--text);
  box-shadow: none;
  flex: 0 0 auto;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text b { font-family: var(--serif); font-size: 15px; letter-spacing: .12em; font-weight: 600; }
.brand-text span {
  font-size: 8.5px; letter-spacing: 2.4px; color: var(--rose);
  font-family: var(--mono); margin-top: 3px;
}

#nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-label {
  font-size: 11px; letter-spacing: 1.2px; color: var(--text-3);
  padding: 14px 10px 6px; font-weight: 600; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  border: none; background: none;
  color: var(--text-2);
  font-size: 13.5px;
  text-align: left;
  transition: background .16s var(--ease), color .16s var(--ease);
  position: relative;
}
.nav-item svg { width: 17px; height: 17px; flex: 0 0 auto; opacity: .85; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; }
.nav-item .count {
  margin-left: auto;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-2);
  background: var(--panel-2);
  padding: 1px 7px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.nav-item.active .count { background: rgba(255, 253, 249, .2); color: var(--accent-fg); }
html[data-theme="light"] .nav-item.active .count { background: rgba(255, 253, 249, .18); }
html[data-theme="dark"] .nav-item.active .count { background: rgba(20, 19, 17, .14); }

.side-foot { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 8px; }
.storage-line {
  font-size: 11px; color: var(--text-2); font-family: var(--mono);
  padding: 0 8px 9px; letter-spacing: .2px;
}
.side-actions { display: flex; gap: 6px; }
.ghost-btn {
  flex: 1;
  display: grid; place-items: center;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text-2);
  transition: .16s var(--ease);
}
.ghost-btn:hover { color: var(--text); border-color: var(--line-strong); background: var(--panel-2); }
.ghost-btn svg { width: 16px; height: 16px; }

/* ---------- 主区 ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

#topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px;
  padding: 20px 26px 14px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  flex: 0 0 auto;
}
#view-title { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: .04em; font-family: var(--serif); }
#view-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--text-2); }
#topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

#view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 26px 60px;
  outline: none;
}

/* ============================================================
   通用控件
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--line-input);
  background: var(--panel);
  color: var(--text);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
  transition: .16s var(--ease);
}
.btn:hover { background: var(--panel-2); border-color: var(--text-3); }
.btn:active { transform: translateY(0); }
.btn svg { width: 15px; height: 15px; flex: 0 0 auto; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--accent-fg); }
.btn.danger { color: var(--danger); border-color: rgba(255, 95, 109, .32); background: var(--danger-soft); }
.btn.danger:hover { background: rgba(255, 95, 109, .22); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); height: 30px; padding: 0 9px; }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); transform: none; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .4; filter: saturate(.35); pointer-events: none; }

.icon-btn {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--text-2);
  transition: .15s var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--panel-2); border-color: var(--line-strong); }
.icon-btn svg { width: 15px; height: 15px; flex: 0 0 auto; }
.icon-btn.on { color: var(--rose); border-color: var(--rose); background: var(--rose-soft); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-size: 11.5px; font-weight: 600; color: var(--text-2);
  letter-spacing: .3px;
}
.field .hint { font-size: 11.5px; color: var(--text-2); line-height: 1.55; }

input[type="text"], input[type="url"], input[type="password"], input[type="number"],
textarea, select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line-input);
  border-radius: 9px;
  padding: 8px 11px;
  color: var(--text);
  outline: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
  font-size: 13px;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(192, 138, 125, .16);
  background: var(--panel);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; min-height: 78px; line-height: 1.6; font-size: 12.5px; }
select { cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
                    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }

input[type="text"], input[type="url"], input[type="password"], input[type="number"], select {
  height: 36px;
  line-height: 20px;
}
select {
  background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px;
}

.search-box { position: relative; display: flex; align-items: center; }
.search-box svg {
  position: absolute; left: 10px; width: 15px; height: 15px; color: var(--text-3); pointer-events: none;
}
.search-box input { padding-left: 32px; height: 34px; width: 240px; border-radius: 9px; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border-radius: 99px;
  border: 1px solid var(--line-input);
  background: var(--panel);
  color: var(--text-2);
  font-size: 12.5px;
  transition: .15s var(--ease);
}
.chip:hover { border-color: var(--text-3); color: var(--text); }
.chip.active {
  background: var(--accent); border-color: var(--accent);
  color: var(--accent-fg); font-weight: 600;
}
.chip.active .n { color: var(--accent-fg); opacity: .6; }
.chip.active .dot { opacity: 1; }
.chip .dot {
  width: 8px; height: 8px; border-radius: 99px;
  background: currentColor; opacity: 1;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .08);
}
.chip .n { font-family: var(--mono); font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 6px;
  background: var(--panel-3); color: var(--text);
  letter-spacing: .2px; white-space: nowrap;
}
.badge.cloud { background: var(--panel-3); color: var(--text-2); }
.badge.local { background: var(--rose-soft); color: var(--rose-ink); }
.badge.ai { background: var(--rose-soft); color: var(--rose-ink); }
.badge.ok { background: var(--accent-soft); color: var(--text); }
.badge.rose { background: var(--rose-soft); color: var(--rose-ink); }
.badge.mono { font-family: var(--mono); font-weight: 500; }

/* ============================================================
   图库
   ============================================================ */
.gallery-toolbar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.gallery-toolbar .spacer { flex: 1; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  align-items: start;
  gap: var(--grid-gap);
}
.grid.dense { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

.card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  cursor: pointer;
  transition: transform .22s var(--ease), border-color .22s var(--ease), box-shadow .22s var(--ease);
  break-inside: avoid;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}
.card-img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: var(--panel-2);
  transition: opacity .3s var(--ease);
}
.card.ratio-34 .card-img { aspect-ratio: 3 / 4; }
.card.ratio-43 .card-img { aspect-ratio: 4 / 3; }
.card.ratio-916 .card-img { aspect-ratio: 9 / 16; }
.card-img.loading { opacity: 0; }

.card-overlay {
  position: absolute; inset: auto 0 0 0;
  padding: 26px 10px 9px;
  background: linear-gradient(to top, rgba(0, 0, 0, .82), rgba(0, 0, 0, .38) 55%, transparent);
  color: #fff;
  opacity: 0;
  transform: translateY(6px);
  transition: .2s var(--ease);
  pointer-events: none;
}
.card:hover .card-overlay { opacity: 1; transform: translateY(0); }
.card-overlay .t {
  font-size: 11.5px;
  line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  opacity: .92;
}
.card-overlay .m {
  display: flex; gap: 6px; margin-top: 6px;
  font-size: 10px; font-family: var(--mono); opacity: .7;
}
.card-top-badges {
  position: absolute; top: 8px; left: 8px; right: 8px;
  display: flex; gap: 5px; align-items: flex-start;
  pointer-events: none;
}
.card-top-badges .badge {
  background: rgba(20, 19, 17, .6);
  color: #fffdf9;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 253, 249, .16);
}
.card-top-badges .badge.ai { color: #f3d1c8; }
.card-fav {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px;
  border-radius: 8px; border: none;
  background: rgba(20, 19, 17, .55);
  backdrop-filter: blur(6px);
  color: rgba(255, 253, 249, .7);
  display: grid; place-items: center;
  opacity: 0;
  transition: .15s var(--ease);
}
.card:hover .card-fav, .card-fav.on { opacity: 1; }
.card-fav.on { color: var(--rose); }
.card-fav svg { width: 14px; height: 14px; }
.card-fav:hover { background: rgba(20, 19, 17, .8); }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  padding: 80px 20px;
  color: var(--text-2);
  text-align: center;
}
.empty svg { width: 42px; height: 42px; opacity: .5; color: var(--text-3); }
.empty b { font-size: 15px; color: var(--text); font-weight: 650; }
.empty p { margin: 0; font-size: 13px; max-width: 400px; line-height: 1.75; color: var(--text-2); }

/* ============================================================
   灯箱 / 详情
   ============================================================ */
#lightbox {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(20, 19, 17, .95);
  backdrop-filter: blur(14px);
  display: flex;
  animation: fade .18s var(--ease);
}
html[data-theme="light"] #lightbox { background: rgba(246, 243, 238, .97); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.lb-stage {
  flex: 1;
  display: flex; flex-direction: column;
  min-width: 0;
  padding: 18px 18px 18px 22px;
}
.lb-topbar {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 12px;
  color: var(--text);
}
.lb-topbar .lb-id { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }
.lb-topbar .spacer { flex: 1; }
.lb-canvas {
  flex: 1;
  position: relative;
  min-height: 0;
  overflow: hidden;
}
.lb-canvas img {
  position: absolute;
  inset: 0;
  margin: auto;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
  object-fit: contain;
}
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 42px; height: 42px; border-radius: 99px;
  border: 1px solid rgba(255, 253, 249, .22);
  background: rgba(20, 19, 17, .55);
  color: #fff; display: grid; place-items: center;
  backdrop-filter: blur(8px);
  transition: .16s var(--ease);
}
.lb-nav:hover { background: rgba(20, 19, 17, .78); }
.lb-nav.prev { left: 4px; }
.lb-nav.next { right: 4px; }
.lb-nav svg { width: 18px; height: 18px; }
.lb-foot { display: flex; gap: 14px; font-size: 11px; color: var(--text-3); font-family: var(--mono); padding-top: 10px; }

.lb-panel {
  width: 396px; flex: 0 0 396px;
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.lb-panel-head {
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.lb-panel-head h3 { margin: 0; font-size: 13.5px; font-weight: 650; }
.lb-panel-head .spacer { flex: 1; }
.lb-panel-body { flex: 1; overflow-y: auto; padding: 14px 16px 30px; }

.prompt-current {
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 12.5px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  color: var(--text);
  max-height: 220px; overflow-y: auto;
  font-family: var(--mono);
}
.prompt-current.empty-text { color: var(--text-3); font-family: var(--font); font-style: italic; }

.ver-list { display: flex; flex-direction: column; gap: 6px; }
.ver {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  padding: 9px 10px;
  transition: .15s var(--ease);
}
.ver:hover { border-color: var(--line-strong); }
.ver.active { border-color: var(--rose); background: var(--rose-soft); }
.ver-head { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.ver-head .vno { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--accent-text); }
.ver-head .time { font-size: 10.5px; color: var(--text-3); font-family: var(--mono); margin-left: auto; }
.ver-body {
  font-size: 12px; line-height: 1.6; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  font-family: var(--mono);
  white-space: pre-wrap; word-break: break-word;
}
.ver.active .ver-body { color: var(--text); }
.ver-actions { display: flex; gap: 4px; margin-top: 7px; opacity: 0; transition: .15s; }
.ver:hover .ver-actions { opacity: 1; }

.kv { display: grid; grid-template-columns: 84px 1fr; gap: 5px 10px; font-size: 12px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); word-break: break-all; font-family: var(--mono); font-size: 11.5px; }

.section { margin-top: 18px; }
.section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .8px;
  color: var(--text-2); text-transform: uppercase;
  margin-bottom: 10px;
}
.section-title .spacer { flex: 1; }
.section-title::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.section-title .spacer + * { }

/* ============================================================
   模型库 / LoRA / 工作流
   ============================================================ */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.model-card {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 15px;
  transition: .18s var(--ease);
  position: relative;
}
.model-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.model-card-head { display: flex; align-items: flex-start; gap: 10px; }
.model-card-icon {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--panel-3); color: var(--accent-text);
  font-weight: 700; font-size: 14px; font-family: var(--mono);
  flex: 0 0 auto;
}
.model-card h3 { margin: 0; font-size: 14px; font-weight: 650; }
.model-card .sub { font-size: 11.5px; color: var(--text-3); font-family: var(--mono); margin-top: 2px; }
.model-card .spacer { flex: 1; }
.model-card .desc {
  font-size: 12px; color: var(--text-2); margin: 10px 0 0; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.model-meta {
  display: flex; gap: 14px; margin-top: 12px;
  padding-top: 11px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--text-3);
}
.model-meta b { color: var(--text); font-family: var(--mono); font-weight: 600; }
.model-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 10px; }

.file-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.file-table th {
  text-align: left; font-size: 11px; letter-spacing: .6px; color: var(--text-2);
  font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line);
  text-transform: uppercase;
}
.file-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.file-table tr:last-child td { border-bottom: none; }
.file-table .mono { font-family: var(--mono); font-size: 11px; color: var(--text-2); word-break: break-all; }
.file-table .kind {
  font-family: var(--mono); font-size: 10px; padding: 2px 6px; border-radius: 5px;
  background: var(--panel-3); color: var(--text-2); white-space: nowrap;
}
.file-table tr.missing td { color: var(--text-3); }

/* ============================================================
   参考图库（服饰 / 人脸）
   ============================================================ */
.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  gap: 12px;
}
.ref-grid.tall { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); }

.ref-card {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.ref-card img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: var(--panel-3);
}
.ref-grid.tall .ref-card img { aspect-ratio: 4 / 5; }

/* 姿势组卡片：同一姿势多视角聚合 */
.ref-card.pose-group { padding-bottom: 26px; }
.ref-card.pose-group img.pose-main { aspect-ratio: 4 / 5; }
.pose-views {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; gap: 3px; justify-content: center; align-items: center;
  height: 26px; padding: 0 6px;
  background: rgba(20, 19, 17, .78);
}
.pose-view-dot {
  flex: 1; max-width: 30px;
  font-size: 10px; line-height: 1; text-align: center;
  color: var(--text-3);
  padding: 3px 0; border-radius: 5px;
}
.pose-view-dot.on { background: var(--rose); color: #fff; }

/* 灯箱内姿势视角切换条 */
.lb-pose-views {
  display: flex; gap: 8px; justify-content: center;
  padding: 10px 12px 2px;
}
.lb-pose-view {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: 2px solid transparent; border-radius: 8px;
  cursor: pointer; padding: 2px;
}
.lb-pose-view img {
  width: 56px; height: 70px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel-3);
}
.lb-pose-view span { font-size: 11px; color: var(--text-2); }
.lb-pose-view.on { border-color: var(--rose); }
.lb-pose-view.on span { color: var(--rose); }


/* 姊妹素材库：线稿标记 / 灯箱插画-线稿切换 */
.lib-badge {
  position: absolute; top: 6px; right: 6px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(20, 19, 17, .72);
  color: #fffdf9;
  font-size: 10px; line-height: 1.4;
  font-family: var(--mono);
  pointer-events: none;
}
.lib-line-toggle {
  display: flex; gap: 8px; justify-content: center;
  padding: 10px 12px 2px;
}

.ref-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.ref-hover {
  position: absolute; inset: auto 0 0 0;
  padding: 20px 8px 7px;
  background: linear-gradient(to top, rgba(20, 19, 17, .86), transparent);
  color: #fffdf9;
  opacity: 0;
  transition: .18s var(--ease);
  pointer-events: none;
}
.ref-card:hover .ref-hover { opacity: 1; }
.ref-id {
  font-family: var(--mono); font-size: 10px; letter-spacing: .2px;
  opacity: .82;
}
.ref-kw {
  font-size: 10.5px; line-height: 1.45; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.ref-total {
  font-size: 12px; color: var(--text-2);
  font-family: var(--mono);
  white-space: nowrap;
}
.ref-more {
  text-align: center;
  padding: 22px 0 6px;
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--mono);
}
.ref-note {
  margin: 26px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.9;
  color: var(--text-3);
}
.ref-note code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--panel-3);
  padding: 1px 5px;
  border-radius: 4px;
}
.ref-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.75;
  color: var(--text-2);
}

/* ============================================================
   无限画布
   ============================================================ */
#view.cv-host {
  padding: 0;
  overflow: hidden;
  position: relative;      /* 关键：.cv-wrap 的 inset:0 要以它为基准，否则铺满整个窗口 */
}

.cv-wrap { position: absolute; inset: 0; }
.cv-viewport {
  position: absolute; inset: 0;
  overflow: hidden;
  cursor: grab;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--line-strong) 1px, transparent 1px);
  background-size: 24px 24px;
  touch-action: none;
}
.cv-viewport:active { cursor: grabbing; }

.cv-world {
  position: absolute; left: 0; top: 0;
  transform-origin: 0 0;
  /* 不要加 will-change / translateZ：那会把这层交给合成器按当前倍率栅格化，
     放大后文字就变成拉伸的位图。让浏览器每次按实际倍率重新绘制才清晰。 */
}
.cv-edges {
  position: absolute; left: 0; top: 0;
  width: 1px; height: 1px;
  overflow: visible;
  color: var(--rose);
  pointer-events: none;
}

/* ---------- 节点 ---------- */
.cv-node {
  position: absolute;
  min-width: 190px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 6px 18px -10px rgba(30, 20, 15, .45);
  user-select: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
/* 自由拉伸时关掉过渡，避免跟手 */
.cv-node.resizing { transition: none; }
/* 主体区在拉伸后撑满剩余高度，让内容可随高度扩展 */
.cv-node > :not(.cv-node-head):not(.cv-port):not(.cv-resize) {
  min-height: 0;
}
.cv-wf, .cv-gen-body, .cv-simple-ref { flex: 1; }
.cv-node.resizing { cursor: nwse-resize; }
.cv-resize {
  position: absolute; right: 3px; bottom: 3px;
  width: 13px; height: 13px; cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 46%, var(--text-3) 46%, var(--text-3) 54%, transparent 54%);
  opacity: .55; border-radius: 0 0 3px 0;
}
.cv-node:hover .cv-resize { opacity: .9; }
.cv-node.resizing .cv-resize { opacity: 1; }
.cv-node:hover { border-color: var(--text-3); }
.cv-node.sel {
  border-color: var(--rose);
  box-shadow: 0 0 0 2px var(--rose-soft), 0 8px 22px -12px rgba(30, 20, 15, .5);
}

.cv-node-head {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px 7px 10px;
  border-bottom: 1px solid var(--line);
  cursor: grab;
}
.cv-tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: .5px;
  padding: 2px 7px; border-radius: 5px;
  background: var(--panel-3); color: var(--text-2);
  white-space: nowrap;
}
.cv-node.node-gen .cv-tag { background: var(--rose-soft); color: var(--rose-ink); }
.cv-node.node-prompt .cv-tag { background: var(--accent-soft); color: var(--accent-text); }
.cv-title {
  flex: 1; min-width: 0;
  font-size: 12.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cv-head-ops { display: flex; gap: 2px; }
.cv-mini {
  width: 20px; height: 20px;
  border: none; background: transparent; border-radius: 5px;
  display: grid; place-items: center;
  color: var(--text-3); cursor: pointer;
}
.cv-mini:hover { background: var(--panel-3); color: var(--text); }

.cv-img { display: block; width: 100%; height: auto; border-radius: 0 0 12px 12px; }
.cv-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 7px; padding: 32px 14px;
  color: var(--text-3); font-size: 12.5px; text-align: center;
  border-bottom: 1px dashed var(--line);
}

.cv-role { display: flex; gap: 4px; padding: 7px 10px 0; }
.cv-role-btn {
  border: 1px solid var(--line-strong); background: transparent;
  color: var(--text-2); font-size: 11.5px;
  padding: 3px 11px; border-radius: 99px; cursor: pointer;
}
.cv-role-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }

.cv-text {
  display: block; width: 100%;
  min-height: 108px; max-height: 300px;
  border: none; background: transparent;
  padding: 9px 12px 12px;
  font-family: var(--mono); font-size: 13px; line-height: 1.65;
  color: var(--text); resize: vertical; outline: none;
}
/* 节点被拉高时，提示词文本域跟着撑满，而不是卡在固定高度 */
.cv-node[style*="height"] .cv-text,
.cv-node.resizing .cv-text {
  flex: 1 1 auto;
  min-height: 60px;
  max-height: none;
}

.cv-gen-body { border-bottom: 1px solid var(--line); }
.cv-gen-meta {
  display: flex; gap: 8px; justify-content: space-between;
  padding: 8px 11px;
  font-size: 11.5px; color: var(--text-3);
  font-family: var(--mono);
  cursor: pointer;
}
.cv-gen-meta:hover { color: var(--text); }
.cv-gen-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-gen-meta span:first-child { flex: 1 1 auto; min-width: 0; }
.cv-gen-meta span:last-child { flex: 0 1 auto; max-width: 58%; }
.cv-gen-status {
  padding: 0 11px 8px;
  font-size: 11.5px; color: var(--text-2);
  line-height: 1.5;
  /* 「已用 00:07」每秒都在变，等宽数字能避免整行左右抖动 */
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.cv-gen-status.error {
  color: var(--danger);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cv-gen-status.done { color: var(--ok); }
.cv-run {
  display: block;
  /* 左右 11px 跟上面的尺寸 / 张数行对齐，8px 会差出一条边 */
  width: calc(100% - 22px);
  margin: 2px 11px 8px;
  height: 33px;
  border: none; border-radius: 8px;
  background: var(--accent); color: var(--accent-fg);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.cv-run:hover { background: var(--accent-2); }
.cv-run:disabled { opacity: .55; cursor: default; }

.cv-wf { padding: 9px 10px; }
.cv-wf-cls {
  font-family: var(--mono); font-size: 12px; color: var(--text-2);
  margin-bottom: 6px; word-break: break-all;
}
.cv-wf-w div {
  font-family: var(--mono); font-size: 11.5px; color: var(--text-3);
  line-height: 1.6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cv-wf-io { margin-top: 7px; font-size: 11px; color: var(--text-3); }

/* ---------- 工作流节点：参数可编辑 ---------- */
.cv-wf.bypassed { opacity: .6; }
.cv-wf-rows { display: flex; flex-direction: column; gap: 5px; }
.cv-wf-row { display: block; }
.cv-wf-row > span {
  display: block; font-family: var(--mono); font-size: 10.5px;
  color: var(--text-3); margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cv-wf-row input, .cv-wf-row textarea {
  display: block; width: 100%;
  border: 1px solid var(--line-input);
  background: var(--panel); color: var(--text);
  border-radius: 7px; padding: 4px 7px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.5;
  resize: vertical; outline: none;
}
.cv-wf-row input:focus, .cv-wf-row textarea:focus { border-color: var(--accent); }
.cv-wf-linked {
  display: block; font-style: normal; font-size: 11px;
  color: var(--text-3); padding: 3px 0;
}

/* ---------- 简易节点 ---------- */
.cv-text.sm {
  min-height: 44px; font-size: 12px;
  border-top: 1px solid var(--line); padding: 7px 12px 9px;
}
.cv-simple-ref { cursor: pointer; }
.cv-drop.sm { padding: 15px 12px; font-size: 11.5px; border-bottom: none; }
.cv-img.sm { max-height: 180px; object-fit: cover; border-radius: 0; }

/* ---------- 简易节点包 ---------- */
.pk-sec { margin-bottom: 22px; }
.pk-sec h3 { font-size: 13px; font-weight: 600; margin-bottom: 3px; color: var(--text); }
.pk-sec p.sub { font-size: 11.5px; color: var(--text-3); margin-bottom: 11px; }
.pk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 10px; }
.pk-card {
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); padding: 12px 13px;
  display: flex; flex-direction: column; gap: 6px;
}
.pk-card b { font-size: 12.5px; color: var(--text); }
.pk-card p { font-size: 11.5px; color: var(--text-3); line-height: 1.55; }
.pk-fields { display: flex; flex-direction: column; gap: 6px; margin: 2px 0 4px; }
.pk-fields label {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--text-2);
}
.pk-fields label > select, .pk-fields label > input {
  flex: 1; min-width: 0;
  border: 1px solid var(--line-input); background: var(--panel);
  color: var(--text); border-radius: 7px; padding: 5px 7px;
  font-size: 11.5px; outline: none;
}
.entity-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel);
}
.entity-row .entity-main { flex: 1; min-width: 0; }
.entity-row .entity-main span {
  display: block; font-size: 11px; color: var(--text-3);
  font-family: var(--mono); margin-top: 2px;
}
.entity-row .entity-main span.entity-sub {
  font-family: inherit; color: var(--text-2);
  line-height: 1.5; word-break: break-all;
}
.entity-row .entity-main span.entity-sub a {
  color: var(--rose); text-decoration: underline;
}

/* ---------- 端口 ---------- */
.cv-port {
  position: absolute; top: 50%;
  width: 13px; height: 13px;
  margin-top: -6.5px;
  border-radius: 99px;
  background: var(--panel);
  border: 2px solid var(--text-3);
  cursor: crosshair;
  transition: .15s var(--ease);
}
.cv-port:hover { border-color: var(--rose); transform: scale(1.25); background: var(--rose-soft); }
.cv-port.in { left: -7px; }
.cv-port.out { right: -7px; }

/* ---------- 浮动工具 ---------- */
.cv-hud {
  position: absolute; left: 18px; bottom: 18px;
  display: flex; align-items: center; gap: 5px;
  padding: 6px;
  background: var(--glass);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}
.cv-tool {
  display: inline-flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 10px;
  border: none; border-radius: 8px;
  background: transparent; color: var(--text-2);
  font-size: 12px; cursor: pointer;
}
.cv-tool:hover { background: var(--panel-3); color: var(--text); }
.cv-tool svg { flex: 0 0 auto; }
.cv-hud-sep { width: 1px; height: 20px; background: var(--line-strong); margin: 0 3px; }
.cv-zoom {
  font-family: var(--mono); font-size: 11.5px; color: var(--text-2);
  min-width: 46px; text-align: center;
  border: none; background: transparent; cursor: pointer;
  border-radius: 7px; height: 28px;
}
.cv-zoom:hover { background: var(--panel-3); color: var(--text); }

/* 缩放比例弹层：锚在 HUD 百分比按钮上方，fixed 定位（zoomMenu 里量好再摆） */
.cv-zoom-pop {
  position: fixed; z-index: 90;
  width: 224px; padding: 12px;
  background: var(--glass);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
}
.cv-zoom-row { display: flex; align-items: center; gap: 4px; }
.cv-zoom-pop input {
  flex: 1; min-width: 0; height: 32px;
  font-family: var(--mono); font-size: 14px; text-align: right;
  color: var(--text); background: var(--panel);
  border: 1px solid var(--line-input); border-radius: 8px;
  padding: 0 8px; outline: none;
}
.cv-zoom-pop input:focus { border-color: var(--accent, var(--text)); }
/* 隐藏 number 输入的上下箭头，窄面板里又挤又没用 */
.cv-zoom-pop input::-webkit-outer-spin-button,
.cv-zoom-pop input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cv-zoom-pop input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.cv-zoom-pct { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.cv-zoom-presets { display: flex; gap: 4px; margin-top: 9px; }
.cv-zoom-presets button {
  flex: 1; height: 24px; padding: 0 5px;
  font-family: var(--mono); font-size: 10.5px; color: var(--text-2);
  white-space: nowrap;
  background: transparent; border: 1px solid var(--line);
  border-radius: 7px; cursor: pointer;
}
.cv-zoom-presets button:hover { background: var(--panel-3); color: var(--text); }
.cv-zoom-hint { margin-top: 8px; font-size: 10.5px; color: var(--text-3); text-align: center; }
.cv-hint {
  position: absolute; right: 18px; bottom: 20px;
  font-size: 11px; color: var(--text-3);
  background: var(--glass);
  padding: 6px 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.entity.is-cur { border-color: var(--rose); background: var(--rose-soft); }

/* ============================================================
   提示词组合台
   ============================================================ */
.composer {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  gap: 26px;
  align-items: stretch;
  max-width: 1180px;
}
.comp-left { display: flex; flex-direction: column; align-items: center; }
.comp-slot {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
}
.comp-slot.empty-slot { border-style: dashed; border-color: var(--line-strong); background: transparent; }
.slot-label {
  align-self: flex-start;
  font-size: 10.5px; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--text-3); font-weight: 600;
}
.slot-empty {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 22px 0 10px;
  color: var(--text-3); font-size: 12.5px;
}
.slot-empty svg { opacity: .5; }
.slot-img {
  width: 100%;
  max-height: 250px;
  border-radius: 10px;
  object-fit: contain;
  background: var(--panel-2);
  display: block;
}
.slot-img.face { aspect-ratio: 4 / 5; }
.slot-img.fit { aspect-ratio: 2 / 3; }
.slot-img.pose { aspect-ratio: 3 / 4; }
.slot-meta { font-size: 11px; color: var(--text-2); font-family: var(--mono); text-align: center; }
.slot-ops { display: flex; gap: 6px; }
.comp-plus {
  font-size: 16px; color: var(--text-3);
  padding: 7px 0;
  font-family: var(--mono);
}
.comp-right { min-width: 0; display: flex; flex-direction: column; }
.comp-text {
  width: 100%;
  min-height: 300px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.75;
}
.comp-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.comp-agent { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.comp-note {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 11.5px;
  line-height: 1.9;
  color: var(--text-2);
}
.comp-note b { color: var(--text); font-weight: 600; }
.comp-note code {
  font-family: var(--mono); font-size: 11px;
  background: var(--panel-3); padding: 1px 5px; border-radius: 4px;
}
.ref-card.picked { border-color: var(--rose); box-shadow: 0 0 0 2px var(--rose-soft); }

/* ---------- 组合历史 ---------- */
.comp-hist {
  display: flex; flex-direction: column; gap: 7px;
  max-height: 340px; overflow-y: auto;
  padding-right: 2px;
}
.hist-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  transition: .15s var(--ease);
}
.hist-item:hover { border-color: var(--line-strong); background: var(--panel-2); }
.hist-imgs { display: flex; gap: 4px; flex: 0 0 auto; }
.hist-imgs img {
  width: 34px; height: 42px;
  object-fit: cover;
  border-radius: 5px;
  background: var(--panel-3);
}
.hist-ph {
  width: 34px; height: 42px;
  border-radius: 5px;
  border: 1px dashed var(--line-strong);
  display: grid; place-items: center;
  font-size: 9px; color: var(--text-3);
}
.hist-main { flex: 1; min-width: 0; }
.hist-text {
  font-size: 11.5px; line-height: 1.5; color: var(--text);
  font-family: var(--mono);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.hist-meta { font-size: 10.5px; color: var(--text-3); margin-top: 3px; }
.hist-del {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  border: none; background: transparent;
  border-radius: 6px;
  display: grid; place-items: center;
  color: var(--text-3);
  opacity: 0;
  transition: .15s;
}
.hist-item:hover .hist-del { opacity: 1; }
.hist-del:hover { background: var(--panel-3); color: var(--danger); }

@media (max-width: 900px) {
  .composer { grid-template-columns: 1fr; gap: 18px; }
  .comp-left { flex-direction: row; align-items: stretch; gap: 10px; }
  .comp-slot { flex: 1; }
  .comp-plus { align-self: center; }
}

/* ---------- 智能体选择 ---------- */
.agent-picker {
  padding: 12px 13px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  margin-bottom: 16px;
}
.agent-picker-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 9px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .3px;
  color: var(--text-2);
}
.agent-chips {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding-bottom: 3px;
}
.agent-chips::-webkit-scrollbar { height: 6px; }
.agent-chip {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 7px 13px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  text-align: left;
  transition: .15s var(--ease);
}
.agent-chip b { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; }
.agent-chip span { font-size: 10px; color: var(--text-3); font-family: var(--mono); white-space: nowrap; }
.agent-chip:hover { border-color: var(--text-3); }
.agent-chip.active { background: var(--accent); border-color: var(--accent); }
.agent-chip.active b { color: var(--accent-fg); }
.agent-chip.active span { color: var(--accent-fg); opacity: .68; }
.agent-meta {
  margin-top: 10px;
  font-size: 11.5px; line-height: 1.65;
  color: var(--text-2);
}

/* ---------- 服务商 / 智能体列表 ---------- */
.entity-list { display: flex; flex-direction: column; gap: 8px; }
.entity {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  transition: .15s var(--ease);
}
.entity:hover { border-color: var(--line-strong); }
.entity-mark {
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 9px;
  display: grid; place-items: center;
  background: var(--panel-3);
  color: var(--text-2);
  font-size: 12px; font-weight: 700;
  font-family: var(--mono);
}
.entity-main { flex: 1; min-width: 0; }
.entity-main b { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
.entity-main small {
  display: block; font-size: 11px; color: var(--text-3);
  font-family: var(--mono); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.entity-main em {
  display: block; font-style: normal; font-size: 11.5px;
  color: var(--text-2); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.entity-ops { display: flex; gap: 4px; flex: 0 0 auto; }
.entity-tag {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 5px;
  background: var(--panel-3); color: var(--text-2); white-space: nowrap;
}
.entity-tag.ok { background: var(--accent-soft); color: var(--text); }
.entity-tag.warn { background: var(--rose-soft); color: var(--rose-ink); }

/* ============================================================
   弹窗
   ============================================================ */
#modal {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(20, 19, 17, .58);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade .16s var(--ease);
}
.modal-box {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
  animation: pop .2s var(--ease);
  overflow: hidden;
}
.modal-box.wide { max-width: 940px; }
.modal-box.narrow { max-width: 440px; }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(8px); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.modal-head .sub { font-size: 11.5px; color: var(--text-3); margin: 2px 0 0; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 13px 20px; border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--panel);
  flex: 0 0 auto;
}
.modal-foot .spacer { flex: 1; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--panel-2); border: 1px solid var(--line-input);
  border-radius: 9px;
}
.seg button {
  border: none; background: none; color: var(--text-2);
  padding: 5px 13px; border-radius: 7px; font-size: 12.5px; font-weight: 500;
  transition: .15s var(--ease);
}
.seg button.active { background: var(--accent); color: var(--accent-fg); font-weight: 600; }

/* ---------- 上传队列 ---------- */
.up-list { display: flex; flex-direction: column; gap: 10px; }
.up-item {
  display: flex; gap: 12px;
  padding: 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
}
.up-item .thumb {
  width: 74px; height: 74px; border-radius: 8px; object-fit: cover;
  background: var(--panel-3); flex: 0 0 auto;
}
.up-item .info { flex: 1; min-width: 0; }
.up-item .fname {
  font-size: 12.5px; font-family: var(--mono); color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.up-item .parsed { font-size: 12px; color: var(--text-2); margin-top: 5px; line-height: 1.55; }
.up-item .parsed .got { color: var(--ok); }
.up-item .mini-input { height: 28px; font-size: 12px; margin-top: 6px; padding: 0 8px; }

.bulk-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 14px;
  background: var(--accent-soft);
  border: 1px solid rgba(124, 92, 255, .25);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.bulk-bar select { width: auto; min-width: 130px; height: 28px; padding: 0 28px 0 9px; font-size: 12px;
  background-position: calc(100% - 15px) 13px, calc(100% - 10px) 13px; }

/* ---------- toast ---------- */
#toasts {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 15px;
  background: var(--panel-3);
  border: 1px solid var(--line-strong);
  color: var(--text);
  border-radius: 10px;
  font-size: 12.5px;
  box-shadow: var(--shadow);
  animation: toastIn .22s var(--ease);
  max-width: 460px;
}
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--danger); color: var(--danger); }
.toast.out { animation: toastOut .2s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* ---------- 拖拽提示 ---------- */
#dropzone-hint {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(10, 12, 16, .8);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  pointer-events: none;
}
.dz-inner {
  border: 2px dashed var(--rose);
  border-radius: 22px;
  padding: 44px 66px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--text);
  background: var(--glass);
  box-shadow: var(--shadow);
}
.dz-inner svg { width: 34px; height: 34px; color: var(--rose); }
.dz-inner b { font-size: 17px; }
.dz-inner span { font-size: 12.5px; color: var(--text-3); }

/* ---------- 加载 ---------- */
.spinner {
  width: 15px; height: 15px; border-radius: 99px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--panel) 25%, var(--panel-3) 50%, var(--panel) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius);
  aspect-ratio: 1/1;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .lb-panel { width: 340px; flex-basis: 340px; }
}
@media (max-width: 860px) {
  #sidebar { width: 64px; flex-basis: 64px; padding: 12px 8px; }
  .brand-text, .nav-item span.lbl, .nav-label, .storage-line { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-item .count { display: none; }
  #topbar { padding: 14px 16px 12px; }
  #view { padding: 14px 16px 50px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  #lightbox { flex-direction: column; }
  .lb-panel { width: 100%; flex: 0 0 46%; border-left: none; border-top: 1px solid var(--line); }
  .lb-stage { padding: 10px; flex: 1 1 54%; min-height: 0; }
}

/* ============================================================
   侧栏社交链接
   ============================================================ */
.side-links {
  display: flex;
  gap: 6px;
  padding: 0 8px 8px;
}
.side-link {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
  text-decoration: none;
  transition: .15s var(--ease);
}
.side-link svg { width: 13px; height: 13px; flex: 0 0 auto; }
.side-link:hover {
  border-color: var(--rose);
  color: var(--rose-ink);
  background: var(--rose-soft);
}

/* ============================================================
   图库筛选
   ============================================================ */
.filter-toggle { gap: 5px; }
.gallery-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-2);
}
.gallery-filters select {
  height: 32px;
  padding: 0 28px 0 10px;
  font-size: 12.5px;
  max-width: 210px;
  background-position: calc(100% - 16px) 14px, calc(100% - 11px) 14px;
}
.chk-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.chk-inline input { width: 14px; height: 14px; accent-color: var(--rose); }

/* ============================================================
   提示词片段
   ============================================================ */
.snip-wrap { max-width: 980px; }
.snip-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.snip-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.snip-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  transition: .15s var(--ease);
}
.snip-row:hover { border-color: var(--line-strong); background: var(--panel-2); }
.snip-row.pick:hover { border-color: var(--rose); }
.snip-main { flex: 1; min-width: 0; }
.snip-text {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
}
.snip-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
}
.snip-used { font-size: 10.5px; color: var(--text-3); font-family: var(--mono); }
.snip-ops {
  display: flex;
  gap: 3px;
  flex: 0 0 auto;
  opacity: .45;
  transition: .15s;
}
.snip-row:hover .snip-ops { opacity: 1; }

.snip-import-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.snip-preview {
  max-height: 48vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: var(--panel-2);
}
.snip-pv {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 6px;
}
.snip-pv:hover { background: var(--panel); }
.snip-pv .badge { flex: 0 0 auto; }
.snip-pv-t {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-2);
  word-break: break-word;
}

/* ============================================================
   画布生成进度条
   ============================================================ */
.cv-prog {
  height: 3px;
  margin: 0 10px 4px;
  border-radius: 99px;
  background: var(--panel-3);
  overflow: hidden;
}
.cv-prog i {
  display: block;
  height: 100%;
  background: var(--rose);
  border-radius: 99px;
  transition: width .25s var(--ease);
}

/* ---------- 设置页外链 ---------- */
.about-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.about-links a {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  font-size: 12px;
  text-decoration: none;
  transition: .15s var(--ease);
}
.about-links a:hover {
  border-color: var(--rose);
  color: var(--rose-ink);
  background: var(--rose-soft);
}

/* 画布 HUD 的退出按钮 */
.cv-exit { font-weight: 600; }
.cv-exit:hover { background: var(--rose-soft); color: var(--rose-ink); }

/* ============================================================
   侧栏收起
   ============================================================ */
#sidebar { position: relative; transition: width .2s var(--ease), flex-basis .2s var(--ease); }

.side-toggle {
  position: absolute;
  top: 22px; right: -11px;
  width: 22px; height: 22px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text-3);
  display: grid; place-items: center;
  cursor: pointer;
  z-index: 6;
  padding: 0;
  transition: .15s var(--ease);
}
.side-toggle svg { width: 13px; height: 13px; }
.side-toggle:hover {
  border-color: var(--rose);
  color: var(--rose-ink);
  background: var(--rose-soft);
}

#app.side-mini #sidebar {
  width: 62px;
  flex: 0 0 62px;
  padding: 16px 8px 12px;
}
#app.side-mini .brand { justify-content: center; padding: 4px 0 16px; }
#app.side-mini .brand-text { display: none; }

#app.side-mini .nav-item {
  justify-content: center;
  padding: 10px 0;
  gap: 0;
}
#app.side-mini .nav-item .lbl,
#app.side-mini .nav-item .count { display: none; }
#app.side-mini .nav-item svg { width: 19px; height: 19px; }

/* 分组标题收成一条细线，保留节奏感 */
#app.side-mini .nav-label {
  display: block;
  height: 1px; padding: 0;
  margin: 9px 8px;
  font-size: 0; letter-spacing: 0;
  background: var(--line);
  border-radius: 1px;
}
#app.side-mini #nav > .nav-label:first-child { margin-top: 4px; }

#app.side-mini .storage-line { display: none; }
#app.side-mini .side-foot { padding-top: 8px; }
#app.side-mini .side-links { flex-direction: column; padding: 0 2px 6px; }
#app.side-mini .side-link { height: 30px; }
#app.side-mini .side-link span { display: none; }
#app.side-mini .side-link svg { width: 15px; height: 15px; }
#app.side-mini .side-actions { flex-direction: column; gap: 4px; }
#app.side-mini .ghost-btn { height: 32px; }

/* ============================================================
   一键安装 ComfyUI（设置页）
   ============================================================ */
.install-box {
  display: flex; flex-direction: column; gap: 10px;
  padding: 13px;
  margin: 0 0 15px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.install-top { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.install-top-txt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.install-top-txt b { font-size: 13px; color: var(--text); font-weight: 600; }
.install-top-txt span { font-size: 11.5px; color: var(--text-2); line-height: 1.65; }
.install-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.install-row > label {
  font-size: 11.5px; font-weight: 600; color: var(--text-2);
  letter-spacing: .3px; min-width: 54px; flex: 0 0 auto;
}
.install-row > input[type="text"] { flex: 1 1 240px; min-width: 160px; font-size: 12.5px; }
.install-row > select { flex: 0 0 auto; width: auto; min-width: 200px; height: 34px; padding: 0 9px; font-size: 12.5px; }
.install-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-2); white-space: nowrap;
  min-width: 0 !important; font-weight: 400 !important;
}
.install-check input { accent-color: var(--rose); }

.install-panel {
  display: flex; flex-direction: column; gap: 9px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}
/* 类选择器比 UA 的 [hidden] 优先级高，必须显式压掉，否则收起不生效 */
.install-panel[hidden] { display: none; }
.install-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.inst-step {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px 3px 4px;
  font-size: 11.5px; color: var(--text-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  transition: .25s var(--ease);
}
.inst-step i {
  font-style: normal; width: 15px; height: 15px; flex: 0 0 auto;
  display: grid; place-items: center;
  font-size: 9px; font-weight: 700;
  border-radius: 50%;
  background: var(--panel-3); color: var(--text-3);
}
.inst-step.running { color: var(--text); border-color: var(--rose); background: var(--rose-soft); }
.inst-step.running i { background: var(--rose); color: #fff; }
.inst-step.done { color: var(--text-2); border-color: rgba(157, 187, 139, .45); }
.inst-step.done i { background: rgba(157, 187, 139, .22); color: var(--ok); }
.inst-step.skip { opacity: .72; }
.inst-step.cancel { opacity: .6; }
.inst-step.cancel i { background: var(--panel-3); color: var(--text-2); }
.inst-step.fail { color: var(--danger); border-color: rgba(224, 138, 128, .55); background: var(--danger-soft); }
.inst-step.fail i { background: var(--danger-soft); color: var(--danger); }
.inst-sep { font-style: normal; color: var(--text-3); opacity: .5; font-size: 11px; }

.install-bar { height: 5px; border-radius: 3px; background: var(--panel-3); overflow: hidden; }
.install-bar > i {
  display: block; height: 100%; width: 0;
  background: var(--rose);
  transition: width .4s var(--ease), background .3s var(--ease);
}
.install-bar > i[data-state="ok"] { background: var(--ok); }
.install-bar > i[data-state="fail"] { background: var(--danger); }

.install-msg { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.install-msg em { font-style: normal; color: var(--text-3); font-size: 11px; }
.install-msg.ok { color: var(--ok); }
.install-msg.fail { color: var(--danger); align-items: flex-start; }

.install-log {
  margin: 0; max-height: 190px; overflow: auto;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--mono); font-size: 10.8px; line-height: 1.65;
  color: var(--text-2);
  white-space: pre-wrap; word-break: break-all;
}
.install-log:empty { display: none; }
.install-foot { display: flex; align-items: center; gap: 10px; }
.install-foot .spacer { flex: 1; }

.spin {
  width: 11px; height: 11px; flex: 0 0 auto;
  border: 1.6px solid var(--line-strong);
  border-top-color: var(--rose);
  border-radius: 50%;
  animation: loom-spin .8s linear infinite;
}
@keyframes loom-spin { to { transform: rotate(360deg); } }

/* 高级选项：模型目录自动识别提示 */
.auto-tag {
  font-style: normal; font-size: 9.5px; font-weight: 600;
  color: var(--rose); background: var(--rose-soft);
  border-radius: 4px; padding: 1px 5px; margin-left: 6px;
  vertical-align: 1px;
}
/* 手动指定的路径和「自动识别」要能一眼分清 */
.auto-tag.custom {
  color: var(--text-3);
  background: var(--accent-soft);
}
.adv-auto {
  font-size: 11.5px; line-height: 1.65;
  color: var(--ok);
  background: rgba(157, 187, 139, .1);
  border: 1px solid rgba(157, 187, 139, .35);
  border-radius: 8px;
  padding: 7px 10px;
  margin-bottom: 11px;
}
.adv-auto.none {
  color: var(--text-2);
  background: var(--panel-2);
  border-color: var(--line);
}
.adv-auto code {
  font-family: var(--mono); font-size: 11px;
  color: var(--text); background: var(--panel);
  padding: 1px 4px; border-radius: 4px;
}

/* 工作流 · 切换模型弹窗 */
.wfm-list { display: flex; flex-direction: column; gap: 9px; }
.wfm-row { display: flex; align-items: flex-start; gap: 10px; }
.wfm-kind {
  flex: 0 0 62px; margin-top: 4px;
  font-size: 10.5px; font-weight: 600; text-align: center;
  color: var(--rose); background: var(--rose-soft);
  border-radius: 6px; padding: 3px 0;
}
.wfm-main { flex: 1; min-width: 0; }
.wfm-main input { width: 100%; font-size: 12.5px; }
.wfm-sub { font-size: 10.5px; color: var(--text-3); margin-top: 3px; }
.wfm-warn { font-style: normal; color: var(--warn); margin-left: 4px; }
.wfm-strength { flex: 0 0 64px; margin-top: 0; text-align: center; font-size: 12.5px; }
.wfm-strength-empty { flex: 0 0 64px; }

/* 画布生成节点的「取消」 */
.cv-cancel {
  width: calc(100% - 22px); margin: 0 11px 10px; height: 26px;
  border-radius: 8px;
  border: 1px solid var(--line-input);
  background: transparent;
  color: var(--text-2);
  font-size: 11.5px;
  transition: .15s var(--ease);
}
.cv-cancel:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

/* 引擎出图导入列表 */
.out-list { display: flex; flex-direction: column; gap: 6px; max-height: 380px; overflow: auto; }
.out-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
}
.out-row:hover { border-color: var(--line-strong); }
.out-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.out-main b {
  font-size: 12px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.out-main span { font-size: 10.5px; color: var(--text-3); }

/* ============================================================
   画布 · 槽位徽章 / 批量 / 图片组 / 遮罩 / 小地图
   ============================================================ */

/* 槽位徽章：工作流标了什么就显示什么 */
.cv-slots {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  /* 左右 11px 跟 .cv-gen-meta / .cv-gen-status 对齐，否则控件像贴在边框上 */
  margin: 2px 11px 6px;
}
.cv-slots i {
  font-style: normal; font-size: 9.5px; font-weight: 600;
  letter-spacing: .2px;
  padding: 1px 6px; border-radius: 20px;
  color: var(--rose-ink); background: var(--rose-soft);
  border: 1px solid transparent;
  white-space: nowrap;
}
.cv-slots i.num {
  color: var(--text-2); background: var(--panel-3);
}
.cv-slots.none {
  font-size: 10px; color: var(--text-3);
  padding: 2px 7px; border-radius: 20px;
  background: var(--panel-2); border: 1px dashed var(--line-strong);
  display: block; width: fit-content;
  margin: 2px 11px 6px;
}

/* 批量张数 + 固定种子 */
.cv-batch {
  display: flex; align-items: center; gap: 5px;
  margin: 0 11px 7px;
  font-size: 10.5px; color: var(--text-3);
}
.cv-batch > span { margin-right: 1px; }
.cv-batch > button {
  width: 20px; height: 20px; padding: 0;
  border-radius: 6px;
  border: 1px solid var(--line-input);
  background: var(--panel-2); color: var(--text-2);
  font-size: 13px; line-height: 1;
  cursor: pointer;
  transition: .15s var(--ease);
}
.cv-batch > button:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); }
.cv-batch > button:disabled { opacity: .4; cursor: default; }
.cv-batch > b {
  min-width: 14px; text-align: center;
  font-size: 12px; color: var(--text); font-weight: 600;
}
.cv-seedfix {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: auto; font-size: 10px; color: var(--text-3);
  cursor: pointer;
}
.cv-seedfix input { accent-color: var(--rose); margin: 0; }

/* 出图尺寸行：只在工作流标了 width / height / duration 槽位时才出现 */
.cv-size {
  display: flex; align-items: center; gap: 5px;
  margin: 0 11px 7px;
  font-size: 10.5px; color: var(--text-3);
  flex-wrap: wrap; row-gap: 4px;
}
.cv-size > span { margin-right: 1px; white-space: nowrap; }
.cv-size > i { font-style: normal; color: var(--text-3); }
/* 必须带上 input[type=number] 才压得住全局那条 `width:100%; height:36px` 的表单样式 */
.cv-size input.cv-size-num[type="number"] {
  width: 54px; height: 22px;
  min-width: 0;
  padding: 0 4px;
  border: 1px solid var(--line-input); border-radius: 6px;
  background: var(--panel-2); color: var(--text);
  font-family: var(--mono); font-size: 11px;
  line-height: 20px;
  text-align: center;
  flex: 0 0 auto;
  -moz-appearance: textfield;
}
.cv-size input.cv-size-num[type="number"]::-webkit-outer-spin-button,
.cv-size input.cv-size-num[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cv-size input.cv-size-num[type="number"]:focus { outline: none; border-color: var(--text-3); box-shadow: none; }
.cv-size select {
  width: auto; height: 22px; max-width: 104px;
  padding: 0 18px 0 6px;
  border: 1px solid var(--line-input); border-radius: 6px;
  background-color: var(--panel-2); background-position: calc(100% - 11px) 9px, calc(100% - 7px) 9px;
  color: var(--text-2);
  font-size: 10.5px; cursor: pointer;
  flex: 0 0 auto;
}
.cv-size select:focus { outline: none; border-color: var(--text-3); box-shadow: none; }
.cv-size-unit { color: var(--text-3); }

/* 重试按钮（错误状态下出现在取消的位置） */
.cv-cancel.retry { color: var(--rose-ink); border-color: var(--rose); }
.cv-cancel.retry:hover { background: var(--rose-soft); }

/* 有遮罩的图片节点 */
.cv-mini.on { color: var(--rose-ink); background: var(--rose-soft); }
.cv-mask-chip {
  position: absolute; left: 8px; bottom: 8px;
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 20px;
  font-size: 9.5px; font-weight: 600;
  color: #fff; background: rgba(214, 120, 145, .9);
  pointer-events: none;
}

/* 图片组节点 */
.cv-group-main { position: relative; }
.cv-group-main .cv-img { display: block; }
.cv-group-count {
  position: absolute; right: 8px; top: 8px;
  padding: 1px 7px; border-radius: 20px;
  font-size: 10px; font-weight: 600;
  color: #fff; background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(4px);
}
.cv-group-strip {
  display: flex; gap: 4px; padding: 6px 8px 0;
  overflow-x: auto; scrollbar-width: none;
}
.cv-group-strip::-webkit-scrollbar { display: none; }
.cv-thumb {
  width: 34px; height: 34px; flex: 0 0 auto;
  object-fit: cover; border-radius: 6px;
  border: 1.5px solid transparent; opacity: .62;
  cursor: pointer; transition: .15s var(--ease);
}
.cv-thumb:hover { opacity: .9; }
.cv-thumb.on { border-color: var(--rose); opacity: 1; }
.cv-group-ops {
  display: flex; gap: 6px; padding: 7px 8px 9px;
}
.cv-group-ops > button {
  flex: 1; height: 24px; border-radius: 7px;
  border: 1px solid var(--line-input);
  background: transparent; color: var(--text-2);
  font-size: 10.5px; cursor: pointer;
  transition: .15s var(--ease);
}
.cv-group-ops > button:hover { color: var(--text); border-color: var(--line-strong); }

/* 展开图片组的网格 */
.group-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  max-height: 62vh; overflow: auto;
}
.group-cell {
  margin: 0; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 10px;
  overflow: hidden; background: var(--panel-2);
  transition: .15s var(--ease);
}
.group-cell:hover { border-color: var(--line-strong); }
.group-cell.on { border-color: var(--rose); box-shadow: 0 0 0 2px var(--rose-soft); }
.group-cell img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.group-cell figcaption {
  padding: 4px 7px; font-size: 10px; color: var(--text-3);
  font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 遮罩编辑器 */
.mask-stage {
  position: relative; margin: 0 auto 12px;
  border-radius: 10px; overflow: hidden;
  background: var(--panel-3);
  touch-action: none;
}
.mask-stage img { display: block; width: 100%; height: 100%; object-fit: contain; }
.mask-stage canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  cursor: crosshair; touch-action: none;
}
.mask-tools {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.mask-size {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-2);
}
.mask-size input { width: 120px; }
.mask-size b { font-family: var(--mono); font-size: 11px; color: var(--text); }
.mask-tools .btn.on { color: var(--rose-ink); border-color: var(--rose); background: var(--rose-soft); }

/* 小地图 */
.cv-map {
  position: absolute; right: 14px; bottom: 14px;
  width: 200px; height: 140px;
  padding: 4px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-elev) 82%, transparent);
  border: 1px solid var(--line);
  box-shadow: 0 6px 22px rgba(0, 0, 0, .18);
  backdrop-filter: blur(6px);
  cursor: crosshair;
  z-index: 6;
}
.cv-map canvas { display: block; width: 100%; height: 100%; border-radius: 8px; }
@media (max-width: 760px) { .cv-map { display: none; } }

/* 框选矩形 */
.cv-box {
  position: absolute; display: none;
  border: 1px solid var(--rose);
  background: var(--rose-soft);
  border-radius: 3px;
  pointer-events: none;
  z-index: 5;
}

/* 底部提示别被小地图压住 */
.cv-hint { right: 232px; max-width: calc(100% - 260px); text-align: right; }
@media (max-width: 760px) { .cv-hint { right: 18px; max-width: calc(100% - 36px); } }

/* 画布底部那条快捷键提示和 toast 都在底部，同时出现会叠在一起。
   画布存在时把 toast 抬起来（:has 不支持时退化成原来的位置，不影响功能）。 */
body:has(.cv-host) #toasts { bottom: 76px; }

/* 张数行：窄节点时换行，别把固定种子挤出去 */
.cv-batch { flex-wrap: wrap; row-gap: 4px; }
.cv-seedfix { flex: 0 0 auto; }

/* ============================================================
   资源监控（顶栏徽章 + 展开面板）
   ============================================================ */
.sys-badge {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 12px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text-2);
  font: inherit; font-size: 12px; line-height: 1;
  cursor: pointer; white-space: nowrap; max-width: 260px;
  transition: border-color .18s var(--ease), color .18s var(--ease), background .18s var(--ease);
}
.sys-badge:hover { color: var(--text); border-color: var(--text-3); }
.sys-badge.active { color: var(--text); border-color: var(--text-3); background: var(--panel-2); }
.sys-badge-text { overflow: hidden; text-overflow: ellipsis; }

.sys-badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-3); flex: 0 0 auto;
  transition: background .2s var(--ease);
}
.sys-badge.on .dot { background: var(--ok); }
.sys-badge.on.busy .dot {
  background: var(--rose);
  animation: sysPulse 1.9s var(--ease) infinite;
}
@keyframes sysPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--rose-soft); }
  50% { box-shadow: 0 0 0 4px transparent; }
}

/* ---------- 面板 ---------- */
.sys-panel {
  position: fixed; top: 68px; right: 24px; z-index: 70;
  width: 338px; max-height: calc(100vh - 100px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: sysIn .16s var(--ease);
}
.sys-panel[hidden] { display: none; }
@keyframes sysIn {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.sys-head {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 4px 6px;
}
.sys-head b { font-size: 13px; font-weight: 600; letter-spacing: .01em; }
.sys-head .sys-state {
  font-size: 11px; color: var(--text-3);
  padding: 1px 7px; border-radius: 99px; background: var(--accent-soft);
}
.sys-head .sys-ico {
  margin-left: auto;
  width: 26px; height: 26px; padding: 0;
  display: inline-grid; place-items: center;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--text-3); cursor: pointer;
}
.sys-head .sys-ico:hover { color: var(--text); background: var(--accent-soft); }
.sys-head .sys-ico svg { width: 15px; height: 15px; }

.sys-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3); flex: 0 0 auto;
}
.sys-dot.on { background: var(--ok); }
.sys-dot.warn { background: var(--warn); }

.sys-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  display: flex; flex-direction: column; gap: 7px;
}
.sys-card.flat { gap: 6px; }

.sys-card-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--text);
}
.sys-card-title svg { width: 14px; height: 14px; color: var(--text-3); flex: 0 0 auto; }
.sys-card-title-gpu span:nth-child(2) {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sys-card-title .sys-side { margin-left: auto; font-weight: 400; font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

.sys-tag {
  margin-left: auto;
  font-size: 11px; font-weight: 400;
  padding: 1px 8px; border-radius: 99px;
  background: var(--accent-soft); color: var(--text-3);
}
.sys-tag.on { background: var(--rose-soft); color: var(--rose-ink); }

.sys-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.sys-kv {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font-size: 12px; color: var(--text-2);
}
.sys-kv b {
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 190px;
}
.sys-grid2 .sys-kv { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.sys-grid2 .sys-kv b { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }

.sys-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text-2);
}
.sys-row b { font-family: var(--mono); font-size: 11.5px; color: var(--text); font-weight: 500; }

.sys-bar {
  height: 6px; border-radius: 99px;
  background: var(--panel-3); overflow: hidden;
}
.sys-bar > i {
  display: block; height: 100%; width: 0;
  border-radius: 99px; background: var(--text-3);
  transition: width .45s var(--ease), background .3s var(--ease);
}
.sys-bar.hot > i { background: var(--warn); }
.sys-bar.crit > i { background: var(--danger); }

.sys-sub { font-size: 11.5px; color: var(--text-3); font-family: var(--mono); }
.sys-card .sys-sub:last-child { margin-top: -2px; }

.sys-free {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; margin-top: 2px;
  border: 1px solid var(--line-strong); border-radius: 11px;
  background: var(--panel-2); color: var(--text);
  font: inherit; font-size: 12.5px; cursor: pointer;
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.sys-free:hover:not(:disabled) { border-color: var(--text-3); background: var(--panel-3); }
.sys-free:disabled { opacity: .45; cursor: not-allowed; }
.sys-free svg { width: 15px; height: 15px; color: var(--text-2); }

@media (max-width: 640px) {
  .sys-panel { right: 10px; left: 10px; width: auto; top: 60px; }
  .sys-badge { max-width: 150px; }
}

/* ============================================================
   画布 · 加参考图弹窗
   ============================================================ */
.refpick-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.refpick-bar input {
  flex: 1; height: 34px; padding: 0 11px;
  border: 1px solid var(--line-input); border-radius: 9px;
  background: var(--panel-2); color: var(--text); font-size: 12.5px;
}
.refpick-bar input:focus { outline: none; border-color: var(--rose); }
.refpick-bar .hint { white-space: nowrap; font-size: 11.5px; color: var(--text-3); }
.refpick-bar .hint.on { color: var(--rose-ink); font-weight: 600; }

.refpick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 9px;
  max-height: 50vh;
  overflow: auto;
  padding: 2px 6px 2px 2px;
}
.refpick {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color .15s var(--ease), transform .15s var(--ease);
}
.refpick:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.refpick.on { border-color: var(--rose); box-shadow: 0 0 0 3px var(--rose-soft); }
.refpick img {
  display: block; width: 100%; aspect-ratio: 3 / 4;
  object-fit: cover; background: var(--panel-3);
}
.refpick i {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 6px 4px;
  font-style: normal; font-size: 10px; color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, .58));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.refpick.on::after {
  content: '✓';
  position: absolute; top: 5px; right: 5px;
  width: 19px; height: 19px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--rose); color: #fff;
  font-size: 11px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}

.empty-mini {
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

/* 底栏的「+ 提示词 / + 参考图 / + 出图」比图标按钮宽一点，窄屏时收成图标 */
.cv-add span { white-space: nowrap; }
@media (max-width: 900px) {
  .cv-add span { display: none; }
  .cv-add { padding: 0 8px; }
}

/* 无后端时的页面说明条（在线体验） */
.page-note {
  display: flex; flex-direction: column; gap: 4px;
  margin: 0 0 14px; padding: 11px 13px;
  border: 1px solid var(--warn); border-radius: 11px;
  background: var(--warn-soft, rgba(200, 150, 60, .10));
  font-size: 12.5px; line-height: 1.7; color: var(--text-2);
}
.page-note b { color: var(--text); font-size: 13px; }
.page-note code {
  font-family: var(--mono); font-size: 11.5px;
  padding: 1px 5px; border-radius: 4px;
  background: var(--panel-3); color: var(--text);
}
