/* ============================================================
   视图：素材生成 —— 私有样式
   只做补充：颜色 / 圆角 / 边框一律取 styles.css 的 CSS 变量，
   组件（.card .btn .seg .chip .zodiac-* .tiles .tile .empty）直接复用，
   类名统一 material- 前缀，不覆盖设计系统。
   ============================================================ */

/* [hidden] 会被 .field{display:flex} / .chip{display:inline-flex} 压过，这里补回来 */
.material-hide[hidden] { display: none; }

/* ---------------- 左卡：生成设置 ---------------- */
.material-ai {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-picked {
  margin-left: 4px;
  color: var(--fg);
  font-weight: 600;
  font-size: 11.5px;
}

/* ---------------- 带货产品选择 ---------------- */
.material-prods {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.material-prod {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 168px;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
  text-align: left;
  transition: .14s;
}
.material-prod:hover { background: var(--surface); border-color: var(--muted); }
.material-prod.on { border-color: var(--fg); box-shadow: inset 0 0 0 1px var(--fg); }
.material-prod-thumb {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
}
.material-prod-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.material-prod-meta { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.material-prod-meta b {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.material-prod-meta small { font-size: 11px; color: var(--muted); }

/* 上传产品图卡位 */
.material-prod-add {
  border-style: dashed;
  background: var(--surface-2);
}
.material-prod-add:hover { background: var(--surface); }
.material-prod-add-ico {
  border: 1px dashed var(--border);
  background: var(--surface);
  font-size: 20px;
  color: var(--muted);
}

/* 上传弹窗里的图片预览 */
.material-up-prev {
  margin-top: 8px;
  max-height: 180px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
}
.material-up-prev img { max-width: 100%; max-height: 180px; display: block; object-fit: contain; }

/* 祝福语搜索 + 随机 */
.material-nur-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}
.material-nur-bar .input {
  flex: 1;
  min-width: 0;
  height: 32px;
  font-size: 12.5px;
}
.material-nur-bar .btn { flex: none; }

/* 祝福语 chip 网格（40 个，滚动区里挤着放） */
.material-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 188px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.material-chip {
  height: 24px;
  cursor: pointer;
  transition: .14s;
  font-size: 12px;
}
.material-chip:hover {
  color: var(--fg);
  border-color: var(--muted);
  background: var(--card);
}
.material-chips .chip.on:hover {
  color: var(--accent-fg);
  background: var(--accent);
  border-color: var(--accent);
}
.material-chips-empty { padding: 6px 2px; }

/* 说明块 */
.material-desc {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 12px 0;
  padding: 9px 11px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.material-desc-main { font-size: 12.5px; line-height: 1.5; }
.material-desc-sub { line-height: 1.5; }

/* 主按钮 */
.material-gen-btn {
  height: 38px;
  font-variant-numeric: tabular-nums;
}
.material-gen-hint {
  margin-top: 8px;
  text-align: center;
}
.material-loading { display: block; }

/* ---------------- 右卡：生成结果 ---------------- */
.material-slots { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.material-slots.single { grid-template-columns: minmax(0, 320px); }

/* 进度条（正在出图 / 出完的提示） */
.material-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--muted);
}
.material-progress b { color: var(--fg); font-weight: 600; }
.material-progress.done { color: var(--muted); border-style: dashed; }

/* 卡位：3:4 竖图（图是 2:3 出图，用 contain 保证图上文案不被裁） */
.material-thumb { position: relative; background: var(--surface-2); }
.material-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.material-no {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11px;
  line-height: 18px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  backdrop-filter: blur(4px);
}
html.dark .material-no { background: rgba(255, 255, 255, .18); }

/* 占位（排队 / 生成中 / 失败 / 已删除） */
.material-ph {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  text-align: center;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
}
.material-ph-err > span:first-child,
.material-ph-dead > span:first-child { font-size: 20px; line-height: 1; }
.material-ph-txt { font-size: 12.5px; color: var(--fg); }
.material-ph-sub { opacity: .85; }
.material-ph-err { background: var(--err-bg); color: var(--err); }
.material-ph-err .material-ph-txt { color: var(--err); }
.material-ph-dead { color: var(--muted); background: var(--surface-2); }

/* 转圈 */
.material-spin {
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--fg);
  animation: material-rot .8s linear infinite;
}
.material-spin.sm { width: 13px; height: 13px; }
@keyframes material-rot { to { transform: rotate(360deg); } }

/* 卡位底部状态行 / 操作 */
.material-slot .meta { gap: 3px; }
.material-slot-s {
  justify-content: flex-start;
  flex-wrap: wrap;
  column-gap: 6px;
  line-height: 1.5;
}
.material-slot-s .num { margin-left: auto; }
.material-ok { color: var(--ok); }
.material-err { color: var(--err); word-break: break-word; }
.material-acts {
  display: flex;
  gap: 6px;
  padding: 0 10px 10px;
}
.material-acts .btn { flex: 1; }
.material-empty { padding: 44px 20px; }

/* ---------------- 底部：历史素材 ---------------- */
.material-his { margin-top: 14px; }

/* card-head 里的小下拉：比表单里的 .select 矮一档 */
.material-select {
  width: auto;
  min-width: 104px;
  height: 30px;
  padding: 0 26px 0 10px;
  font-size: 12.5px;
  background-position: calc(100% - 14px) 12px, calc(100% - 9px) 12px;
}

.material-his-tile .thumb img { transition: transform .2s; }
.material-his-tile:hover .thumb img { transform: scale(1.02); }

.material-skeleton .thumb .skeleton {
  width: 100%;
  height: 100%;
  border-radius: 0;
}
.material-skeleton .meta .skeleton + .skeleton { margin-top: 6px; }

/* ---------------- 窄屏 ---------------- */
@media (max-width: 1000px) {
  .material-select { min-width: 92px; }
  .material-slots { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .material-slots.single { grid-template-columns: minmax(0, 280px); }
  .material-chips { max-height: 150px; }
}
