/* ==========================================================================
   AI Chat 交互界面样式
   布局参考 liblib.art 图片生成器：上方对话记录，底部居中输入窗体
   ========================================================================== */

.ai-chat-page {
  --chat-primary: #0044ff;
  --chat-primary-soft: #e9f0ff;
  --chat-ink: #0f2033;
  --chat-muted: #64748b;
  --chat-border: #e2e8f0;
  --chat-bubble-user: #0044ff;
  --chat-bubble-bot: #f4f6fb;
  position: relative;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 72px);
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ── 对话记录区 ── */
.ai-chat-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.25rem 0.25rem 1rem;
  /* 历史上滑 prepend 时必须用 auto；关闭 overflow-anchor，避免与手动保位互相抢滚动 */
  scroll-behavior: auto;
  overflow-anchor: none;
  /* 隐藏滚动条（保留滚动能力）：对话记录区不展示多余滚动条 */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.ai-chat-scroll::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.ai-chat-page.has-history-tools .ai-chat-scroll {
  padding-top: 3.1rem;
}

.ai-chat-load-more {
  position: sticky;
  top: 0.55rem;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  margin: 0.15rem 0 -28px;
  padding: 0;
  pointer-events: none;
  overflow-anchor: none;
}

.ai-chat-load-more[hidden] {
  display: none !important;
}

.ai-chat-load-more-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #d7e0ee;
  border-top-color: var(--chat-primary);
  border-radius: 50%;
  animation: ai-chat-spin 0.7s linear infinite;
  flex: 0 0 auto;
}

.ai-chat-history-tools {
  position: absolute;
  top: 0.7rem;
  right: 1.15rem;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  pointer-events: auto;
}

.ai-chat-history-tools[hidden] {
  display: none !important;
}

.ai-chat-history-search {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  width: 34px;
  height: 34px;
  overflow: hidden;
  border: 1px solid var(--chat-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 4px 14px rgba(15, 32, 51, 0.08);
  backdrop-filter: blur(8px);
  transition: width 0.2s ease;
}

.ai-chat-history-search:hover,
.ai-chat-history-search.is-open {
  width: 198px;
}

.ai-chat-history-search-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  padding: 0;
  font-size: 0.78rem;
  color: var(--chat-ink);
  opacity: 0;
  pointer-events: none;
}

.ai-chat-history-search:hover .ai-chat-history-search-input,
.ai-chat-history-search.is-open .ai-chat-history-search-input {
  padding: 0 0 0 0.85rem;
  opacity: 1;
  pointer-events: auto;
}

.ai-chat-history-search-clear {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-right: 0.1rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--chat-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.ai-chat-history-search-clear:hover {
  color: var(--chat-ink);
  background: #eef2f7;
}

.ai-chat-history-search-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: #475569;
  cursor: pointer;
}

.ai-chat-history-search-btn svg {
  width: 15px;
  height: 15px;
}

.ai-chat-history-type {
  height: 34px;
  max-width: 7.6rem;
  padding: 0 1.6rem 0 0.7rem;
  border: 1px solid var(--chat-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E") no-repeat right 0.55rem center;
  box-shadow: 0 4px 14px rgba(15, 32, 51, 0.08);
  backdrop-filter: blur(8px);
  color: var(--chat-ink);
  font-size: 0.75rem;
  appearance: none;
  cursor: pointer;
}

.ai-chat-history-type:focus {
  outline: none;
  border-color: #93b4ff;
}

@media (max-width: 640px) {
  .ai-chat-history-search:hover,
  .ai-chat-history-search.is-open {
    width: 154px;
  }

  .ai-chat-history-type {
    max-width: 6.4rem;
    font-size: 0.7rem;
  }
}

@keyframes ai-chat-spin {
  to { transform: rotate(360deg); }
}

/* 空状态欢迎区 */
.ai-chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3.5rem 1rem 2rem;
  color: var(--chat-ink);
}

.ai-chat-empty-icon {
  font-size: 2rem;
  color: var(--chat-primary);
  margin-bottom: 0.75rem;
}

.ai-chat-empty h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.ai-chat-empty p {
  color: var(--chat-muted);
  max-width: 520px;
  line-height: 1.8;
}

