* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #1a0f14;
  --card: #261820;
  --card-border: #3d2835;
  --text: #f5e6ec;
  --text-secondary: #a88a96;
  --accent: #ff6b9d;
  --accent-soft: #ff8fb3;
  --accent-deep: #c44569;
  --success: #00d9a5;
  --prob-glow: rgba(255, 107, 157, 0.25);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  line-height: 1.6;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.page .user-bar {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  margin-bottom: 16px;
  color: var(--text);
}
.page .user-bar-info { color: var(--text-secondary); }
.page .user-bar-info strong { color: var(--text); }
.page .btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  color: var(--text);
}
.page .auth-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
}
.page .auth-card input {
  background: var(--bg);
  border-color: var(--card-border);
  color: var(--text);
}
.page .btn-link { color: var(--text-secondary); }

.container {
  max-width: none;
  margin: 0;
  padding: 0;
}

.workspace {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.main-col {
  flex: 1;
  min-width: 0;
}

/* 历史侧栏 */
.history-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  overflow: hidden;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
}

.history-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--card-border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.history-sidebar-header button {
  padding: 4px 10px;
  font-size: 12px;
  background: rgba(255, 107, 157, 0.15);
  border: none;
  border-radius: 8px;
  color: var(--accent-soft);
  cursor: pointer;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 160px;
  max-height: 420px;
}

.conv-item {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.15s;
}

.conv-item:hover { background: rgba(255, 255, 255, 0.05); }
.conv-item.active {
  background: rgba(255, 107, 157, 0.12);
  border: 1px solid rgba(255, 107, 157, 0.25);
}

.conv-item-title {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-item-time {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.conv-empty, .history-tip {
  padding: 16px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.history-tip {
  border-top: 1px solid var(--card-border);
  margin: 0;
}

.conv-load-more {
  padding: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
}
.conv-load-more.hidden { display: none; }

.header {
  text-align: center;
  margin-bottom: 28px;
  padding-top: 12px;
}

.header h1 {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.header p { color: var(--text-secondary); font-size: 14px; }

.tip-box {
  background: rgba(255, 107, 157, 0.08);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: 0 12px 12px 0;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

.tip-box strong { color: var(--accent-soft); }

.form-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 20px;
}

.form-group { margin-bottom: 20px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
}

.form-label span {
  color: var(--text-secondary);
  font-weight: 400;
  font-size: 12px;
  margin-left: 6px;
}

textarea, input[type="text"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
  resize: vertical;
}

textarea:focus, input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--prob-glow);
}

textarea { min-height: 160px; line-height: 1.7; }
textarea::placeholder { color: var(--text-secondary); opacity: 0.7; }

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  appearance: none;
  border: 1.5px solid var(--card-border);
  background: var(--bg);
  color: var(--text-secondary);
  border-radius: 980px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.chip:hover {
  border-color: #5a3d4a;
  color: var(--text);
}

.chip.active {
  border-color: var(--accent);
  background: rgba(255, 107, 157, 0.12);
  color: var(--accent-soft);
}

.gender-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  font-family: inherit;
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(255, 107, 157, 0.35); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.result-section {
  display: none;
  animation: fadeIn 0.5s ease;
}
.result-section.show { display: block; }

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

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}

.section-toggle-title { font-size: 18px; font-weight: 700; }
.section-toggle-hint {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.section-toggle:hover .section-toggle-hint { color: var(--accent-soft); }

.chat-panel {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  margin-bottom: 20px;
  overflow: hidden;
}
.chat-panel.hidden { display: none; }

.chat-messages {
  max-height: 360px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-empty, .chat-loading {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 32px 16px;
  line-height: 1.6;
}

.chat-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.chat-loading .spinner {
  border-color: rgba(255, 107, 157, 0.2);
  border-top-color: var(--accent);
}

.msg {
  max-width: 88%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-ai {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-bottom-left-radius: 4px;
}

.stream-cursor {
  display: inline-block;
  color: var(--accent);
  animation: blink 0.9s step-end infinite;
  margin-left: 2px;
}

@keyframes blink { 50% { opacity: 0; } }

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

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

/* 概率展示区 */
.prob-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  text-align: center;
}

.prob-card.hidden { display: none; }

.prob-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.prob-value {
  font-size: 48px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
  line-height: 1.1;
}

.prob-bar {
  width: 100%;
  height: 10px;
  background: rgba(255, 107, 157, 0.12);
  border-radius: 5px;
  overflow: hidden;
}

.prob-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  border-radius: 5px;
  transition: width 0.6s ease;
  width: 0%;
}

.prob-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 10px;
}

/* 分析结果 */
.analysis-result {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  min-height: 100px;
}

.analysis-result.streaming {
  border-color: rgba(255, 107, 157, 0.3);
}

.analysis-body {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
}

.analysis-body h1, .analysis-body h2, .analysis-body h3 {
  color: var(--accent-soft);
  margin-top: 16px;
  margin-bottom: 8px;
  font-size: 16px;
}

.analysis-body h1:first-child, .analysis-body h2:first-child, .analysis-body h3:first-child {
  margin-top: 0;
}

.analysis-body strong { color: var(--accent-soft); }
.analysis-body ul, .analysis-body ol { padding-left: 20px; margin: 8px 0; }
.analysis-body p { margin-bottom: 8px; }

.copy-btn {
  float: right;
  background: var(--bg);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  margin-bottom: 8px;
}
.copy-btn:hover { color: var(--text); }

.footer-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 24px;
  padding-bottom: 8px;
}

.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 14px 28px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 1000;
  display: none;
  pointer-events: none;
  backdrop-filter: blur(10px);
}
.toast.show { display: block; animation: fadeIn 0.2s ease; }

@media (max-width: 768px) {
  .workspace { flex-direction: column; }
  .history-sidebar {
    width: 100%;
    position: static;
    max-height: none;
  }
  .conv-list { max-height: 200px; }
  .gender-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .page { padding: 12px 12px 32px; }
  .header h1 { font-size: 24px; }
  .prob-value { font-size: 40px; }
  .chat-messages { max-height: 280px; }
  .msg { max-width: 94%; }
}
