.hidden {
  display: none !important;
}
/* ===== AI 对话面板（参考截图优化） ===== */
.ai-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 480px;
  height: min(720px, calc(100vh - 48px));
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: row;
  z-index: 200;
  overflow: hidden;
  animation: slideUp 0.3s ease;
  border: 1px solid #ebebeb;
  transition: width 0.28s ease, height 0.28s ease, right 0.28s ease, bottom 0.28s ease, border-radius 0.28s ease;
}

.ai-chat-panel.with-side {
  width: min(1100px, calc(100vw - 48px));
  height: min(800px, calc(100vh - 48px));
}

.ai-chat-panel.fullscreen {
  right: 16px;
  bottom: 16px;
  width: calc(100vw - 32px);
  height: calc(100vh - 32px);
  border-radius: 8px;
}

.ai-chat-panel.fullscreen.with-side {
  width: calc(100vw - 32px);
}

/* 左侧第三屏 */
.ai-side-panel {
  width: 0;
  flex-shrink: 0;
  overflow: hidden;
  border-right: 1px solid transparent;
  display: flex;
  flex-direction: column;
  background: #fff;
  transition: width 0.28s ease, border-color 0.28s ease;
}

.ai-side-panel.third-panel {
  border-left: none;
}

.ai-chat-panel.with-side .ai-side-panel {
  width: min(480px, 44%);
  min-width: 360px;
  border-right-color: #f0f0f0;
}

.ai-chat-panel.fullscreen.with-side .ai-side-panel {
  width: min(520px, 42vw);
}

/* 右侧主对话区 */
.ai-chat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* 顶部栏 */
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
  background: #fff;
}

.ai-chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ai-chat-title {
  font-size: 16px;
  font-weight: 600;
  color: #1f1f1f;
  white-space: nowrap;
}

.ai-new-chat-link {
  border: none;
  background: transparent;
  color: #ff4d4f;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.ai-new-chat-link:hover {
  opacity: 0.75;
  text-decoration: underline;
}

.ai-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.ai-header-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  transition: background 0.2s, color 0.2s;
}

.ai-header-btn:hover {
  background: #f5f5f5;
  color: #333;
}

.ai-header-btn.active {
  background: #fff1f0;
  color: #ff4d4f;
}

.ai-header-close:hover {
  background: #fff1f0;
  color: #ff4d4f;
}

/* 消息区 */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: #fff;
}

.chat-msg {
  display: flex;
  gap: 10px;
  max-width: 92%;
}

.chat-msg > .chat-msg-body {
  flex: 1;
  min-width: 0;
}

.chat-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.chat-msg.assistant .chat-msg-avatar {
  background: transparent;
}

.chat-msg.assistant .chat-msg-avatar .ai-logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.chat-msg.user .chat-msg-avatar {
  background: #fff1f0;
  color: #ff4d4f;
}

.chat-msg.user .chat-msg-avatar svg {
  width: 18px;
  height: 18px;
}

.chat-msg-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
}

.chat-msg.assistant .chat-msg-bubble {
  background: transparent;
  color: #333;
  padding: 0;
  border-radius: 0;
}

.chat-msg.user .chat-msg-bubble {
  background: #fff0f3;
  color: #333;
  border: 1px solid #ffe0e6;
  border-top-right-radius: 4px;
}

/* 检索引用条 */
.msg-ref-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  margin-bottom: 8px;
  border: 1px solid #eee;
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  text-align: left;
}

.msg-ref-bar:hover,
.msg-ref-bar.active {
  color: #ff4d4f;
  border-color: #ffd6d6;
  background: #fffafa;
}

.msg-ref-bar .msg-ref-arrow {
  font-size: 14px;
  color: #bfbfbf;
  margin-left: 2px;
}

.msg-ref-bar.active .msg-ref-arrow {
  color: #ff4d4f;
}

/* 正文内文件引用 */
.msg-cite-link {
  display: inline;
  padding: 1px 6px;
  margin: 0 2px;
  border: none;
  border-radius: 4px;
  background: #f5f5f5;
  color: #ff4d4f;
  font-size: inherit;
  font-family: inherit;
  line-height: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.msg-cite-link:hover,
.msg-cite-link.active {
  background: #fff1f0;
}

.msg-cite-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  margin-left: 2px;
  padding: 0 4px;
  border-radius: 50%;
  background: #f0f0f0;
  color: #999;
  font-size: 11px;
  font-weight: 500;
  vertical-align: super;
  line-height: 1;
}

