/* static/css/materials-ai-warehouse.css — AI-first materials discovery redesign */

/* ---------- AI Discovery Header ---------- */
.materials-hero-title {
  font-size: 44px;
  font-weight: 800;
  margin: 40px auto 26px;
  letter-spacing: 0.01em;
  text-align: center;
  color: #5eead4; /* 淡青绿 */
  text-shadow: 0 0 42px rgba(94,234,212,0.16);
}

/* ---------- AI Composer（大输入组件：上方文字输入区 + 底部独立工具栏行） ---------- */
.materials-ai-composer {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 840px;
  max-width: 100%;
  height: 135px;
  margin: 0 auto;
  border-radius: 24px;
  background: rgba(18, 20, 22, 0.62);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 0 0 1px rgba(94,234,212,0.04), 0 0 44px rgba(94,234,212,0.10), 0 14px 36px rgba(0,0,0,0.32);
  transition: border-color .2s, box-shadow .2s;
}
.materials-ai-composer:focus-within {
  border-color: rgba(94,234,212,0.45);
  box-shadow: 0 0 0 4px rgba(94,234,212,0.08), 0 0 52px rgba(94,234,212,0.16), 0 14px 36px rgba(0,0,0,0.32);
}
html[data-theme="light"] .materials-ai-composer {
  background: rgba(255,255,255,0.82);
  border-color: rgba(0,0,0,0.10);
}

/* 文字输入区：仅占组件上方（红框区域），不覆盖底部工具栏 */
.materials-ai-composer textarea {
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 16px 20px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  resize: none;
  outline: none;
}
.materials-ai-composer textarea::placeholder { color: var(--text-muted); }

/* 底部工具栏行：独立于 textarea，文字永不覆盖 */
.materials-ai-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
html[data-theme="light"] .materials-ai-toolbar { border-top-color: rgba(0,0,0,0.08); }
.materials-ai-upload {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px dashed rgba(255,255,255,0.26);
  background: rgba(255,255,255,0.05);
  color: var(--text-dim);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all .2s ease;
}
.materials-ai-upload:hover {
  color: #5eead4;
  border-color: rgba(94,234,212,0.6);
  border-style: solid;
  background: rgba(94,234,212,0.10);
}
.materials-ai-upload svg { width: 16px; height: 16px; }
.materials-ai-model {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,0.12);
}
html[data-theme="light"] .materials-ai-model { border-left-color: rgba(0,0,0,0.12); }
.materials-ai-model-label {
  font-size: 12px;
  color: var(--text-muted);
}
.materials-ai-model select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 20px 6px 0;
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 2px center;
  background-size: 12px;
}
.materials-ai-model select option { background: #14181b; color: #e5e7eb; }
.materials-ai-submit {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #4ade80, #34d399);
  color: #04210f;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(74,222,128,0.26);
  transition: transform .15s, filter .15s, box-shadow .2s;
}
.materials-ai-submit:hover { transform: scale(1.06); filter: brightness(1.08); box-shadow: 0 8px 26px rgba(74,222,128,0.38); }
.materials-ai-submit:active { transform: scale(0.96); }
.materials-ai-submit svg { width: 18px; height: 18px; }

/* ---------- Mini tool row + category pills ---------- */
.materials-ai-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  width: 840px;
  max-width: 100%;
  margin: 26px auto 0;
}
.materials-mini-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
}
.materials-mini-tool:hover { color: var(--text); border-color: rgba(94,234,212,0.4); }
.materials-mini-tool svg { width: 14px; height: 14px; }
.materials-cat-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.materials-cat {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .18s ease;
}
.materials-cat:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-hover); }
.materials-cat.active {
  color: #5eead4;
  border-color: rgba(94,234,212,0.55);
  background: rgba(94,234,212,0.10);
  font-weight: 700;
}