.ai-chat-empty-tips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.ai-chat-tip {
  border: 1px solid var(--chat-border);
  background: #fff;
  color: var(--chat-ink);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.ai-chat-tip:hover {
  border-color: var(--chat-primary);
  color: var(--chat-primary);
  background: var(--chat-primary-soft);
}

/* ── 消息列表 ── */
.ai-chat-list {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  overflow-anchor: none;
}

.ai-chat-item {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overflow-anchor: none;
}

.ai-chat-row {
  display: flex;
  gap: 0.6rem;
}

.ai-chat-row.is-user {
  justify-content: flex-end;
}

.ai-chat-bubble {
  max-width: 78%;
  border-radius: 16px;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-chat-row.is-user .ai-chat-bubble {
  background: var(--chat-bubble-user);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.ai-chat-row.is-bot .ai-chat-bubble {
  background: var(--chat-bubble-bot);
  color: var(--chat-ink);
  border-bottom-left-radius: 6px;
}

.ai-chat-bubble.is-error {
  background: #fef2f2;
  color: #b91c1c;
}

/* 气泡内元信息（模式/模型标签、时间） */
.ai-chat-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--chat-muted);
  margin-top: 0.3rem;
}

.ai-chat-row.is-user .ai-chat-meta,
.ai-chat-meta.is-end {
  justify-content: flex-end;
}

.ai-chat-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.05rem 0.55rem;
  background: var(--chat-primary-soft);
  color: var(--chat-primary);
  font-size: 0.72rem;
}

/* 请求附件缩略图 / 回复媒体 */
.ai-chat-bubble-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.ai-chat-bubble-images img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 10px;
  cursor: zoom-in;
}

.ai-chat-assets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.ai-chat-assets img {
  height: 182px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  border-radius: 12px;
  cursor: zoom-in;
  background: #e5e9f2;
}

.ai-chat-assets video {
  height: 182px;
  width: auto;
  max-width: 100%;
  border-radius: 12px;
  background: #000;
}

/* 对话列表视频：隐藏原生底部控件，悬停预览 + 角标操作 */
.ai-chat-video {
  position: relative;
  margin: 0;
  display: inline-block;
  max-width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  cursor: pointer;
  line-height: 0;
}

.ai-chat-video video {
  display: block;
  height: 182px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  background: #000;
  pointer-events: none;
}

.ai-chat-video-chrome {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 1;
}

.ai-chat-video-duration {
  color: rgba(255, 255, 255, 0.95);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}

.ai-chat-video-duration[hidden] {
  display: none !important;
}

.ai-chat-video-play {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(15, 23, 42, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(2px);
  flex-shrink: 0;
  box-sizing: border-box;
  padding: 0;
  line-height: 0;
  overflow: hidden;
}

.ai-chat-video-play svg {
  width: 14px;
  height: 14px;
  display: block;
}

.ai-chat-video:hover .ai-chat-video-chrome,
.ai-chat-video.is-playing .ai-chat-video-chrome {
  opacity: 0;
}

.ai-chat-video-btn {
  position: absolute;
  bottom: 8px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(15, 23, 42, 0.55);
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  cursor: pointer;
  padding: 0;
  z-index: 2;
}

.ai-chat-video-btn svg {
  width: 15px;
  height: 15px;
}

.ai-chat-video-btn:hover {
  background: rgba(15, 23, 42, 0.78);
}

.ai-chat-video-dl {
  left: 8px;
}

.ai-chat-video-fs {
  right: 8px;
}

.ai-chat-video:hover .ai-chat-video-btn {
  opacity: 1;
}

.ai-chat-video-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-video-lightbox[hidden] {
  display: none !important;
}

.ai-chat-video-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(4px);
}

.ai-chat-video-lightbox-body {
  position: relative;
  width: min(92vw, 56rem);
  height: min(88vh, 36rem);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.45);
  background: #000;
  z-index: 1;
}

