/* ===== 基础重置与移动端适配 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background: #0a0a0f;
  color: #e0e0e0;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app {
  height: 100vh;
  height: 100dvh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  position: relative;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.hidden {
  display: none !important;
}

/* ===== 引导页 ===== */
#onboarding {
  background: linear-gradient(180deg, #0a0a0f 0%, #1a1425 100%);
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.onboarding-content {
  max-width: 400px;
  width: 100%;
  margin: 0 auto;
  padding-bottom: 40px;
}

.logo {
  font-size: 56px;
  text-align: center;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #c9a96e, #e8d5a3);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#onboarding h1 {
  font-size: 24px;
  text-align: center;
  margin-bottom: 8px;
  color: #f0f0f0;
  font-weight: 600;
}

.subtitle {
  text-align: center;
  color: #888;
  font-size: 14px;
  margin-bottom: 32px;
}

/* ===== 表单 ===== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  color: #aaa;
  margin-bottom: 8px;
  font-weight: 500;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid #2a2a35;
  border-radius: 12px;
  background: #12121a;
  color: #e0e0e0;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: #c9a96e;
}

.date-row {
  display: flex;
  gap: 10px;
}

.date-row select {
  width: 90px;
  flex-shrink: 0;
}

.hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: #666;
}

/* 性别选择 */
.gender-select {
  display: flex;
  gap: 10px;
}

.gender-btn {
  flex: 1;
  padding: 14px;
  border: 1px solid #2a2a35;
  border-radius: 12px;
  background: #12121a;
  color: #888;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.gender-btn.active {
  border-color: #c9a96e;
  background: rgba(201, 169, 110, 0.1);
  color: #c9a96e;
}

/* 标签多选 */
.tags-select {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  padding: 8px 16px;
  border: 1px solid #2a2a35;
  border-radius: 20px;
  background: #12121a;
  color: #888;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.tag.active {
  border-color: #c9a96e;
  background: rgba(201, 169, 110, 0.15);
  color: #c9a96e;
}

/* 按钮 */
.btn-primary {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #c9a96e, #b8956a);
  color: #0a0a0f;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
  transition: opacity 0.2s;
}

.btn-primary:active {
  opacity: 0.85;
}

.btn-secondary {
  width: 100%;
  padding: 14px;
  border: 1px solid #2a2a35;
  border-radius: 12px;
  background: transparent;
  color: #888;
  font-size: 15px;
  cursor: pointer;
}

/* ===== 聊天页 ===== */
#chat-screen {
  background: #0a0a0f;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #1a1a25;
  flex-shrink: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c9a96e, #8b7355);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #0a0a0f;
}

.header-info h2 {
  font-size: 16px;
  font-weight: 600;
  color: #f0f0f0;
}

.status {
  font-size: 12px;
  color: #4caf50;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #888;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== 消息区域 ===== */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.system-hint {
  text-align: center;
  padding: 12px 16px;
  background: rgba(201, 169, 110, 0.08);
  border: 1px solid rgba(201, 169, 110, 0.15);
  border-radius: 12px;
  margin-bottom: 8px;
}

.system-hint span {
  font-size: 13px;
  color: #c9a96e;
  line-height: 1.5;
}

.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.6;
  word-break: break-word;
  animation: fadeInUp 0.3s ease;
}

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

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #c9a96e, #b8956a);
  color: #0a0a0f;
  border-bottom-right-radius: 4px;
}

.message.assistant {
  align-self: flex-start;
  background: #1a1a25;
  color: #e0e0e0;
  border-bottom-left-radius: 4px;
}

.message.assistant .msg-title {
  font-weight: 600;
  color: #c9a96e;
  margin-bottom: 6px;
  font-size: 14px;
}

.message.assistant table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}

.message.assistant th,
.message.assistant td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid #2a2a35;
}

.message.assistant th {
  color: #c9a96e;
  font-weight: 500;
  background: rgba(201, 169, 110, 0.05);
}

.message.assistant .highlight {
  color: #c9a96e;
  font-weight: 500;
}

.message.assistant .section-title {
  color: #c9a96e;
  font-weight: 600;
  margin-top: 12px;
  margin-bottom: 6px;
  font-size: 14px;
}

/* ===== 快捷操作 ===== */
.quick-actions {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.quick-actions::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  padding: 8px 16px;
  border: 1px solid #2a2a35;
  border-radius: 20px;
  background: #12121a;
  color: #aaa;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.chip:active {
  background: rgba(201, 169, 110, 0.15);
  border-color: #c9a96e;
  color: #c9a96e;
}

/* ===== 输入区 ===== */
.input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px max(16px, env(safe-area-inset-bottom));
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid #1a1a25;
  flex-shrink: 0;
}

.input-wrapper {
  flex: 1;
  background: #1a1a25;
  border-radius: 20px;
  padding: 8px 14px;
  max-height: 120px;
  overflow-y: auto;
}

#message-input {
  width: 100%;
  border: none;
  background: transparent;
  color: #e0e0e0;
  font-size: 15px;
  line-height: 1.4;
  outline: none;
  resize: none;
  font-family: inherit;
  max-height: 100px;
}

#message-input::placeholder {
  color: #555;
}

.voice-btn {
  flex-shrink: 0;
  font-size: 20px;
}

.send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #c9a96e, #b8956a);
  color: #0a0a0f;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

.send-btn svg {
  width: 18px;
  height: 18px;
}

.send-btn:active {
  opacity: 0.8;
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== 加载 ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 10, 15, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #2a2a35;
  border-top-color: #c9a96e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-overlay p {
  color: #c9a96e;
  font-size: 14px;
}

/* ===== 模态框 ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

.modal-content {
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  background: #12121a;
  border-radius: 20px 20px 0 0;
  padding: 20px;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 18px;
  color: #f0f0f0;
}

.close-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 18px;
  cursor: pointer;
}

#profile-display {
  margin-bottom: 16px;
}

.profile-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #1a1a25;
  font-size: 14px;
}

.profile-item .label {
  color: #888;
}

.profile-item .value {
  color: #e0e0e0;
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #2a2a35;
  border-radius: 2px;
}

/* ===== 响应式 ===== */
@media (min-width: 480px) {
  #app {
    max-width: 480px;
    margin: 0 auto;
    border-left: 1px solid #1a1a25;
    border-right: 1px solid #1a1a25;
  }
}

/* iPhone 安全区域 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .input-area {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

/* ===== 思考中动效 ===== */
.message.assistant.thinking {
  align-self: flex-start;
  background: #1a1a25;
  color: #888;
  border-bottom-left-radius: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  animation: fadeInUp 0.3s ease;
}

.thinking-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}

.thinking-dots span {
  width: 7px;
  height: 7px;
  background: #c9a96e;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
  opacity: 0.7;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }

.thinking-text {
  font-size: 14px;
  color: #999;
}

.message.assistant.stream {
  align-self: flex-start;
  background: #1e1e2a;
  color: #e0e0e0;
  border-bottom-left-radius: 4px;
  line-height: 1.7;
  font-size: 15px;
}

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
