/* ===== Chat-style diagnostic layout ===== */

.chat-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 16px 100px;
  max-width: 600px;
  margin: 0 auto;
  min-height: calc(100vh - 60px);
}

/* --- Message row --- */
.chat-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 88%;
  animation: chatFadeIn 0.35s ease both;
}

.chat-row--ai {
  align-self: flex-start;
}

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

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

/* --- Avatar --- */
.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.chat-avatar--ai {
  background: #6C5CE7;
  color: #fff;
}

.chat-avatar--user {
  background: #E8E5FF;
  color: #6C5CE7;
}

.chat-avatar svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Brand S mark (viewBox 64×64) — bold S, fill style */
.chat-avatar svg.chat-avatar__mark {
  width: 20px;
  height: 20px;
  fill: currentColor;
  stroke: none;
}

/* --- Bubbles --- */
.chat-bubble-ai {
  background: #F1F3F5;
  border-radius: 16px 16px 4px 16px;
  padding: 12px 16px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--color-text, #2d3436);
  word-break: break-word;
}

.chat-bubble-user {
  background: #6C5CE7;
  color: #fff;
  border-radius: 16px 4px 16px 16px;
  padding: 12px 16px;
  font-size: 15px;
  line-height: 1.6;
  word-break: break-word;
}

/* --- Insight card --- */
.chat-insight {
  background: #FFF8E1;
  border-left: 3px solid #F59E0B;
  padding: 12px 16px;
  border-radius: 4px;
  margin-top: 8px;
  max-width: 88%;
  animation: chatFadeIn 0.35s ease both;
  font-size: 14px;
  line-height: 1.6;
  color: #78350F;
}

.chat-insight__icon {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-right: 8px;
  color: #b45309;
}
.chat-insight__icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Options inside chat --- */
.chat-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.chat-option-btn {
  background: #fff;
  border: 1.5px solid #E2DFD9;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--color-text, #1a1a2e);
  font-family: inherit;
  line-height: 1.5;
}

.chat-option-btn:hover {
  border-color: #6C5CE7;
  background: #FAF8FF;
}

.chat-option-btn:active {
  transform: scale(0.99);
}

.chat-option-btn.selected {
  border-color: #6C5CE7;
  background: #F3F0FF;
  color: #5b4acf;
  font-weight: 500;
}

/* Multi-select indicators */
.chat-option-btn .indicator {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #D1D5DB;
  margin-right: 10px;
  vertical-align: middle;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-option-btn.selected .indicator {
  border-color: #6C5CE7;
  background: #6C5CE7;
  box-shadow: inset 0 0 0 3px #fff;
}

/* Checkbox variant */
.chat-option-btn[data-multi="true"] .indicator {
  border-radius: 4px;
}

/* Other input inside option */
.chat-option-other-input {
  display: none;
  margin-top: 8px;
  width: calc(100% - 28px);
  margin-left: 28px;
  padding: 10px 12px;
  font-size: 13px;
  border: 1.5px solid #E2DFD9;
  border-radius: 8px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s ease;
  box-sizing: border-box;
}

.chat-option-other-input.visible {
  display: block;
}

.chat-option-other-input:focus {
  border-color: #6C5CE7;
}

/* --- Text input for open questions --- */
.chat-text-input {
  margin-top: 10px;
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  border: 1.5px solid #E2DFD9;
  border-radius: 12px;
  outline: none;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  min-height: 60px;
  box-sizing: border-box;
  transition: border-color 0.2s ease;
  background: #fff;
  color: var(--color-text, #1a1a2e);
}

.chat-text-input:focus {
  border-color: #6C5CE7;
}

/* --- Submit button in chat --- */
.chat-submit-row {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.chat-submit-btn {
  background: #6C5CE7;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
  opacity: 0.4;
  pointer-events: none;
}

.chat-submit-btn.active {
  opacity: 1;
  pointer-events: auto;
}

.chat-submit-btn.active:hover {
  background: #5b4acf;
}

.chat-submit-btn.active:active {
  transform: translateY(1px);
}

/* --- Typing indicator --- */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 14px 18px;
  align-items: center;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: #9CA3AF;
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* --- Closing message --- */
.chat-closing {
  text-align: center;
  padding: 20px;
  font-size: 14px;
  color: #6B7280;
  animation: chatFadeIn 0.5s ease both;
}

.chat-closing a {
  color: #6C5CE7;
  text-decoration: none;
  font-weight: 500;
}

.chat-closing a:hover {
  text-decoration: underline;
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .chat-container {
    padding: 16px 12px 100px;
    gap: 12px;
  }

  .chat-row {
    max-width: 92%;
  }

  .chat-bubble-ai,
  .chat-bubble-user {
    padding: 10px 14px;
    font-size: 14px;
  }
}

/* ----- /beta/chat.html — 独立顾问页（Jessica006） ----- */
.chat-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 16px 140px;
  min-height: 100vh;
  box-sizing: border-box;
}

.chat-page__title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--color-text);
}

.chat-page__lead {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

#chatThread {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-compose {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 12px 16px max(24px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(247, 247, 250, 0) 0%, #f7f7fa 35%);
  box-sizing: border-box;
}

.chat-compose__inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-compose textarea {
  flex: 1;
  min-height: 48px;
  max-height: 120px;
  padding: 12px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
}

.chat-compose textarea:focus {
  outline: none;
  border-color: #6c5ce7;
}

.chat-compose button {
  padding: 12px 20px;
  background: #6c5ce7;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}

.chat-compose button:hover {
  background: #5b4acf;
}

.chat-compose button:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.sending-tip {
  font-size: 12px;
  color: #6b7280;
  margin-top: 8px;
  text-align: right;
  display: none;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 4px;
}

.chat-rec-section {
  display: none;
  margin-top: 20px;
  padding: 16px;
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e8e8ed;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

.chat-rec-section.is-visible {
  display: block;
}

.chat-rec-section__title {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 14px;
}

.chat-rec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
}

.chat-rec-card {
  display: block;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #e8e8ed;
  background: #fafafa;
  text-decoration: none;
  color: #1a1a1a;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.chat-rec-card:hover {
  border-color: #6c5ce7;
  box-shadow: 0 4px 14px rgba(108, 92, 231, 0.18);
  transform: translateY(-1px);
}

.chat-rec-card__id {
  font-size: 12px;
  font-weight: 700;
  color: #6c5ce7;
  letter-spacing: 0.02em;
}

.chat-rec-card__name {
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
  line-height: 1.35;
}

.chat-rec-card__hint {
  font-size: 11px;
  color: #86868b;
  margin-top: 6px;
}

.chat-typing-bubble {
  padding: 14px 18px !important;
}

@media (max-width: 640px) {
  .chat-page {
    padding-left: 12px;
    padding-right: 12px;
  }

  .chat-rec-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Bottom chat input bar (open-ended questions) ===== */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  max-width: 600px;
  margin: 0 auto;
  border-top: 1px solid var(--border, #e5e7eb);
  background: var(--bg-card, #fff);
}
.chat-input-field {
  flex: 1;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
  font-family: inherit;
  max-height: 120px;
  transition: border-color 0.2s;
}
.chat-input-field:focus {
  border-color: var(--accent, #5B21B6);
}
.chat-input-send-btn {
  background: var(--accent, #5B21B6);
  color: #fff;
  border: none;
  border-radius: 12px;
  width: 40px;
  height: 40px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
.chat-input-send-btn:hover { opacity: 0.85; }
