.studio {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.studio-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 16px;
}
.studio-card h2, .studio-card h3 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.studio-card .lead { margin: 6px 0 0; color: var(--muted-foreground); font-size: 13px; }
.studio-label { display: flex; justify-content: space-between; margin: 14px 0 6px; font-size: 13px; font-weight: 600; }
.studio-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.studio-tags:empty { display: none; }
.studio-label em { font-style: normal; color: var(--muted-foreground); font-weight: 500; }
.studio select, .studio textarea, .studio input[type="text"] {
  width: 100%;
  border: 1px solid var(--input);
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  font: inherit;
}
.studio textarea { min-height: 140px; resize: vertical; }
/* 可输入下拉（`.combo`）的样式已经搬去 index.html 的 `.select-menu` 旁边：全站一份，
   渠道配置的「字段名」、创作页和画布的「尺寸」共用（ui.js 的 `upgradeCombos`）。 */
.ref-box { display: grid; gap: 8px; padding: 8px; border: 1px dashed var(--border); border-radius: 12px; background: #fff; }
.ref-add { display: flex; align-items: center; gap: 10px; }
/* 「上传」排在前面、地址框退到「或」后面：两个是并列的两种给法，不是一个先填后交的表单。
   少了这个「或」，输入框先出现、按钮跟在后面，看着就像「不填地址就点不了上传」。 */
.ref-or { flex: none; color: var(--muted-foreground); font-size: 12px; }
.ref-list { display: flex; flex-wrap: wrap; gap: 8px; }
.ref-list:empty { display: none; }
.ref-item { position: relative; width: 64px; height: 64px; }
.ref-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; background: var(--muted); display: block; }
.ref-item button { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border: 0; border-radius: 999px; background: #111; color: #fff; font-size: 12px; line-height: 18px; padding: 0; }
/* 参考素材：图片/视频/音频三块是同一个渲染函数出的，所以样式也共用。
   能带几样由模型自己的上限说了算，页面上只有「还可以加 N 张」和「不可用」两种说法。 */
.ref-block { margin-top: 4px; }
.ref-block .ref-box { margin-top: 6px; }
.ref-link { flex: 1; min-width: 0; width: auto !important; height: 32px; padding: 0 10px !important; border-radius: 8px !important; font-size: 13px; }
.ref-note { margin: 0; color: var(--muted-foreground); font-size: 12px; line-height: 1.4; }
/* 不支持的那一类整块灰下去：看得出是「这个模型不吃」，而不是「加载失败」。 */
.ref-block.is-off .ref-box { border-style: solid; background: var(--muted); pointer-events: none; }
.ref-block.is-off .ref-note { color: var(--foreground); }
/* 视频/音频当不了缩略图，列表里放个名字胶囊（上传的用文件名，贴地址的用域名/尾段）。 */
.ref-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; padding: 5px 6px 5px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--muted); font-size: 12px; }
.ref-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-chip button { flex: none; border: 0; background: transparent; color: var(--muted-foreground); font-size: 14px; line-height: 1; padding: 0 2px; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}
.chip.on { border-color: var(--primary); background: var(--accent); color: var(--accent-foreground); }
.studio-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.studio-actions strong { font-size: 16px; }
.studio-actions p { margin: 2px 0 0; color: var(--muted-foreground); font-size: 12px; }
/* 生成中按钮上转个小圈（跟画布 .actbar button.is-loading 同一套）：光把按钮变灰，看着
   像点坏了而不是在跑。这里是实心主色按钮（白字），所以圈也画成白的；文字透明只为留宽度。 */
.studio-actions .btn.is-loading { position: relative; color: transparent; }
/* 生成中这个按钮虽然是 disabled，但别让它跟着透明：`.btn:disabled` 的 opacity .5 会把白圈
   糊在浅色底上（几乎看不见），看着还是像坏了。点不动由 pointer-events 兜着，不会误点。 */
.studio-actions .btn.is-loading:disabled { opacity: 1; }
.studio-actions .btn.is-loading:before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 99px;
  animation: su-spin .7s linear infinite;
}
@keyframes su-spin { to { transform: rotate(360deg); } }
.studio-result { min-height: 420px; }
.studio-media { display: grid; gap: 12px; }
.studio-media img, .studio-media video { width: 100%; border-radius: 12px; background: var(--muted); pointer-events: none; }
.studio-empty, .canvas-empty {
  display: grid;
  place-content: center;
  gap: 6px;
  min-height: 220px;
  color: var(--muted-foreground);
  text-align: center;
}
.studio-empty strong, .canvas-empty strong { color: var(--foreground); }
/* 历史记录一条一格、宽度不够就换行：原来是单列满宽，54px 缩略图后面空一大片，
   记录一多就成一条拉不到底的长列表（排法跟 `.canvas-grid` 一样）。窄面板下自动退回单列。 */
