:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1f2329;
  --sub: #8a909c;
  --brand: #c8102e;        /* 汇智红 */
  --brand-ink: #ffffff;
  --bubble-bot: #ffffff;
  --bubble-user: #c8102e;
  --line: #e8eaed;
  --chip: #eef1f5;
  --brand-soft: #fff5f6;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; }

/* ============ 移动端（默认，H5 聊天形态，外观不变） ============ */
body { display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; }

/* ① 顶栏 */
.topbar { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.openpay-btn { display: inline-block; border: 0; border-radius: 12px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 600; padding: 5px 10px; line-height: 1; }
.openpay-btn[hidden] { display: none; }
.openpay-btn:active { opacity: .85; }
.status { font-size: 12px; color: var(--sub); background: var(--chip); padding: 4px 10px; border-radius: 12px; }
.status.member { color: var(--brand-ink); background: var(--brand); }

/* ④ 对话区容器（移动端：竖排占满） */
.chatwrap { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.chatcol { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }

/* ② 对话流 */
.chat { flex: 1 1 auto; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.msg { max-width: 82%; line-height: 1.6; font-size: 14px; padding: 10px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; }
.msg.bot { align-self: flex-start; background: var(--bubble-bot); border: 1px solid var(--line); }
.msg.user { align-self: flex-end; background: var(--bubble-user); color: #fff; }
.msg .src { display: block; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 11px; color: var(--sub); line-height: 1.6; }
.msg.tool-card { max-width: 92%; align-self: flex-start; background: var(--bubble-bot); border: 1px solid var(--line); }

/* Markdown 渲染样式（仅作用于 AI 回答气泡） */
.msg.bot { white-space: normal; max-width: 90%; }
.msg.bot > :first-child { margin-top: 0; }
.msg.bot > :last-child { margin-bottom: 0; }
.msg.bot h1, .msg.bot h2, .msg.bot h3, .msg.bot h4 { margin: 14px 0 8px; line-height: 1.35; color: var(--ink); }
.msg.bot h1 { font-size: 18px; }
.msg.bot h2 { font-size: 16px; }
.msg.bot h3 { font-size: 15px; }
.msg.bot h4 { font-size: 14px; }
.msg.bot p { margin: 8px 0; }
.msg.bot ul, .msg.bot ol { margin: 8px 0; padding-left: 22px; }
.msg.bot li { margin: 4px 0; }
.msg.bot strong { font-weight: 700; color: var(--ink); }
.msg.bot a { color: var(--brand); text-decoration: none; border-bottom: 1px solid rgba(200,16,46,.35); }
.msg.bot code { background: #f0f2f5; border-radius: 4px; padding: 1px 5px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; color: #c8102e; }
.msg.bot pre { background: #1f2329; color: #e6e8eb; border-radius: 8px; padding: 12px; overflow-x: auto; margin: 8px 0; }
.msg.bot pre code { background: transparent; color: inherit; padding: 0; font-size: 12px; white-space: pre; }
.msg.bot blockquote { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--brand); background: var(--brand-soft); color: var(--sub); border-radius: 0 8px 8px 0; }
.msg.bot blockquote p { margin: 4px 0; }
.msg.bot hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.msg.bot table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 12px; display: block; overflow-x: auto; }
.msg.bot th, .msg.bot td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.msg.bot th { background: #fafbfc; font-weight: 700; color: var(--ink); }
.typing { align-self: flex-start; color: var(--sub); font-size: 13px; padding: 6px 2px; }

/* ③ chips */
.chips { flex: 0 0 auto; display: flex; gap: 8px; overflow-x: auto; padding: 8px 14px; background: var(--bg); }
.chip { flex: 0 0 auto; font-size: 12px; color: var(--ink); background: var(--chip); padding: 6px 12px; border-radius: 14px; }
.chip:active { background: #dfe4ea; }

/* ④ 付费卡 */
.paycard-mask[hidden], .payqr[hidden], .membernav[hidden] { display: none; }
.paycard-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.paycard { width: 100%; max-width: 480px; background: #fff; border-radius: 16px 16px 0 0; padding: 20px 18px 24px; position: relative; }
.paycard-close { position: absolute; right: 14px; top: 10px; font-size: 22px; color: var(--sub); }
.paycard h3 { margin: 0 0 4px; font-size: 18px; }
.dev-badge { display: inline-block; margin: 0 0 12px; font-size: 11px; font-weight: 600; color: #fff; background: #e6a23c; border-radius: 10px; padding: 3px 10px; }
.dev-badge[hidden] { display: none; }
.paycard-sub { margin: 0 0 14px; font-size: 13px; color: var(--sub); }
.tier-row { display: flex; gap: 12px; }
.tier { flex: 1; border: 2px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.tier.active { border-color: var(--brand); background: var(--brand-soft); }
.tier-name { font-size: 13px; }
.tier-name .tag { display: inline-block; margin-left: 4px; font-size: 10px; color: #fff; background: var(--brand); border-radius: 8px; padding: 1px 5px; }
.tier-price { font-size: 20px; font-weight: 700; margin-top: 6px; }
.tier-price span { font-size: 12px; color: var(--sub); font-weight: 400; }
.payqr { margin-top: 16px; text-align: center; }
.payqr img { width: 180px; height: 180px; border: 1px solid var(--line); border-radius: 8px; }
.payqr-tip { font-size: 12px; color: var(--sub); margin: 8px 0; }
/* 微信 Native 扫码（对公）：客户端渲染二维码 */
.qrcode-box { display: inline-block; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; line-height: 0; }
.qrcode-box img, .qrcode-box canvas { display: block; width: 200px; height: 200px; }
.payqr-status { font-size: 12px; color: var(--brand); font-weight: 600; margin-top: 2px; }
.btn-paid { width: 100%; padding: 12px; border: 0; border-radius: 10px; background: var(--brand); color: #fff; font-size: 15px; font-weight: 600; }
.pay-note { margin-top: 12px; font-size: 11px; color: var(--sub); line-height: 1.5; }

/* ⑤ 输入栏 */
.inputbar { flex: 0 0 auto; display: flex; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); }
.inputbar input { flex: 1; border: 1px solid var(--line); border-radius: 20px; padding: 10px 14px; font-size: 14px; outline: none; }
.inputbar input:disabled { background: #f0f1f3; color: var(--sub); }
.inputbar button { flex: 0 0 auto; border: 0; border-radius: 20px; background: var(--brand); color: #fff; padding: 0 18px; font-size: 14px; font-weight: 600; }
.inputbar button:disabled { background: #d9a3ab; }

/* ⑥ 会员入口 */
.membernav { flex: 0 0 auto; display: flex; gap: 16px; justify-content: center; padding: 8px; background: var(--card); border-top: 1px solid var(--line); font-size: 12px; color: var(--brand); }
.membernav span { padding: 4px 10px; }

/* 桌面 / 移动端都隐藏的装饰块（默认隐藏，桌面 media query 内显示） */
.webnav, .webhero, .webaside { display: none; }

/* ============ 桌面端（≥ 820px）：品牌落地页 + 宽屏对话 ============ */
@media (min-width: 820px) {
  body { max-width: 1180px; min-height: 100vh; height: auto; padding: 0 24px 24px; }

  /* 移动顶栏隐藏，启用桌面导航 */
  .topbar { display: none; }
  .webnav { display: block; position: sticky; top: 0; z-index: 10; margin: 0 -24px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
  .webnav-inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; }
  .webnav-brand { display: flex; align-items: center; gap: 10px; }
  .webnav-logo { background: var(--brand); color: #fff; font-weight: 700; border-radius: 8px; padding: 4px 10px; font-size: 15px; }
  .webnav-name { font-weight: 700; font-size: 17px; }
  .webnav-links { display: flex; gap: 26px; font-size: 14px; }
  .webnav-links a { color: var(--ink); text-decoration: none; }
  .webnav-links a:hover { color: var(--brand); }
  .webnav-pay { border: 0; border-radius: 10px; background: var(--brand); color: #fff; font-size: 14px; font-weight: 600; padding: 8px 18px; cursor: pointer; }
  .webnav-pay:hover { opacity: .9; }

  /* Hero */
  .webhero { display: block; padding: 40px 0 28px; }
  .webhero-inner { display: grid; grid-template-columns: 1.1fr 1fr; gap: 36px; align-items: center; }
  .webhero-copy h1 { margin: 0 0 14px; font-size: 34px; line-height: 1.25; letter-spacing: -.5px; }
  .webhero-sub { margin: 0 0 22px; font-size: 15px; line-height: 1.7; color: var(--sub); }
  .webhero-cta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
  .hero-cta-primary { background: var(--brand); color: #fff; text-decoration: none; font-weight: 700; font-size: 15px; padding: 12px 26px; border-radius: 10px; }
  .hero-cta-primary:hover { opacity: .92; }
  .hero-cta-note { font-size: 13px; color: var(--sub); }
  .webhero-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .hcard { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
  .hcard-ico { font-size: 22px; }
  .hcard-t { font-weight: 700; font-size: 15px; margin: 6px 0 4px; }
  .hcard-d { font-size: 12px; color: var(--sub); line-height: 1.5; }

  /* 对话区：两栏（左能力栏 + 右对话），占满剩余视口高度 */
  .chatwrap { display: grid; grid-template-columns: 300px 1fr; gap: 24px; flex: 1 1 auto; min-height: 0; padding-top: 12px; }
  .webaside { display: block; align-self: start; }
  .webaside-block { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
  .webaside-block h4 { margin: 0 0 10px; font-size: 14px; color: var(--brand); }
  .webaside-block ul { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.9; color: var(--ink); }
  .webaside-tip { margin: 0; font-size: 12px; line-height: 1.6; color: var(--sub); }
  .webaside-faq p { margin: 0 0 10px; font-size: 12px; line-height: 1.6; color: var(--ink); }
  .webaside-faq p b { color: var(--ink); }

  .chatcol { border: 1px solid var(--line); border-radius: 14px; background: var(--bg); overflow: hidden; min-height: 0; }
  .chat { background: transparent; padding: 18px; }
  .chat .msg.bot { max-width: 96%; }
  .chips { padding: 10px 18px; }
  .inputbar { border-radius: 0; border-top: 1px solid var(--line); }
  .membernav { border-top: 1px solid var(--line); }

  /* 付费卡在桌面居中、圆角完整 */
  .paycard-mask { align-items: center; }
  .paycard { border-radius: 16px; max-width: 420px; }
}