.ai-chat-video-lightbox-player {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

.ai-chat-video-lightbox-actions {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  z-index: 2;
}

.ai-chat-video-lightbox-btn {
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.ai-chat-video-lightbox-btn svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

.ai-chat-video-lightbox-btn:hover {
  background: rgba(37, 99, 235, 0.85);
}

.ai-chat-video-lightbox-lock {
  overflow: hidden;
}

.ai-chat-video-lightbox-body > .ai-gen-mark {
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  line-height: 1;
  padding: 0.22em;
}

.ai-chat-asset {
  position: relative;
  margin: 0;
  cursor: zoom-in;
}

.ai-chat-asset img {
  display: block;
}

.ai-chat-asset-view {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(15, 32, 51, 0.55);
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.ai-chat-asset-view svg {
  width: 16px;
  height: 16px;
}

.ai-chat-asset:hover .ai-chat-asset-view {
  opacity: 1;
}

/* 生成中占位框：按请求规格提前展示尺寸与数量（小尺寸骨架，保证一页可见更多内容） */
.ai-chat-ph-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.ai-chat-ph {
  position: relative;
  height: 182px;
  width: auto;
  flex: 0 0 auto;
  max-width: 100%;
  border-radius: 10px;
  background: linear-gradient(110deg, #eef1f6 30%, #f7f9fc 50%, #eef1f6 70%);
  background-size: 200% 100%;
  animation: aiChatPhShimmer 1.6s linear infinite;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  color: var(--chat-muted);
}

.ai-chat-ph.is-video {
  height: 182px;
}

.ai-chat-ph .ai-chat-load-more-spinner {
  border-top-color: var(--chat-primary);
}

.ai-chat-ph-label {
  font-size: 0.7rem;
}

@keyframes aiChatPhShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 生成中占位 */
.ai-chat-pending {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--chat-muted);
}

.ai-chat-pending .ai-chat-load-more-spinner {
  border-top-color: var(--chat-primary);
}

/* 记录底部操作行：重新编辑 / 重新生成 / 删除 */
.ai-chat-item-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: -0.2rem;
}

.ai-chat-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.ai-chat-action-btn svg {
  width: 15px;
  height: 15px;
}

.ai-chat-action-btn:hover {
  background: var(--chat-primary-soft);
  color: var(--chat-primary);
}

.ai-chat-action-btn[data-chat-action="delete"]:hover {
  background: #fef2f2;
  color: #dc2626;
}

/* 删除确认时高亮整组对话（请求+回复）范围：平台主题蓝色描边 + 淺蓝底色凸显区分，小偏移避免被滚动容器左右裁切 */
.ai-chat-item.is-delete-target {
  outline: 2px solid var(--chat-primary);
  outline-offset: 2px;
  border-radius: 12px;
  background: var(--chat-primary-soft);
  box-shadow: 0 0 0 4px rgba(0, 68, 255, 0.08);
}

/* ── 输入窗体（底部居中） ── */
.ai-chat-composer-wrap {
  flex: 0 0 auto;
  padding: 0.5rem 0 0.75rem;
  position: relative;
  z-index: 20;
}

.ai-chat-composer {
  position: relative;
  border: 1px solid var(--chat-border);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 32px rgba(15, 32, 51, 0.08);
  padding: 0.75rem 0.9rem 0.65rem;
}

.ai-chat-composer:focus-within {
  border-color: var(--chat-primary);
}

/* 左上角模式列表 + 右上角灵感入口 */
.ai-chat-modes-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.ai-chat-modes {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0;
}

.ai-chat-mode {
  border: 1px solid transparent;
  background: #f1f5f9;
  color: var(--chat-muted);
  border-radius: 999px;
  padding: 0.28rem 0.85rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.ai-chat-mode.is-active {
  background: var(--chat-primary);
  color: #fff;
}

/* 与通用「灵感助手」按钮同源：ty-star 图标 +「灵感」文案 */
.ai-chat-inspire-btn {
  display: inline-flex;
  align-items: center;
  border: none;
  background-color: transparent;
  background-image: url('https://hx-ai-storage.oss-cn-shenzhen.aliyuncs.com/res/assets/ty-star.png');
  background-repeat: no-repeat;
  background-position: 6px center;
  background-size: 20px 19px;
  color: #2563eb;
  border-radius: 6px;
  padding: 0.2rem 0.55rem 0.2rem 1.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s;
}

.ai-chat-inspire-btn:hover,
.ai-chat-inspire-btn.is-active {
  background-color: #eff6ff;
  color: #2563eb;
}

.ai-chat-inspire-panel {
  position: absolute;
  left: 0.65rem;
  right: 0.65rem;
  bottom: calc(100% + 0.45rem);
  z-index: 30;
  max-height: min(64vh, 600px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(15, 32, 51, 0.16);
}

.ai-chat-inspire-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.28);
}

.ai-chat-inspire-close {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 1.25rem;
  line-height: 1;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 8px;
  cursor: pointer;
}

.ai-chat-inspire-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.ai-chat-inspire-masonry {
  flex: 1 1 auto;
  min-height: 0;
  column-count: 5;
  column-gap: 0.45rem;
  column-fill: balance;
  padding: 0.55rem;
  overflow: auto;
}

/* 加载中 / 空态：关掉分栏，避免先露出空卡片边框栅格 */
.ai-chat-inspire-masonry.is-pending,
.ai-chat-inspire-masonry.is-empty {
  display: block;
  column-count: 1;
  column-gap: 0;
}

.ai-chat-inspire-card {
  display: inline-block;
  width: 100%;
  break-inside: avoid;
  margin-bottom: 0.45rem;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.28);
  cursor: pointer;
  background: #f8fafc;
}

/* 媒体未就绪前不显示边框/底，避免预置空卡片栅格 */
.ai-chat-inspire-card:not(.is-ready) {
  border-color: transparent;
  background: transparent;
}

.ai-chat-inspire-card:not(.is-ready) .ai-chat-inspire-overlay,
.ai-chat-inspire-card:not(.is-ready) .ai-chat-inspire-cat {
  opacity: 0;
}

.ai-chat-inspire-card:not(.is-ready) img,
.ai-chat-inspire-card:not(.is-ready) video {
  opacity: 0;
  background: transparent;
}

.ai-chat-inspire-card:hover {
  border-color: var(--chat-primary);
}

.ai-chat-inspire-card:not(.is-ready):hover {
  border-color: transparent;
}

.ai-chat-inspire-cover {
  position: relative;
  display: block;
}

.ai-chat-inspire-cover img,
.ai-chat-inspire-cover video {
  width: 100%;
  display: block;
  vertical-align: top;
  background: #e2e8f0;
}

.ai-chat-inspire-cover video {
  width: 100%;
  height: auto;
  object-fit: contain;
  pointer-events: none;
}

.ai-chat-inspire-card:not(.is-ready) .ai-chat-inspire-cover img,
.ai-chat-inspire-card:not(.is-ready) .ai-chat-inspire-cover video {
  opacity: 0;
  background: transparent;
}

.ai-chat-inspire-card:not(.is-ready) .ai-chat-inspire-cover-empty {
  display: none;
}

.ai-chat-inspire-cover-empty {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 0.7rem;
}

.ai-chat-inspire-cat {
  position: absolute;
  top: 0.28rem;
  left: 0.28rem;
  padding: 0.08rem 0.35rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.62);
  color: #fff;
  font-size: 0.58rem;
}