.hist { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin-top: 14px; }
.hist button {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 8px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 6px;
  text-align: left;
  cursor: pointer;
}
/* 整格都要能点开：媒体本身不接事件，点击一路落到外面的 button 上 */
.hist img, .hist video { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; background: var(--muted); pointer-events: none; }
.hist strong, .hist span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist span { color: var(--muted-foreground); font-size: 12px; }
.canvas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.canvas-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  padding: 0;
}
.canvas-card .thumb {
  height: 140px;
  background:
    linear-gradient(#e6e6e6 1px, transparent 1px),
    linear-gradient(90deg, #e6e6e6 1px, transparent 1px),
    #f7f7f7;
  background-size: 24px 24px;
}
.canvas-card .meta { display: grid; gap: 4px; padding: 10px 12px 12px; }
.canvas-card .meta span { color: var(--muted-foreground); font-size: 12px; }
.canvas-card .del { position: absolute; top: 8px; right: 8px; }
.pane.pane-fill { padding: 0; overflow: hidden; }
.board-page { height: 100%; min-height: 0; display: flex; flex-direction: column; background: #f4f5f7; }
.board-top { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 12px; border-bottom: 1px solid var(--border); background: #fff; }
.board-top input { border: 0; font: inherit; font-weight: 600; min-width: 160px; background: transparent; }
.board-top .save { margin-left: auto; color: var(--muted-foreground); font-size: 12px; }
.board { position: relative; flex: 1; min-height: 0; overflow: hidden; cursor: grab; touch-action: none; }
.board.is-select { cursor: default; }
.world { position: absolute; inset: 0; transform-origin: 0 0; }
.wires { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.wires path { fill: none; stroke: #8aa0bd; stroke-width: 2; pointer-events: stroke; }
.wires path.on { stroke: var(--primary); }
.cnode {
  position: absolute;
  border: 1px solid rgba(23, 49, 90, .12);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(23, 49, 90, .08);
  overflow: visible;
}
.cnode.on { outline: 2px solid var(--primary); }
.cnode header { height: 32px; display: flex; align-items: center; padding: 0 12px; font-size: 12px; color: #3d5678; }
.cnode .body { height: calc(100% - 32px); margin: 0 10px 10px; border-radius: 10px; background: #f3f6fb; overflow: hidden; display: grid; place-items: center; }
.cnode img, .cnode video { width: 100%; height: 100%; object-fit: cover; }
.cnode textarea { width: 100%; height: 100%; border: 0; resize: none; background: transparent; padding: 8px; font: inherit; }
.port {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid #fff;
  border-radius: 99px;
  background: var(--primary);
  padding: 0;
  cursor: crosshair;
}
.port.in { left: -7px; }
.port.out { right: -7px; }
.dock, .zoombar, .promptbar, .cmenu { position: absolute; z-index: 5; }
.dock, .zoombar {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 44px;
  padding: 0 8px;
  border: 1px solid rgba(23, 49, 90, .08);
  border-radius: 14px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 12px 32px rgba(23, 49, 90, .12);
}
.dock { left: 50%; bottom: 16px; transform: translateX(-50%); }
.zoombar { left: 16px; bottom: 16px; }
.dock button, .zoombar button, .cmenu button {
  border: 0;
  background: transparent;
  border-radius: 8px;
  height: 32px;
  min-width: 32px;
  cursor: pointer;
}
.dock button.on, .dock button:hover, .zoombar button:hover, .cmenu button:hover { background: var(--muted); pointer-events: none; }
.promptbar {
  width: min(420px, calc(100% - 24px));
  padding: 10px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(23, 49, 90, .16);
}
.promptbar textarea { min-height: 72px; }
.promptbar input[type="text"], .promptbar select { width: 100%; margin-top: 8px; border: 1px solid var(--input); border-radius: 10px; padding: 8px 10px; font: inherit; }
.cmenu {
  min-width: 160px;
  padding: 4px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(23, 49, 90, .16);
}
.cmenu button { display: block; width: 100%; text-align: left; padding: 0 10px; }
.cmenu .danger { color: var(--destructive); }
.progress-line { height: 8px; border-radius: 99px; background: var(--muted); overflow: hidden; margin-top: 10px; }
/* 宽度是每 500ms 推一小步，加个线性过渡才连成一条在爬的进度（否则是 0.75% 一跳）。 */
.progress-line span { display: block; height: 100%; background: var(--primary); transition: width .5s linear; }
@media (max-width: 900px) {
  .studio { grid-template-columns: 1fr; }
}
