/* ==================== 智囊模块全部自定义样式 ==================== */
/* 以下类名与 HTML 严格对应，无 Tailwind 视觉类干扰 */

/* ==================== 桌面端布局网格 ==================== */
.thinktank-desktop-layout {
  gap: 24px;
  align-items: start;
}

@media (min-width: 1024px) {
  .thinktank-desktop-layout.hidden.md\:grid,
  .thinktank-desktop-layout {
    display: grid !important;
    grid-template-columns: minmax(260px, 360px) minmax(0, 1fr) !important;
    column-gap: 32px;
    align-items: start;
  }

  .thinktank-desktop-layout > aside {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .thinktank-desktop-layout > :not(aside) {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }
}

/* 左侧聊天工作区 */
.thinktank-chat-shell {
  min-width: 0;
}

/* 右侧辅助信息栏 */
.thinktank-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ----- 桌面端主卡片 ----- */
.thinktank-chat-card {
  background-color: #FFFFFF;
  border-radius: 20px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: clamp(620px, calc(100dvh - 170px), 820px);
  min-height: 620px;
  border: 1px solid rgba(226, 232, 240, 0.3);
  position: relative;
}

/* ----- 对话头部 ----- */
.thinktank-chat-header {
  padding: 12px 20px;
  background-color: #F8FAFC;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(226, 232, 240, 0.3);
  flex: 0 0 auto;
}

.thinktank-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.thinktank-end-session-btn {
  background: none;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: #64748b;
  font-size: 12px;
  padding: 4px 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.thinktank-end-session-btn:hover {
  border-color: #94a3b8;
  color: #334155;
  background: #f1f5f9;
}
.thinktank-end-session-btn:active {
  transform: scale(0.97);
}

.thinktank-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  background-color: #0052CC;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.thinktank-chat-title {
  font-weight: 700;
  color: #0F172A;
  font-size: 0.9375rem;
  margin: 0;
}

.thinktank-chat-status {
  font-size: 0.6875rem;
  color: rgba(71, 85, 105, 0.8);
  margin: 0;
}

.thinktank-status-badge {
  padding: 0.2rem 0.6rem;
  background-color: #ECFDF5;
  color: #065F46;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: 9999px;
}

/* P1 修复（智谱审计问题7：新对话按钮不清空历史）：
   桌面端与移动端"新对话"按钮样式。原 thinktank.php 未渲染该按钮元素，
   导致 thinktank.js:2255-2266 的事件绑定成死代码。 */
.thinktank-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.thinktank-new-session-btn {
  padding: 0.3rem 0.85rem;
  background-color: #FFFFFF;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid #E2E8F0;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.thinktank-new-session-btn:hover {
  background-color: #F1F5F9;
  color: #0F172A;
  border-color: #CBD5E1;
}

.thinktank-new-session-btn:active {
  background-color: #E2E8F0;
}

.thinktank-new-session-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.thinktank-mobile-new-session-btn {
  padding: 0.3rem 0.7rem;
  background-color: transparent;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid rgba(226, 232, 240, 0.5);
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.thinktank-mobile-new-session-btn:hover {
  background-color: rgba(241, 245, 249, 0.8);
  color: #0F172A;
}

.thinktank-mobile-new-session-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 消息容器 */
.thinktank-messages-container {
  flex: 1 1 auto;
  min-height: 0;
  padding: 20px 24px 28px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: linear-gradient(to bottom, rgba(249, 250, 251, 0.3), white);
}

/* 底部输入区 */
.thinktank-chat-composer,
.thinktank-chat-footer {
  padding: 16px 20px;
  background-color: #FFFFFF;
  border-top: 1px solid rgba(226, 232, 240, 0.3);
  flex: 0 0 auto;
  position: relative;
  z-index: 3;
}

.thinktank-chat-input {
  width: 100%;
  background-color: #F1F5F9;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 12px 48px 12px 16px;
  font-size: 0.875rem;
  min-height: 48px;
  max-height: 140px;
  resize: none;
  outline: none;
  line-height: 1.5;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.thinktank-chat-input:focus {
  border-color: #0052CC;
  box-shadow: 0 0 0 2px rgba(0, 82, 204, 0.1);
}

.thinktank-send-btn {
  position: absolute;
  bottom: 28px;
  right: 32px;
  background-color: #0052CC;
  color: white;
  padding: 8px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thinktank-send-btn:hover {
  background-color: #003d9b;
}
.thinktank-send-btn:active {
  transform: scale(0.92);
}
.thinktank-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.thinktank-input-hint {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.625rem;
  color: rgba(71, 85, 105, 0.7);
  margin-top: 8px;
}

/* ----- 右侧边栏卡片 ----- */
.thinktank-sidebar-card {
  background-color: #F8FAFC;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid rgba(226, 232, 240, 0.3);
}

.thinktank-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.thinktank-card-title {
  font-weight: 700;
  color: #0F172A;
  font-size: 0.9375rem;
  margin: 0;
}

.thinktank-hot-question {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.thinktank-question-item-simple {
  padding: 8px 12px;
  background-color: #FFFFFF;
  border-radius: 10px;
  transition: background-color 0.2s, border-color 0.2s;
  border: 1px solid transparent;
}
.thinktank-question-item-simple:hover {
  background-color: rgba(0, 82, 204, 0.04);
  border-color: rgba(0, 82, 204, 0.15);
}
.thinktank-question-item-simple p {
  font-size: 0.8125rem;
  color: #1E293B;
  line-height: 1.4;
  margin: 0;
}

/* 定制智囊团卡片 */
.thinktank-custom-card {
  background: linear-gradient(135deg, #003D9B 0%, #0052CC 100%);
  border-radius: 16px;
  padding: 20px;
  color: white;
  position: relative;
  overflow: hidden;
}

.thinktank-custom-card-watermark {
  position: absolute;
  top: -4px;
  right: -4px;
  opacity: 0.08;
}
.thinktank-custom-card-watermark span {
  font-size: 4rem;
}

.thinktank-custom-card-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 8px 0;
  position: relative;
}

.thinktank-custom-card-desc {
  font-size: 0.8125rem;
  opacity: 0.85;
  margin-bottom: 16px;
  line-height: 1.6;
  position: relative;
}

.thinktank-custom-card-btn {
  display: block;
  width: 100%;
  background-color: #FFFFFF;
  color: #0052CC;
  padding: 10px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.8125rem;
  text-align: center;
  text-decoration: none;
  transition: background-color 0.2s;
  position: relative;
}
.thinktank-custom-card-btn:hover {
  background-color: rgba(255, 255, 255, 0.92);
}

/* ----- 移动端入口 ----- */
.thinktank-mobile-entry-card {
  background-color: #FFFFFF;
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(226, 232, 240, 0.3);
}

.thinktank-mobile-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 12px;
  background-color: #0052CC;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.thinktank-mobile-title {
  font-weight: 700;
  color: #0F172A;
  margin: 0;
}

.thinktank-mobile-subtitle {
  font-size: 0.75rem;
  color: rgba(71, 85, 105, 0.8);
  margin: 0;
}

.thinktank-mobile-question {
  background: #F1F5F9;
  border: 1px solid transparent;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.8125rem;
  color: #1E293B;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.thinktank-mobile-question:hover {
  border-color: rgba(0, 82, 204, 0.15);
  background: rgba(0, 82, 204, 0.04);
}
.thinktank-mobile-question:active {
  transform: scale(0.98);
}

.thinktank-mobile-start-btn {
  width: 100%;
  background-color: #0052CC;
  color: white;
  padding: 12px;
  border-radius: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.9375rem;
  min-height: 48px;
  transition: background-color 0.2s;
}
.thinktank-mobile-start-btn:hover {
  background-color: #003d9b;
}
.thinktank-mobile-start-btn:active {
  transform: scale(0.98);
}

/* ==================== 移动端全屏聊天 ==================== */
.thinktank-mobile-chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background-color: #FFFFFF;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 100vw;
  overflow: hidden;
}
.thinktank-mobile-chat-overlay.hidden {
  display: none;
}

.thinktank-mobile-chat-header {
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid rgba(226, 232, 240, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #F8FAFC;
  flex: 0 0 auto;
}

.thinktank-mobile-chat-title {
  font-weight: 700;
  color: #0F172A;
  font-size: 0.9375rem;
}

.thinktank-mobile-close-btn {
  padding: 6px;
  color: rgba(71, 85, 105, 0.8);
  background: none;
  border: none;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.2s;
}
.thinktank-mobile-close-btn:hover {
  background: rgba(0, 61, 155, 0.06);
}

.thinktank-mobile-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
}

.thinktank-mobile-chat-footer {
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background-color: #FFFFFF;
  border-top: 1px solid rgba(226, 232, 240, 0.3);
  flex: 0 0 auto;
}

.thinktank-mobile-chat-input {
  width: 100%;
  background-color: #F1F5F9;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 12px 48px 12px 16px;
  font-size: 0.875rem;
  min-height: 48px;
  max-height: 120px;
  resize: none;
  outline: none;
  line-height: 1.5;
  transition: border-color 0.2s;
}
.thinktank-mobile-chat-input:focus {
  border-color: #0052CC;
}

.thinktank-mobile-send-btn {
  position: absolute;
  bottom: 24px;
  right: 28px;
  background-color: #0052CC;
  color: white;
  padding: 8px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thinktank-mobile-input-hint {
  font-size: 0.625rem;
  color: rgba(71, 85, 105, 0.7);
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
}

/* ==================== 消息气泡 ==================== */
.message-user {
  display: flex;
  justify-content: flex-end;
}
.message-user .message-bubble {
  background: linear-gradient(135deg, #0052CC 0%, #2B4F8E 100%);
  color: white;
  border-radius: 18px 18px 4px 18px;
  padding: 10px 16px;
  font-size: 14px;
  max-width: 70%;
  box-shadow: 0 2px 8px rgba(0, 82, 204, 0.15);
  line-height: 1.5;
}

.message-ai {
  display: flex;
  justify-content: flex-start;
}
.message-ai .message-bubble {
  background: white;
  border: 1px solid #E2E8F0;
  border-radius: 18px 18px 18px 4px;
  padding: 14px 18px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
  max-width: 85%;
}

.message-animate {
  animation: fadeInUp 0.25s ease-out forwards;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 滚动条 */
.custom-scroll::-webkit-scrollbar { width: 4px; }
.custom-scroll::-webkit-scrollbar-track { background: transparent; }
.custom-scroll::-webkit-scrollbar-thumb { background: #CBD5E0; border-radius: 10px; }
.custom-scroll::-webkit-scrollbar-thumb:hover { background: #A0AEC0; }

/* ==================== 回应卡片 ==================== */
.thinktank-response {
  width: min(560px, 100%);
  overflow-wrap: anywhere;
}

.thinktank-response:not(.thinktank-mode-direct) {
  border-left: 3px solid #0052cc;
}

.thinktank-response-title {
  color: #0f172a;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
}

.thinktank-response-summary,
.thinktank-response-copy {
  color: #334155;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.thinktank-response-summary {
  margin-bottom: 12px;
}

.thinktank-response-section {
  border-top: 1px solid #e2e8f0;
  margin-top: 12px;
  padding-top: 12px;
}

.thinktank-response-section-title {
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.thinktank-response-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.thinktank-response-actions button {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  color: #1d4ed8;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  padding: 8px 14px;
  transition: all 0.2s;
  min-height: 36px;
}
.thinktank-response-actions button:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}
.thinktank-response-actions button:active {
  transform: scale(0.97);
}
.thinktank-response-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==================== 顾问式结构化知识渲染 ==================== */
.thinktank-consultant .thinktank-answer-paragraph {
  line-height: 1.8;
  margin: 0;
}

.thinktank-consultant .thinktank-answer-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  counter-reset: consultant-step;
}

.thinktank-consultant .thinktank-answer-list li {
  line-height: 1.75;
  padding-left: 28px;
  position: relative;
  counter-increment: consultant-step;
}

.thinktank-consultant .thinktank-answer-list li::before {
  content: counter(consultant-step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thinktank-consultant-steps .thinktank-answer-list li::before {
  background: #dbeafe;
  color: #0052CC;
}

/* CTA area: weakened style */
.thinktank-consultant-cta button {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #475569;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
}
.thinktank-consultant-cta button:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

/* Aside collapsible */
.thinktank-consultant-aside summary::-webkit-details-marker {
  display: none;
}
.thinktank-consultant-aside[open] summary::after {
  content: ' ▾';
}
.thinktank-consultant-aside:not([open]) summary::after {
  content: ' ▸';
}
.thinktank-consultant-aside summary .aside-arrow {
  display: none;
}

/* Mobile adaptation for consultant rendering */
@media (max-width: 640px) {
  .thinktank-consultant .thinktank-answer-list li {
    padding-left: 24px;
  }
  .thinktank-consultant .thinktank-answer-list li::before {
    width: 18px;
    height: 18px;
    font-size: 11px;
  }
  .thinktank-consultant-cta button {
    min-height: 36px;
  }
}

/* ==================== 单条消息反馈 (per-message feedback) ==================== */
.thinktank-message-feedback {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
}
.thinktank-message-feedback button {
  padding: 6px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  font: inherit;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  min-height: 32px;
  box-sizing: border-box;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.thinktank-message-feedback button:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
}
.thinktank-message-feedback button.is-active {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}
.thinktank-message-feedback button:disabled {
  cursor: default;
  opacity: 0.85;
}
.thinktank-message-feedback button.is-active:disabled {
  opacity: 1;
}

/* ==================== 会话级反馈卡片 ==================== */
.thinktank-session-feedback {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  padding: 20px;
  margin-top: 12px;
  max-width: min(480px, 100%);
}

.thinktank-session-feedback-title {
  font-size: 14px;
  font-weight: 700;
  color: #0F172A;
  margin: 0 0 16px 0;
}

.thinktank-session-feedback-group {
  margin-bottom: 16px;
}

.thinktank-session-feedback-label {
  font-size: 13px;
  color: #475569;
  margin-bottom: 8px;
  font-weight: 500;
}

.thinktank-session-feedback-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.thinktank-session-feedback-options button {
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #334155;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  padding: 8px 16px;
  transition: all 0.2s;
  min-height: 40px;
}
.thinktank-session-feedback-options button:hover {
  border-color: #94a3b8;
  background: #f1f5f9;
}
.thinktank-session-feedback-options button:active {
  transform: scale(0.97);
}
.thinktank-session-feedback-options button.selected {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
  font-weight: 600;
}

.thinktank-session-feedback-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.thinktank-session-feedback-reasons button {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: #64748b;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 6px 12px;
  transition: all 0.2s;
  min-height: 36px;
}
.thinktank-session-feedback-reasons button:hover {
  border-color: #94a3b8;
  color: #334155;
}

.thinktank-session-feedback-submit {
  display: block;
  width: 100%;
  background: #0052CC;
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
  transition: background 0.2s;
  min-height: 44px;
}
.thinktank-session-feedback-submit:hover {
  background: #003d9b;
}
.thinktank-session-feedback-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.thinktank-session-feedback-done {
  text-align: center;
  color: #059669;
  font-size: 14px;
  font-weight: 500;
  padding: 12px;
}

.thinktank-session-feedback-error {
  color: #dc2626;
  font-size: 13px;
  text-align: center;
  padding: 6px 0;
}

/* 关闭确认弹层 */
.thinktank-close-confirm {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 24, 72, 0.4);
  padding: 24px;
}
.thinktank-close-confirm-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  max-width: 320px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  text-align: center;
}
.thinktank-close-confirm-card p {
  font-size: 15px;
  color: #0F172A;
  margin: 0 0 20px 0;
  font-weight: 500;
}
.thinktank-close-confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.thinktank-close-confirm-actions button {
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: all 0.2s;
}
.thinktank-close-confirm-continue {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #334155;
}
.thinktank-close-confirm-continue:hover {
  background: #e2e8f0;
}
.thinktank-close-confirm-end {
  background: #0052CC;
  border: none;
  color: white;
}
.thinktank-close-confirm-end:hover {
  background: #003d9b;
}

/* ==================== 旧版 per-message feedback（保留兼容但不再主动使用） ==================== */
.thinktank-feedback {
  display: none;
}

.thinktank-feedback-state {
  color: #64748b;
  font-size: 12px;
}

/* ==================== handoff 留资表单卡片 ==================== */
.thinktank-handoff-form {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: min(420px, 100%);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  box-sizing: border-box;
}
.thinktank-handoff-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}
.thinktank-handoff-desc {
  margin: 0;
  font-size: 12px;
  color: #64748b;
  line-height: 1.5;
}
.thinktank-handoff-type-group {
  display: flex;
  background: #e2e8f0;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  width: 100%;
  box-sizing: border-box;
}
.thinktank-handoff-type-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: #475569;
  font: inherit;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  min-height: 36px;
  transition: background 0.2s, color 0.2s;
}
.thinktank-handoff-type-btn:hover {
  color: #0f172a;
}
.thinktank-handoff-type-btn.active {
  background: #fff;
  color: #0052CC;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}
.thinktank-handoff-input {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  min-width: 0;
  width: 100%;
  padding: 10px 12px;
  min-height: 44px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  background: #fff;
}
.thinktank-handoff-input:focus {
  border-color: #0052CC;
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.12);
}
.thinktank-handoff-input.is-invalid {
  border-color: #dc2626;
}
.thinktank-handoff-error {
  color: #dc2626;
  font-size: 12px;
  margin: 0;
  display: none;
}
.thinktank-handoff-error.is-visible {
  display: block;
}
.thinktank-handoff-submit {
  background: #0052CC;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  width: 100%;
  box-sizing: border-box;
  transition: background 0.2s;
}
.thinktank-handoff-submit:hover {
  background: #003d9b;
}
.thinktank-handoff-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.thinktank-handoff-success {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  color: #166534;
  font-size: 13px;
  line-height: 1.6;
}
.thinktank-handoff-success::before {
  content: "✓";
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.6;
}


/* ==================== Tablet (768px-1023px) 显式控制 ==================== */
@media (min-width: 768px) and (max-width: 1023px) {
  .thinktank-mobile-entry {
    display: block !important;
  }
  .thinktank-desktop-layout {
    display: none !important;
  }
  /* 旧版结构兼容：生产站 thinktank.php 将 .thinktank-mobile-entry 包裹在
     <div class="block md:hidden"> 中，Tailwind md:hidden 在 >=768px 将该父级
     设为 display:none，导致子级 .thinktank-mobile-entry 即便有 display:block!important
     也无法渲染（父级隐藏则子级 0 高度）。此处用 :has() 强制该包裹层在 Pad 端可见，
     使移动入口卡片在 768-1023px 正常渲染。对新版结构（.thinktank-mobile-entry 直接
     位于 main 内）无副作用，因其父级本就是 block。 */
  div:has(> .thinktank-mobile-entry) {
    display: block !important;
  }
}
/* ==================== 响应式 ==================== */
@media (max-width: 1024px) {
  /* Pad 和手机：全屏聊天模式 */
  body.thinktank-chat-open {
    overflow: hidden;
  }

  .thinktank-mobile-chat-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    overflow: hidden;
    background: #fff;
  }

  .thinktank-mobile-chat-overlay.hidden {
    display: none;
  }

  .thinktank-mobile-chat-header {
    flex: 0 0 auto;
  }

  .thinktank-mobile-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .thinktank-mobile-chat-footer {
    flex: 0 0 auto;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  /* 手机端隐藏 footer */
  body.thinktank-chat-open footer {
    display: none;
  }
}

@media (max-width: 640px) {
  .thinktank-response,
  .thinktank-response-actions,
  .thinktank-session-feedback {
    max-width: 100%;
  }

  /* 移动端触摸目标接近 44px */
  .thinktank-response-actions button {
    min-height: 40px;
    padding: 9px 14px;
  }
  .thinktank-message-feedback button {
    min-height: 36px;
    padding: 7px 14px;
  }
  .thinktank-handoff-form {
    max-width: 100%;
  }

  .message-user .message-bubble {
    max-width: 80%;
  }

  .message-ai .message-bubble {
    max-width: 92%;
  }
}

/* Body scroll lock when mobile chat is open */
body.thinktank-chat-open {
  overflow: hidden;
}

/* Desktop layout fallback for JIT Tailwind builds without responsive grid utilities */
@media (min-width: 1024px) {
  .thinktank-desktop-layout.hidden.md\:grid {
    display: grid !important;
  }

  .thinktank-mobile-entry.md\:hidden {
    display: none !important;
  }
}

/* ==================== SEO/GEO 长内容区三端隐藏（保留给爬虫/AI抓取，不对用户直接显示） ==================== */
section[aria-labelledby="thinktank-about-heading"] {
  display: none !important;
}

/* ==================== Agent 接管通知横幅 ==================== */
.thinktank-agent-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin: 8px 0 12px;
  background: #f0f4f8;
  border: 1px solid #d6dee6;
  border-radius: 12px;
  position: sticky;
  top: 0;
  z-index: 5;
  animation: fadeInUp 0.3s ease-out;
}
.thinktank-agent-banner-icon {
  font-size: 22px;
  flex-shrink: 0;
}
.thinktank-agent-banner-text {
  font-size: 13px;
  color: #1e3a5f;
  line-height: 1.5;
}
.thinktank-agent-banner-text strong {
  color: #1e3a5f;
}
.thinktank-agent-banner-end {
  margin-left: auto;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #1e3a5f;
  background: #fff;
  border: 1px solid #1e3a5f;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}
.thinktank-agent-banner-end:hover {
  background: #1e3a5f;
  color: #fff;
  border-color: #1e3a5f;
}

/* ==================== 系统提示条（区别于 AI/客服气泡） ==================== */
/* 用于：转人工等待、转人工超时、追问引导、会话已结束等系统级提示 */
/* 居中显示，不占据 AI 气泡宽度，无反馈按钮 */
.thinktank-system-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 85%;
  margin: 8px auto;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  animation: fadeInUp 0.3s ease-out;
}
.thinktank-system-notice-icon {
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1;
}
.thinktank-system-notice--info {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #475569;
}
.thinktank-system-notice--waiting {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}
.thinktank-system-notice--success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}
.thinktank-system-notice--warning {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
/* 卡片变体：含交互内容（表单/多行信息） */
.thinktank-system-notice--card {
  flex-direction: column;
  gap: 6px;
  max-width: 320px;
  padding: 14px 18px;
}
.thinktank-system-notice-title {
  font-size: 14px;
  font-weight: 600;
}
.thinktank-system-notice-subtext {
  font-size: 12px;
  opacity: 0.85;
}
.thinktank-system-notice-form {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 260px;
  margin-top: 4px;
}
.thinktank-system-notice-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.thinktank-system-notice-input:focus {
  border-color: #6366f1;
}
.thinktank-system-notice-btn {
  padding: 8px 16px;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.thinktank-system-notice-btn:hover {
  background: #4f46e5;
}

/* ==================== 右侧进度导航条 ==================== */
/* DeepSeek 风格：多轮对话后右侧竖条，hover 显示锚点列表，点击定位 */
/* 注意：top/bottom 由 JS 注入时根据容器设置，避免双 CSS 冲突 */
.chat-progress-rail {
  position: absolute;
  right: 6px;
  width: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  cursor: pointer;
  z-index: 5;
  transition: width 0.15s ease;
}
.chat-progress-rail:hover {
  width: 6px;
}
.chat-progress-rail.is-hidden {
  display: none;
}
.chat-progress-thumb {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: #6366f1;
  border-radius: 2px;
  height: 0%;
  transition: height 0.12s linear;
}
.chat-progress-popover {
  position: absolute;
  right: 16px;
  top: 0;
  width: 220px;
  max-height: 320px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: 6px;
  opacity: 0;
  transform: translateX(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 23, 42, 0.15) transparent;
}
.chat-progress-popover::-webkit-scrollbar {
  width: 5px;
}
.chat-progress-popover::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.15);
  border-radius: 4px;
}
.chat-progress-rail:hover .chat-progress-popover {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.chat-progress-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: #475569;
  transition: background 0.12s ease;
}
.chat-progress-item:hover {
  background: #f1f5f9;
}
.chat-progress-item.is-active {
  color: #6366f1;
  font-weight: 600;
}
.chat-progress-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #cbd5e1;
  flex-shrink: 0;
  transition: transform 0.15s ease, background 0.15s ease;
}
.chat-progress-item.is-active .chat-progress-dot {
  background: #6366f1;
  transform: scale(1.4);
}
.chat-progress-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-progress-num {
  font-size: 10px;
  color: #94a3b8;
  flex-shrink: 0;
}
/* 消息高亮闪烁（点击锚点定位后） */
.chat-message-flash {
  animation: chatFlashHighlight 1.2s ease-out;
}
@keyframes chatFlashHighlight {
  0% { background-color: rgba(99, 102, 241, 0.15); }
  100% { background-color: transparent; }
}

/* ==================== Agent 消息气泡 ==================== */
.message-agent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding-left: 4px;
}
.message-agent-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1e3a5f;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}
.message-agent-body {
  flex: 1;
  min-width: 0;
}
.message-agent-bubble {
  display: inline-block;
  background: #f0f4f8;
  color: #1f2430;
  border: 1px solid #d6dee6;
  border-radius: 18px 18px 18px 4px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 85%;
  white-space: pre-wrap;
  word-break: break-word;
}
.message-agent-label {
  font-size: 11px;
  color: #6b7785;
  margin-top: 4px;
  padding-left: 2px;
  font-weight: 600;
}

/* 移动端适配 */
@media (max-width: 767px) {
  .message-agent-bubble {
    max-width: 92%;
    font-size: 13px;
  }
}