.ai-chat-inspire-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1rem 0.4rem 0.35rem;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.78), transparent);
  color: #fff;
}

.ai-chat-inspire-overlay h3 {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.25;
}

.ai-chat-inspire-empty {
  column-span: all;
  text-align: center;
  color: #94a3b8;
  padding: 1.5rem 0.5rem;
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .ai-chat-inspire-masonry {
    column-count: 4;
  }
}

@media (max-width: 720px) {
  .ai-chat-inspire-masonry {
    column-count: 3;
  }

  .ai-chat-inspire-panel {
    max-height: min(60vh, 560px);
  }
}

/* 附件预览 */
.ai-chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.ai-chat-attachment {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--chat-border);
  background: #f8fafc;
}

.ai-chat-attachment img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-chat-attachment-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 0.62rem;
  color: var(--chat-muted);
  padding: 0.2rem;
  text-align: center;
  word-break: break-all;
  overflow: hidden;
}

.ai-chat-attachment-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 32, 51, 0.65);
  color: #fff;
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
}

/* 文本输入框 */
.ai-chat-input {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--chat-ink);
  background: transparent;
  max-height: 180px;
}

.ai-chat-input::placeholder {
  color: #9aa7b8;
}

/* 底部工具行 */
.ai-chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.4rem;
}