/* 思考过程 */
.msg-thinking {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  margin-bottom: 8px;
  background: #f7f7f8;
  border: 1px solid #eee;
  border-radius: 8px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.msg-thinking:hover {
  background: #f0f0f0;
}

.msg-thinking .thinking-arrow {
  font-size: 11px;
  color: #999;
  transition: transform 0.2s;
}

.msg-thinking.expanded .thinking-arrow {
  transform: rotate(90deg);
}

.msg-thinking-detail {
  display: none;
  padding: 10px 14px;
  margin-bottom: 8px;
  background: #fafafa;
  border-left: 3px solid #ddd;
  border-radius: 0 6px 6px 0;
  font-size: 12px;
  color: #888;
  line-height: 1.6;
}

.msg-thinking-detail.show {
  display: block;
}

/* 消息操作栏 */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 10px;
}

.msg-actions-divider {
  width: 1px;
  height: 14px;
  background: #e8e8e8;
  margin: 0 6px;
  flex-shrink: 0;
}

.msg-action-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  transition: background 0.2s, color 0.2s;
  padding: 0;
}

.msg-action-btn:hover {
  background: #f5f5f5;
  color: #666;
}

.msg-action-btn.active,
.msg-action-btn.liked,
.msg-action-btn.disliked {
  color: #ff4d4f;
}

/* 插件按钮（打开第三屏） */
.msg-plugin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 0;
  background: transparent;
  border: none;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.2s;
}

.msg-plugin:hover,
.msg-plugin.active {
  color: #ff4d4f;
}

.msg-plugin .msg-plugin-count {
  color: #ff4d4f;
  font-weight: 600;
}

.msg-plugin .msg-plugin-arrow {
  color: #bfbfbf;
  font-size: 12px;
}

.chat-msg-bubble.typing::after {
  content: "...";
  animation: typing 1.2s infinite;
}

