/* 看片灯箱：冷灰蓝的灯箱底 + 黑色胶片边条 + 红色油性笔做强调。
   结果卡片底部的边条印着这次生成的真实信息（编号 / 类型 / 模型 / 耗时 / 尺寸），同时就是「AI 生成」标识。 */

:root {
  --bg: #eceff3;
  --surface: #ffffff;
  --surface-2: #f4f6f8;
  --ink: #14181e;
  --muted: #667180;
  --line: #d9dee5;
  --marker: #d63a2a;
  --marker-ink: #ffffff;
  --marker-soft: #fbe7e3;
  --film: #17191d;
  --edge: #edb246;
  --hole: #eceff3;
  --radius: 10px;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1115;
    --surface: #161a20;
    --surface-2: #1c2129;
    --ink: #e6e9ed;
    --muted: #8e97a4;
    --line: #272d36;
    --marker: #f05a44;
    --marker-soft: #3a1f1b;
    --film: #08090b;
    --edge: #e9ae45;
    --hole: #39404a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 20px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--marker); min-height: 1.4em; font-size: 13.5px; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--marker); outline-offset: 2px; }

.primary {
  border: 0;
  border-radius: 8px;
  padding: 11px 18px;
  background: var(--marker);
  color: var(--marker-ink);
  font-weight: 600;
}
.primary:disabled { opacity: 0.55; cursor: progress; }
.ghost {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  background: var(--surface);
  color: var(--muted);
}
.ghost:hover { color: var(--ink); }
.link { border: 0; padding: 0; background: none; color: var(--marker); text-decoration: underline; text-underline-offset: 3px; }

input[type="email"], input[type="password"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
textarea { resize: vertical; line-height: 1.55; }
input[type="range"] { width: 100%; accent-color: var(--marker); }
input[type="file"] { font-size: 13px; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; font-size: 13px; font-weight: 500; color: var(--muted); }
.field legend { padding: 0; margin-bottom: 6px; }
.label-row { display: flex; justify-content: space-between; }
.counter, .timer { font-family: var(--mono); font-size: 12px; font-weight: 400; }

/* ---------- 品牌 ---------- */
.wordmark { display: flex; align-items: center; gap: 9px; font-family: var(--mono); font-size: 13px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
.mark { width: 12px; height: 12px; border-radius: 3px; background: var(--marker); }

/* ---------- 登录 ---------- */
.auth { min-height: 100%; display: grid; place-items: center; align-content: center; padding: 24px 16px; }
.auth-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.auth-card h1 { font-size: 26px; margin-top: 10px; }
/* ICP 备案号：登录页卡片下方、桌面端左侧导航底部 */
.beian { color: var(--muted); font-size: 12px; text-decoration: none; }
.beian:hover { text-decoration: underline; text-underline-offset: 3px; }
.auth .beian { margin-top: 18px; }

/* ---------- 整体布局：左侧导航 + 舞台 ---------- */
.app { display: grid; grid-template-columns: 196px 1fr; min-height: 100%; }
.mobile-top { display: none; }

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.rail > .wordmark { padding: 0 8px; }
.tabs { display: flex; flex-direction: column; gap: 2px; }
.tabs button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 15px;
  text-align: left;
}
.tabs button:hover { color: var(--ink); background: var(--surface-2); }
.tabs button.active { color: var(--ink); background: var(--surface-2); font-weight: 600; }
.tabs button.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--marker); }
.tabs svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 0 8px; }
.rail-foot #user-email { word-break: break-all; }
.rail-foot .link { font-size: 13px; color: var(--muted); }
.rail-foot p { margin-top: 10px; }

.stage { min-width: 0; padding: 28px clamp(16px, 3vw, 40px); }
.panel-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.panel-head select { width: auto; min-width: 240px; }

/* ---------- 创作页：左操作台 + 右灯箱 ---------- */
.studio { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; gap: 28px; align-items: start; }
.console {
  position: sticky;
  top: 28px;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.console-body { display: flex; flex-direction: column; gap: 18px; }

.examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -8px; }
.examples button {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 3px 9px;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  text-align: left;
}
.examples button:hover { color: var(--ink); border-color: var(--muted); }

.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { position: relative; }
.thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.thumb button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--surface);
  font-size: 12px;
  line-height: 20px;
  padding: 0;
}

/* 单选：模型卡片和小圆角选项 */
.model-cards { display: flex; flex-direction: column; gap: 6px; }
/* 选项多时排两列，预计耗时挪到第三行 */
.model-cards.compact { display: grid; grid-template-columns: 1fr 1fr; }
.model-cards.compact .model-card { grid-template-columns: 1fr; }
.model-cards.compact .eta { grid-column: 1; grid-row: auto; align-self: start; }
.model-cards label, .chips label { position: relative; }
.model-cards input, .chips input { position: absolute; opacity: 0; pointer-events: none; }
.model-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}
.model-card .name { color: var(--ink); font-size: 14px; font-weight: 600; }
.model-card .meta { grid-column: 1; font-size: 12px; font-weight: 400; color: var(--muted); }
.model-card .eta { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-family: var(--mono); font-size: 11.5px; font-weight: 400; color: var(--muted); }
.model-cards input:checked + .model-card { border-color: var(--marker); box-shadow: inset 0 0 0 1px var(--marker); }
.model-cards input:focus-visible + .model-card, .chips input:focus-visible + span { outline: 2px solid var(--marker); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span {
  display: inline-block;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 400;
  cursor: pointer;
}
.chips input:checked + span { border-color: var(--marker); background: var(--marker-soft); color: var(--ink); }


.segmented { display: flex; padding: 3px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); }
.segmented button { flex: 1; border: 0; border-radius: 7px; padding: 6px 10px; background: none; color: var(--muted); font-size: 14px; }
.segmented button.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }

.recorder { display: flex; align-items: center; gap: 14px; }
.record { display: inline-flex; align-items: center; gap: 9px; padding: 9px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 600; }
.record .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--marker); }
.record.on { border-color: var(--marker); color: var(--marker); }
.record.on .dot { animation: blink 1s steps(2, start) infinite; }

