* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --green: #07c160;
  --green-hover: #06ad56;
  --bg: #ededed;
  --chat-bg: #ebebeb;
  --white: #ffffff;
  --text: #111;
  --text-sub: #999;
  --border: #d9d9d9;
  --bubble-self: #95ec69;
  --bubble-other: #ffffff;
  --header-bg: #ededed;
  --footer-bg: #f7f7f7;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  overflow: hidden;
}

/* === Views === */
.view {
  display: none;
  height: 100%;
  width: 100%;
}
.view.active {
  display: flex;
}

/* === 选择页 === */
#view-select {
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.select-container {
  max-width: 380px;
  width: 100%;
  text-align: center;
}

.select-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.select-subtitle {
  color: var(--text-sub);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

/* === 加载过渡页 === */
#view-loading {
  align-items: center;
  justify-content: center;
  background: var(--bg);
  flex-direction: column;
}

.loading-container {
  text-align: center;
}

.loading-animation {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.loading-circle {
  width: 12px;
  height: 12px;
  background: var(--green);
  border-radius: 50%;
  animation: bounce 1.4s ease-in-out infinite;
}

.loading-circle.delay-1 {
  animation-delay: 0.16s;
}

.loading-circle.delay-2 {
  animation-delay: 0.32s;
}

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.loading-text {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.loading-subtext {
  font-size: 0.85rem;
  color: var(--text-sub);
  transition: opacity 0.3s;
}

/* 性别选择器 */
.gender-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.gender-btn {
  flex: 1;
  padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
}

.gender-btn .gender-icon {
  font-size: 1.3rem;
}

.gender-btn.active {
  border-color: var(--green);
  background: #e8f8ef;
}

.gender-btn:hover {
  border-color: var(--green);
}

.mbti-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.dimension {
  display: flex;
  gap: 8px;
}

.dim-btn {
  flex: 1;
  padding: 12px 6px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.15s;
}

.dim-btn span {
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-sub);
}

.dim-btn.active {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

.dim-btn.active span {
  color: rgba(255,255,255,0.8);
}

.btn-start {
  width: 100%;
  padding: 14px;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-start:hover {
  background: var(--green-hover);
}

/* === 聊天页 - 微信风格 === */
.wechat-chat {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 500px;
  margin: 0 auto;
  background: var(--chat-bg);
  position: relative;
}

/* 顶部栏 */
.wechat-header {
  height: 48px;
  background: var(--header-bg);
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  flex-shrink: 0;
}

.wechat-back {
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--text);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wechat-title {
  font-size: 1rem;
  font-weight: 500;
}

.mbti-badge {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--green);
  background: rgba(7, 193, 96, 0.1);
  padding: 1px 6px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

.wechat-more {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text);
  cursor: pointer;
  padding: 4px 8px;
}

/* === 下拉菜单 === */
.dropdown-menu {
  position: absolute;
  top: 48px;
  right: 12px;
  background: #4c4c4c;
  border-radius: 6px;
  padding: 4px 0;
  z-index: 100;
  min-width: 150px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  animation: fadeInMenu 0.15s ease;
}

.dropdown-menu.hidden {
  display: none;
}

@keyframes fadeInMenu {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-menu::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 16px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #4c4c4c;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  color: #fff;
  font-size: 0.88rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.dropdown-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.dropdown-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  margin: 4px 0;
}

/* === AI 资料面板 === */
.profile-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: slideInRight 0.25s ease;
}

.profile-panel.hidden {
  display: none;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.profile-card {
  background: var(--white);
  border-radius: 12px;
  max-width: 340px;
  width: 100%;
  overflow: hidden;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 24px 20px 16px;
  border-bottom: 1px solid #f0f0f0;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-name {
  font-size: 1.1rem;
  font-weight: 600;
}

.profile-details {
  padding: 12px 20px;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f5f5f5;
}

.profile-row:last-child {
  border-bottom: none;
}

.profile-label {
  font-size: 0.88rem;
  color: var(--text-sub);
}

.profile-value {
  font-size: 0.88rem;
  color: var(--text);
}

.profile-close {
  width: 100%;
  padding: 14px;
  background: none;
  border: none;
  border-top: 8px solid #f5f5f5;
  font-size: 0.95rem;
  color: var(--green);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.profile-close:hover {
  background: #f9f9f9;
}

/* === 朋友圈面板 === */
.moments-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 50;
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.25s ease;
}

.moments-panel.hidden {
  display: none;
}

.moments-header {
  height: 48px;
  background: #ededed;
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  flex-shrink: 0;
}

.moments-title {
  font-size: 1rem;
  font-weight: 500;
}

.moments-cover {
  height: 200px;
  background: linear-gradient(135deg, #2d2b55 0%, #0a0a23 100%);
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 16px;
  gap: 10px;
}

.moments-user-avatar {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 2px solid #fff;
  object-fit: cover;
}

.moments-username {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  margin-bottom: 8px;
}

.moments-list {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.moment-item {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-bottom: 0.5px solid #f0f0f0;
  background: var(--white);
}

.moment-avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.moment-content {
  flex: 1;
}

.moment-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #576b95;
  margin-bottom: 4px;
}

.moment-text {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 6px;
}

.moment-time {
  font-size: 0.75rem;
  color: var(--text-sub);
}

/* 消息区域 */
.wechat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

/* 单条消息 */
.msg {
  display: flex;
  gap: 8px;
  max-width: 82%;
  align-items: flex-start;
}

.msg.self {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg.other {
  align-self: flex-start;
}

.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.msg-body {
  display: flex;
  flex-direction: column;
}

.msg.self .msg-body {
  align-items: flex-end;
}

.msg-bubble {
  padding: 9px 12px;
  border-radius: 4px;
  font-size: 0.93rem;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
}

.msg.other .msg-bubble {
  background: var(--bubble-other);
}

.msg.other .msg-bubble::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 12px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 6px solid var(--bubble-other);
}

.msg.self .msg-bubble {
  background: var(--bubble-self);
}

.msg.self .msg-bubble::before {
  content: '';
  position: absolute;
  right: -6px;
  top: 12px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 6px solid var(--bubble-self);
}

/* 打字指示器（三个跳动的点） */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: var(--bubble-other);
  border-radius: 4px;
  position: relative;
}

.typing-dots::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 10px;
  border: 5px solid transparent;
  border-right: 6px solid var(--bubble-other);
  border-left: none;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: dot-bounce 1.2s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* 时间标签 */
.msg-time {
  font-size: 0.65rem;
  color: var(--text-sub);
  margin-top: 3px;
  padding: 0 2px;
}

/* 时间分割线 */
.time-sep {
  align-self: center;
  font-size: 0.7rem;
  color: var(--text-sub);
  background: rgba(0,0,0,0.04);
  padding: 2px 10px;
  border-radius: 3px;
}

/* 底部输入栏 */
.wechat-footer {
  background: var(--footer-bg);
  border-top: 0.5px solid var(--border);
  padding: 8px 10px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.wechat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 0.93rem;
  font-family: inherit;
  resize: none;
  max-height: 90px;
  line-height: 1.4;
  outline: none;
  background: var(--white);
}

.wechat-input:focus {
  border-color: var(--green);
}

.wechat-send {
  height: 34px;
  padding: 0 14px;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.wechat-send:hover {
  background: var(--green-hover);
}

.wechat-send:disabled {
  background: #a0dcb4;
  cursor: not-allowed;
}

/* Scrollbar */
.wechat-messages::-webkit-scrollbar {
  width: 3px;
}
.wechat-messages::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.1);
  border-radius: 2px;
}

/* 表情按钮 */
.wechat-emoji-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: transform 0.15s;
  flex-shrink: 0;
}