@keyframes typing {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.chat-welcome-screen {
  padding: 24px 16px 12px;
  text-align: center;
}

.chat-welcome-title {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 600;
  color: #ff4d4f;
  line-height: 1.4;
}

.chat-welcome-title.hero {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 28px;
  font-weight: 600;
  color: #ff4d4f;
}

.welcome-hi {
  font-style: italic;
  font-size: 40px;
  line-height: 1;
  letter-spacing: -0.02em;
}

.welcome-i-dot {
  position: relative;
  font-style: italic;
}

.welcome-i-dot::after {
  content: "";
  position: absolute;
  top: 0.12em;
  right: 0.08em;
  width: 0.22em;
  height: 0.22em;
  background: #fa8c16;
  border-radius: 1px;
}

.welcome-name {
  font-size: 28px;
  font-weight: 600;
  color: #ff4d4f;
}

.chat-welcome-screen.hero .chat-welcome-desc {
  margin-bottom: 28px;
  font-size: 16px;
  color: #999;
}

.chat-welcome-desc {
  margin: 0 auto 20px;
  max-width: 420px;
  font-size: 13px;
  line-height: 1.7;
  color: #ff7875;
}

.chat-welcome-capabilities {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 auto 14px;
  max-width: 460px;
  text-align: left;
}

.welcome-cap-card {
  padding: 14px 12px;
  background: #fff;
  border: 1px solid #f0f0f0;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.welcome-cap-icon {
  width: 28px;
  height: 28px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.welcome-cap-icon svg {
  width: 18px;
  height: 18px;
}

.welcome-cap-icon.red { background: #fff1f0; color: #ff4d4f; }
.welcome-cap-icon.green { background: #f6ffed; color: #52c41a; }
.welcome-cap-icon.blue { background: #e6f4ff; color: #1677ff; }
.welcome-cap-icon.purple { background: #f9f0ff; color: #722ed1; }

.welcome-cap-title {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}

.welcome-cap-desc {
  font-size: 12px;
  line-height: 1.5;
  color: #999;
}

.chat-welcome-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 18px;
}

.chat-welcome-dots span {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: #f0f0f0;
}

.chat-welcome-dots span.active {
  background: #ff4d4f;
}

.chat-welcome-suggestions {
  max-width: 460px;
  margin: 0 auto;
  text-align: left;
}

.chat-welcome-suggest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
  color: #999;
}

.chat-welcome-refresh {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: none;
  background: transparent;
  color: #999;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.2s;
}

.chat-welcome-refresh:hover {
  color: #ff4d4f;
}

.chat-welcome-suggest-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-welcome-suggest-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: #f7f7f8;
  border: 1px solid #eee;
  border-radius: 8px;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: all 0.2s;
}

.chat-welcome-suggest-chip:hover {
  border-color: #ff4d4f;
  color: #ff4d4f;
  background: #fff5f5;
}

.chat-welcome-suggest-chip svg {
  flex-shrink: 0;
  color: #ccc;
}

/* 猜你还想问 — 跟随 AI 消息 */
.msg-suggestions {
  margin-top: 12px;
}

.ai-suggest-label {
  font-size: 13px;
  color: #999;
  display: block;
  margin-bottom: 8px;
}

.ai-suggest-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.ai-suggest-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #f7f7f8;
  border: 1px solid #eee;
  border-radius: 8px;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  max-width: 100%;
  text-align: left;
}

.ai-suggest-chip:hover {
  border-color: #ff4d4f;
  color: #ff4d4f;
  background: #fff5f5;
}

.ai-suggest-chip svg {
  flex-shrink: 0;
  color: #ccc;
}

/* 输入区 */
.ai-chat-input-area {
  padding: 0 18px 16px;
  flex-shrink: 0;
}

.ai-attachment-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: #fff5f5;
  border: 1px solid #ffe0e6;
  border-radius: 8px;
  font-size: 12px;
  color: #666;
}

.ai-attachment-icon {
  font-size: 14px;
}

.ai-attachment-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-attachment-close {
  border: none;
  background: transparent;
  font-size: 16px;
  color: #999;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.ai-input-box {
  position: relative;
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  background: #fff;
  overflow: visible;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-input-box:focus-within {
  border-color: rgba(255, 77, 79, 0.4);
  box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.08);
}

.ai-input-top {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  column-gap: 8px;
  padding: 12px 14px 6px;
  --input-line-height: 20px;
  --input-default-rows: 3;
}

.ai-agent-chip {
  position: relative;
  z-index: 1;
  grid-column: 1;
  grid-row: 1;
  display: inline-flex;
  align-items: flex-start;
  gap: 4px;
  margin: 0;
  padding: 0 8px;
  border: none;
  border-radius: 6px;
  background: #fff7e6;
  color: #fa8c16;
  font-size: 13px;
  line-height: 20px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.ai-agent-chip:hover,
.ai-agent-chip.open {
  background: #ffe7ba;
}

.ai-agent-chip svg {
  opacity: 0.7;
}

.ai-agent-menu {
  position: absolute;
  left: 14px;
  bottom: calc(100% + 6px);
  z-index: 10;
  min-width: 140px;
  padding: 6px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.ai-agent-option {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #333;
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.ai-agent-option:hover {
  background: #fafafa;
}

.ai-agent-option.active {
  background: #fff7e6;
  color: #fa8c16;
}

.ai-input-box .ai-input-top textarea {
  display: block;
  grid-column: 1 / -1;
  grid-row: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  margin: 0;
  padding: 0;
  padding-block: 0;
  padding-inline: 0;
  appearance: none;
  -webkit-appearance: none;
  font-size: 13px;
  font-family: inherit;
  color: #333;
  line-height: var(--input-line-height);
  background: transparent;
  min-height: calc(var(--input-line-height) * var(--input-default-rows));
  height: calc(var(--input-line-height) * var(--input-default-rows));
  overflow-y: hidden;
  box-sizing: border-box;
  text-indent: var(--agent-chip-indent, 88px);
  field-sizing: content;
}

.ai-input-box .ai-input-top textarea::placeholder {
  color: #bbb;
}

.ai-input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px 10px;
}

.ai-input-tools-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-tool-img-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  line-height: 0;
  transition: opacity 0.2s, transform 0.15s;
}

.ai-tool-img-btn:hover {
  opacity: 0.85;
}

.ai-tool-img-btn:active {
  transform: scale(0.97);
}

.ai-tool-img-btn.active {
  outline: 1px solid #ff4d4f;
  outline-offset: 1px;
  border-radius: 10px;
}

.portal-ai-toolbar .ai-tool-btn,
.ai-input-tools-left .ai-tool-btn,
.portal-ai-toolbar .ai-tool-img-btn,
.ai-input-tools-left .ai-tool-img-btn {
  position: relative;
}

.portal-ai-toolbar .ai-tool-btn::after,
.ai-input-tools-left .ai-tool-btn::after,
.portal-ai-toolbar .ai-tool-img-btn::after,
.ai-input-tools-left .ai-tool-img-btn::after {
  content: attr(aria-label);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  padding: 5px 10px;
  background: rgba(31, 31, 31, 0.88);
  color: #fff;
  font-size: 12px;
  line-height: 1.3;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 1000;
  font-weight: 400;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.portal-ai-toolbar .ai-tool-btn:hover::after,
.portal-ai-toolbar .ai-tool-btn:focus-visible::after,
.ai-input-tools-left .ai-tool-btn:hover::after,
.ai-input-tools-left .ai-tool-btn:focus-visible::after,
.portal-ai-toolbar .ai-tool-img-btn:hover::after,
.portal-ai-toolbar .ai-tool-img-btn:focus-visible::after,
.ai-input-tools-left .ai-tool-img-btn:hover::after,
.ai-input-tools-left .ai-tool-img-btn:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.ai-tool-img {
  display: block;
  height: 32px;
  width: auto;
  pointer-events: none;
}

.ai-tool-img-square {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.ai-tool-img-auto {
  height: 32px;
}

.ai-tool-img-chip {
  height: 32px;
}

.ai-tool-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid #e8e8e8;
  border-radius: 16px;
  background: #fff;
  color: #333;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.2s, box-shadow 0.2s, color 0.2s;
}

.ai-tool-chip-btn:hover {
  border-color: #d9d9d9;
}

.ai-tool-chip-btn:active {
  transform: scale(0.98);
}

.ai-tool-chip-btn.active {
  border-color: #ff4d4f;
  color: #ff4d4f;
  box-shadow: 0 0 0 1px rgba(255, 77, 79, 0.12);
}

.ai-tool-chip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: inherit;
}

.ai-tool-chip-label {
  line-height: 1;
}

/* 大模型选择下拉 */
.ai-model-select-wrap {
  position: relative;
  flex-shrink: 0;
}

.ai-model-select-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #e8e8e8;
  border-radius: 16px;
  background: #fff;
  color: #333;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-model-select-trigger:hover,
.ai-model-select-trigger.open {
  border-color: #d9d9d9;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ai-model-select-trigger svg {
  color: #999;
  flex-shrink: 0;
}

.ai-model-select-menu {
  position: absolute;
  left: 0;
  z-index: 300;
  min-width: 240px;
  max-width: 280px;
  max-height: 360px;
  overflow-y: auto;
  padding: 6px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.portal-ai-toolbar .ai-model-select-menu {
  top: calc(100% + 6px);
  bottom: auto;
}

.ai-input-tools-left .ai-model-select-menu {
  bottom: calc(100% + 6px);
  top: auto;
}

.ai-model-select-group + .ai-model-select-group {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid #f5f5f5;
}

.ai-model-select-group-title {
  padding: 6px 10px 4px;
  font-size: 11px;
  color: #999;
  font-weight: 500;
}

.ai-model-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s;
}

.ai-model-select-option:hover {
  background: #f5f5f5;
}

.ai-model-select-option.active {
  background: #fff1f0;
}

.ai-model-select-option-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ai-model-select-option-name {
  font-size: 13px;
  color: #1f1f1f;
  font-weight: 500;
}

.ai-model-select-option-vendor {
  font-size: 11px;
  color: #999;
}

.ai-model-select-check {
  flex-shrink: 0;
  color: #ff4d4f;
  display: flex;
  align-items: center;
}

.ai-tool-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #e8e8e8;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  padding: 0;
  transition: all 0.2s;
}

.ai-tool-btn:hover {
  border-color: #d9d9d9;
  color: #666;
}

.ai-tool-btn.active {
  border-color: #ff4d4f;
  color: #ff4d4f;
  background: #fffafa;
}

.ai-tool-icon {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  transition: all 0.2s;
}

.ai-tool-icon:hover {
  background: #f5f5f5;
  color: #666;
}

.ai-tool-icon.active {
  background: #fff1f0;
  color: #ff4d4f;
}

.ai-tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid #e8e8e8;
  background: #fff;
  border-radius: 16px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.ai-tool-chip:hover,
.ai-tool-chip.active {
  border-color: #ff4d4f;
  color: #ff4d4f;
}

.ai-input-tools-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-upload-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  transition: all 0.2s;
}