/* ---------- 灯箱和胶片帧 ---------- */
.lightbox { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.lightbox:empty::before, .contact-sheet:empty::before {
  content: attr(data-empty);
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 24px;
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
}

.frame { margin: 0; overflow: hidden; border-radius: var(--radius); background: var(--film); box-shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 8px 24px -12px rgb(20 24 30 / 0.25); }
.frame-media { display: grid; place-items: center; background: #0b0c0f; }
.frame-media a { display: block; width: 100%; }
.frame-media img, .frame-media video { display: block; width: 100%; height: auto; max-height: 72vh; object-fit: contain; }
.frame-media audio { width: calc(100% - 32px); margin: 22px 16px 6px; }
.frame-text { width: 100%; padding: 18px 20px; background: var(--surface); color: var(--ink); white-space: pre-wrap; font-size: 15px; }
.frame-caption { width: 100%; padding: 4px 20px 18px; color: #9aa3ae; font-size: 13px; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.frame-media:has(audio) { place-items: stretch; }
.frame-error { padding: 28px 22px; color: #ff9b8c; font-size: 14px; }

.frame.processing .frame-media {
  min-height: 240px;
  background:
    linear-gradient(105deg, transparent 35%, rgb(237 178 70 / 0.14) 50%, transparent 65%) 0 0 / 220% 100%,
    #0b0c0f;
  animation: develop 2.4s ease-in-out infinite;
}
.developing { max-width: 34em; padding: 24px; color: #8b939d; font-size: 14px; text-align: center; }

.edge {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  padding: 15px 14px 11px;
  color: var(--edge);
  font: 11px/1.3 var(--mono);
  letter-spacing: 0.08em;
  /* 不再全大写：中英混排时「GPT IMAGE」「0.1S」不好看 */
}
/* 齿孔：灯箱的光从孔里透出来 */
.edge::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 6px;
  right: 6px;
  height: 5px;
  background: radial-gradient(circle, var(--hole) 0 1.7px, transparent 2.1px) 0 0 / 14px 5px repeat-x;
  opacity: 0.85;
}
.edge .ai { padding: 1px 5px; border: 1px solid currentColor; border-radius: 3px; }
/* 用作参考图 / 做视频 / 问问 AI / 接着生成 / 下载，靠右 */
.edge .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.edge .actions a, .edge .actions button {
  height: auto;
  padding: 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  border-radius: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-decoration: none;
}
.edge .actions a:hover, .edge .actions button:hover { color: #fff; border-color: currentColor; }
/* 文字按钮太小，点击区域往外扩一圈（不影响布局），手机上不容易误点到「下载」 */
.edge .actions > * { position: relative; }
.edge .actions > *::after { content: ""; position: absolute; inset: -10px -6px; }
.edge .actions button:disabled { opacity: 0.5; cursor: progress; }
.frame.failed .edge { color: #ff8a78; }
.frame.processing .live::before { content: "● "; animation: blink 1s steps(2, start) infinite; }

.contact-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
/* 印样：图片和视频统一画框比例，留黑边不裁切 */
.contact-sheet .frame-media:has(img), .contact-sheet .frame-media:has(video) { position: relative; display: block; aspect-ratio: 16 / 10; }
.contact-sheet .frame-media > a, .contact-sheet .frame-media > video { position: absolute; inset: 0; }
.contact-sheet .frame-media img, .contact-sheet .frame-media video { width: 100%; height: 100%; max-height: none; }
.contact-sheet .edge { letter-spacing: 0.05em; }

/* ---------- 对话 ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - 56px); max-width: 900px; margin: 0 auto; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; padding: 4px 2px 20px; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); }
.chat-empty .examples { justify-content: center; margin-top: 14px; }
.msg-user { align-self: flex-end; max-width: 78%; padding: 10px 14px; border-radius: 12px 12px 4px 12px; background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.msg-ai { max-width: 100%; word-break: break-word; }
.msg-ai .md > :first-child { margin-top: 0; }
.md p, .md ul, .md ol, .md pre, .md h4 { margin: 0 0 10px; }
.md ul, .md ol { padding-left: 1.4em; }
.md h4 { font-size: 15.5px; }
.md code { font-family: var(--mono); font-size: 0.9em; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); }
.md pre { padding: 12px 14px; overflow-x: auto; border-radius: 8px; background: var(--film); color: #e6e9ed; }
.md pre code { padding: 0; border: 0; background: none; color: inherit; }
/* 长公式横向滚动，不撑破版面 */
.md .katex-display { margin: 4px 0 12px; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.md .katex { font-size: 1.08em; }
.msg-meta { display: flex; align-items: center; gap: 12px; margin-top: 6px; font: 11px/1.4 var(--mono); letter-spacing: 0.02em; color: var(--muted); }
.msg-meta button { border: 0; padding: 0; background: none; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.thinking { color: #b5822a; font: 12px var(--mono); }
.msg-ai.failed .md { color: var(--marker); }
.composer { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.composer.over { border-color: var(--marker); background: var(--marker-soft); }
/* 待发送的图片单独占一行，在输入框上面 */
.composer > .thumbs { flex-basis: 100%; }
.composer > .thumbs:empty { display: none; }
.composer > .thumbs:not(:empty) { margin: 0 0 2px; }
.icon-btn { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 8px; background: none; color: var(--muted); }
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.chat-hint { min-height: 1.4em; margin-top: 6px; font-size: 12.5px; color: var(--marker); }
.msg-images { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-bottom: 6px; }
.msg-images img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.composer textarea { flex: 1; border: 0; padding: 6px 4px; resize: none; max-height: 220px; background: none; }
.composer textarea:focus-visible { outline: none; }
.composer:focus-within { border-color: var(--muted); }

@keyframes develop { from { background-position: 120% 0, 0 0; } to { background-position: -120% 0, 0 0; } }
@keyframes blink { to { visibility: hidden; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- 手机：导航移到底部 ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .mobile-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 0; }
  .mobile-top .link { color: var(--muted); font-size: 13px; }
  .rail {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 10;
    height: auto;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .rail > .wordmark, .rail-foot { display: none; }
  .tabs { flex-direction: row; justify-content: space-around; }
  .tabs button { flex: 1; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 11.5px; text-align: center; }
  .tabs button.active { background: none; }
  .tabs button.active::before { left: 30%; right: 30%; top: -4px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .stage { padding: 16px 16px 96px; }
  .studio { grid-template-columns: 1fr; gap: 20px; }
  .console { position: static; max-height: none; overflow: visible; padding: 18px; }
  .chat { height: calc(100vh - 150px); }
  .panel-head select { min-width: 0; flex: 1; }
  .msg-user { max-width: 90%; }
}

/* ---------- 图像 / 视频工作台：上面记录流，下面输入框（参考即梦、可灵、海螺网页版） ---------- */
.stage:has(> .workbench:not([hidden])) { padding: 0; }
.workbench { position: relative; height: 100vh; height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
.feed { overflow-y: auto; overscroll-behavior: contain; padding: 0 clamp(16px, 3vw, 40px); }
.feed-col { max-width: 880px; min-height: 100%; margin: 0 auto; display: flex; flex-direction: column; justify-content: flex-end; padding: 24px 0 32px; }
.feed-top { min-height: 1px; padding: 0 0 16px; text-align: center; font-size: 12.5px; color: var(--muted); }
.records { display: flex; flex-direction: column; gap: 30px; }
.day { align-self: center; margin-bottom: -10px; padding: 3px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font: 12px/1.4 var(--mono); letter-spacing: 0.06em; color: var(--muted); }

/* 一条记录：头部（参考图 + 提示词 + 元信息）、画面、按钮 */
.rec { display: flex; flex-direction: column; gap: 10px; }
.rec-head { display: flex; gap: 12px; align-items: flex-start; }
.rec-refs { display: flex; flex-wrap: wrap; gap: 4px; max-width: 136px; flex: none; }
.rec-refs img { object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; background: var(--surface-2); }
.rec-refs-lost { font-size: 11.5px; color: var(--muted); padding: 2px 6px; border: 1px dashed var(--line); border-radius: 6px; white-space: nowrap; }
.rec-text { flex: 1; min-width: 0; }
.rec-prompt-row { display: flex; gap: 10px; align-items: baseline; }
.rec-prompt { flex: 1; min-width: 0; font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; cursor: pointer; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rec-prompt.open { display: block; }
.copy { flex: none; border: 0; padding: 0; background: none; color: var(--muted); font-size: 12.5px; text-decoration: underline; text-underline-offset: 2px; }
.copy:hover { color: var(--ink); }
.rec-meta { margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font: 12px/1.5 var(--mono); color: var(--muted); }
.ai-tag { padding: 0 6px; border: 1px solid currentColor; border-radius: 4px; font: 11px/1.6 var(--mono); letter-spacing: 0.06em; color: var(--muted); }

/* 画面按比例先占位，加载时页面不跳 */
.rec-media { --mh: min(420px, 50vh); position: relative; aspect-ratio: var(--ar); width: min(100%, calc(var(--mh) * var(--ar))); border-radius: 10px; overflow: hidden; background: var(--film); }
.rec-media img, .rec-media video { display: block; width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.rec-badge { position: absolute; left: 8px; bottom: 8px; padding: 1px 8px; border-radius: 999px; background: rgb(0 0 0 / 0.55); color: #fff; font: 11px/1.7 var(--mono); pointer-events: none; }
.rec-zoom { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: rgb(0 0 0 / 0.55); color: #fff; font-size: 15px; opacity: 0; transition: opacity 0.15s; }
.rec-media:hover .rec-zoom, .rec-zoom:focus-visible { opacity: 1; }
@media (hover: none) { .rec-zoom { opacity: 1; } }
.rec-wait {
  display: grid;
  place-items: center;
  min-height: 160px;
  background:
    linear-gradient(105deg, transparent 35%, rgb(237 178 70 / 0.14) 50%, transparent 65%) 0 0 / 220% 100%,
    #0b0c0f;
  animation: develop 2.4s ease-in-out infinite;
}
.wait-text { display: grid; gap: 6px; max-width: 30em; padding: 16px; text-align: center; color: #9aa3ae; font-size: 13px; }
.wait-text .since { color: #e9ae45; font: 13px/1.5 var(--mono); }
.wait-text .link { justify-self: center; color: #ffb4a6; }
.rec-fail { padding: 14px 16px; border-radius: 10px; background: var(--marker-soft); color: var(--ink); font-size: 14px; border-left: 3px solid var(--marker); }
.rec-fail details { margin-top: 6px; color: var(--muted); font-size: 12px; }
.rec-fail summary { cursor: pointer; }
.rec-fail pre { margin: 6px 0 0; white-space: pre-wrap; word-break: break-all; font: 11.5px/1.5 var(--mono); }
.rec-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; }
.rec-actions > div { display: flex; flex-wrap: wrap; gap: 6px; }
.act { display: inline-flex; align-items: center; height: 30px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 13px; text-decoration: none; white-space: nowrap; }
.act:hover { border-color: var(--muted); }
.act:disabled { opacity: 0.5; cursor: not-allowed; }
.act.danger { border-color: transparent; background: var(--marker); color: var(--marker-ink); }

/* 空状态：问候 + 示例卡（点了只填进输入框，不直接生成） */
.empty-state h3 { margin: 0 0 4px; font-size: 22px; font-weight: 650; }
.examples-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 16px; }
.ex-card { display: flex; flex-direction: column; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; }
.ex-card:hover { border-color: var(--muted); }
.ex-card p { font-size: 13.5px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ex-card small { font: 11.5px var(--mono); color: var(--muted); }
.ex-upload { border-style: dashed; }

/* 输入框 */
.composer-wrap { position: relative; padding: 0 clamp(16px, 3vw, 40px) 12px; }
.composer-wrap::before { content: ""; position: absolute; left: 0; right: 0; top: -24px; height: 24px; background: linear-gradient(to bottom, transparent, var(--bg)); pointer-events: none; }
.wb-composer { position: relative; display: flex; flex-direction: column; gap: 6px; max-width: 880px; margin: 0 auto; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 24px -12px rgb(20 24 30 / 0.25); }
.wb-composer:focus-within { border-color: var(--muted); }
.wb-composer textarea { border: 0; padding: 6px 4px; background: none; resize: none; font-size: 15px; line-height: 1.55; max-height: 200px; }
.wb-composer textarea:focus-visible { outline: none; }
.wb-composer.over { border-color: var(--marker); background: var(--marker-soft); }
.drop-veil { position: absolute; inset: 0; display: none; place-items: center; border-radius: inherit; font-weight: 600; color: var(--marker); pointer-events: none; }
.wb-composer.over .drop-veil { display: grid; }
.wb-composer.over > :not(.drop-veil) { visibility: hidden; }
.wb-hint { max-width: 880px; min-height: 1.4em; margin: 6px auto 0; font-size: 12.5px; color: var(--muted); opacity: 0; transition: opacity 0.3s; }
.wb-hint.on { opacity: 1; }
.to-latest { position: absolute; left: 50%; top: -46px; z-index: 2; height: 32px; padding: 0 14px; transform: translateX(-50%); border: 1px solid var(--line); border-radius: 999px; background: var(--surface); box-shadow: 0 4px 14px -6px rgb(20 24 30 / 0.3); font-size: 13px; }

/* 素材栏：参考图带编号（点编号插入「图N」），视频是一张首帧 */
.assets { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 6px 4px 2px; }
.asset { position: relative; }
.asset img { display: block; width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.asset.frame img { width: auto; max-width: 128px; height: 72px; }
.asset .num, .asset .rm { position: absolute; top: -7px; min-width: 18px; height: 18px; padding: 0 4px; border: 0; border-radius: 9px; background: var(--ink); color: var(--surface); font: 600 11px/18px var(--sans); }
.asset .num { left: -7px; }
.asset .rm { right: -7px; width: 18px; padding: 0; }
.asset .cap { position: absolute; left: 4px; bottom: 4px; padding: 0 5px; border-radius: 4px; background: rgb(0 0 0 / 0.6); color: #fff; font-size: 11px; }
.asset-add { width: 56px; height: 56px; border: 1.5px dashed var(--line); border-radius: 8px; background: none; color: var(--muted); font-size: 22px; }
.asset-add:hover { color: var(--ink); border-color: var(--muted); }
.asset-count { font: 12px var(--mono); color: var(--muted); }
.asset-note { display: flex; flex-direction: column; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.asset-note .warn { color: var(--marker); }
.assets.flash, .wb-composer.flash, .chip.flash { animation: flash-ring 0.6s; }
@keyframes flash-ring { 50% { box-shadow: 0 0 0 3px var(--marker-soft), 0 0 0 4px var(--marker); } }

/* 工具条：左边参数（手机上横向滚动），右边进行中 / 预计耗时 / 生成 */
.toolbar { display: flex; align-items: center; gap: 10px; }
.toolbar .params { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 3px; margin: -3px; }
.toolbar .go { flex: none; display: flex; align-items: center; gap: 10px; }
.toolbar .icon-btn { width: 32px; height: 32px; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--ink); font-size: 13px; white-space: nowrap; }
.chip::after { content: "▾"; font-size: 10px; color: var(--muted); }
.chip:hover { border-color: var(--muted); }
.chip:disabled { color: var(--muted); cursor: not-allowed; }
.chip:disabled::after { content: none; }
.ratio-ico { display: inline-block; flex: none; border: 1.5px solid currentColor; border-radius: 2px; }
.seg { flex: none; display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); }
.seg button { height: 24px; padding: 0 10px; border: 0; border-radius: 999px; background: none; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }
.mode-tag { flex: none; padding: 0 4px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.running { height: 26px; padding: 0 10px; border: 0; border-radius: 999px; background: var(--marker-soft); color: var(--ink); font-size: 12px; white-space: nowrap; }
.running::before { content: "● "; color: var(--marker); animation: blink 1s steps(2, start) infinite; }
.toolbar .eta { font: 12px var(--mono); color: var(--muted); white-space: nowrap; }
.toolbar .primary { height: 36px; padding: 0 20px; }

/* 参数弹层 */
.pop-backdrop { position: fixed; inset: 0; z-index: 49; }
.pop { position: fixed; z-index: 50; min-width: 240px; max-width: min(380px, calc(100vw - 16px)); max-height: 60vh; overflow-y: auto; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px -12px rgb(0 0 0 / 0.35); }
.pop-title { padding: 6px 10px 4px; font-size: 12px; color: var(--muted); }
.pop-opt { position: relative; display: flex; flex-direction: column; gap: 1px; width: 100%; padding: 9px 36px 9px 14px; border: 0; border-radius: 8px; background: none; text-align: left; }
.pop-opt:hover, .pop-opt:focus-visible { background: var(--surface-2); }
.pop-opt.on::before { content: ""; position: absolute; left: 4px; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--marker); }
.pop-opt.on::after { content: "✓"; position: absolute; right: 12px; top: 9px; color: var(--marker); font-weight: 700; }
.opt-line { display: flex; justify-content: space-between; gap: 16px; }
.opt-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.opt-eta, .opt-cap { font: 11.5px/1.6 var(--mono); color: var(--muted); }
.opt-meta { font-size: 12px; color: var(--muted); }
.opt-note { font-size: 12px; color: var(--marker); }
.ratio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; padding: 4px; }
.ratio-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: none; font-size: 13px; color: var(--ink); }
.ratio-opt .ratio-ico { transform: scale(1.6); margin: 6px 0; }
.ratio-opt small { font: 11px var(--mono); color: var(--muted); }
.ratio-opt:hover { border-color: var(--muted); }
.ratio-opt.on { border-color: var(--marker); background: var(--marker-soft); }

/* 有新结果的工作台：导航上点个红点 */
.tabs button.has-new::after { content: ""; position: absolute; top: 7px; left: 26px; width: 7px; height: 7px; border-radius: 50%; background: var(--marker); }

/* 看图层：左边大图 / 视频，右边信息栏 */
.viewer { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgb(8 9 11 / 0.96); color: #e6e9ed; }
.viewer:not([open]) { display: none; }
.viewer[open] { display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.viewer::backdrop { background: transparent; }
.viewer-stage { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; padding: 24px 76px; }
.viewer-media { display: grid; place-items: center; width: 100%; height: 100%; min-height: 0; }
.viewer-media img, .viewer-media video { display: block; max-width: 100%; max-height: calc(100dvh - 48px); object-fit: contain; }
.viewer-nav { position: absolute; top: 50%; width: 48px; height: 48px; transform: translateY(-50%); border: 0; border-radius: 50%; background: rgb(255 255 255 / 0.1); color: #fff; font-size: 28px; line-height: 1; }
.viewer-nav:hover { background: rgb(255 255 255 / 0.2); }
.viewer-nav:disabled { opacity: 0.25; cursor: default; }
.viewer-nav.prev { left: 14px; }
.viewer-nav.next { right: 14px; }
.viewer-close { position: absolute; top: 12px; right: 352px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgb(255 255 255 / 0.1); color: #fff; font-size: 22px; }
.viewer-info { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; padding: 22px 20px; background: var(--surface); color: var(--ink); }
.vi-row { display: flex; justify-content: space-between; align-items: baseline; }
.vi-row h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.vi-prompt { white-space: pre-wrap; word-break: break-word; font-size: 14.5px; line-height: 1.6; }
.vi-params { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.vi-params dt { color: var(--muted); }
.vi-params dd { margin: 0; font-family: var(--mono); font-size: 12.5px; }
.viewer-info .ai-tag { align-self: flex-start; }
.vi-acts { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.vi-acts .act { justify-content: center; height: 36px; }

@media (max-width: 860px) {
  /* 工作台夹在顶部条和底部导航之间；打字时藏起导航，输入框跟着键盘走。
     工作台脱离文档流后 .app 的行会被拉伸，顶部条按内容高度排 */
  .app { align-content: start; }
  .workbench { position: fixed; z-index: 1; left: 0; right: 0; top: var(--top-h, 48px); bottom: var(--nav-h, 64px); height: auto; background: var(--bg); }
  body.composing .rail { display: none; }
  body.composing .workbench { bottom: auto; top: calc(var(--top-h, 48px) + var(--vv-top, 0px)); height: calc(var(--vv-h, 100dvh) - var(--top-h, 48px)); }
  .feed { padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); }
  .composer-wrap { padding: 0 max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left)); }
  .toolbar .params { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .toolbar .params::-webkit-scrollbar { display: none; }
  .rec-refs-lost { white-space: normal; }
  .composer textarea, input[type="email"], input[type="password"] { font-size: 16px; }
  .wb-composer { padding: 8px 10px; border-radius: 14px; }
  .wb-composer textarea { font-size: 16px; max-height: 130px; } /* 小于 16px 时 iOS 一聚焦就放大页面 */
  .toolbar .eta { display: none; }
  .rec-media { --mh: 60vh; }
  .rec-refs { max-width: 72px; }
  .examples-grid { grid-template-columns: 1fr 1fr; }
  .to-latest { top: -42px; }
  /* 弹层改成底部面板 */
  .pop-backdrop { background: rgb(0 0 0 / 0.35); }
  .pop { left: 0 !important; right: 0; bottom: 0 !important; max-width: none; max-height: 60dvh; padding: 6px max(8px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); border-radius: 16px 16px 0 0; }
  .pop-title { padding: 14px 10px 8px; text-align: center; font-size: 14px; font-weight: 600; color: var(--ink); }
  .pop-title::before { content: ""; display: block; width: 36px; height: 4px; margin: -6px auto 10px; border-radius: 2px; background: var(--line); }
  /* 看图层：信息栏放到下面 */
  .viewer[open] { grid-template-columns: 1fr; grid-template-rows: auto auto; overflow-y: auto; }
  .viewer-stage { padding: 56px 0 64px; }
  .viewer-media img, .viewer-media video { max-height: 60dvh; }
  .viewer-nav { top: auto; bottom: 12px; transform: none; width: 40px; height: 40px; background: rgb(255 255 255 / 0.12); }
  .viewer-close { right: 12px; }
}

/* ---------- 画布（demo）：作品摊在可拖动、缩放的画板上，连线是「谁由谁生成」 ---------- */
.stage:has(> .canvas:not([hidden])) { padding: 0; }
.canvas { position: relative; height: 100vh; height: 100dvh; overflow: hidden; }
.cv-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--line) 1px, transparent 1.2px);
  background-size: 22px 22px;
}
.cv-viewport.dragging { cursor: grabbing; }
.cv-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.cv-edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.cv-edges path { fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-dasharray: 5 4; opacity: 0.7; }
.cv-empty { position: absolute; inset: 40% 0 auto; text-align: center; color: var(--muted); }
.cv-card {
  position: absolute;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
  user-select: none;
}
.cv-card.selected { border-color: var(--marker); box-shadow: 0 0 0 3px var(--marker-soft); }
.cv-card.asset { opacity: 0.85; }
.cv-media { display: grid; place-items: center; overflow: hidden; border-radius: 8px; background: var(--film); }
.cv-media img, .cv-media video { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.cv-media video { pointer-events: auto; }
.cv-wait, .cv-fail { padding: 12px; color: #c9d1db; font: 12px/1.5 var(--mono); text-align: center; }
.cv-fail { color: #ffb4a6; }
.cv-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 6px; font: 11px/1.5 var(--mono); color: var(--muted); }
.cv-meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-meta .ai-tag { flex: none; white-space: nowrap; }
.cv-prompt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; font-size: 12.5px; line-height: 1.45; }
.cv-zoom { position: absolute; top: 16px; right: 16px; display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.cv-zoom button { min-width: 32px; height: 30px; padding: 0 8px; border: 0; border-radius: 7px; background: none; color: var(--muted); font-size: 13px; }
.cv-zoom button:hover { background: var(--surface-2); color: var(--ink); }
.cv-bar {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(760px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.12);
}
.cv-bar-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cv-bar-top select { width: auto; max-width: 240px; padding: 5px 8px; font-size: 13px; }
.cv-sel { font: 12px/1.5 var(--mono); color: var(--muted); margin-right: auto; }
.cv-mode button { padding: 4px 12px; font-size: 13px; }
.cv-bar-row { display: flex; gap: 8px; }
.cv-bar-row input { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.cv-hint { min-height: 0; font-size: 12.5px; color: var(--marker); }
.cv-hint:empty { display: none; }

/* 画布 / 工作流共用的切换器：列表 + 新建 / 重命名 / 删除 */
.bd-switch { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.bd-switch select, .bd-name { width: auto; min-width: 150px; max-width: 240px; padding: 6px 10px; font-size: 14px; }
.bd-name { border: 1px solid var(--marker); border-radius: 8px; background: var(--surface); }
.bd-btn { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); font-size: 13px; }
.bd-btn:hover { color: var(--ink); }
.bd-status { font: 12px/1.5 var(--mono); color: var(--muted); }
.cv-head { position: absolute; top: 16px; left: 16px; right: 240px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; width: max-content; max-width: calc(100% - 260px); }
.cv-remove { padding: 3px 10px; border: 1px solid var(--line); border-radius: 7px; background: none; color: var(--muted); font-size: 12.5px; }
.cv-remove:hover { color: var(--marker); border-color: var(--marker); }


@media (max-width: 860px) {
  .canvas { height: calc(100dvh - 100px - env(safe-area-inset-bottom)); } /* 减去顶栏 ~35px 和底部导航 ~61px */
  .cv-bar { bottom: 12px; }
  .cv-zoom { top: 12px; right: 12px; }
  .cv-head { top: 60px; left: 12px; max-width: calc(100% - 24px); }
}

/* ---------- 动效：状态变化有过渡，进出有淡入，不再瞬间跳变。系统开了「减少动态效果」的全部关掉（见上面） ---------- */
:root { --ease: cubic-bezier(0.2, 0.8, 0.2, 1); }
button, .chip, .pop-opt, .tabs button, .bd-btn, .cv-card, .wfn, .as-card, .rec, a, input, textarea, select {
  transition: background-color 0.16s var(--ease), color 0.16s var(--ease), border-color 0.16s var(--ease), box-shadow 0.2s var(--ease), opacity 0.2s var(--ease), transform 0.16s var(--ease);
}
.primary:active:not(:disabled), .chip:active:not(:disabled), .bd-btn:active, .ghost:active, .segmented button:active { transform: scale(0.97); }
section[data-panel]:not([hidden]) { animation: panel-in 0.22s var(--ease); }
@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } }
.pop:not([hidden]) { animation: pop-in 0.16s var(--ease); }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
.pop-backdrop:not([hidden]), .viewer[open] { animation: fade-in 0.18s var(--ease); }
@keyframes fade-in { from { opacity: 0; } }
/* 图片下载解码完再淡入（app.js 给带 fade 的 <img> 加 loaded） */
img.fade { opacity: 0; transition: opacity 0.35s var(--ease); }
img.fade.loaded { opacity: 1; }
.msg-ai, .msg-user, .cv-card.enter, .wfn-results > * { animation: rise 0.28s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.cv-card:hover { box-shadow: 0 8px 22px rgb(0 0 0 / 0.12); }
.cv-card.selected { box-shadow: 0 0 0 3px var(--marker-soft), 0 8px 22px rgb(0 0 0 / 0.12); }
.cv-edges path { transition: stroke 0.2s var(--ease); }

/* ---------- 统一的选择器（模型 / 尺寸 / 时长 / 模板）：胶囊按钮 + 弹出面板 ---------- */
.picker { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-head .picker { height: 38px; padding: 0 14px; font-size: 15px; font-weight: 500; background: var(--surface); }
.field > .picker { align-self: flex-start; height: 34px; background: var(--surface); }
.pop-group { padding: 10px 10px 4px; font: 600 11.5px/1.4 var(--sans); color: var(--muted); letter-spacing: 0.04em; }
.pop-group:first-child { padding-top: 2px; }

/* ---------- 工作台改网格（参考即梦 / Midjourney）：每次生成一张卡片，图在上；操作按钮悬停时出现，手机上点开看大图操作 ---------- */
.feed-col { max-width: 1240px; }
.records { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; align-items: start; }
.records > .day { grid-column: 1 / -1; justify-self: center; margin: 6px 0 -4px; }
.rec { position: relative; gap: 8px; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.rec:hover { box-shadow: 0 8px 24px rgb(0 0 0 / 0.08); }
.rec > .rec-media, .rec > .rec-fail { order: -1; }
.rec-media { width: 100%; aspect-ratio: 1; border-radius: 10px; }
.rec-media img, .rec-media video { object-fit: cover; }
.rec-wait { min-height: 0; }
.rec-head { gap: 8px; }
.rec-prompt { font-size: 13.5px; }
.rec-meta { font-size: 11px; }
.rec-actions { gap: 4px; }
.rec-actions .act { height: 26px; padding: 0 8px; font-size: 12px; }
@media (hover: hover) {
  .rec-actions { opacity: 0; }
  .rec:hover .rec-actions, .rec:focus-within .rec-actions { opacity: 1; }
}

/* ---------- 历史：和工作台一样的白卡片，不再是黑底胶片 ---------- */
.contact-sheet { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.frame { padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: none; }
.frame:hover { box-shadow: 0 8px 24px rgb(0 0 0 / 0.08); }
.frame-media { border-radius: 10px; overflow: hidden; background: var(--film); }
.contact-sheet .frame-media:has(img), .contact-sheet .frame-media:has(video) { aspect-ratio: 1; }
.contact-sheet .frame-media img, .contact-sheet .frame-media video { object-fit: cover; }
.frame-media:has(audio), .frame-media:has(.frame-text) { background: var(--surface-2); }
.frame-text { padding: 12px; background: none; font-size: 14px; }
.frame-text.chat { max-height: calc(1.6em * 8 + 24px); overflow: hidden; line-height: 1.6; } /* -webkit-box 截断在网格里高度会算错 */
.frame-q { width: 100%; padding: 12px 12px 0; font-weight: 600; font-size: 14px; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.frame-caption { color: var(--muted); }
.frame-error { color: var(--marker); }
.edge { gap: 4px 10px; padding: 8px 4px 2px; color: var(--muted); font: 11.5px/1.5 var(--mono); letter-spacing: 0.02em; }
.edge::before { content: none; }
.edge .ai { padding: 0 6px; border-radius: 4px; }
.edge .actions { width: 100%; margin: 4px 0 0; gap: 6px; }
.edge .actions a, .edge .actions button { display: inline-flex; align-items: center; height: 26px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: 12px/1 var(--sans); letter-spacing: 0; }
.edge .actions a:hover, .edge .actions button:hover { color: var(--ink); border-color: var(--muted); }
.edge .actions > *::after { content: none; }
.frame.failed .edge { color: var(--marker); }
@media (hover: hover) {
  .contact-sheet .edge .actions { opacity: 0; }
  .contact-sheet .frame:hover .edge .actions, .contact-sheet .frame:focus-within .edge .actions { opacity: 1; }
}

@media (max-width: 860px) {
  .records, .contact-sheet { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .rec-actions, .rec-refs, .rec .copy { display: none; }
  .rec { padding: 6px; }
}

/* ---------- 首页（展示页） ---------- */
.home { max-width: 1240px; margin: 0 auto; padding-bottom: 40px; }
.hm-hero { padding: 36px 0 28px; }
.hm-kicker { font: 600 12.5px/1.4 var(--mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--marker); }
.hm-hero h1 { margin-top: 10px; font-size: clamp(28px, 4vw, 44px); line-height: 1.15; letter-spacing: -0.02em; }
.hm-sub { margin-top: 12px; max-width: 36em; font-size: 16px; color: var(--muted); }
.hm-stats { margin-top: 14px; font: 12.5px/1.6 var(--mono); color: var(--muted); }
.hm-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.hm-cta .primary, .hm-cta .ghost { height: 42px; padding: 0 18px; }
.hm-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin: 34px 0 14px; font-size: 18px; }
.hm-note { font-size: 13px; font-weight: 400; color: var(--muted); }
.hm-more { margin-left: auto; font-size: 13px; }
.hm-features { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1180px) { .hm-features { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.hm-feature { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; color: var(--ink); }
.hm-feature:hover { border-color: var(--muted); box-shadow: 0 8px 24px rgb(0 0 0 / 0.08); transform: translateY(-2px); }
.hm-feature strong { font-size: 16px; }
.hm-desc { font-size: 13.5px; color: var(--muted); }
.hm-models { font: 11.5px/1.5 var(--mono); color: var(--muted); }
.hm-gallery { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.hm-gallery.edit { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 820px; }
@media (max-width: 1180px) { .hm-gallery:not(.edit) { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.hm-tile { position: relative; margin: 0; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.hm-gallery.mine .hm-tile { cursor: pointer; }
.hm-tile:hover { box-shadow: 0 8px 24px rgb(0 0 0 / 0.1); }
.hm-pic { position: relative; }
.hm-tile img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--film); }
.hm-ai { position: absolute; left: 8px; bottom: 8px; padding: 1px 7px; border-radius: 6px; background: rgb(0 0 0 / 0.5); color: #fff; font: 11px/1.6 var(--mono); backdrop-filter: blur(4px); pointer-events: none; }
.hm-tile figcaption { display: grid; gap: 2px; padding: 8px 4px 2px; }
.hm-name { font-size: 13px; line-height: 1.4; } /* 名字放不下就换行，不截断 */
.hm-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 11.5px/1.5 var(--mono); color: var(--muted); }
.hm-try { position: absolute; top: 14px; right: 14px; height: 28px; font-size: 12.5px; box-shadow: 0 2px 8px rgb(0 0 0 / 0.2); }
@media (hover: hover) {
  .hm-try { opacity: 0; }
  .hm-tile:hover .hm-try, .hm-try:focus-visible { opacity: 1; }
}
@media (max-width: 860px) {
  .hm-hero { padding-top: 12px; }
  .hm-gallery, .hm-gallery.edit, .hm-features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 生成好的卡片：操作按钮浮在图片底部，深色渐变衬底 */
.rec-media .rec-actions { position: absolute; left: 0; right: 0; bottom: 0; justify-content: flex-start; padding: 36px 8px 8px; background: linear-gradient(transparent, rgb(0 0 0 / 0.68)); }
.rec-media .rec-actions .act { border-color: rgb(255 255 255 / 0.28); background: rgb(255 255 255 / 0.14); color: #fff; backdrop-filter: blur(6px); }
.rec-media .rec-actions .act:hover { background: rgb(255 255 255 / 0.28); border-color: rgb(255 255 255 / 0.5); }
.contact-sheet { align-items: start; }

/* 首页视频示例：封面是首帧，悬停 / 点击播放 */
.hm-tile.video video { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--film); cursor: pointer; }
.hm-play { position: absolute; right: 8px; bottom: 8px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: rgb(0 0 0 / 0.5); color: #fff; font-size: 11px; pointer-events: none; }

/* ---------- 资产：用户维护的角色形象（名字 + 设定 + 1～4 张形象图）。卡片网格，点开编辑 ---------- */
.assets-page { max-width: 1400px; margin: 0 auto; }
.as-head { flex-wrap: wrap; }
.as-tip { flex: 1 1 320px; }
.as-search { width: 200px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 14px; }
.as-head .primary { padding: 9px 16px; }
.as-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; align-items: start; }
.as-card { margin: 0; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; cursor: pointer; }
.as-card:hover { box-shadow: 0 8px 24px rgb(0 0 0 / 0.1); }
.as-cover { position: relative; aspect-ratio: 3 / 4; overflow: hidden; border-radius: 10px; background: var(--film); }
.as-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.as-count { position: absolute; right: 8px; top: 8px; padding: 1px 7px; border-radius: 6px; background: rgb(0 0 0 / 0.5); color: #fff; font: 11px/1.6 var(--mono); }
.as-acts { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-wrap: wrap; gap: 4px; padding: 36px 8px 8px; background: linear-gradient(transparent, rgb(0 0 0 / 0.7)); }
.as-acts .act { height: 26px; padding: 0 8px; font-size: 12px; border-color: rgb(255 255 255 / 0.3); background: rgb(255 255 255 / 0.15); color: #fff; backdrop-filter: blur(6px); }
.as-acts .act:hover { background: rgb(255 255 255 / 0.3); }
@media (hover: hover) {
  .as-acts { opacity: 0; transition: opacity 0.16s var(--ease); }
  .as-card:hover .as-acts, .as-card:focus-within .as-acts { opacity: 1; }
}
.as-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 4px; }
.as-strip:empty { display: none; }
.as-strip img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--film); }
.as-card figcaption { padding: 8px 2px 2px; }
.as-card strong { font-size: 15px; }
.as-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.as-empty { grid-column: 1 / -1; padding: 24px 0; text-align: center; color: var(--muted); font-size: 13.5px; }
.as-empty-page { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 460px; margin: 60px auto; text-align: center; }
.as-empty-page h3 { margin: 0; font-size: 20px; }
.as-status { font-size: 12.5px; color: var(--marker); }
.as-status:empty { display: none; }

/* 资产相关的对话框（编辑角色、选角色、设为资产、从作品里选） */
.as-dialog { width: min(720px, calc(100vw - 32px)); max-height: min(820px, calc(100dvh - 40px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgb(0 0 0 / 0.35); }
.as-dialog[open] { display: flex; flex-direction: column; animation: pop-in 0.16s var(--ease); }
.as-dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.as-dialog.as-picker { width: min(960px, calc(100vw - 32px)); height: min(720px, calc(100dvh - 40px)); }
.as-dialog-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px 8px; }
.as-dialog-head h3 { margin: 0; font-size: 17px; }
.as-dialog-x { margin-left: auto; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--surface-2); font-size: 18px; line-height: 1; }
.as-dialog-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 8px 20px 16px; }
.as-dialog-foot { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); }
.as-dialog-foot .primary { padding: 8px 22px; }
.as-grow { flex: 1; }
.danger-text { color: var(--marker) !important; }
.as-dialog.over { outline: 3px dashed var(--marker); outline-offset: -8px; }
.as-ed-images { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.as-ed-img { position: relative; aspect-ratio: 3 / 4; overflow: hidden; border-radius: 10px; background: var(--film); }
.as-ed-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.as-ed-img.loading { display: grid; place-items: center; color: #c9d1db; font-size: 12.5px; }
.as-ed-cover, .as-ed-mk { position: absolute; left: 6px; bottom: 6px; padding: 1px 8px; border: 0; border-radius: 6px; background: var(--marker); color: #fff; font-size: 11.5px; line-height: 1.7; }
.as-ed-mk { background: rgb(0 0 0 / 0.55); }
.as-ed-rm { position: absolute; right: 6px; top: 6px; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: rgb(0 0 0 / 0.55); color: #fff; font-size: 15px; line-height: 1; }
.as-ed-add { display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 8px; aspect-ratio: 3 / 4; padding: 10px; border: 1.5px dashed var(--line); border-radius: 10px; }
.as-ed-add button { padding: 8px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink); font-size: 13px; }
.as-ed-add button:hover { border-color: var(--muted); }
.as-ed-tip { grid-column: 1 / -1; font-size: 12px; font-weight: 400; color: var(--muted); }
.as-ed-name, .as-ed-desc { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 14px; }
.as-save-strip { display: flex; gap: 8px; }
.as-save-strip img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: var(--film); }
.as-save-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.as-save-item { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-align: left; }
.as-save-item:hover:not(:disabled) { border-color: var(--marker); }
.as-save-item:disabled { opacity: 0.45; cursor: not-allowed; }
.as-save-item img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 6px; background: var(--film); }
.as-save-item.new { align-items: center; justify-content: center; min-height: 140px; border-style: dashed; color: var(--muted); }
.as-save-plus { font-size: 26px; line-height: 1; }
.as-save-name { font-size: 13.5px; font-weight: 600; }
.as-save-n { font: 11px var(--mono); color: var(--muted); }
.as-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; align-content: start; }
.as-pick-card { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.as-pick-card:hover { border-color: var(--muted); }
.as-pick-card.on { border-color: var(--marker); box-shadow: 0 0 0 3px var(--marker-soft); }
.as-pick-imgs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.as-pick-img { padding: 0; border: 0; border-radius: 6px; overflow: hidden; background: var(--film); }
button.as-pick-img:hover { outline: 2px solid var(--marker); }
.as-pick-img img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.as-pick-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12px; line-height: 1.5; color: var(--muted); }
.as-works-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; align-content: start; }
.as-work { position: relative; padding: 0; aspect-ratio: 1; overflow: hidden; border: 2px solid transparent; border-radius: 8px; background: var(--film); }
.as-work.on { border-color: var(--marker); }
.as-work img, .as-work video { display: block; width: 100%; height: 100%; object-fit: cover; }
.as-work-audio { display: grid; place-items: center; height: 100%; padding: 8px; background: var(--surface-2); font-size: 12px; color: var(--ink); }
.as-more-btn { align-self: center; }

/* 生图参考图上的用途标签：角色资产显示名字，其他显示「用途」或已选的用途 */
.asset .role { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 6px; height: 17px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); font: 11px/15px var(--sans); }
.asset .role.set { border-color: var(--ink); color: var(--ink); }
.asset .role.char { border-color: var(--marker); background: var(--marker); color: #fff; }
.assets:has(.role) { padding-bottom: 10px; }

/* 画布：左上角的切换器和「＋ 角色」 */
.cv-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

@media (max-width: 860px) {
  .as-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .as-search { flex: 1; font-size: 16px; }
  .as-dialog, .as-dialog.as-picker { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .as-ed-images { grid-template-columns: repeat(2, 1fr); }
  .as-pick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- 工作流：节点图（参考 ComfyUI / Flora / Weavy）。端口按数据类型上色，只有同色能连 ---------- */
:root { --t-text: #7a5af5; --t-image: #0f9d76; --t-video: #e0662a; --t-audio: #2a84d2; --t-media: #8a94a3; }
@media (prefers-color-scheme: dark) { :root { --t-text: #a08bff; --t-image: #33c497; --t-video: #ff8a4f; --t-audio: #5aa8ef; --t-media: #9aa3b1; } }
.stage:has(> .workflow:not([hidden])) { padding: 0; }
.workflow { position: relative; height: 100vh; height: 100dvh; overflow: hidden; }
.wfg-viewport { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; background-color: var(--bg); background-image: radial-gradient(circle, var(--line) 1px, transparent 1.2px); background-size: 22px 22px; }
.wfg-viewport.dragging { cursor: grabbing; }
.wfg-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.wfg-edges { position: absolute; overflow: visible; pointer-events: none; }
.wfe { fill: none; stroke-width: 2.4; opacity: 0.8; }
.wfe.t-text { stroke: var(--t-text); }
.wfe.t-image { stroke: var(--t-image); }
.wfe.t-video { stroke: var(--t-video); }
.wfe.t-audio { stroke: var(--t-audio); }
.wfe.selected { stroke-width: 4; opacity: 1; }
.wfe.drafting { stroke-dasharray: 6 5; opacity: 1; }
.wfe.live { stroke-dasharray: 8 6; animation: wfe-flow 0.8s linear infinite; }
@keyframes wfe-flow { to { stroke-dashoffset: -14; } }
.wfe-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.wfe-cut { pointer-events: all; cursor: pointer; }
.wfe-cut circle { fill: var(--marker); }
.wfe-cut text { fill: #fff; font: 700 14px var(--sans); text-anchor: middle; }

.wfn { position: absolute; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 3px rgb(0 0 0 / 0.06); cursor: default; }
.wfn:hover { box-shadow: 0 8px 22px rgb(0 0 0 / 0.1); }
.wfn.selected { border-color: var(--marker); box-shadow: 0 0 0 3px var(--marker-soft), 0 8px 22px rgb(0 0 0 / 0.1); }
.wfn.is-running { border-color: color-mix(in srgb, var(--marker) 60%, var(--line)); }
.wfn-head { position: relative; display: flex; align-items: center; gap: 7px; padding: 9px 10px 8px 12px; border-bottom: 1px solid var(--line); border-radius: 12px 12px 0 0; background: var(--surface-2); cursor: grab; user-select: none; }
.wfg-viewport.dragging .wfn-head { cursor: grabbing; }
.wfn-dot { flex: none; width: 9px; height: 9px; border-radius: 3px; background: var(--muted); }
.g-ai .wfn-dot { background: var(--marker); }
.g-tool .wfn-dot { background: var(--t-media); border-radius: 50%; }
.g-input .wfn-dot { background: var(--ink); }
.wfn-name { min-width: 0; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.wfn-rename { min-width: 0; width: 150px; padding: 2px 6px; border: 1px solid var(--marker); border-radius: 6px; background: var(--surface); color: var(--ink); font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1.3; outline: none; }
.wfn-status { margin-left: auto; font: 11.5px/1.4 var(--mono); color: var(--muted); white-space: nowrap; }
.wfn-status.running { color: var(--marker); }
.wfn-status.done { color: var(--t-image); }
.wfn-status.failed { color: var(--marker); font-weight: 600; cursor: help; }
.wfn-status.stale { color: #b7861c; cursor: help; }
.wfn-status.skipped { cursor: help; }
.wfn-btn { flex: none; width: 26px; height: 24px; padding: 0; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--muted); font-size: 13px; line-height: 1; }
.wfn-btn:hover { border-color: var(--line); background: var(--surface); color: var(--ink); }
.wfn-run { color: var(--marker); }
.wfn-status:empty + .wfn-run, .wfn-name + .wfn-btn, .wfn-rename + .wfn-btn { margin-left: auto; }

/* 全屏编辑：节点本身挪进对话框，放大 */
.wf-full { width: min(1000px, calc(100vw - 32px)); max-width: none; height: calc(100dvh - 48px); max-height: none; margin: auto; padding: 0; border: 0; background: transparent; overflow: visible; }
.wf-full::backdrop { background: rgb(15 15 15 / 0.5); }
.wf-full[open] { animation: pop-in 0.16s var(--ease); }
.wfn.is-full { position: relative; left: auto !important; top: auto !important; width: 100% !important; height: 100%; overflow-y: auto; box-shadow: 0 24px 60px -20px rgb(0 0 0 / 0.5); }
.wfn.is-full:hover, .wfn.is-full.selected { box-shadow: 0 24px 60px -20px rgb(0 0 0 / 0.5); border-color: var(--line); }
.wfn.is-full .wfp { display: none; }
.wfn.is-full .wfn-head { position: sticky; top: 0; z-index: 3; padding: 12px 14px 11px 20px; cursor: default; }
.wfn.is-full .wfn-name { font-size: 16px; }
.wfn.is-full .wfn-ins, .wfn.is-full .wfn-outs { padding-left: 6px; padding-right: 6px; }
.wfn.is-full .wfn-body { gap: 14px; padding: 16px 20px 20px; }
.wfn.is-full .wfn-body textarea { min-height: 96px; font-size: 14px; }
.wfn.is-full .wfn-body textarea.wfn-main { min-height: 30vh; }
.wfn.is-full .wfn-out { max-height: none; overflow: visible; padding: 16px 20px 20px; }
.wfn.is-full .wfn-results { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.wfn.is-full .wfn-results.texts { grid-template-columns: 1fr; }
.wfn.is-full .wfn-ref img, .wfn.is-full .wfn-ref-ph { width: 40px; height: 40px; }

/* 端口：输入在左边缘，输出在标题栏右边缘 */
.wfp { position: absolute; z-index: 2; width: 14px; height: 14px; border: 2.5px solid var(--surface); border-radius: 50%; background: var(--t-media); box-shadow: 0 0 0 1px var(--line); cursor: crosshair; touch-action: none; }
.wfp::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; } /* 点击范围放大 */
.wfp.out { right: -8px; top: 50%; margin-top: -7px; }
.wfp.in { left: -8px; top: 50%; margin-top: -7px; }
.wfp.t-text { background: var(--t-text); }
.wfp.t-image { background: var(--t-image); }
.wfp.t-video { background: var(--t-video); }
.wfp.t-audio { background: var(--t-audio); }
.wfp.t-media { background: conic-gradient(var(--t-image) 0 33%, var(--t-video) 0 66%, var(--t-audio) 0); }
.wfp:hover, .wfp.hot { transform: scale(1.35); box-shadow: 0 0 0 3px var(--marker-soft); }
.wfn-ins { display: flex; flex-direction: column; padding: 6px 0 2px; }
.wfn-outs { display: flex; flex-direction: column; padding: 6px 0 2px; border-bottom: 1px dashed var(--line); }
.wfn-outrow { position: relative; display: flex; justify-content: flex-end; padding: 3px 14px; font-size: 12.5px; }
.wfn-chars { display: flex; flex-direction: column; gap: 6px; }
.wfn-char { position: relative; display: flex; align-items: center; gap: 8px; padding: 4px 28px 4px 4px; border: 1px solid var(--line); border-radius: 8px; }
.wfn-char.gone { border-style: dashed; color: var(--marker); }
.wfn-char img { width: 40px; height: 52px; object-fit: cover; border-radius: 6px; background: var(--film); }
.wfn-char-txt { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.wfn-char-txt small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11.5px; }
.wfn-char .wfn-x { top: 50%; margin-top: -10px; }
.wfn-res-img { position: relative; }
.g-logic .wfn-dot { background: var(--t-text); border-radius: 2px; transform: rotate(45deg); }
.wfn-cls { display: flex; flex-direction: column; gap: 8px; }
.wfn-sub { font-size: 12px; font-weight: 600; color: var(--muted); }
.wfn-cats { display: flex; flex-direction: column; gap: 6px; }
.wfn-cat { display: grid; grid-template-columns: 1fr 24px; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.wfn-cat .wfn-cat-name { font-weight: 600; }
.wfn-cat .wfn-cat-desc { grid-column: 1 / -1; font-size: 12px; }
.wfn-cat .wfn-x { position: static; align-self: center; width: 22px; height: 22px; background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.wfn-cat .wfn-x:disabled { opacity: 0.35; }
.wfn-cls > .bd-btn { align-self: flex-start; padding: 4px 10px; font-size: 12.5px; }
.wfn-text-box { display: flex; flex-direction: column; gap: 3px; }
/* 生图节点的参考图列表：编号、缩略图、名字（@名字 引用）、用途、调顺序 */
.wfn-refs { display: flex; flex-direction: column; gap: 4px; }
.wfn-ref { display: flex; align-items: center; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.wfn-ref-no { flex: none; min-width: 34px; padding: 0 4px; border-radius: 5px; background: var(--t-image); color: #fff; font: 600 11px/1.8 var(--mono); text-align: center; }
.wfn-ref img, .wfn-ref-ph { flex: none; width: 26px; height: 26px; border-radius: 5px; object-fit: cover; background: var(--film); }
.wfn-body .wfn-ref .wfn-ref-name { flex: 1; min-width: 0; padding: 3px 6px; font-size: 12px; }
.wfn-ref .wfn-ref-role { flex: none; height: 24px; padding: 0 7px; font-size: 11.5px; background: var(--surface); }
.wfn-ref .wfn-btn { width: 20px; height: 22px; font-size: 12px; }
.wfn-ref .wfn-btn:disabled { opacity: 0.3; }
.wfn-tag { align-self: flex-start; padding: 0 6px; border-radius: 5px; background: var(--surface-2); color: var(--muted); font: 11px/1.7 var(--mono); }
.wfn-tag.on-media { position: absolute; left: 4px; top: 4px; background: rgb(0 0 0 / 0.6); color: #fff; }
.wfn-results video { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--film); }
.wfn-save { position: absolute; left: 4px; bottom: 4px; padding: 1px 7px; border: 0; border-radius: 6px; background: rgb(0 0 0 / 0.6); color: #fff; font-size: 11px; line-height: 1.7; }
@media (hover: hover) {
  .wfn-save { opacity: 0; }
  .wfn-res-img:hover .wfn-save { opacity: 1; }
}
.wfn-in { position: relative; display: flex; align-items: baseline; gap: 8px; padding: 3px 12px 3px 14px; font-size: 12.5px; }
.wfn-in-label { flex: none; font-weight: 600; white-space: nowrap; }
.wfn-in-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11.5px; }
.wfn-body { display: flex; flex-direction: column; gap: 9px; padding: 8px 12px 12px; }
.wfn-body textarea, .wfn-body input:not([type=checkbox]) { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13px; line-height: 1.5; resize: vertical; }
.wfn-field { gap: 4px; font-size: 12px; }
.wfn-field > .picker { height: 30px; padding: 0 10px; font-size: 12.5px; }
.wfn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.wfn-row > .wfn-field { flex: 1; min-width: 0; }
.wfn-check { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink); cursor: pointer; }
.wfn-check input { accent-color: var(--marker); }
.wfn-hint { font-size: 11.5px; font-weight: 400; color: var(--muted); }
.wfn-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }
.wfn-media { display: flex; flex-direction: column; gap: 8px; border-radius: 8px; }
.wfn-media.over { outline: 2px dashed var(--marker); outline-offset: 4px; }
.wfn-items { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-height: 220px; overflow-y: auto; }
.wfn-items > .wfn-hint { grid-column: 1 / -1; padding: 10px 0; text-align: center; }
.wfn-item { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 6px; background: var(--film); }
.wfn-item img, .wfn-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.wfn-item.audio { grid-column: 1 / -1; aspect-ratio: auto; padding: 8px 28px 8px 10px; background: var(--surface-2); font-size: 12.5px; }
.wfn-audio { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wfn-x { position: absolute; right: 3px; top: 3px; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: rgb(0 0 0 / 0.55); color: #fff; font-size: 13px; line-height: 1; }
.wfn-btns { display: flex; gap: 6px; }
.wfn-btns .bd-btn { flex: 1; padding: 5px 8px; font-size: 12.5px; }
.wfn-out:empty { display: none; }
.wfn-out { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; padding: 10px 12px 12px; border-top: 1px dashed var(--line); }
.wfn-results { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.wfn-results.texts { grid-template-columns: 1fr; }
.wfn-results img, .wfn-results video { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--film); }
.wfn-results a { display: block; }
.wfn-results audio { grid-column: 1 / -1; width: 100%; height: 34px; }
.wfn-text { position: relative; max-height: 140px; overflow-y: auto; padding: 6px 8px; border-radius: 6px; background: var(--surface-2); font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.wfn-text[data-n]::before { content: attr(data-n); display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-right: 6px; border-radius: 9px; background: var(--t-text); color: #fff; font: 600 11px/1 var(--mono); vertical-align: 1px; }
.wfn-err { font-size: 12px; color: var(--marker); word-break: break-word; }
.wfn-note { font-size: 12px; color: #b7861c; }
.wfn-out-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }

.wfg-head { right: 230px; }

/* 工作流列表页：先进列表，点开一个进编辑页（is-list 时只显示列表） */
.workflow.is-list { height: auto; overflow: visible; }
.stage:has(> .workflow.is-list:not([hidden])) { padding: 28px clamp(16px, 3vw, 40px); }
.workflow.is-list > :not(.wfl) { display: none !important; }
.workflow:not(.is-list) > .wfl { display: none; }
.wfl-tip { flex: 1 1 320px; }
.wfl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; align-items: start; }
.wfl-card { display: flex; flex-direction: column; gap: 7px; padding: 14px 14px 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; cursor: pointer; transition: box-shadow 0.15s var(--ease), border-color 0.15s var(--ease); }
.wfl-card:hover, .wfl-card:focus-visible { border-color: color-mix(in srgb, var(--ink) 18%, var(--line)); box-shadow: 0 8px 24px rgb(0 0 0 / 0.1); outline: none; }
.wfl-top { display: flex; align-items: flex-start; gap: 8px; }
.wfl-name { flex: 1; min-width: 0; font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
.wfl-more { margin: -3px -5px 0 0; }
.wfl-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); }
.wfl-meta > span { padding: 1px 7px; border-radius: 6px; background: var(--surface-2); }
.wfl-meta > .wfl-pub { background: color-mix(in srgb, var(--t-image) 14%, transparent); color: var(--t-image); }
.wfl-time { margin: 0; font-size: 12.5px; }
.wfl-empty { grid-column: 1 / -1; margin: 0; padding: 48px 0; text-align: center; }
.wfl-rename { flex: 1; width: 100%; min-width: 0; max-width: none; }
.wfg-back { white-space: nowrap; }
.wfg-title { max-width: 260px; overflow: hidden; padding: 4px 8px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--ink); font-size: 15px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.wfg-title:hover:not(:disabled) { border-color: var(--line); }
.wfg-title:disabled { cursor: default; }
.wfg-run { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px); padding: 8px 10px 8px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 6px 24px rgb(0 0 0 / 0.12); }
.wfg-run .primary { flex: none; padding: 8px 18px; }
.wfg-run .ghost { flex: none; }
.wfg-plan { font-size: 12.5px; color: var(--muted); }
.wfg-menu { position: absolute; z-index: 30; width: 300px; max-height: min(520px, calc(100% - 16px)); overflow-y: auto; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px -12px rgb(0 0 0 / 0.35); }
.wfg-menu-tip { padding: 6px 10px 2px; font-size: 12px; color: var(--marker); }
.wfg-menu-h { padding: 8px 10px 4px; font: 600 11.5px/1.4 var(--sans); color: var(--muted); letter-spacing: 0.04em; }
.wfg-menu-item { display: grid; grid-template-columns: 9px 1fr; align-items: center; column-gap: 9px; width: 100%; padding: 7px 10px; border: 0; border-radius: 8px; background: none; text-align: left; }
.wfg-menu-item .opt-meta { grid-column: 2; font-size: 11.5px; }
.wfg-menu-item:hover, .wfg-menu-item:focus-visible { background: var(--surface-2); }
/* 拖文件进工作流时的提示层 */
.cv-drop { display: none; position: absolute; inset: 0; z-index: 5; place-items: center; border: 2px dashed var(--marker); background: color-mix(in srgb, var(--marker-soft) 80%, transparent); color: var(--marker); font-weight: 600; pointer-events: none; }
.over > .cv-drop { display: grid; }

@media (max-width: 860px) {
  .workflow { height: calc(100dvh - 100px - env(safe-area-inset-bottom)); }
  .wfg-head { top: 60px; left: 12px; right: 12px; max-width: none; }
  .wfg-run { bottom: 12px; flex-wrap: wrap; }
  .wfg-plan { flex-basis: 100%; }
  .wfp::after { inset: -14px; }
}

/* ---------- 来源：工作流 / 画布里生成的作品，点了跳回去 ---------- */
.src-link { padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--ink); font: 11px/1.7 var(--sans); white-space: nowrap; }
.src-link:hover:not(:disabled) { border-color: var(--marker); color: var(--marker); }
.src-link:disabled { color: var(--muted); cursor: default; }
.src-link.vi { font-size: 12.5px; }
.rec-meta .src-link { margin-left: 6px; }
#history-source { margin-left: 4px; }

/* ---------- 工作流：运行记录、节点的历次结果 ---------- */
.as-dialog.wf-dialog.wide { width: min(980px, calc(100vw - 32px)); }
.wf-runs { display: flex; flex-direction: column; gap: 10px; }
.wf-run { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.wf-run.focus { border-color: var(--marker); box-shadow: 0 0 0 3px var(--marker-soft); }
.wf-run-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.wf-run-head .act { margin-left: auto; height: 28px; }
.wf-run-st { padding: 0 7px; border-radius: 6px; font-size: 12px; line-height: 1.8; background: var(--surface-2); }
.wf-run-st.done { color: var(--t-image); }
.wf-run-st.failed { color: var(--marker); }
.wf-run-st.stopped, .wf-run-st.running { color: #b7861c; }
.wf-run-nodes { display: flex; flex-wrap: wrap; gap: 4px; }
.wf-node-chip { padding: 0 7px; border: 1px solid var(--line); border-radius: 6px; font: 11.5px/1.8 var(--sans); color: var(--muted); }
.wf-node-chip.done { color: var(--ink); }
.wf-node-chip.failed { border-color: var(--marker); color: var(--marker); }
.wf-run-detail { display: flex; flex-direction: column; gap: 10px; padding-top: 6px; border-top: 1px dashed var(--line); }
.wf-run-detail > .primary { align-self: flex-start; padding: 8px 16px; }
.wf-run-node { display: flex; flex-direction: column; gap: 6px; }
.wf-mini { display: flex; flex-wrap: wrap; gap: 6px; }
.wf-mini-img { display: block; width: 96px; height: 96px; overflow: hidden; border-radius: 8px; background: var(--film); }
.wf-mini-img img, video.wf-mini-img { width: 96px; height: 96px; object-fit: cover; display: block; }
.wf-mini-text { flex: 1 1 100%; max-height: 90px; overflow: auto; padding: 6px 8px; border-radius: 6px; background: var(--surface-2); font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; }
.wfn-out-foot .link { font-size: 11.5px; }

/* ---------- 工作流接口：发布、输入输出、API Key、调用示例 ---------- */
.wfn-api { margin: 0; padding: 3px 12px; background: color-mix(in srgb, var(--t-text) 12%, transparent); color: var(--t-text); font: 600 11.5px/1.7 var(--sans); }
.wf-api-sec { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.wf-api-sec:last-child { border-bottom: 0; }
.wf-api-sec h4 { margin: 0; font-size: 15px; }
.wf-api-sec .primary { align-self: flex-start; padding: 8px 16px; }
.wf-api-h { margin-top: 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.wf-api-io { display: grid; grid-template-columns: 18px 1fr 160px; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.wf-api-io input[type=checkbox] { accent-color: var(--marker); }
.wf-api-io input:not([type]) { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 13px; }
.wf-api-io input:disabled { opacity: 0.45; }
.wf-api-node { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-api-key { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--marker); border-radius: 8px; background: var(--marker-soft); }
.wf-api-key code { font: 12.5px var(--mono); word-break: break-all; }
.wf-api-keyrow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.wf-api-keyrow code { font: 12px var(--mono); color: var(--muted); }
.wf-api-keyrow .act { margin-left: auto; height: 26px; }
.wf-api-keyrow.revoked { opacity: 0.5; }
.wf-api-add { display: flex; gap: 8px; }
.wf-api-add input { flex: 1; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13px; }
.wf-api-code { margin: 0; padding: 10px 12px; overflow-x: auto; border-radius: 8px; background: var(--film); color: #d7dde6; font: 12px/1.6 var(--mono); white-space: pre; }
.wf-run-st.api { color: var(--t-text); }
