:root {
  --bg: #f5f6fc;
  --ink: #12141f;
  --ink-2: #3d4256;
  --muted: #767c93;
  --line: #e7e9f3;
  --panel: rgba(255, 255, 255, 0.88);
  --brand: #5b5bf5;
  --brand-2: #8b5cf6;
  --brand-3: #ec4899;
  --brand-soft: #eef0fe;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 22px;
  --shadow-lg: 0 44px 80px -44px rgba(43, 38, 122, 0.5), 0 8px 26px -18px rgba(43, 38, 122, 0.28);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, textarea, input { font-family: inherit; }

/* ---------- 背景装饰 ---------- */
.bg-decor { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.blob { position: absolute; border-radius: 50%; filter: blur(10px); opacity: .55; }
.b1 {
  width: 620px; height: 620px; top: -220px; left: -120px;
  background: radial-gradient(circle at 30% 30%, #c7d2fe, rgba(199, 210, 254, 0));
  animation: float1 18s ease-in-out infinite;
}
.b2 {
  width: 720px; height: 720px; bottom: -320px; right: -180px;
  background: radial-gradient(circle at 60% 40%, #fbcfe8, rgba(251, 207, 232, 0));
  animation: float2 22s ease-in-out infinite;
}
.b3 {
  width: 520px; height: 520px; top: 38%; left: 46%;
  background: radial-gradient(circle at 50% 50%, #ddd6fe, rgba(221, 214, 254, 0));
  opacity: .5;
  animation: float1 26s ease-in-out infinite reverse;
}
.mesh {
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(91, 91, 245, 0.13) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(ellipse 68% 56% at 50% 40%, #000 20%, transparent 76%);
  -webkit-mask-image: radial-gradient(ellipse 68% 56% at 50% 40%, #000 20%, transparent 76%);
  opacity: .5;
}
@keyframes float1 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(26px, 34px, 0) scale(1.05); }
}
@keyframes float2 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(-30px, -22px, 0) scale(1.04); }
}

/* ---------- 布局 ---------- */
.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(420px, 0.98fr);
  gap: clamp(28px, 5vw, 76px);
  align-items: center;
  width: min(1240px, calc(100% - 64px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 40px 0;
}

/* ---------- 左侧介绍 ---------- */
.intro { max-width: 560px; }

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 650; letter-spacing: .2px;
  color: var(--ink-2);
  padding: 7px 14px 7px 8px;
  background: rgba(255, 255, 255, .7);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 999px;
  box-shadow: 0 6px 20px -12px rgba(43, 38, 122, .4);
  backdrop-filter: blur(8px);
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 9px;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 4px 12px -4px rgba(91, 91, 245, .8);
}
.brand-mark svg { width: 17px; height: 17px; }

.intro h1 {
  margin: 26px 0 18px;
  font-size: clamp(38px, 4.5vw, 60px);
  line-height: 1.1;
  letter-spacing: -2.2px;
  font-weight: 800;
}
.grad {
  background: linear-gradient(100deg, #4f46e5 0%, #7c3aed 46%, #db2777 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lede {
  margin: 0 0 30px;
  font-size: 16px;
  line-height: 1.75;
  color: var(--muted);
  max-width: 440px;
}

.features { list-style: none; margin: 0 0 34px; padding: 0; display: grid; gap: 14px; }
.features li {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 12px 14px;
  border-radius: 16px;
  transition: background .2s ease, transform .2s ease;
}
.features li:hover { background: rgba(255, 255, 255, .72); transform: translateX(2px); }
.features b { display: block; font-size: 14.5px; font-weight: 650; margin-bottom: 3px; }
.features span:not(.f-ico) { font-size: 13.5px; color: var(--muted); line-height: 1.6; }
.f-ico {
  flex: 0 0 38px;
  width: 38px; height: 38px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: #fff;
  box-shadow: 0 6px 16px -10px rgba(43, 38, 122, .5), inset 0 0 0 1px rgba(231, 233, 243, .9);
}
.f-ico svg { width: 19px; height: 19px; }
.f-ico.i1 { color: #6366f1; }
.f-ico.i2 { color: #0ea5e9; }
.f-ico.i3 { color: #ec4899; }

.metrics {
  display: flex; gap: 34px;
  padding-top: 24px;
  border-top: 1px solid rgba(91, 91, 245, .13);
}
.metrics b { display: block; font-size: 22px; font-weight: 750; letter-spacing: -.5px; }
.metrics span { font-size: 12px; color: var(--muted); }

/* ---------- 聊天卡片 ---------- */
.chat-card {
  display: flex;
  flex-direction: column;
  height: min(732px, calc(100dvh - 80px));
  min-height: 520px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, .95);
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px) saturate(1.2);
  overflow: hidden;
}

.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .72);
}
.avatar {
  flex: 0 0 42px;
  width: 42px; height: 42px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 16px; color: #fff;
  background: linear-gradient(135deg, #6366f1, #a855f7 60%, #ec4899);
  box-shadow: 0 8px 20px -10px rgba(124, 58, 237, .9), inset 0 0 0 1px rgba(255, 255, 255, .28);
  position: relative;
}
.avatar::after {
  content: ''; position: absolute; right: -2px; bottom: -2px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--ok);
  border: 2.5px solid #fff;
}
.avatar.sm { width: 30px; height: 30px; flex-basis: 30px; border-radius: 10px; font-size: 12px; }
.avatar.sm::after { display: none; }
.who { flex: 1; min-width: 0; }
.name { display: flex; align-items: center; gap: 7px; font-weight: 650; font-size: 15px; }
.badge-ai {
  font-size: 9.5px; font-weight: 700; letter-spacing: .6px;
  padding: 2px 6px; border-radius: 5px;
  color: #6366f1; background: var(--brand-soft);
  border: 1px solid #e0e2fd;
}
.status { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 11.5px; color: var(--muted); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(16, 185, 129, .14); }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(245, 158, 11, .16); }

.head-actions { display: flex; align-items: center; gap: 6px; }
.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 550;
  padding: 7px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all .18s ease;
}
.ghost:hover { border-color: #c7caf5; color: var(--brand); background: #fafaff; }
.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 10px;
  cursor: pointer;
  transition: all .18s ease;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--brand); border-color: #c7caf5; transform: rotate(-18deg); }

/* ---------- 消息区 ---------- */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px 8px;
  scroll-behavior: smooth;
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(238, 240, 254, .7), transparent 60%),
    linear-gradient(180deg, rgba(250, 250, 255, .5), rgba(255, 255, 255, 0));
}
.chat-body::-webkit-scrollbar { width: 7px; }
.chat-body::-webkit-scrollbar-thumb { background: #dcdfef; border-radius: 10px; }
.chat-body::-webkit-scrollbar-track { background: transparent; }

.msg-list { display: flex; flex-direction: column; gap: 18px; }

.msg { display: flex; gap: 10px; align-items: flex-end; animation: rise .32s cubic-bezier(.22, .9, .3, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg .avatar { flex: 0 0 30px; width: 30px; height: 30px; border-radius: 10px; font-size: 12px; }
.msg .avatar::after { display: none; }
.bubble-wrap { max-width: 84%; min-width: 0; }
.bubble {
  padding: 11px 14px;
  font-size: 14px;
  line-height: 1.72;
  border-radius: 16px 16px 16px 5px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 3px 10px -8px rgba(17, 24, 39, .4);
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble b { font-weight: 650; }
.bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  background: #f3f4fb;
  padding: 1px 5px;
  border-radius: 5px;
  color: #4338ca;
}
.bubble a { color: var(--brand); text-decoration: none; border-bottom: 1px solid rgba(91, 91, 245, .3); }
.bubble ul, .bubble ol { margin: 6px 0; padding-left: 20px; }
.bubble li { margin: 2px 0; }

.msg.user { justify-content: flex-end; }
.msg.user .bubble-wrap { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble {
  background: linear-gradient(135deg, #5b5bf5, #7c3aed);
  color: #fff;
  border: none;
  border-radius: 16px 16px 5px 16px;
  box-shadow: 0 10px 24px -14px rgba(91, 91, 245, .95);
}
.msg.agent .bubble { border-color: #ffe2b8; background: #fffdf7; }

.msg-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 7px;
  font-size: 10.5px;
  color: #9aa0b5;
}
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  background: #f4f5fb;
  border: 1px solid #eceef7;
  color: #7c8199;
  font-size: 10.5px;
  line-height: 1.5;
  cursor: default;
}
.tag.intent { background: #eef2ff; border-color: #e0e7ff; color: #4f46e5; font-weight: 600; }
.tag.kb { background: #f0f9ff; border-color: #e0f2fe; color: #0284c7; }
.tag.agent-tag { background: #fff7ed; border-color: #ffedd5; color: #c2410c; font-weight: 600; }
.tag.human-tag { background: #fff1f2; border-color: #ffe4e6; color: #be123c; font-weight: 600; }

.msg.system { justify-content: center; }
.msg.system .notice {
  font-size: 11.5px;
  color: #8b90a6;
  background: rgba(255, 255, 255, .8);
  border: 1px dashed #e3e6f2;
  padding: 5px 12px;
  border-radius: 999px;
  text-align: center;
  max-width: 90%;
}

/* 转人工横幅 */
.transfer-banner {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 14px;
  padding: 11px 14px;
  border-radius: 14px;
  background: linear-gradient(100deg, #fff7ed, #fff1f2);
  border: 1px solid #ffe4cc;
  color: #9a3412;
  font-size: 12.5px;
  animation: rise .3s ease both;
}
.transfer-banner .tb-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #f97316; flex: 0 0 8px;
  box-shadow: 0 0 0 4px rgba(249, 115, 22, .15);
  animation: pulse 1.5s infinite;
}
.transfer-banner b { font-weight: 650; }

/* 输入中 */
.typing { display: flex; align-items: flex-end; gap: 10px; padding: 12px 2px 6px; }
.dots {
  display: inline-flex; gap: 4px; align-items: center;
  background: #fff; border: 1px solid var(--line);
  padding: 12px 14px; border-radius: 16px 16px 16px 5px;
}
.dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #b9bdd2;
  animation: bounce 1.25s infinite ease-in-out;
}
.dots i:nth-child(2) { animation-delay: .16s; }
.dots i:nth-child(3) { animation-delay: .32s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---------- 底部输入 ---------- */
.chat-foot { padding: 8px 14px 14px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, .82); }
.chips {
  display: flex; gap: 7px; overflow-x: auto;
  padding: 6px 2px 10px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid #e3e5f4;
  background: #fff;
  color: #4b5069;
  font-size: 12.5px;
  cursor: pointer;
  transition: all .16s ease;
  white-space: nowrap;
}
.chip:hover { border-color: #b9bcf7; color: var(--brand); background: #fbfbff; transform: translateY(-1px); }

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 6px 6px 6px 14px;
  border: 1px solid #e3e6f2;
  border-radius: 16px;
  background: #fff;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.composer:focus-within { border-color: #b9bcf7; box-shadow: 0 0 0 4px rgba(91, 91, 245, .08); }
.composer textarea {
  flex: 1;
  border: 0;
  outline: 0;
  resize: none;
  font-size: 14px;
  line-height: 1.6;
  padding: 9px 0;
  max-height: 120px;
  color: var(--ink);
  background: transparent;
}
.composer textarea::placeholder { color: #a7abbe; }
.composer button[type="submit"] {
  flex: 0 0 40px;
  width: 40px; height: 40px;
  border-radius: 12px;
  border: none;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #5b5bf5, #8b5cf6);
  box-shadow: 0 8px 18px -10px rgba(91, 91, 245, .9);
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease;
}
.composer button svg { width: 18px; height: 18px; }
.composer button:hover { transform: translateY(-1px); }
.composer button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.foot-hint {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px 4px 0;
  font-size: 10.5px;
  color: #a3a8bd;
}
.foot-hint #aiHint { color: #9aa0b5; }

/* ---------- 满意度卡片 ---------- */
.rating-card {
  margin: 4px 0 6px;
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(150deg, #fbfbff, #f6f3ff);
  border: 1px solid #e9e6fb;
  animation: rise .3s ease both;
}
.rating-card h4 { margin: 0 0 3px; font-size: 13px; font-weight: 650; }
.rating-card p { margin: 0 0 10px; font-size: 11.5px; color: var(--muted); }
.stars { display: flex; gap: 4px; }
.star {
  width: 28px; height: 28px;
  border: 0; background: transparent; cursor: pointer;
  padding: 0;
  color: #ccd1e0;
  transition: transform .12s ease, color .12s ease;
}
.star svg { width: 26px; height: 26px; }
.star:hover { transform: scale(1.12) translateY(-1px); }
.star.on { color: #f59e0b; }
.stars:hover .star { color: #fbbf24; }
.stars .star:hover ~ .star { color: #d8dbe9; }
.rating-extra { margin-top: 10px; display: none; }
.rating-extra.show { display: block; }
.rating-extra textarea {
  width: 100%;
  border: 1px solid #e6e8f3;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12.5px;
  resize: none;
  outline: none;
  background: #fff;
}
.rating-extra textarea:focus { border-color: #c4c7f7; }
.rating-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.btn-sm {
  border: 1px solid #e3e6f2;
  background: #fff;
  color: var(--ink-2);
  font-size: 12px;
  padding: 7px 13px;
  border-radius: 9px;
  cursor: pointer;
}
.btn-sm.primary {
  background: linear-gradient(135deg, #5b5bf5, #8b5cf6);
  border-color: transparent;
  color: #fff;
  font-weight: 550;
  box-shadow: 0 8px 16px -10px rgba(91, 91, 245, .9);
}
.btn-sm:disabled { opacity: .6; cursor: default; }
.rated-tip { font-size: 11.5px; color: #059669; display: flex; align-items: center; gap: 5px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 34px;
  transform: translate(-50%, 20px);
  background: #1f2333;
  color: #fff;
  font-size: 12.5px;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 16px 36px -16px rgba(0, 0, 0, .6);
  opacity: 0;
  pointer-events: none;
  transition: all .24s ease;
  z-index: 60;
  max-width: 82vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .shell {
    grid-template-columns: 1fr;
    width: min(620px, calc(100% - 40px));
    gap: 24px;
    padding: 28px 0 32px;
  }
  .intro { max-width: none; }
  .intro h1 { font-size: clamp(32px, 8vw, 44px); margin: 20px 0 14px; letter-spacing: -1.4px; }
  .lede { margin-bottom: 20px; font-size: 14.5px; }
  .features { display: none; }
  .metrics { padding-top: 18px; gap: 28px; }
  .chat-card { height: min(680px, calc(100dvh - 120px)); }
}

@media (max-width: 640px) {
  .shell { width: 100%; padding: 0; gap: 0; min-height: 100dvh; }
  .intro { display: none; }
  .chat-card {
    height: 100dvh;
    min-height: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
    background: #fff;
  }
  .chat-head { padding: 12px 14px; }
  .chat-body { padding: 16px 14px 4px; }
  .chat-foot { padding: 6px 10px calc(10px + env(safe-area-inset-bottom)); }
  .bubble-wrap { max-width: 88%; }
  .foot-hint { font-size: 10px; }
  .toast { top: auto; bottom: calc(120px + env(safe-area-inset-bottom)); }
}

/* ---------- 嵌入模式 ---------- */
body.embed .bg-decor,
body.embed .intro { display: none; }
body.embed .shell {
  width: 100%;
  min-height: 100dvh;
  padding: 0;
  grid-template-columns: 1fr;
  gap: 0;
}
body.embed .chat-card {
  height: 100dvh;
  min-height: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
  background: #fff;
}
body.embed .chat-head { padding: 12px 14px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