.ai-upload-btn:hover {
  background: #f5f5f5;
  color: #666;
}

.ai-chat-input-area .ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ff4d4f;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

.ai-chat-input-area .ai-send-btn:hover {
  background: #cf1322;
  transform: scale(1.05);
}

/* ===== 左侧第三屏 - 历史记录 ===== */
.side-history {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.side-history-search {
  padding: 14px 14px 10px;
  flex-shrink: 0;
}

.side-history-search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid #eee;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  background: #fafafa url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 10px center;
  transition: border-color 0.2s;
}

.side-history-search input:focus {
  border-color: #ff4d4f;
  background-color: #fff;
}

.side-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 14px 10px;
  flex-shrink: 0;
}

.side-history-collapse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: #999;
}

.side-history-collapse:hover {
  background: #f5f5f5;
  color: #333;
}

.side-history-header h4 {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.side-history-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 0 8px 12px;
}

.side-history-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 2px;
  position: relative;
}

.side-history-item:hover {
  background: #fafafa;
}

.side-history-item.active {
  background: #fff5f5;
}

.side-history-item-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #fff1f0;
  color: #ff4d4f;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.side-history-item-body {
  flex: 1;
  min-width: 0;
}

.side-history-item-title {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-history-item-preview {
  font-size: 12px;
  color: #999;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.side-history-item-actions {
  display: none;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  position: absolute;
  right: 8px;
  top: 12px;
}

.side-history-item:hover .side-history-item-actions {
  display: flex;
}

.side-history-action {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 14px;
  transition: all 0.2s;
}

.side-history-action:hover {
  background: #f0f0f0;
  color: #666;
}

.side-history-action.pinned {
  color: #ff4d4f;
}

/* ===== 左侧第三屏 - 检索结果 ===== */
.side-ref-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #f5f5f5;
  flex-shrink: 0;
}