/* ---------- Status progress bar ---------- */
.materials-progress {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  width: 840px;
  max-width: 100%;
  margin: 16px auto 0;
}
.materials-progress-track {
  position: relative;
  width: 220px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  overflow: hidden;
  flex-shrink: 0;
}
html[data-theme="light"] .materials-progress-track { background: rgba(0,0,0,0.10); }
.materials-progress-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 32%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(94,234,212,0.35), #5eead4);
  opacity: 0.35;
  transition: opacity .3s ease;
}
.materials-progress.active .materials-progress-bar {
  opacity: 1;
  animation: matScan 1.8s ease-in-out infinite;
}
.materials-progress-label {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
@keyframes matScan {
  0% { left: -36%; }
  100% { left: 106%; }
}

/* ---------- Shell & Sections ---------- */
#view-materials.active {
  display: flex;
  flex-direction: column;
  max-width: 2028px; /* 素材画廊充分利用横向空间 */
}
.materials-shell {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 4px 24px 0;
}
.materials-section {
  margin-bottom: 28px;
}
.materials-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.materials-section-head h2 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-icon { font-size: 18px; }
.section-more {
  font-size: 12px;
  font-weight: 700;
  color: var(--neon-bright);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: opacity .15s;
}
.section-more:hover { opacity: .8; }

/* Masonry 瀑布流（Pinterest-like）：CSS column 原生布局，无需 JS 计算高度 */
/* 单容器：最大宽度 2028px 水平居中，充分利用横向空间；小于该宽度自动收缩 */
.materials-masonry,
.materials-results-grid {
  width: 100%;
  max-width: 2028px;
  margin: 0 auto;
  border-radius: 16px; /* 外层包裹容器整体大圆角 */
  overflow: hidden;    /* 裁切内部素材 */
  column-count: 6;
  column-width: 220px; /* 随容器宽度自适应列数 */
  column-gap: 6px;
  masonry-auto-flow: next;
}
.materials-masonry .mat-result-card,
.materials-results-grid .mat-result-card {
  break-inside: avoid;
  margin-bottom: 6px;
}

/* ---------- Result Card (Pinterest 式：透明、无边框、纯图片 + hover 信息浮层) ---------- */
.mat-result-card {
  position: relative;
  border-radius: 3px; /* 卡片 3px 微小倒角 */
  background: transparent;
  border: none;
  box-shadow: none; /* 禁止任何描边边框线条 */
  overflow: hidden;
  cursor: pointer;
  transition: transform .25s cubic-bezier(0.16,1,0.3,1);
  /* 去掉入场缩放动画：列表加载/重绘不再闪 */
}
.mat-result-card:hover { transform: translateY(-3px); }
.mat-result-card.in-library .mat-overlay-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 4;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(59,130,246,0.85);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

/* 媒体：高度由图片原始比例撑开，不写死 height */
.mat-result-card .mat-media {
  position: relative;
  width: 100%;
  background: var(--bg-elevated);
  overflow: hidden;
  border-radius: 3px; /* 图片跟随卡片 3px 微小倒角 */
}
.mat-result-card .mat-media img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  transition: transform .4s ease;
}
.mat-result-card .mat-media video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9; /* 视频无固有比例，按 16:9 撑开 */
  object-fit: cover;
  transition: transform .4s ease;
}
.mat-result-card .mat-media .mat-placeholder {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: rgba(255,255,255,0.55);
}
.mat-result-card .mat-media .mat-placeholder svg { width: 40px; height: 40px; }
.mat-result-card .mat-media .mat-placeholder span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.mat-result-card:hover .mat-media img,
.mat-result-card:hover .mat-media video { transform: scale(1.04); }

/* 视频角落播放小图标（静态常显） */

