:root {
  --tab-bar-height: 0px;
  --mp-tabbar-height: calc(1.333rem + env(safe-area-inset-bottom, 0px));
  /* tip + chips + input + paddings，避免挡住小程序底部导航 */
  --mp-bottom-area-height: 5.2rem;
  --primary: #4F7CFF;
  --primary-dark: #3B66F0;
  --page-bg: #F3F5F9;
  --card: #FFFFFF;
  --text: #1A1A1A;
  --muted: #999999;
  --suggest-bg: #F5F6F8;
  --user-bubble: #4F7CFF;
  --accent: #4F7CFF;
  --accent-soft: #EAF0FF;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--page-bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.page {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--page-bg);
  display: flex;
  flex-direction: column;
}

.app-nav {
  position: relative;
  z-index: 12;
  flex-shrink: 0;
  height: calc(1.173rem + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-nav-title {
  font-size: 0.453rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.01em;
}

html.mp-tabbar-visible .app-nav {
  display: none;
}

.main-content {
  position: relative;
  z-index: 5;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.32rem 0.32rem 0.213rem;
}

.hero-card {
  background: var(--card);
  border-radius: 0.32rem;
  padding: 0.427rem 0.373rem 0.373rem;
  box-shadow: 0 0.027rem 0.16rem rgba(0, 0, 0, 0.04);
  animation: fade-up 0.4s ease-out;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(0.2rem); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.267rem;
  margin-bottom: 0.373rem;
}

.hero-hi {
  font-size: 0.453rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.45;
  padding-top: 0.107rem;
}

.hero-logo-wrap {
  position: relative;
  width: 1.6rem;
  height: 1.6rem;
  flex-shrink: 0;
}

.hero-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 50%;
}

.hero-logo-text {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.16rem;
  text-align: center;
  font-size: 0.213rem;
  font-weight: 600;
  color: #fff;
  line-height: 1;
  pointer-events: none;
}

.suggest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.213rem;
}

.suggest-header .label {
  font-size: 0.32rem;
  color: var(--muted);
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 0.08rem;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

.refresh-btn img {
  width: 0.293rem;
  height: 0.293rem;
}

.refresh-btn img.spin {
  animation: spin 0.6s linear;
}

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

.refresh-btn span {
  font-size: 0.293rem;
  color: var(--muted);
}

.suggest-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.213rem;
}

.suggest-item {
  display: flex;
  align-items: center;
  min-height: 1.067rem;
  padding: 0.293rem 0.32rem;
  background: var(--suggest-bg);
  border-radius: 0.213rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.suggest-item:active {
  transform: scale(0.99);
  background: #eceef3;
}

.suggest-item .icon {
  display: none;
}

.suggest-item .text {
  flex: 1;
  font-size: 0.373rem;
  color: var(--text);
  line-height: 1.4;
}

.suggest-item .arrow {
  width: 0.293rem;
  height: 0.293rem;
  flex-shrink: 0;
  opacity: 0.45;
  margin-left: 0.213rem;
}

.page.chatting .hero-card {
  display: none;
}

.chat-area {
  display: none;
  padding: 0.213rem 0.053rem 0.213rem;
}

.chat-area.visible {
  display: block;
  animation: fade-up 0.3s ease-out;
}

.msg {
  display: flex;
  margin-bottom: 0.373rem;
}

.msg.user {
  justify-content: flex-end;
}

.msg.ai {
  justify-content: flex-start;
}

.msg-bubble {
  max-width: 80%;
  padding: 0.293rem 0.373rem;
  border-radius: 0.32rem;
  font-size: 0.373rem;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg.user .msg-bubble {
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 0.08rem;
}

.msg.ai .msg-bubble {
  background: #fff;
  color: var(--text);
  border-bottom-left-radius: 0.08rem;
  box-shadow: 0 0.027rem 0.107rem rgba(0, 0, 0, 0.04);
}

.msg.ai.loading .msg-bubble {
  padding: 0.373rem 0.48rem;
}

.typing-dots {
  display: inline-flex;
  gap: 0.133rem;
  align-items: center;
}

.typing-dots span {
  width: 0.187rem;
  height: 0.187rem;
  border-radius: 50%;
  background: #999;
  animation: bounce 1.2s infinite ease-in-out;
}

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

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-0.133rem); opacity: 1; }
}

.bottom-area {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 20;
  padding: 0.16rem 0.32rem 0.267rem;
  padding-bottom: calc(0.267rem + env(safe-area-inset-bottom, 0));
  background: #fff;
  border-top: 0.013rem solid #eef0f4;
}

