/* ── 全局 ─────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: #f5f5f5;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  color: #1a1a2e;
  font-size: 15px;
}

/* ── #app 容器 ─────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ── 页面通用 ─────────────────────────────── */
.page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ── 激活页 #page-activate ────────────────── */
#page-activate {
  align-items: center;
  padding: 32px 24px 24px;
  gap: 20px;
  background: #fff;
  overflow-y: auto;
}

.logo-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  object-fit: cover;
  display: block;
}

.title {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a2e;
  text-align: center;
}

.subtitle {
  font-size: 14px;
  color: #888;
  text-align: center;
}

/* ── 标签切换 ────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  border: 1.5px solid #3d4fe2;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: #fff;
}

.tab {
  padding: 8px 24px;
  font-size: 14px;
  font-weight: 600;
  color: #3d4fe2;
  background: #fff;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
}

.tab.active {
  background: #3d4fe2;
  color: #fff;
}

.tab:not(.active):hover {
  background: #f0f2ff;
}

/* ── 标签内容 ────────────────────────────── */
.tab-content {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 360px;
}

.tab-content.active { display: flex; }

/* ── 输入框 ─────────────────────────────── */
.input {
  width: 100%;
  border: 1.5px solid #ddd;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  resize: none;
  transition: border-color 0.2s;
  background: #fff;
  text-align: center;
  letter-spacing: 2px;
}

.input:focus { border-color: #3d4fe2; }

/* ── 按钮 ─────────────────────────────── */
.btn {
  border: none;
  border-radius: 24px;
  padding: 12px 40px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
  max-width: 280px;
}

.btn-primary {
  background: #3d4fe2;
  color: #fff;
}

.btn-primary:hover { background: #2d3fc2; }
.btn-primary:active { background: #1d2fb2; }

/* ── 提示和消息 ─────────────────────────── */
.trial-tip {
  font-size: 13px;
  color: #888;
  text-align: center;
}

.msg {
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 8px;
  text-align: center;
  min-height: 20px;
}

.msg.error {
  background: #fff0f0;
  color: #e74c3c;
}

.msg.success {
  background: #f0fff4;
  color: #27ae60;
}

/* ── 加载动画 ─────────────────────────── */
.loading {
  display: flex;
  justify-content: center;
  padding: 12px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e0e0e0;
  border-top-color: #3d4fe2;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── 对话页 #page-chat ─────────────────── */
#page-chat {
  height: 100%;
  background: #f5f5f5;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #1a1a2e;
  color: #fff;
  flex-shrink: 0;
}

.chat-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
}

.tier-badge {
  background: #3d4fe2;
  color: #fff;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.renew-banner {
  background: #fff3cd;
  color: #856404;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  border-bottom: 1px solid #ffeeba;
}

/* 激活页过期提示（红色，紧急感） */
.expire-notice {
  background: #f8d7da;
  color: #721c24;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  border-bottom: 1px solid #f5c6cb;
  margin: 0 14px;
  border-radius: 6px;
  margin-top: 10px;
}

.renew-link {
  color: #856404;
  font-weight: 700;
  text-decoration: none;
  font-size: 14px;
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #eee;
  flex-shrink: 0;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.chat-input {
  flex: 1;
  border: 1.5px solid #ddd;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.2s;
}

.chat-input:focus { border-color: #3d4fe2; }

.btn-send {
  background: #3d4fe2;
  color: #fff;
  border: none;
  border-radius: 22px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.btn-send:hover { background: #2d3fc2; }
.btn-send:active { background: #1d2fb2; }

/* ── 消息气泡 ─────────────────────────── */
.bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
}

.bubble-row.user {
  flex-direction: row-reverse;
}

.bubble-row.assistant {
  flex-direction: row;
}

.bubble-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.bubble-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bubble-row.user .bubble-avatar {
  background: #e8e8e8;
  /* 用户头像等微信授权后显示，现在留空 */
}

.bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble-row.user .bubble {
  background: #3d4fe2;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bubble-row.assistant .bubble {
  background: #fff;
  color: #1a1a2e;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.bubble.thinking {
  color: #888;
  font-style: italic;
}

/* ── 手机适配 ─────────────────────────────── */
@media (max-width: 480px) {
  .bubble { max-width: 88%; font-size: 15px; }
  #page-activate { padding: 24px 20px 20px; gap: 16px; }
  .title { font-size: 20px; }
  .logo { width: 56px; height: 56px; }
  .btn { max-width: 100%; }
  .tab { padding: 7px 18px; font-size: 13px; }
  .chat-input-area { padding: 8px 10px; }
  .btn-send { padding: 9px 16px; font-size: 14px; }
}