.side-ref-header h4 {
  font-size: 15px;
  font-weight: 600;
  color: #333;
}

.side-ref-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 0;
  margin: 0;
}

.side-ref-item {
  border-bottom: 1px solid #f8f8f8;
}

.side-ref-link {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.side-ref-link:hover {
  background: #fafafa;
}

.side-ref-icon {
  flex-shrink: 0;
  padding-top: 2px;
}

.side-ref-body {
  flex: 1;
  min-width: 0;
}

.side-ref-title {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  margin-bottom: 6px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 6px;
}

.side-ref-title.highlight {
  color: #ff4d4f;
}

.side-ref-download {
  color: #999;
  flex-shrink: 0;
}

.side-ref-snippet {
  font-size: 12px;
  color: #999;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== 左侧第三屏 - 工作台 ===== */
.side-workbench {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.side-wb-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
}

.side-wb-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
}

.side-wb-btn {
  padding: 6px 20px;
  border: 1px solid #d9d9d9;
  background: #fff;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  color: #333;
  transition: all 0.2s;
}

.side-wb-btn.primary {
  background: #ff4d4f;
  border-color: #ff4d4f;
  color: #fff;
}

.side-wb-btn:hover {
  border-color: #ff4d4f;
  color: #ff4d4f;
}

.side-wb-btn.primary:hover {
  background: #cf1322;
  color: #fff;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== 响应式 ===== */
@media (max-width: 1200px) {
  .app-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (max-width: 960px) {
  .portal-body {
    flex-direction: column;
  }

  .portal-sidebar {
    width: 100%;
    max-height: none;
  }

  .content-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .ai-quick-queries {
    padding-left: 0;
  }

  .ai-label {
    display: none;
  }

  .ai-chat-panel {
    right: 8px;
    left: 8px;
    width: auto;
    height: calc(100vh - 16px);
    bottom: 8px;
  }

  .ai-chat-panel.with-side {
    width: auto;
  }

  .ai-chat-panel.with-side .ai-side-panel {
    width: 280px;
  }

  .ai-chat-panel.fullscreen {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
}