.wechat-emoji-btn:hover {
  transform: scale(1.15);
}

/* 表情面板 */
.emoji-panel {
  background: var(--footer-bg);
  border-top: 0.5px solid var(--border);
  height: 220px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.emoji-panel.hidden {
  display: none;
}

.emoji-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}

.emoji-item {
  background: none;
  border: none;
  font-size: 1.5rem;
  padding: 6px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.1s;
  line-height: 1;
  text-align: center;
}

.emoji-item:hover {
  background: rgba(0, 0, 0, 0.06);
}

.emoji-item:active {
  transform: scale(0.9);
}

.emoji-tabs {
  display: flex;
  border-top: 0.5px solid var(--border);
  background: var(--white);
  padding: 4px 8px;
  gap: 4px;
}

.emoji-tab {
  background: none;
  border: none;
  font-size: 1.1rem;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 6px;
  opacity: 0.5;
  transition: all 0.15s;
}

.emoji-tab.active {
  opacity: 1;
  background: rgba(0, 0, 0, 0.05);
}

.emoji-tab:hover {
  opacity: 0.8;
}

/* === 公告弹窗 === */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: var(--white);
  border-radius: 12px;
  max-width: 340px;
  width: 100%;
  padding: 24px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.modal-body {
  text-align: left;
  margin-bottom: 20px;
}