.ai-chat-toolbar-left,
.ai-chat-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.ai-chat-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--chat-border);
  background: #fff;
  color: var(--chat-muted);
  border-radius: 10px;
  padding: 0.35rem 0.55rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.ai-chat-tool-btn:hover {
  border-color: var(--chat-primary);
  color: var(--chat-primary);
}

.ai-chat-tool-btn svg {
  width: 17px;
  height: 17px;
}

/* 规格按钮：展示当前比例 + 数量/时长预览 */
.ai-chat-spec-btn {
  gap: 0.35rem;
  min-width: 0;
}

.ai-chat-spec-preview {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--chat-ink);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.ai-chat-spec-preview-sep {
  color: var(--chat-muted);
  font-weight: 500;
}

/* 模型选择下拉 */
.ai-chat-model-picker {
  position: relative;
}

.ai-chat-model-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--chat-border);
  background: #fff;
  color: var(--chat-ink);
  border-radius: 10px;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
  max-width: 260px;
}

.ai-chat-model-trigger:hover {
  border-color: var(--chat-primary);
}

.ai-chat-model-trigger #chatModelName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-chat-caret {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
}

.ai-chat-model-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 280px;
  max-width: 360px;
  max-height: 360px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(15, 32, 51, 0.14);
  padding: 0.4rem;
  z-index: 30;
}

.ai-chat-model-filter-wrap {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.15rem 0.15rem 0.4rem;
  background: #fff;
}

.ai-chat-model-filter {
  width: 100%;
  border: 1px solid var(--chat-border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  color: var(--chat-ink);
  outline: none;
  background: #f8fafc;
}

.ai-chat-model-filter:focus {
  border-color: var(--chat-primary);
  background: #fff;
}

.ai-chat-model-empty {
  padding: 0.75rem 0.6rem;
  font-size: 0.8rem;
  color: var(--chat-muted);
  text-align: center;
}

.ai-chat-model-group {
  font-size: 0.72rem;
  color: var(--chat-muted);
  padding: 0.4rem 0.6rem 0.2rem;
}

.ai-chat-model-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  color: var(--chat-ink);
  text-align: left;
  cursor: pointer;
}

.ai-chat-model-option:hover {
  background: var(--chat-primary-soft);
}

.ai-chat-model-option.is-selected {
  color: var(--chat-primary);
}

.ai-chat-model-option.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ai-chat-model-option.is-disabled:hover {
  background: transparent;
}

.ai-chat-model-ico {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #f2f5f9;
  color: var(--chat-muted);
}

.ai-chat-model-option.is-selected .ai-chat-model-ico {
  background: var(--chat-primary-soft);
  color: var(--chat-primary);
}

.ai-chat-model-ico svg {
  width: 16px;
  height: 16px;
}

.ai-chat-model-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  flex: 1 1 auto;
}

