/* ============================================================
   创作工作台 v2（即梦式）：左侧会话 + 中央作品画布 + 底部创作面板
   依赖 styles.css 设计变量（--border、--surface-2、--brand 等）。
   ============================================================ */

.icon-button.mobile-nav-toggle {
  display: none;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 21px;
  line-height: 1;
}
.mobile-nav-toggle span {
  display: block;
  transform: translateY(-1px);
}

#chatPanel {
  height: calc(100vh - 96px);
  min-height: 560px;
}

.chat-workspace {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #f4f5f7;
}

/* ------------------------------------------------------------
   左侧会话栏
   ------------------------------------------------------------ */

.chat-history {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: #fbfcfd;
}

.chat-history-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border);
}

.chat-history-head .eyebrow,
.chat-history-head h2 {
  margin: 0;
}

.chat-history-head h2 {
  font-size: 17px;
}

.chat-new-button {
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 14px;
  border: 1px solid var(--brand);
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.chat-new-button:hover {
  background: var(--brand-hover);
}

.chat-conversation-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.chat-conversation-item {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
  padding: 10px 11px;
  margin: 0 0 4px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.chat-conversation-item:hover {
  background: var(--surface-3);
}

.chat-conversation-item.active {
  border-color: var(--border);
  background: #fff;
}

.chat-conversation-item strong,
.chat-conversation-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-conversation-item strong {
  grid-column: 1 / -1;
  font-size: 13px;
  font-weight: 600;
}

.chat-conversation-item span {
  color: var(--text-muted);
  font-size: 11.5px;
}

.chat-conversation-item time {
  color: var(--text-faint);
  font-size: 10.5px;
  white-space: nowrap;
}

.chat-conversation-empty {
  padding: 30px 12px;
  color: var(--text-faint);
  font-size: 12.5px;
  text-align: center;
}

/* ------------------------------------------------------------
   中央画布
   ------------------------------------------------------------ */

.chat-canvas {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #f4f5f7;
}

.chat-canvas-head {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.chat-canvas-titles {
  min-width: 0;
  flex: 1;
}

.chat-canvas-head h2,
.chat-canvas-head p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-canvas-head h2 {
  font-size: 15.5px;
}

.chat-canvas-head p {
  margin-top: 1px;
  color: var(--text-muted);
  font-size: 11.5px;
}

.chat-history-toggle {
  display: none;
  flex: 0 0 auto;
  height: 32px;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.chat-history-toggle svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.chat-delete-button {
  flex: 0 0 auto;
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--danger);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.chat-delete-button:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.chat-delete-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-canvas-stream {
  min-height: 0;
  overflow: auto;
  padding: 22px max(20px, calc((100% - 860px) / 2)) 18px;
  scroll-behavior: auto;
}

/* 空状态 */

.chat-empty-state {
  min-height: min(430px, 100%);
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  color: var(--text-muted);
  text-align: center;
  min-width: 0;
  padding: 20px 0;
}

.chat-empty-state h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 24px;
  letter-spacing: 0.5px;
}

.chat-empty-state p {
  max-width: 470px;
  margin: 0 0 26px;
  font-size: 13px;
  line-height: 1.75;
}

.chat-empty-state code {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
}

.chat-start-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.chat-start-card {
  width: 156px;
  display: grid;
  justify-items: start;
  gap: 7px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.chat-start-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}

.chat-start-card strong {
  font-size: 13.5px;
}

.chat-start-card > span:last-child {
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.chat-kind-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.chat-kind-icon[data-kind="image"] { background: #EEF2FF; color: #4338CA; }
.chat-kind-icon[data-kind="video"] { background: #FEF3E8; color: #C2570B; }
.chat-kind-icon[data-kind="text"]  { background: #ECFDF5; color: #0F766E; }

/* 作品卡（生成的图片 / 视频） */

.art-card {
  width: 100%;
  margin: 0 0 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.art-media {
  padding: 10px;
}

.chat-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.chat-result-card {
  position: relative;
  margin: 0;
  min-width: 0;
}

.chat-result-image {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--surface-2);
  cursor: zoom-in;
  overflow: hidden;
}

.chat-result-image img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 360px;
  object-fit: contain;
  border-radius: 12px;
}

.chat-result-image:hover img {
  filter: brightness(0.97);
}

.chat-result-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin: 0;
}

.chat-result-actions-static {
  position: static;
  justify-content: flex-start;
  padding: 0 2px;
}

.chat-result-action {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.94);
  color: #334155;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(8px);
  text-decoration: none;
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
}

.chat-result-action svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-result-action:hover {
  border-color: #cbd5e1;
  background: #fff;
  color: #0f172a;
}

.chat-result-video-card {
  margin: 0;
}

/* 视频播放器：frame 负责圆角裁剪与加载占位，video 自适应原始宽高避免大黑边。 */
.chat-result-video-frame {
  position: relative;
  width: fit-content;
  max-width: 100%;
  min-width: min(320px, 100%);
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(100deg, #171a20 40%, #232732 50%, #171a20 60%);
  background-size: 200% 100%;
  animation: art-shimmer 1.6s linear infinite;
}

.chat-result-video-frame.ready {
  animation: none;
}

.chat-result-video {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 420px;
  margin: 0;
  background: transparent;
}

.chat-video-fallback {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  padding: 20px;
  text-align: center;
  background: #12151b;
  color: #dbe2ea;
}

.chat-video-fallback-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
}

.chat-video-fallback-hint {
  margin: 0;
  max-width: 340px;
  color: #98a2b3;
  font-size: 11.5px;
  line-height: 1.6;
}

.chat-video-fallback-download {
  margin-top: 6px;
  padding: 7px 16px;
  border: 1px solid #3a4250;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  text-decoration: none;
}

.chat-video-fallback-download:hover {
  background: #232732;
}

.chat-result-error {
  padding: 12px;
  border-radius: 12px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 12px;
}

.art-media-loading {
  display: grid;
  gap: 10px;
  padding: 6px 4px 2px;
}

.art-media-loading p {
  margin: 4px 0 0;
  color: var(--text-faint);
  font-size: 12px;
}

.art-skeleton {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 220px;
  border-radius: 12px;
  background: linear-gradient(100deg, #eceef1 40%, #f7f8fa 50%, #eceef1 60%);
  background-size: 200% 100%;
  animation: art-shimmer 1.4s linear infinite;
}

.art-media-loading {
  align-content: start;
}

@keyframes art-shimmer {
  to { background-position: -200% 0; }
}

.art-info {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--surface-3);
}

.art-card-failed .art-info {
  display: grid;
  gap: 6px;
}

.art-card-failed .art-meta {
  order: 0;
}

.art-card-failed .chat-message-refs {
  order: 1;
  margin-top: 0;
}

.art-card-failed .art-prompt {
  order: 2;
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.art-card-failed .chat-message-error {
  order: 3;
  margin: 0;
}

.art-prompt {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 8px;
}

.art-prompt-badge {
  flex: 0 0 auto;
  margin-top: 2px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.art-prompt-text {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.art-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text-faint);
  font-size: 11px;
}

.art-meta .chat-kind-icon {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  font-size: 10px;
}

.art-meta strong {
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
}

.art-meta time {
  color: var(--text-faint);
}

.art-meta em {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-style: normal;
  font-size: 10.5px;
}

.art-meta em[data-status="running"],
.art-meta em[data-status="queued"],
.art-meta em[data-status="pending"] {
  color: var(--warning);
  background: var(--warning-soft);
}

.art-meta em[data-status="failed"],
.art-meta em[data-status="timeout"],
.art-meta em[data-status="cancelled"] {
  color: var(--danger);
  background: var(--danger-soft);
}

/* 文字对话气泡 */

.chat-message {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 11px;
  margin: 0 0 16px;
}

.chat-message.user {
  grid-template-columns: minmax(0, 1fr) 32px;
}

.chat-message.user .chat-message-avatar {
  grid-column: 2;
  grid-row: 1;
}

.chat-message.user .chat-message-body {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  max-width: min(680px, 86%);
  padding: 10px 13px;
  border-radius: 15px 4px 15px 15px;
  background: var(--surface-3);
}

.chat-message.assistant .chat-message-body {
  max-width: min(720px, 92%);
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 4px 15px 15px 15px;
  background: #fff;
}

.chat-message-avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
}

.chat-message.assistant .chat-message-avatar {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.chat-message-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 5px;
  color: var(--text-faint);
  font-size: 10.5px;
}

.chat-message-meta strong {
  color: var(--text);
  font-size: 12px;
}

.chat-message-meta em {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-style: normal;
}

.chat-message-meta em[data-status="running"],
.chat-message-meta em[data-status="queued"],
.chat-message-meta em[data-status="pending"] {
  color: var(--warning);
  background: var(--warning-soft);
}

.chat-message-meta em[data-status="failed"],
.chat-message-meta em[data-status="timeout"],
.chat-message-meta em[data-status="cancelled"] {
  color: var(--danger);
  background: var(--danger-soft);
}

.chat-message-text {
  margin: 0;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.7;
  font-size: 13px;
}

.chat-message-error {
  margin: 8px 0 0;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 11.5px;
}

/* 用户消息 / 作品卡里的参考图缩略行 */

.chat-message-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chat-ref-card {
  position: relative;
  width: 64px;
  margin: 0;
  overflow: hidden;
}

.chat-ref-card img,
.chat-ref-card video {
  display: block;
  width: 100%;
  height: 64px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
}

.chat-ref-card video {
  object-fit: contain;
  background: #000;
}

.chat-ref-badge {
  position: absolute;
  top: 5px;
  left: 5px;
  z-index: 2;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.82);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.3;
  pointer-events: none;
}

.chat-ref-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 3;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.72);
  color: #fff;
  cursor: pointer;
}

.chat-ref-remove:hover {
  background: rgba(17, 24, 39, 0.92);
}

.chat-ref-remove svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.chat-ref-file {
  display: grid;
  place-items: center;
  width: 100%;
  height: 84px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text-muted);
}