/* 视频卡片 hover 预览：封面叠在视频上层（video 底层），hover 时隐藏封面播放 */
.mat-result-card .mat-media .mat-video-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #000;
  z-index: 1;
  pointer-events: none;
  transition: transform .4s ease, opacity .18s ease;
}
.mat-result-card .mat-media .mat-video-cover-hidden { opacity: 0; }
.mat-result-card:hover .mat-media .mat-video-cover { transform: scale(1.04); }
.mat-result-card .mat-play {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.18);
  display: grid;
  place-items: center;
  z-index: 2;
  pointer-events: none;
}
.mat-result-card .mat-play svg { width: 14px; height: 14px; color: #fff; }

/* Card overlay：hover 浮现（顶部收藏 + 底部操作按钮） */
.mat-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px;
  background: linear-gradient(180deg, rgba(0,0,0,0.40) 0%, transparent 32%);
  opacity: 0;
  transition: opacity .22s ease;
  z-index: 3;
  pointer-events: none;
}
.mat-result-card:hover .mat-overlay { opacity: 1; pointer-events: auto; }
.mat-overlay-top,
.mat-overlay-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mat-overlay-top { justify-content: space-between; }
.mat-overlay-bottom { justify-content: flex-end; }
.mat-overlay-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.45);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all .15s;
  backdrop-filter: blur(4px);
}
.mat-overlay-btn:hover { background: var(--neon); color: #04210f; border-color: var(--neon); }
.mat-overlay-btn svg { width: 15px; height: 15px; }
.mat-overlay-btn.add-cart { width: 36px; height: 36px; }
.mat-overlay-btn.add-cart svg { width: 21px; height: 21px; }
.mat-overlay-btn.add-cart.active { background: var(--neon); color: #04210f; border-color: var(--neon); }
.mat-overlay-btn.fav.active { background: #fbbf24; color: #fff; border-color: #fbbf24; }

/* Source badge on card */
.mat-source-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 4;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  color: var(--text);
  z-index: 2;
}
/* 已加入清单：常驻标记（圆 + 对勾，不随 hover 隐藏） */
.mat-cart-badge {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 5;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(74,222,128,0.92);
  color: #04210f;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
.mat-cart-badge svg { width: 17px; height: 17px; }
/* 序列帧灰色标签（过滤项显示开关打开时展示） */
.mat-seq-badge {
  position: absolute;
  left: 10px;
  top: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  background: rgba(107,114,128,0.85);
  color: #fff;
  z-index: 2;
  letter-spacing: 0.5px;
}

/* 视频压缩转码产物角标（素材源视频压缩完成后展示，点击新窗口打开压缩版） */
.mat-transcode-badge {
  position: absolute;
  right: 10px;
  top: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  background: rgba(74,222,128,0.9);
  color: #04210f;
  z-index: 2;
  text-decoration: none;
  letter-spacing: 0.3px;
}
.mat-transcode-badge:hover { background: var(--neon); }
.mat-duration {
  position: absolute;
  right: 10px;
  bottom: 44px; /* 给右下角播放图标让位 */
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(0,0,0,0.55);
  color: var(--text);
  z-index: 2;
}

/* hover 底部悬浮信息层：标题 + 标签 + 元信息 */
.mat-result-card .mat-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  padding: 36px 12px 12px 12px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.82) 55%);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
}
.mat-result-card:hover .mat-info { opacity: 1; transform: translateY(0); }
.mat-result-card .mat-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.mat-result-card .mat-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.mat-result-card .mat-tags span {
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.14);
  backdrop-filter: blur(4px);
  white-space: nowrap;
}
.mat-result-card .mat-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: rgba(255,255,255,0.75);
}

/* Popover 悬浮窗 / Hover Card（UI 组件库 design.html 同款，适配主应用） */
.ui-hover-card {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(6px);
  width: 200px;
  padding: 10px;
  border-radius: 12px;
  background: #101826;
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 16px 44px rgba(0,0,0,0.45);
  opacity: 0;
  visibility: hidden;
  transition: all .18s ease;
  z-index: 99999;
  text-align: left;
}
.ui-hover-card .ui-hover-media {
  height: 110px;
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--bg-elevated);
  overflow: hidden;
}
.ui-hover-card .ui-hover-media img,
.ui-hover-card .ui-hover-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.ui-hover-card .ui-hover-title {
  font-size: 11px;
  font-weight: 600;
  color: #e2e8f0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ui-hover-card .ui-hover-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ui-hover-card.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.ui-hover-card.ui-hover-follow {
  position: fixed;
  left: auto;
  bottom: auto;
  width: 200px;
  height: auto;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -100%);
  transition: opacity .18s ease, transform .18s cubic-bezier(.22,.61,.36,1), visibility .18s;
}
.ui-hover-card.ui-hover-follow.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, calc(-100% - 10px));
}

