/* ===================== 基础 ===================== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #f4f5f9;
  --card: #ffffff;
  --text: #1b1d2a;
  --text-2: #6b7080;
  --text-3: #a2a7b6;
  --line: #eef0f6;
  --brand: #7c5cf5;
  --grad: linear-gradient(120deg, #5b8cff 0%, #7c5cf5 55%, #a45cf5 100%);
  --shadow: 0 6px 18px rgba(24, 28, 60, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
html, body { height: 100%; overflow-x: hidden; }
body {
  background: #eceef4;
  color: var(--text);
  font: 400 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; }
button, input, textarea { font: inherit; color: inherit; border: 0; background: none; outline: none; }
button { cursor: pointer; }

.phone {
  position: absolute;                              /* 用 left+translate 居中，避免布局框比视口宽时 auto margin 失效被裁切 */
  left: 50%;
  top: 0;
  width: 375px;                                    /* 设计稿固定宽，整体等比缩放 */
  height: var(--phone-h, 100%);                 /* JS 注入：固定为一屏高，内容超出由内部滚动 */
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(-50%) scale(var(--k, 1));
  transform-origin: top center;
}

/* ===================== 顶部 ===================== */
.header {
  flex: none;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.header__title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .5px;
  margin-bottom: 12px;
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px 0 12px;
  background: #f2f3f8;
  border-radius: 20px;
}
.search__icon { width: 18px; height: 18px; fill: #9aa0b2; flex: none; }
.search__input { flex: 1; min-width: 0; font-size: 14px; background: none; }
.search__input::placeholder { color: #a8adbc; }
.search__input::-webkit-search-cancel-button { display: none; }
.search__clear { display: none; width: 18px; height: 18px; flex: none; }
.search__clear svg { width: 100%; height: 100%; fill: #b6bac7; }
.search__clear.is-show { display: block; }

/* ===================== 内容区 ===================== */
.main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px calc(20px + var(--safe-b));
}

/* ===================== banner ===================== */
.banner {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 18px 14px 18px 18px;
  border-radius: 16px;
  background: var(--grad);
  box-shadow: 0 8px 20px rgba(100, 90, 240, .25);
  text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.banner:active { transform: scale(.985); box-shadow: 0 4px 12px rgba(100, 90, 240, .22); }
.banner::after {
  content: "";
  position: absolute;
  right: -30px; top: -46px;
  width: 150px; height: 150px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.banner__text { position: relative; z-index: 1; min-width: 0; }
.banner__title { color: #fff; font-size: 18px; font-weight: 700; }
.banner__desc { margin-top: 6px; color: rgba(255, 255, 255, .85); font-size: 11px; line-height: 1.6; }
.banner__right { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; flex: none; }
.robot { width: 62px; height: 60px; }
.robot__svg { width: 100%; height: 100%; filter: drop-shadow(0 4px 8px rgba(20, 16, 60, .18)); }
.banner__go {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(20, 16, 60, .18);
  flex: none;
}
.banner__go svg { width: 16px; height: 16px; fill: var(--brand); }

/* ===================== 板块 ===================== */
.block { margin-top: 20px; }
.block__head { display: flex; align-items: center; margin-bottom: 12px; }
.block__bar { width: 4px; height: 15px; border-radius: 2px; background: var(--grad); margin-right: 8px; }
.block__title { font-size: 16px; font-weight: 700; }
.block__more { margin-left: auto; font-size: 12px; color: var(--text-3); }
.block__more .dot { font-style: normal; font-size: 14px; margin-left: 2px; }

/* ===================== 功能卡片 ===================== */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:active { transform: scale(.97); box-shadow: 0 2px 8px rgba(24, 28, 60, .08); }
.card__ico { width: 40px; height: 40px; flex: none; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.card__ico svg { width: 22px; height: 22px; }
.card__body { min-width: 0; }
.card__name { font-size: 14px; font-weight: 600; white-space: nowrap; }
.card__desc { margin-top: 3px; font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tip { margin: 22px 0 6px; text-align: center; font-size: 11px; color: #b8bcc9; }

/* ===================== Toast ===================== */
.toast {
  position: fixed;
  left: 50%; bottom: 12%;
  transform: translate(-50%, 12px);
  max-width: 78%;
  padding: 9px 16px;
  border-radius: 20px;
  background: rgba(20, 22, 36, .88);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 99;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ===================== 对话页 ===================== */
.chat { position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column; z-index: 10; }
.chat__head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 50px;
  padding: env(safe-area-inset-top, 0px) 14px 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.chat__back { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; }
.chat__back svg { width: 20px; height: 20px; fill: var(--text); }
.chat__name { font-size: 16px; font-weight: 600; }
.chat__model { margin-left: auto; font-size: 11px; color: var(--text-3); }

.chat__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 14px 6px;
  transition: max-height .26s cubic-bezier(.22, .8, .3, 1);
}
.msg { display: flex; gap: 9px; margin-bottom: 16px; }
.msg__av { width: 30px; height: 30px; flex: none; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.msg__av svg { width: 17px; height: 17px; }
.msg__av--ai { background: var(--grad); }
.msg__av--ai svg { fill: #fff; }
.msg__av--me { background: #e9ebf3; }
.msg__av--me svg { fill: #6b7080; }
.bubble {
  max-width: calc(100% - 46px);
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.65;
  background: #fff;
  box-shadow: var(--shadow);
  word-break: break-word;
  white-space: pre-wrap;
}
.msg--me { flex-direction: row-reverse; }
.msg--me .bubble { background: var(--grad); color: #fff; }
.bubble--wait::after {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--brand);
  animation: blink 1s infinite;
}
@keyframes blink { 0%, 100% { opacity: .2 } 50% { opacity: 1 } }

.chat__bar {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px calc(8px + var(--safe-b));
  background: #fff;
  border-top: 1px solid var(--line);
}
/* 输入时输入框上移居中，避开软键盘；输入结束回到底部 */
.chat.is-typing .chat__body { max-height: 44%; }
.chat.is-typing .chat__bar,
.chat.is-typing-out .chat__bar {
  position: absolute;
  left: 14px; right: 14px;
  top: 50%;
  bottom: auto;
  z-index: 3;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(18, 20, 40, .16);
  transform: translateY(-50%);
  animation: barUp .24s cubic-bezier(.22, .8, .3, 1);
}
.chat.is-typing-out .chat__bar { animation: barDown .2s ease forwards; }
@keyframes barUp { from { opacity: 0; transform: translateY(calc(-50% + 26px)) } }
@keyframes barDown { to { opacity: 0; transform: translateY(calc(-50% + 26px)) } }
.chat__input {
  flex: 1;
  min-width: 0;
  max-height: 96px;
  padding: 9px 13px;
  border-radius: 19px;
  background: #f2f3f8;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  overflow-y: auto;
}
.chat__send {
  flex: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(110, 90, 240, .3);
}
.chat__send svg { width: 18px; height: 18px; fill: #fff; }
.chat__send:disabled { background: #d3d6e0; box-shadow: none; }

.quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 8px; }
.quick__item {
  padding: 6px 12px;
  border-radius: 15px;
  background: #fff;
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--text-2);
}