.chat-ref-file svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------
   底部创作面板
   ------------------------------------------------------------ */

.chat-composer {
  min-width: 0;
  width: min(880px, calc(100% - 32px));
  margin: 0 auto 14px;
  padding: 10px 14px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 16px 44px rgba(15, 23, 42, 0.10);
}

.chat-composer:focus-within {
  border-color: var(--border-strong);
}

.chat-composer > .error {
  margin: 2px 2px 8px;
}

/* 参考图条 */

.chat-reference-strip {
  display: flex;
  align-items: stretch;
  gap: 9px;
  overflow-x: auto;
  padding: 2px 2px 9px;
  scrollbar-width: thin;
}

.chat-reference-strip .chat-ref-card {
  width: 68px;
  height: 68px;
  flex: 0 0 auto;
  overflow: hidden;
}

.chat-reference-strip .chat-ref-card img,
.chat-reference-strip .chat-ref-card .chat-ref-file {
  width: 68px;
  height: 68px;
  border-radius: 11px;
}

.chat-ref-add {
  flex: 0 0 auto;
  width: 68px;
  height: 68px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  border: 1px dashed var(--border-strong);
  border-radius: 11px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 10.5px;
  cursor: pointer;
}

.chat-ref-add:hover {
  border-color: var(--text-muted);
  color: var(--text);
  background: var(--surface-2);
}