/* 我的素材库导入弹窗 */
.ui-import-modal { min-width: 360px; max-width: 440px; padding: 18px 20px; box-sizing: border-box; }
.ui-import-sub { font-size: 13px; color: var(--text-muted); margin: 0 0 10px; }
.ui-import-folders { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.ui-import-folder {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer;
  font-size: 12px; color: var(--text);
}
.ui-import-folder input { accent-color: var(--neon); }
.ui-import-folder:has(input:checked) { border-color: var(--neon); background: rgba(74,222,128,0.10); color: var(--neon-bright); }
.ui-import-modal .settings-input { margin-bottom: 10px; }
.ui-import-info { font-size: 12px; color: var(--text-muted); }
.ui-import-info b { color: var(--neon-bright); }

/* 批量下载弹窗 */
.ui-dl-modal { min-width: 380px; max-width: 480px; padding: 18px 20px; box-sizing: border-box; }
.ui-dl-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ui-dl-head h3 { margin: 0; font-size: 16px; }
.ui-dl-block { margin-bottom: 12px; }
.ui-dl-block h4 { font-size: 12px; color: var(--text-muted); margin: 0 0 6px; font-weight: 600; }
.ui-dl-methods { display: flex; flex-direction: column; gap: 6px; }
.ui-dl-method {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.ui-dl-method input { accent-color: var(--neon); flex-shrink: 0; }
.ui-dl-method span { display: flex; flex-direction: column; min-width: 0; }
.ui-dl-method b { font-size: 13px; color: var(--text); }
.ui-dl-method em { font-size: 11px; color: var(--text-muted); font-style: normal; }
.ui-dl-check { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--text); }
.ui-dl-check input { accent-color: var(--neon); }
.ui-dl-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ui-dl-actions .btn-ghost { font-size: 12px; padding: 5px 12px; }
.ui-dl-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.ui-dl-foot .btn-neon, .ui-dl-foot .btn-ghost { font-size: 12px; padding: 6px 14px; }

/* 侧栏“加入清单”操作按钮（标题行右侧） */
.mat-cart-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mat-cart-actions .btn-neon,
.mat-cart-actions .btn-ghost { font-size: 12px; padding: 5px 12px; white-space: nowrap; }
#matCartCountSide { white-space: nowrap; }
.mat-cart-actions .btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }

/* 侧栏“加入清单”缩略图列表 + 悬浮预览 */
.mat-cart-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.mat-cart-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface);
  flex-shrink: 0;
}
.mat-cart-thumb img,
.mat-cart-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.mat-cart-thumb-x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.62);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.mat-cart-thumb:hover .mat-cart-thumb-x { display: flex; }
.mat-cart-thumb-x:hover { background: #ef4444; }
.mat-cart-empty { font-size: 12px; color: var(--text-muted); padding: 8px 2px; }
.mat-cart-preview {
  position: fixed;
  z-index: 99999;
  display: none;
  width: 220px;
  max-height: 170px;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 16px 44px rgba(0,0,0,0.5);
  pointer-events: none;
}
.mat-cart-preview img,
.mat-cart-preview video { width: 100%; max-height: 170px; object-fit: contain; display: block; }

/* 无限滚动加载哨兵 */
.materials-load-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 0 26px;
  color: var(--text-muted);
  font-size: 12px;
}
.materials-load-more[hidden] { display: none; }
.materials-load-more-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(94,234,212,0.25);
  border-top-color: #5eead4;
  animation: matSpin .8s linear infinite;
}
@keyframes matSpin { to { transform: rotate(360deg); } }