.ai-chat-model-text strong {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-chat-model-text small {
  font-size: 0.72rem;
  color: var(--chat-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-chat-model-cost {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin-left: auto;
  color: var(--chat-muted);
  font-size: 0.78rem;
}

.ai-chat-model-cost strong {
  font-weight: 600;
  color: var(--chat-ink);
  font-variant-numeric: tabular-nums;
}

.ai-chat-model-cost-ico {
  width: 12px;
  height: 12px;
}

.ai-chat-coin-badge {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

/* 预计消耗（内嵌在生成按钮内部，仅登录后展示） */
.ai-chat-estimate {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  color: #fff;
  font-size: 0.88rem;
}

.ai-chat-estimate img {
  width: 16px;
  height: 16px;
}

/* 登录态切换：未登录隐藏预计消耗并显示“生成”文字；登录后反之 */
.ai-chat-composer.is-guest .ai-chat-estimate {
  display: none;
}

.ai-chat-composer:not(.is-guest) .ai-chat-send-text {
  display: none;
}

/* 生成发送按钮（胶囊：左侧预计消耗/文字 + 右侧向上箭头圆片） */
.ai-chat-send-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #0044ff, #0576ff);
  color: #fff;
  padding: 0.32rem 0.38rem 0.32rem 0.95rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}

.ai-chat-send-btn:hover {
  transform: translateY(-1px);
}

.ai-chat-send-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.ai-chat-send-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  flex: 0 0 auto;
}

.ai-chat-send-icon {
  width: 15px;
  height: 15px;
}

/* 规格配置弹层（贴靠规格按钮上方，与模型菜单同款定位） */
.ai-chat-spec-picker {
  position: relative;
  display: inline-flex;
}

.ai-chat-spec-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: min(400px, calc(100vw - 2rem));
  background: #fff;
  border: 1px solid var(--chat-border);
  border-radius: 14px;
  box-shadow: 0 14px 40px rgba(15, 32, 51, 0.16);
  padding: 1rem 1.1rem;
  z-index: 40;
}

.ai-chat-spec-panel[hidden] {
  display: none;
}

.ai-chat-spec-group {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.ai-chat-spec-group[hidden] {
  display: none;
}

.ai-chat-spec-block {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.ai-chat-spec-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--chat-ink);
}

/* 分段按钮组：浅灰容器 + 选中项白底浮起；项过多时自动换行 */
.ai-chat-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  background: #f2f4f7;
  border-radius: 10px;
  padding: 0.25rem;
}

.ai-chat-seg-item {
  flex: 1 1 auto;
  min-width: 4.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
  color: var(--chat-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
  white-space: nowrap;
}

.ai-chat-seg-item:hover {
  color: var(--chat-ink);
}

.ai-chat-seg-item.is-active {
  background: #fff;
  color: var(--chat-ink);
  font-weight: 600;
  border-color: var(--chat-border);
  box-shadow: 0 1px 4px rgba(15, 32, 51, 0.08);
}

.ai-chat-seg-item.is-disabled,
.ai-chat-seg-item:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  color: var(--chat-muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.ai-chat-seg-item.is-disabled:hover,
.ai-chat-seg-item:disabled:hover {
  color: var(--chat-muted);
}

/* 尺寸宫格：多行排列 + 比例形状图标 */
.ai-chat-seg--grid {
  flex-wrap: wrap;
}

.ai-chat-seg--grid .ai-chat-seg-item {
  flex: 0 0 calc(25% - 0.2rem);
  min-width: 0;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.42rem 0.3rem;
  font-size: 0.74rem;
}

.ai-chat-seg--wrap .ai-chat-seg-item {
  flex: 1 1 calc(33.333% - 0.2rem);
  min-width: 5.2rem;
}

.ai-chat-ratio-ico {
  display: inline-block;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  opacity: 0.75;
}

.ai-chat-seg-item.is-active .ai-chat-ratio-ico {
  opacity: 1;
}

/* 视频时长滚动轴：2–20，吸附模型支持尺度 */
.ai-chat-duration-slider {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.55rem 0.65rem 0.5rem;
  background: #f2f4f7;
  border-radius: 10px;
}

.ai-chat-duration-slider-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.ai-chat-duration-slider-head strong {
  font-size: 0.92rem;
  color: var(--chat-ink);
  font-variant-numeric: tabular-nums;
}

.ai-chat-duration-slider-hint {
  font-size: 0.7rem;
  color: var(--chat-muted);
}

.ai-chat-duration-range {
  width: 100%;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #c9d4e8, #0044ff);
  outline: none;
  cursor: pointer;
}

.ai-chat-duration-range::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #0044ff;
  box-shadow: 0 1px 4px rgba(15, 32, 51, 0.2);
  cursor: pointer;
}

.ai-chat-duration-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #0044ff;
  box-shadow: 0 1px 4px rgba(15, 32, 51, 0.2);
  cursor: pointer;
}

.ai-chat-duration-slider-scale {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  color: var(--chat-muted);
}

.ai-chat-duration-ticks {
  position: relative;
  flex: 1 1 auto;
  height: 8px;
}