.modal-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--green);
  margin-bottom: 8px;
}

.modal-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.modal-list li {
  font-size: 0.85rem;
  color: #555;
  padding: 4px 0;
  padding-left: 16px;
  position: relative;
}

.modal-list li::before {
  content: '·';
  position: absolute;
  left: 4px;
  color: var(--green);
  font-weight: bold;
}

.modal-tip {
  font-size: 0.8rem;
  color: var(--text-sub);
  background: #f9f9f9;
  padding: 10px 12px;
  border-radius: 6px;
  text-align: center;
  line-height: 1.5;
}

.modal-close {
  width: 100%;
  padding: 12px;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.modal-close:hover {
  background: var(--green-hover);
}

/* === PC 端：桌面微信窗口风格 === */
@media (min-width: 768px) {
  html, body {
    background: #e3e3e3;
  }

  /* 选择页居中卡片 */
  #view-select {
    background: #e3e3e3;
  }

  .select-container {
    background: var(--white);
    padding: 40px 36px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  }

  /* 加载页 */
  #view-loading {
    background: #e3e3e3;
  }

  .loading-container {
    background: var(--white);
    padding: 60px 48px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  }

  /* 聊天页 - 桌面微信窗口（全屏大窗口） */
  #view-chat {
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: #e3e3e3;
  }

  .wechat-chat {
    max-width: 100%;
    width: 100%;
    height: 96vh;
    max-height: none;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    border: 1px solid var(--border);
  }

  /* 桌面版头部更高 */
  .wechat-header {
    height: 56px;
    padding: 0 20px;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
  }

  .dropdown-menu {
    top: 56px;
    right: 20px;
  }

  .wechat-title {
    font-size: 1.05rem;
  }

  .wechat-back {
    font-size: 1.3rem;
  }

  /* 消息区域加大 padding */
  .wechat-messages {
    padding: 20px 40px;
    gap: 14px;
  }

  .msg {
    max-width: 65%;
  }

  .msg-avatar {
    width: 42px;
    height: 42px;
  }

  .msg-bubble {
    padding: 10px 14px;
    font-size: 0.95rem;
  }

  /* 底部输入栏 - 桌面版更宽松 */
  .wechat-footer {
    padding: 12px 20px;
    gap: 12px;
  }

  .wechat-input {
    padding: 10px 14px;
    font-size: 0.95rem;
    border-radius: 6px;
  }

  .wechat-send {
    height: 38px;
    padding: 0 20px;
    font-size: 0.9rem;
    border-radius: 6px;
  }

  /* 表情面板 - 桌面版更大 */
  .emoji-panel {
    height: 260px;
  }

  .emoji-grid {
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    padding: 4px;
  }

  .emoji-item {
    font-size: 1.6rem;
    padding: 8px;
  }
}

/* === 超宽屏 - 限制最大宽度避免太散 === */
@media (min-width: 1400px) {
  .wechat-chat {
    max-width: 1100px;
  }

  .wechat-messages {
    padding: 24px 80px;
  }

  .msg {
    max-width: 55%;
  }
}