/* ---------- Search Results ---------- */
.materials-results { animation: fadeIn .3s ease; }
.materials-results-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.materials-results-head h2 {
  flex: 1;
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}
.results-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}
.results-back:hover { background: var(--surface-hover); color: var(--text); }
.results-back svg { width: 16px; height: 16px; }
.results-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.results-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.results-filter-toggle:hover { background: var(--surface-hover); color: var(--text); }
.results-filter-toggle svg { width: 14px; height: 14px; }

.materials-results-grid {
  padding-bottom: 20px;
}

/* Compact view toggle */
.view-toggle.compact button { padding: 7px; }

/* ---------- History chips ---------- */
.materials-history-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.materials-history-chips .history-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.materials-history-chips .history-chip:hover { border-color: var(--neon); color: var(--neon-bright); }

/* ---------- Cart bar ---------- */
.materials-cart-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 16px;
  animation: slideUp .3s cubic-bezier(0.16,1,0.3,1) both;
}
.materials-cart-bar[hidden] { display: none; }
.materials-cart-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.materials-cart-count {
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--neon);
  color: #04210f;
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
}
.materials-cart-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.materials-cart-actions .btn-neon { display: inline-flex; align-items: center; gap: 6px; }
.materials-cart-actions .btn-neon svg { width: 14px; height: 14px; }

/* ---------- Filter panel slim ---------- */
.materials-filter-panel.slim .materials-filter-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------- Empty state ---------- */
.materials-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--text-muted); text-align: center; padding: 60px 20px; }
.materials-empty[hidden] { display: none; }
.materials-empty svg { width: 48px; height: 48px; opacity: .6; }
.materials-empty p { margin: 0; font-size: 15px; font-weight: 700; color: var(--text-dim); }
.materials-empty span { font-size: 12px; }

/* ---------- Animations ---------- */
@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .materials-hero-title { font-size: 32px; margin-top: 30px; }
  .materials-ai-tools { gap: 8px; margin-top: 22px; }
  .materials-mini-tool { padding: 6px 12px; font-size: 12px; }
  .materials-cat { padding: 6px 12px; font-size: 12px; }
  .materials-progress { width: 100%; }
  .materials-results-head { flex-wrap: wrap; }
  .materials-results-head h2 { width: 100%; order: 3; margin-top: 6px; }
  .materials-masonry,
  .materials-results-grid { column-count: 3; column-width: 200px; }
  .materials-cart-bar { left: 16px; right: 16px; transform: none; width: auto; }
}
@media (max-width: 560px) {
  .materials-hero-title { font-size: 26px; margin-top: 22px; }
  .materials-ai-composer { height: 132px; border-radius: 20px; }
  .materials-ai-composer textarea { padding: 12px 14px; font-size: 14px; }
  .materials-ai-toolbar { padding: 4px 8px; }
  .materials-ai-upload { width: 32px; height: 32px; }
  .materials-ai-submit { width: 34px; height: 34px; }
  .materials-ai-model { padding-left: 8px; }
  .materials-ai-model-label { display: none; }
  .materials-progress-label { display: none; }
  .materials-progress { justify-content: flex-end; }
  .materials-masonry,
  .materials-results-grid { column-count: 2; column-width: 150px; }
}