.ai-chat-duration-tick {
  position: absolute;
  top: 1px;
  width: 2px;
  height: 6px;
  margin-left: -1px;
  background: #b7c2d3;
  border-radius: 1px;
}

.ai-chat-duration-tick.is-active {
  background: #0044ff;
  height: 8px;
  top: 0;
}

.ai-chat-spec-field {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--chat-muted);
}

/* 视频首帧/尾帧上传（工具栏规格按钮右侧，仅视频模式展示，非必选） */
.ai-chat-frames {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.ai-chat-frames[hidden] {
  display: none;
}

.ai-chat-frame-slot {
  position: relative;
  display: inline-flex;
}

.ai-chat-frame-slot img {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--chat-border);
}

.ai-chat-frame-add {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  border: 1px dashed var(--chat-border);
  background: #fff;
  color: var(--chat-muted);
  border-radius: 10px;
  padding: 0.32rem 0.55rem;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

.ai-chat-frame-add span {
  font-size: 0.92rem;
  line-height: 1;
}

.ai-chat-frame-add:hover {
  border-color: var(--chat-primary);
  color: var(--chat-primary);
}

.ai-chat-frame-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 32, 51, 0.65);
  color: #fff;
  font-size: 0.66rem;
  line-height: 1;
  cursor: pointer;
}

/* 底部说明 */
.ai-chat-footnote {
  text-align: center;
  color: #9aa7b8;
  font-size: 0.76rem;
  margin: 0.55rem 0 0;
}

.ai-chat-footnote a {
  color: var(--chat-muted);
}

/* ── 响应式 ── */
@media (max-width: 768px) {
  .ai-chat-page {
    height: calc(100vh - 60px);
    padding: 0 0.6rem;
  }

  .ai-chat-bubble {
    max-width: 88%;
  }

  .ai-chat-assets img {
    height: 151px;
    width: auto;
  }

  .ai-chat-assets video {
    height: 151px;
    width: auto;
  }

  .ai-chat-ph {
    height: 151px;
  }

  .ai-chat-ph.is-video {
    height: 151px;
  }

  /* 工具行换行：左侧控件一行，生成按钮独占整行避免显示不全 */
  .ai-chat-toolbar {
    flex-wrap: wrap;
    align-items: stretch;
    row-gap: 0.55rem;
  }

  .ai-chat-toolbar-left {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
  }

  .ai-chat-toolbar-right {
    flex: 1 1 100%;
    width: 100%;
  }

  .ai-chat-send-btn {
    width: 100%;
    justify-content: center;
    padding-left: 1rem;
    padding-right: 0.45rem;
  }

  .ai-chat-spec-preview {
    font-size: 0.72rem;
  }

  /* 移动端：模型 / 规格改为底部全宽弹层，避免桌面 absolute 弹层显示不全 */
  .ai-chat-mobile-sheet {
    position: fixed;
    inset: 0;
    z-index: 11050;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease;
  }

  .ai-chat-mobile-sheet.is-open {
    pointer-events: auto;
    opacity: 1;
  }

  .ai-chat-mobile-sheet-scrim {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
  }

  .ai-chat-mobile-sheet-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-height: min(78vh, 640px);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 36px rgba(15, 23, 42, 0.18);
    transform: translateY(12px);
    transition: transform 0.2s ease;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .ai-chat-mobile-sheet.is-open .ai-chat-mobile-sheet-panel {
    transform: translateY(0);
  }

  .ai-chat-mobile-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 1rem 0.65rem;
    border-bottom: 1px solid var(--chat-border);
  }

  .ai-chat-mobile-sheet-header strong {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--chat-ink);
  }

  .ai-chat-mobile-sheet-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
  }

  .ai-chat-mobile-sheet-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.55rem 0.75rem 1rem;
  }

  .ai-chat-model-menu.is-mobile-sheet-content,
  .ai-chat-spec-panel.is-mobile-sheet-content {
    position: static !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    top: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    max-height: none !important;
    overflow: visible !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: transparent !important;
  }

  .ai-chat-model-menu.is-mobile-sheet-content .ai-chat-model-filter-wrap {
    position: sticky;
    top: 0;
  }
}
