/* ==========================================================================
   资产库 / API 登录 页面布局
   ========================================================================== */

/* body 用 overflow-x: clip 兜底（clip 不产生滚动容器，实测不影响 sticky 侧栏） */
body { overflow-x: clip; }

/* 装饰层：fixed + overflow:hidden，把故意溢出视口的有机色块裁掉，避免出现横向滚动条。
   fixed 元素不参与文档布局，因此这里不会产生滚动容器破坏 sticky。 */
.page-decor {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  /* 底部留白：给固定在视口底部的 .site-footer 让位，
     否则页��最后一屏的内容（表单保存按钮等）会被压在备案条下面点不到。 */
  padding: 24px 24px 64px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  border-radius: 2rem;
  background: #faf6f1;
  border: 1px solid #e8ded2;
  box-shadow: 0 8px 24px -18px rgba(92, 64, 51, 0.45);
  flex-wrap: wrap;
}

.page-nav { display: flex; gap: 8px; flex-wrap: wrap; }

.page-title { margin: 44px 0 26px; }
.page-title h2 { margin: 0 0 8px; }
.page-title p { margin: 0; max-width: 62ch; }

.page-blob-one { width: 420px; height: 380px; background: rgba(139, 157, 119, 0.24); top: -160px; left: -160px; }
.page-blob-two { width: 340px; height: 340px; background: rgba(212, 163, 115, 0.2); top: 40%; right: -170px; animation-delay: -10s; }

/* ------------------------------- 管理页布局 ------------------------------- */
.manager-layout {
  display: grid;
  grid-template-columns: 264px 1fr;
  gap: 24px;
  align-items: start;
}

.manager-side {
  border-radius: 2rem;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 24px;
}

.side-block { display: flex; flex-direction: column; gap: 10px; }

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8c7c6d;
  padding-left: 8px;
}

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

.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: #5c4033;
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: all 500ms var(--no-ease);
  width: 100%;
}