.chat-ref-add svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

/* 提示词输入 */

#chatPromptInput {
  width: 100%;
  min-height: 52px;
  max-height: 180px;
  resize: none;
  padding: 7px 4px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.6;
}

#chatPromptInput::placeholder {
  color: var(--text-faint);
}

/* 底部工具行 */

.chat-composer-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-composer-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}

.chat-composer-toolbar::-webkit-scrollbar {
  display: none;
}

.chat-tool-button {
  flex: 0 0 auto;
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.chat-tool-button:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.chat-tool-button:disabled {
  opacity: .55;
  cursor: wait;
}

.chat-tool-button svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-tool-button .chat-caret {
  width: 12px;
  height: 12px;
  color: var(--text-faint);
}

.chat-tool-key {
  color: var(--text-faint);
  font-size: 11px;
}

.chat-tool-button strong {
  font-weight: 600;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-model-button {
  max-width: 230px;
}

.chat-kind-icon.chat-kind-icon {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  font-size: 10px;
}

.chat-composer-status {
  flex: 0 1 auto;
  min-width: 0;
  color: var(--warning);
  font-size: 10.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-composer-status:empty {
  display: none;
}

.chat-point-cost {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
}

.chat-send-button {
  flex: 0 0 auto;
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  border: 1px solid var(--brand);
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.chat-send-button:hover {
  background: var(--brand-hover);
}

.chat-send-button:disabled {
  opacity: .55;
  cursor: wait;
}

.chat-send-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------
   全局弹层（fixed，避免被工具条 overflow 裁剪）
   ------------------------------------------------------------ */

.chat-popover {
  position: fixed;
  z-index: 60;
  min-width: 250px;
  max-width: min(430px, calc(100vw - 24px));
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-float);
  overflow: auto;
}

.chat-model-menu {
  display: block;
}

.chat-model-group + .chat-model-group {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--surface-3);
}

.chat-model-group-title {
  display: block;
  padding: 4px 8px 5px;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
}

.chat-model-option {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.chat-model-option:hover,
.chat-model-option.active {
  background: var(--surface-2);
}

.chat-model-option-text {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.chat-model-option-text strong {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-model-option-text em {
  color: var(--text-faint);
  font-size: 10.5px;
  font-style: normal;
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-model-price {
  color: var(--text-muted);
  font-size: 10.5px;
  white-space: nowrap;
}

.chat-model-empty {
  padding: 24px 12px;
  color: var(--text-faint);
  font-size: 12.5px;
  text-align: center;
}

/* 弹层里的参数控件 */

.chat-popover .chat-param-field + .chat-param-field {
  margin-top: 12px;
}

.chat-param-field {
  display: grid;
  gap: 7px;
}

.chat-param-label {
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
}

.chat-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-chip {
  min-height: 28px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.chat-chip:hover {
  border-color: var(--border-strong);
}

.chat-chip.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.chat-chip-aspect {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
}

.chat-chip-aspect i {
  display: block;
  border: 1.5px solid currentColor;
  border-radius: 2.5px;
  opacity: .85;
}

.chat-chip-aspect span {
  font-size: 10.5px;
}

.chat-count-stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
}

.chat-count-stepper button {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.chat-count-stepper button:hover:not(:disabled) {
  background: var(--surface-3);
}

.chat-count-stepper button:disabled {
  color: var(--text-faint);
  cursor: not-allowed;
}

.chat-count-stepper strong {
  min-width: 44px;
  font-size: 11.5px;
  text-align: center;
}

.chat-popover input[type="url"],
.chat-popover textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: 0;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  line-height: 1.6;
}

.chat-popover input[type="url"] {
  height: 34px;
  padding: 0 10px;
}

.chat-popover textarea {
  padding: 8px 10px;
  resize: vertical;
  min-height: 96px;
}

.chat-popover input[type="url"]:focus,
.chat-popover textarea:focus {
  border-color: var(--border-strong);
  background: #fff;
}

/* @ 提及弹层 */

.chat-mention-pop {
  position: fixed;
  z-index: 70;
  width: min(340px, calc(100vw - 24px));
  max-height: 250px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-float);
}

.chat-mention-hint {
  margin: 4px 8px 6px;
  color: var(--text-faint);
  font-size: 10.5px;
}

.chat-mention-item {
  width: 100%;
  display: grid;
  grid-template-columns: 30px auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.chat-mention-item:hover,
.chat-mention-item.active {
  background: var(--surface-2);
}

.chat-mention-item img,
.chat-mention-item > span {
  width: 30px;
  height: 30px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  display: grid;
  place-items: center;
}

.chat-mention-item strong {
  font-size: 12px;
  white-space: nowrap;
}

.chat-mention-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 11px;
}

/* ------------------------------------------------------------
   响应式
   ------------------------------------------------------------ */

@media (max-width: 900px) {
  #chatPanel,
  .chat-workspace {
    min-height: calc(100vh - 130px);
  }

  .chat-workspace {
    grid-template-columns: minmax(0, 1fr);
    position: relative;
  }

  .chat-history {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 8;
    width: min(300px, 86vw);
    transform: translateX(-102%);
    transition: transform 160ms ease;
    box-shadow: var(--shadow-float);
  }

  body.chat-sidebar-open .chat-history {
    transform: translateX(0);
  }

  .chat-history-toggle {
    display: inline-flex;
  }

  .chat-canvas-stream {
    padding-inline: 14px;
  }
}

@media (max-width: 620px) {
  #chatPanel {
    height: calc(100dvh - 64px);
    min-height: 460px;
  }

  .chat-workspace {
    height: 100%;
    border-radius: 12px;
  }

  .chat-canvas-head {
    min-height: 46px;
    gap: 8px;
    padding: 7px 9px;
  }

  .chat-canvas-head h2 {
    font-size: 13.5px;
  }

  .chat-canvas-head p {
    font-size: 10px;
  }

  .chat-history-toggle,
  .chat-delete-button {
    height: 29px;
    padding: 0 8px;
    font-size: 11px;
  }

  .chat-canvas-stream {
    padding: 12px 8px 10px;
  }

  .art-card {
    margin-bottom: 12px;
    border-radius: 14px;
  }

  .art-media {
    padding: 7px;
  }

  .chat-result-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
  }

  .chat-result-image img {
    max-height: min(240px, 38vh);
  }

  .art-skeleton {
    max-height: 150px;
  }

  .chat-result-actions {
    top: 5px;
    right: 5px;
    gap: 3px;
  }

  .chat-result-action {
    width: 26px;
    height: 26px;
    border-radius: 7px;
  }

  .chat-result-action svg {
    width: 14px;
    height: 14px;
  }

  .chat-result-video {
    max-height: min(240px, 40vh);
  }

  .chat-result-video-frame {
    min-width: min(200px, 100%);
  }

  .art-info {
    padding: 8px 11px 10px;
  }

  .art-prompt {
    font-size: 12px;
  }

  .chat-message.user .chat-message-body,
  .chat-message.assistant .chat-message-body {
    max-width: 100%;
  }

  .chat-message {
    grid-template-columns: 27px minmax(0, 1fr);
    gap: 7px;
    margin-bottom: 12px;
  }

  .chat-message.user {
    grid-template-columns: minmax(0, 1fr) 27px;
  }

  .chat-message-avatar {
    width: 27px;
    height: 27px;
    border-radius: 8px;
    font-size: 9px;
  }

  .chat-message-text {
    font-size: 12.5px;
  }

  .chat-empty-state h3 {
    font-size: 19px;
  }

  .chat-empty-state p {
    max-width: 330px;
    font-size: 12px;
  }

  .chat-start-card {
    width: 136px;
    padding: 11px;
  }

  .chat-composer {
    width: calc(100% - 12px);
    margin-bottom: 8px;
    padding: 8px 10px;
    border-radius: 16px;
  }

  #chatPromptInput {
    min-height: 42px;
    max-height: 110px;
    font-size: 12.5px;
  }

  .chat-composer-footer {
    flex-wrap: wrap;
    gap: 6px;
  }

  .chat-composer-toolbar {
    flex-basis: 100%;
    order: 1;
  }

  .chat-composer-status {
    flex-basis: 100%;
    order: 2;
  }

  .chat-point-cost {
    order: 3;
    min-height: 24px;
    padding-inline: 7px;
    font-size: 9.5px;
  }

  .chat-send-button {
    order: 4;
    margin-left: auto;
    height: 32px;
    padding: 0 13px;
    font-size: 12px;
  }

  .chat-tool-button {
    height: 29px;
    padding: 0 8px;
    font-size: 11px;
  }

  .chat-model-button {
    max-width: 52vw;
  }

  .chat-tool-button strong {
    max-width: 26vw;
  }

  .chat-reference-strip .chat-ref-card,
  .chat-ref-add {
    width: 60px;
  }

  .chat-reference-strip .chat-ref-card img,
  .chat-reference-strip .chat-ref-card .chat-ref-file,
  .chat-ref-add {
    height: 60px;
  }

  .chat-composer > .error {
    font-size: 11px;
  }

  .chat-popover {
    left: 8px !important;
    max-width: calc(100vw - 16px);
  }
}