/* ---------- NAS 素材媒体处理状态占位 ---------- */
.mat-media-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.15);
}
.mat-media-badge.processing { color: #fbbf24; border-color: rgba(251,191,36,0.4); }
.mat-media-badge.error { color: #f87171; border-color: rgba(248,113,113,0.4); }
.mat-media-retry {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(248,113,113,0.5);
  background: rgba(248,113,113,0.15);
  color: #f87171;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.mat-media-retry:hover { background: rgba(248,113,113,0.3); }

/* ---------- 相似素材（感知哈希聚类） ---------- */
.mat-sim-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  color: #c4b5fd;
  background: rgba(30,27,45,0.72);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(167,139,250,0.45);
  cursor: pointer;
  transition: all .15s ease;
}
.mat-sim-badge:hover { color: #ede9fe; border-color: #a78bfa; background: rgba(76,29,149,0.55); }
.mat-sim-modal-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  margin: 12px 0;
}
.mat-sim-modal-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.mat-sim-modal-item.pinned { border-color: rgba(74,222,128,0.5); background: rgba(74,222,128,0.08); }
.mat-sim-modal-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex-shrink: 0; background: rgba(255,255,255,0.06); }
.mat-sim-thumb-empty { width: 56px; height: 56px; border-radius: 8px; background: rgba(255,255,255,0.06); flex-shrink: 0; }
.mat-sim-modal-name { flex: 1; min-width: 0; font-size: 12px; color: var(--text, #e5e7eb); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mat-sim-modal-name em { font-style: normal; color: #a78bfa; font-size: 11px; }
.mat-sim-modal-ops { flex-shrink: 0; }

/* ---------- 媒体查看器（灯箱） ---------- */
.mat-preview-zoom { cursor: zoom-in; }
.media-viewer-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.78); backdrop-filter: blur(8px);
  padding: 24px;
}
.media-viewer-box {
  max-width: min(1200px, 96vw); max-height: 94vh;
  width: auto; display: flex; flex-direction: column;
  background: var(--modal-bg, #16181d); border: 1px solid var(--modal-border, rgba(255,255,255,0.12));
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
}
.media-viewer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.media-viewer-title { font-size: 14px; font-weight: 700; color: var(--text, #e5e7eb); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-viewer-stage {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  background: #000; overflow: hidden;
}
.media-viewer-stage img { max-width: 100%; max-height: calc(94vh - 110px); object-fit: contain; }
.media-viewer-stage video { width: 100%; max-height: calc(94vh - 110px); object-fit: contain; background: #000; }
.media-viewer-meta {
  padding: 10px 16px; font-size: 12px; color: var(--text-muted, #94a3b8);
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* 批量下载：百度网盘分发（进度 / 结果 / 错误） */
.ui-bd-progress-modal { min-width: 400px; max-width: 520px; padding: 18px 20px; box-sizing: border-box; }
.ui-bd-bar {
  height: 10px; border-radius: 999px; background: rgba(128,128,128,0.18);
  overflow: hidden; margin-bottom: 10px; border: 1px solid var(--border);
}
.ui-bd-bar-inner {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--neon), var(--neon-bright, #4ade80));
  transition: width 0.4s ease;
}
.ui-bd-meta { font-size: 12px; color: var(--text); margin-bottom: 6px; }
.ui-bd-current { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-bd-done { text-align: center; }
.ui-bd-done-icon {
  width: 46px; height: 46px; margin: 6px auto 10px; border-radius: 50%;
  background: rgba(74,222,128,0.15); color: #4ade80; border: 1px solid rgba(74,222,128,0.4);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.ui-bd-done-title { font-size: 13px; color: var(--text); margin-bottom: 12px; font-weight: 600; }
.ui-bd-link-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.ui-bd-link-row span, .ui-bd-meta-row span { font-size: 12px; color: var(--text-muted); flex-shrink: 0; width: 52px; text-align: left; }
.ui-bd-link-row input { flex: 1; min-width: 0; font-size: 12px; }
.ui-bd-link-row .btn-ghost { font-size: 12px; padding: 5px 12px; white-space: nowrap; }
.ui-bd-meta-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; }
.ui-bd-meta-row b { color: var(--neon-bright); letter-spacing: 1px; }
.ui-bd-error {
  padding: 10px 12px; border-radius: 8px; background: rgba(248,113,113,0.08);
  border: 1px solid rgba(248,113,113,0.35); color: #f87171; font-size: 12px; margin-bottom: 10px;
  word-break: break-all; max-height: 140px; overflow: auto;
}
.ui-bd-hint { font-size: 11px; color: var(--text-muted); line-height: 1.6; }