.side-item svg { width: 15px; height: 15px; color: #8b9d77; flex-shrink: 0; }
.side-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item small { font-size: 11px; color: #a3937f; }
.side-item:hover { background: #f2ece3; }
.side-item.is-active { background: rgba(139, 157, 119, 0.18); border-color: #8b9d77; }
.side-item .side-item-del {
  opacity: 0;
  border: none;
  background: transparent;
  color: #a3937f;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  transition: opacity 300ms var(--no-ease), color 300ms var(--no-ease);
}
.side-item:hover .side-item-del { opacity: 1; }
.side-item .side-item-del:hover { color: #8c4a34; }

/* ------------------------------- 素材主区域 ------------------------------- */
.manager-main { min-width: 0; }

.main-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.main-bar h3 { margin: 0 0 4px; }
.main-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 30px 20px;
  margin-bottom: 26px;
  border: 1px dashed #d4a373;
  border-radius: 2rem;
  background: rgba(255, 253, 249, 0.6);
  color: #8c7c6d;
  text-align: center;
  cursor: pointer;
  transition: all 500ms var(--no-ease);
}
.upload-zone svg { width: 26px; height: 26px; color: #d4a373; }
.upload-zone strong { font-size: 14px; color: #5c4033; font-weight: 500; }
.upload-zone span { font-size: 12px; }
.upload-zone:hover,
.upload-zone.is-over { background: rgba(139, 157, 119, 0.16); border-color: #6f8160; }

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 16px;
}

.asset-card {
  display: flex;
  flex-direction: column;
  border: 1px solid #e8ded2;
  border-radius: 1.6rem;
  background: #fffdf9;
  overflow: hidden;
  transition: all 500ms var(--no-ease);
}
.asset-card:hover { border-color: #8b9d77; transform: translateY(-2px); }

.asset-thumb { position: relative; aspect-ratio: 1; background: #f2ece3; cursor: zoom-in; }
.asset-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.asset-meta { display: flex; align-items: center; gap: 6px; padding: 10px 12px; }
.asset-name {
  flex: 1;
  font-size: 12px;
  color: #5c4033;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.asset-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 400ms var(--no-ease); }
.asset-card:hover .asset-actions { opacity: 1; }
.asset-actions .mini-btn { width: 28px; height: 28px; min-height: 28px; }

.preview-body { display: flex; align-items: center; justify-content: center; }
.preview-body img { max-width: 100%; max-height: 62vh; border-radius: 1.4rem; display: block; }

/* ------------------------------- API 登录页 ------------------------------- */
.api-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}

.provider-panel {
  display: flex;
  flex-direction: column;
  border-radius: 2rem;
  background: #faf6f1;
  border: 1px solid #e8ded2;
  padding: 20px;
  gap: 12px;
  position: sticky;
  top: 24px;
}

.provider-list { display: flex; flex-direction: column; gap: 6px; flex: 1; }

.api-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-radius: 2rem;
  background: #faf6f1;
  border: 1px solid #e8ded2;
  padding: 26px;
  max-width: 720px;
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }

.form-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.status-box {
  border-radius: 1.4rem;
  border: 1px solid #e8ded2;
  background: #fffdf9;
  padding: 14px 18px;
  font-size: 13px;
  color: #6b5d51;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 500ms var(--no-ease);
}
.status-box.is-ok { background: rgba(139, 157, 119, 0.16); border-color: #8b9d77; color: #4f5c44; }
.status-box.is-error { background: rgba(212, 163, 115, 0.18); border-color: #d4a373; color: #8c4a34; }
.status-box svg { width: 16px; height: 16px; flex-shrink: 0; }

.hint-text { font-size: 12px; color: #8c7c6d; margin: 0; padding-left: 6px; }

/* ------------------------- 配置导出 / 导入 / 存储 ------------------------- */
.side-actions { display: flex; gap: 8px; }
.side-actions .tool-btn { flex: 1; justify-content: center; min-height: 36px; padding: 7px 12px; font-size: 12px; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 11px 16px;
  border: 1px solid #e8ded2;
  border-radius: 1.2rem;
  background: #fffdf9;
  font-size: 13px;
  color: #5c4033;
  cursor: pointer;
  transition: all 400ms var(--no-ease);
}
.check-row:hover { background: #f2ece3; }
.check-row input { width: 16px; height: 16px; accent-color: #8b9d77; cursor: pointer; flex-shrink: 0; }

.import-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 14px 0 4px;
  max-height: 210px;
  overflow-y: auto;
}

.import-preview .import-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid #e8ded2;
  border-radius: 1rem;
  background: #fffdf9;
  font-size: 12px;
  color: #5c4033;
}
.import-preview .import-row svg { width: 14px; height: 14px; color: #8b9d77; flex-shrink: 0; }
.import-preview .import-row b { font-weight: 500; }
.import-preview .import-row small { color: #a3937f; }
.import-preview .import-row .import-flag {
  margin-left: auto;
  font-size: 11px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #f2ece3;
  color: #8c7c6d;
  white-space: nowrap;
}
.import-preview .import-row .import-flag.is-new { background: rgba(139, 157, 119, 0.2); color: #5c4033; }

.is-busy svg { animation: no-spin 1.1s linear infinite; }

@keyframes no-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* --------------------------- 模型卡片与模型框 --------------------------- */
.model-count {
  display: inline-block;
  min-width: 18px;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #f2ece3;
  color: #8c7c6d;
  font-size: 10px;
  text-align: center;
}

/* 可拖入的模型框 */
.model-box {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  min-height: 76px;
  max-height: 190px;
  overflow-y: auto;
  padding: 10px;
  border: 1px dashed #ddcebd;
  border-radius: 1.2rem;
  background: #fffdf9;
  transition: border-color 300ms var(--no-ease), background 300ms var(--no-ease), box-shadow 300ms var(--no-ease);
}
.model-box.is-drop {
  border-color: #8b9d77;
  border-style: solid;
  background: #f4f7ef;
  box-shadow: 0 0 0 3px rgba(139, 157, 119, 0.16);
}

/* 框里的模型卡片：一键删除 */
.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  padding: 4px 4px 4px 12px;
  border: 1px solid #e2d6c6;
  border-radius: 999px;
  background: #f7f2ea;
  color: #5c4033;
  font-size: 11.5px;
  cursor: grab;
  transition: all 300ms var(--no-ease);
}
.model-chip:hover { border-color: #c6b49f; background: #f2ece3; }
.model-chip.is-dragging { opacity: 0.45; }
.model-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-chip-x {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #a3937f;
  cursor: pointer;
  transition: all 300ms var(--no-ease);
}
.model-chip-x svg { width: 12px; height: 12px; }
.model-chip-x:hover { background: #a8452c; color: #faf6f1; }

.model-add {
  flex: 1 1 120px;
  min-width: 110px;
  padding: 5px 6px;
  border: none;
  background: transparent;
  color: #5c4033;
  font-family: inherit;
  font-size: 11.5px;
  outline: none;
}
.model-add::placeholder { color: #b8a894; }

/* 拉取结果：分类 + 卡片 */
.fetched-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.model-target { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #8c7c6d; }
.seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid #e8ded2;
  border-radius: 999px;
  background: #fffdf9;
}
.seg-btn {
  padding: 5px 14px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #6b5d51;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 300ms var(--no-ease);
}
.seg-btn:hover { background: #f2ece3; }
.seg-btn.is-active { background: #8b9d77; color: #faf6f1; }

.model-groups {
  max-height: 300px;
  overflow-y: auto;
  padding: 2px;
  /* 模型可能上百个，限高滚动，避免把下方操作按钮挤出视野 */
}
.model-group + .model-group { margin-top: 12px; }
.model-group-head {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #8c7c6d;
}
.model-cards { display: flex; flex-wrap: wrap; gap: 6px; }

.model-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 5px 10px 5px 12px;
  border: 1px solid #e8ded2;
  border-radius: 999px;
  background: #fffdf9;
  color: #5c4033;
  font-family: inherit;
  font-size: 11px;
  cursor: grab;
  transition: all 300ms var(--no-ease);
}
.model-card:hover { border-color: #c6b49f; background: #f7f2ea; }
.model-card.is-dragging { opacity: 0.45; }
.model-card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-card-kind {
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  background: #f2ece3;
  color: #8c7c6d;
}
.model-card-kind.kind-chat { background: #eef1ea; color: #6f8160; }
.model-card-kind.kind-image { background: #f7ece2; color: #b5794a; }
.model-card-kind.kind-video { background: #ece8f0; color: #7d6f8f; }
.model-card.is-added { opacity: 0.5; background: #f4f1ec; }

/* -------------------------------- 响应式 --------------------------------- */
@media (max-width: 900px) {
  .manager-layout,
  .api-layout { grid-template-columns: 1fr; }
  .manager-side,
  .provider-panel { position: static; }
  .form-grid { grid-template-columns: 1fr; }
  .page { padding: 16px 16px 64px; }
  .page-title { margin: 28px 0 20px; }
  .page-nav .tool-btn span { display: none; }
}

/* --------------------------------- 页脚 ---------------------------------
 * 版权 + ICP 备案号。工信部要求备案信息在网站底部显著位置可查，
 * 且备案号必须能跳转到 beian.miit.gov.cn —— 所以这里是真链接，
 * 不是纯文本。用 <a> 而不是 button：它就是「跳到备案查询站」这一个动作。
 * 四页共用（画布页也挂 pages.css）。
 */
.site-footer {
  /* ⛔ 固定在视口底部，而不是文档流末尾。
   * 二级页（尤其 api-settings）内容很长，文档流末尾的 footer 要滚到底才看得见，
   * 而工信部要求的是「页面底部可查」—— 滚不到就等于没做。
   * fixed 后任何一页打开即见，且不占布局高度、不影响滚动。 */
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  margin-top: 0;
  padding: 6px 12px 7px;
  border-top: 1px solid rgba(138, 122, 109, 0.16);
  background: rgba(250, 246, 241, 0.82);
  backdrop-filter: blur(6px);
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  color: #8c7c6d;
}
.site-footer p { margin: 0; }
.site-footer a {
  color: #8c7c6d;
  text-decoration: none;
  border-bottom: 1px solid rgba(140, 124, 109, 0.4);
  transition: color .15s ease, border-color .15s ease;
}
.site-footer a:hover { color: #5c4033; border-color: #5c4033; }
.site-footer .footer-sep { margin: 0 6px; opacity: .5; }

@media (max-width: 900px) {
  .site-footer { font-size: 11px; padding: 4px 8px 5px; }
}