.ai-tip {
  text-align: center;
  font-size: 0.293rem;
  color: #b0b4bf;
  margin-bottom: 0.16rem;
}

.model-chips {
  display: flex;
  gap: 0.16rem;
  overflow-x: auto;
  padding: 0 0 0.213rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.model-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  display: flex;
  align-items: center;
  gap: 0.107rem;
  flex-shrink: 0;
  height: 0.64rem;
  padding: 0 0.24rem 0 0.16rem;
  background: #f5f6f8;
  border: 0.013rem solid transparent;
  border-radius: 999px;
  cursor: pointer;
}

.chip.active {
  background: var(--accent-soft);
  border-color: var(--primary);
}

.chip img {
  width: 0.373rem;
  height: 0.373rem;
  object-fit: contain;
  border-radius: 50%;
}

.chip span {
  font-size: 0.267rem;
  color: #555;
  white-space: nowrap;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 0.187rem;
}

.plus-btn,
.mic-btn {
  width: 0.8rem;
  height: 0.8rem;
  flex-shrink: 0;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.plus-btn img,
.mic-btn img {
  width: 0.587rem;
  height: 0.587rem;
  object-fit: contain;
  opacity: 0.75;
}

.mic-btn img {
  width: 0.453rem;
  height: 0.453rem;
  object-fit: contain;
  filter: invert(39%) sepia(98%) saturate(1800%) hue-rotate(210deg) brightness(100%);
}

.input-box {
  flex: 1;
  display: flex;
  align-items: center;
  height: 0.96rem;
  background: #f5f6f8;
  border-radius: 0.48rem;
  padding: 0 0.267rem;
  gap: 0.133rem;
  min-width: 0;
}

.input-box input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.373rem;
  color: var(--text);
  min-width: 0;
}

.input-box input::placeholder {
  color: #b0b4bf;
}

.send-btn {
  flex-shrink: 0;
  height: 0.96rem;
  min-width: 1.493rem;
  padding: 0 0.373rem;
  border: none;
  border-radius: 0.213rem;
  background: var(--primary);
  color: #fff;
  font-size: 0.373rem;
  font-weight: 600;
  cursor: pointer;
}

.send-btn:active {
  background: var(--primary-dark);
}

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

.bottom-spacer {
  height: calc(4.4rem + var(--tab-bar-height));
}

/* 小程序 / App 嵌入 */
html.mp-tabbar-visible,
html.mp-tabbar-visible body {
  height: 100%;
  overflow: hidden;
}

html.mp-tabbar-visible .page {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  padding-bottom: calc(var(--mp-bottom-area-height) + var(--mp-tabbar-height));
  box-sizing: border-box;
}

html.mp-tabbar-visible .main-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

html.mp-tabbar-visible .bottom-spacer {
  display: none;
}

html.mp-tabbar-visible .bottom-area {
  position: fixed !important;
  bottom: var(--mp-tabbar-height) !important;
  left: 0 !important;
  right: 0;
  width: 100%;
  z-index: 20;
  padding: 0.12rem 0.32rem 0.16rem;
  padding-bottom: 0.16rem !important;
  background: #fff;
  border-top: 0.013rem solid #eef0f4;
  box-sizing: border-box;
}

html.mp-tabbar-visible .ai-tip {
  margin-bottom: 0.107rem;
}

html.mp-tabbar-visible .model-chips {
  padding: 0 0 0.16rem;
}

.mp-tabbar {
  display: none;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
  background: #fff;
  align-items: stretch;
}

html.mp-tabbar-visible .mp-tabbar {
  display: flex !important;
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0;
  z-index: 30;
  min-height: var(--mp-tabbar-height);
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -0.013rem 0 rgba(0, 0, 0, 0.06);
}

.mp-tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 1.333rem;
  min-width: 0;
  padding: 0;
  cursor: pointer;
}

.mp-tabbar-item.active {
  cursor: default;
}

.mp-tabbar-icon-wrap {
  width: 0.6rem;
  height: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mp-tabbar-icon {
  display: block;
  width: 0.587rem !important;
  height: 0.587rem !important;
  max-width: 0.587rem !important;
  max-height: 0.587rem !important;
  object-fit: contain;
  flex-shrink: 0;
}

.mp-tabbar-label {
  margin-top: 0.16rem;
  font-size: 0.32rem;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  color: #0D160E;
}
