/* 阿爪智能体 · 用户端样式（移动端优先） */
:root {
  --primary: #5b6cff;
  --primary-dark: #4453e0;
  --primary-soft: #eef0ff;
  --danger: #e5484d;
  --warn: #f5a524;
  --ok: #30a46c;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1a1d29;
  --text-sub: #6b7280;
  --text-weak: #9aa1b1;
  --line: #eceef4;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(20, 26, 60, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  padding-bottom: env(safe-area-inset-bottom);
}
input, textarea, button { font-family: inherit; font-size: 15px; }
a { color: inherit; text-decoration: none; }

/* ---------- 通用组件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 18px; border: none; border-radius: 10px;
  background: var(--primary); color: #fff; cursor: pointer;
  font-weight: 500; transition: .15s; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 8px 14px; font-size: 14px; }
.btn.tiny { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.btn.send { padding: 10px 18px; border-radius: 10px; }

.notice {
  background: #fff8e6; color: #8a5a00; border: 1px solid #ffe2a8;
  padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px;
}

/* ---------- 登录页 ---------- */
.auth-wrap { min-height: 100vh; padding: 60px 24px 40px; display: flex; flex-direction: column; }
.auth-brand { text-align: center; margin-bottom: 32px; }
.auth-logo { font-size: 56px; line-height: 1; margin-bottom: 12px; }
.auth-brand h1 { margin: 0 0 6px; font-size: 24px; font-weight: 600; letter-spacing: .5px; }
.auth-brand p { margin: 0; color: var(--text-sub); font-size: 14px; }
.auth-card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow);
}
.tabs { display: flex; gap: 6px; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.tab { flex: 1; text-align: center; padding: 9px; border-radius: 8px; cursor: pointer; color: var(--text-sub); font-weight: 500; }
.tab.active { background: #fff; color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.form input, .form textarea {
  width: 100%; padding: 13px 14px; margin-bottom: 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fbfbfd;
  outline: none; transition: .15s;
}
.form input:focus { border-color: var(--primary); background: #fff; }
.tip { text-align: center; color: var(--text-weak); font-size: 13px; margin-top: 6px; }
.tip b { color: var(--primary); }
.auth-foot { text-align: center; margin-top: 24px; }
.admin-link { color: var(--text-weak); font-size: 13px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 12px 16px; display: flex; align-items: center; gap: 10px;
  padding-top: calc(12px + env(safe-area-inset-top));
}
.tb-left, .tb-right { display: flex; align-items: center; }
.tb-title { font-size: 17px; font-weight: 600; }
.tb-sub { font-size: 12px; color: var(--text-weak); font-weight: 400; }
.tb-center { flex: 1; min-width: 0; }
.tb-center .tb-title, .tb-center .tb-sub {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tb-right { margin-left: auto; }
.tb-btn {
  background: none; border: none; font-size: 18px; cursor: pointer; padding: 4px 8px; color: var(--text-sub);
}
.back { background: none; border: none; font-size: 26px; line-height: 1; cursor: pointer; padding: 0 6px 0 0; color: var(--text); }
.points-chip {
  display: flex; align-items: center; gap: 5px;
  background: var(--primary-soft); color: var(--primary-dark);
  padding: 6px 12px; border-radius: 20px; font-weight: 600; font-size: 14px;
}
.pc-icon { font-size: 13px; }

/* ---------- 首页 ---------- */
.home-body { padding: 16px 16px 90px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 12px; }
.section-head:first-child { margin-top: 4px; }
.section-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.sh-sub { font-size: 12px; color: var(--text-weak); margin-left: 8px; }
.agent-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.agent-card {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); cursor: pointer; transition: .15s;
  display: flex; flex-direction: column; gap: 6px;
}
.agent-card:active { transform: scale(.98); }
.ac-emoji { font-size: 28px; line-height: 1; }
.ac-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.ac-badge {
  background: var(--primary-soft); color: var(--primary-dark);
  font-size: 11px; padding: 1px 6px; border-radius: 5px; font-weight: 500;
}
.ac-tag { font-size: 12px; color: var(--text-sub); line-height: 1.45; min-height: 34px; }
.ac-cost { font-size: 12px; color: var(--text-weak); }

.empty { text-align: center; padding: 28px 16px; color: var(--text-weak); font-size: 14px; }
.empty-icon { font-size: 34px; margin-bottom: 8px; }
.empty-sub { font-size: 12px; margin: 4px 0 14px; }

.referral { display: flex; flex-direction: column; gap: 10px; }
.ref-item {
  background: var(--card); border-radius: var(--radius); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow);
}
.ref-emoji { font-size: 22px; }
.ref-body { flex: 1; display: flex; flex-direction: column; }
.ref-body b { font-size: 14px; font-weight: 600; }
.ref-body small { color: var(--text-weak); font-size: 12px; }
.ref-item i { color: var(--text-weak); font-style: normal; }

/* ---------- 聊天页 ---------- */
.page-chat { display: flex; flex-direction: column; height: 100vh; }
.chat-topbar { flex-shrink: 0; }
.chat-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px; }
.chat-inner { max-width: 760px; margin: 0 auto; }
.msg { display: flex; margin-bottom: 16px; }
.msg-ai { justify-content: flex-start; }
.msg-me { justify-content: flex-end; }
.bubble {
  max-width: 82%; padding: 11px 14px; border-radius: 14px;
  font-size: 15px; line-height: 1.7; word-break: break-word; white-space: normal;
}
.msg-ai .bubble { background: #fff; border: 1px solid var(--line); border-top-left-radius: 4px; }
.msg-me .bubble { background: var(--primary); color: #fff; border-top-right-radius: 4px; }
.msg-foot { font-size: 11px; color: var(--text-weak); margin-top: 4px; text-align: right; }
.msg-ai .msg-foot { text-align: left; }
.typing { color: var(--text-weak); }
.typing::after { content: '…'; animation: dots 1.2s infinite; }
@keyframes dots { 0%,20% { opacity: .2 } 50% { opacity: 1 } 100% { opacity: .2 } }
.err { color: var(--danger); }

.chat-bottom {
  flex-shrink: 0; background: #fff; border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
.mode-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.mode-item {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--text-sub); cursor: pointer;
  padding: 4px 10px; border-radius: 16px; background: var(--bg);
}
.mode-item input { display: none; }
.mode-item:has(input:checked) { background: var(--primary-soft); color: var(--primary-dark); font-weight: 500; }
.mode-hint { margin-left: auto; font-size: 12px; color: var(--text-weak); }
.input-bar { display: flex; gap: 8px; align-items: flex-end; }
#chatInput {
  flex: 1; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); resize: none; outline: none; max-height: 120px; line-height: 1.5;
}
#chatInput:focus { border-color: var(--primary); background: #fff; }

/* ---------- 我的 ---------- */
.mine-body { padding: 16px 16px 90px; }
.mine-card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px;
}
.avatar {
  width: 46px; height: 46px; border-radius: 50%; background: var(--primary-soft);
  color: var(--primary-dark); display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 600; flex-shrink: 0;
}
.uc-info { flex: 1; min-width: 0; }
.uc-name { font-weight: 600; }
.uc-phone { font-size: 13px; color: var(--text-weak); }

.points-panel {
  margin-top: 14px; background: linear-gradient(135deg, #5b6cff, #7b5bff);
  color: #fff; border-radius: var(--radius); padding: 18px;
  display: flex; align-items: center; justify-content: space-between;
}
.pp-label { font-size: 13px; opacity: .85; }
.pp-num { font-size: 30px; font-weight: 700; line-height: 1.2; }
.pp-side { display: flex; gap: 18px; text-align: center; }
.pp-side div { display: flex; flex-direction: column; }
.pp-side span { font-size: 17px; font-weight: 600; }
.pp-side small { font-size: 11px; opacity: .85; }
.pp-actions { display: flex; gap: 10px; margin-top: 12px; }
.pp-actions .btn { flex: 1; }

.mine-list { margin-top: 16px; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.ml-item {
  padding: 15px 16px; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; border-bottom: 1px solid var(--line);
}
.ml-item:last-child { border-bottom: none; }
.ml-item:active { background: var(--bg); }
.ml-item i { color: var(--text-weak); font-style: normal; }

/* ---------- 表单块 ---------- */
.form-block { margin-bottom: 18px; }
.form-block label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.form-block .req { color: var(--danger); }
.form-block input, .form-block textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; outline: none; resize: vertical; line-height: 1.6;
}
.form-block input:focus, .form-block textarea:focus { border-color: var(--primary); }
.hint { font-size: 12px; color: var(--text-weak); margin-top: 6px; line-height: 1.5; }

.emoji-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.ep {
  width: 42px; height: 42px; border-radius: 10px; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; cursor: pointer; border: 2px solid transparent;
}
.ep.active { border-color: var(--primary); background: var(--primary-soft); }

.upload-zone {
  border: 1.5px dashed var(--line); border-radius: 12px; padding: 22px 16px;
  text-align: center; cursor: pointer; background: #fbfbfd;
}
.upload-zone:active { background: var(--primary-soft); }
.uz-icon { font-size: 28px; }
.uz-text { font-size: 14px; font-weight: 500; margin-top: 4px; }
.uz-sub { font-size: 12px; color: var(--text-weak); margin-top: 2px; }
.doc-list { margin-bottom: 10px; }
.doc-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px;
  font-size: 14px;
}
.doc-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-item small { color: var(--text-weak); }
.del-doc { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 13px; }

/* ---------- 充值 ---------- */
.redeem-row { display: flex; gap: 8px; }
.redeem-row input { flex: 1; }
.pkg-list { display: flex; flex-direction: column; gap: 10px; }
.pkg {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.pk-points { font-size: 17px; font-weight: 700; }
.pk-label { font-size: 13px; color: var(--text-weak); }
.pk-price { font-size: 16px; color: var(--primary); font-weight: 600; }

/* ---------- 明细 ---------- */
.ledger-filters {
  display: flex; gap: 8px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line);
}
.lf {
  padding: 6px 14px; border-radius: 16px; background: var(--bg);
  font-size: 13px; cursor: pointer; color: var(--text-sub);
}
.lf.active { background: var(--primary); color: #fff; }
.ledger-list { padding: 8px 16px 40px; }
.lg-item {
  background: #fff; border-radius: 12px; padding: 13px 15px; margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: var(--shadow);
}
.lg-main { flex: 1; min-width: 0; }
.lg-desc { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-meta { font-size: 11px; color: var(--text-weak); margin-top: 2px; }
.lg-amt { font-weight: 700; font-size: 16px; flex-shrink: 0; }
.lg-amt.minus { color: var(--text); }
.lg-amt.plus { color: var(--ok); }
.load-more { text-align: center; padding: 14px; color: var(--primary); cursor: pointer; font-size: 14px; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
  flex: 1; text-align: center; padding: 9px 0; font-size: 12px;
  color: var(--text-weak); cursor: pointer;
}
.tab-item span { display: block; font-size: 20px; line-height: 1.3; }
.tab-item.active { color: var(--primary); }

/* ---------- 弹窗 / Toast ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 18, 35, .45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  background: #fff; border-radius: 16px; padding: 20px; width: 100%; max-width: 340px;
}
.m-title { font-size: 17px; font-weight: 600; margin-bottom: 10px; }
.m-body { font-size: 14px; color: var(--text-sub); line-height: 1.7; }
.m-form { display: flex; flex-direction: column; gap: 10px; }
.m-form input {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; outline: none;
}
.m-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: rgba(26, 29, 41, .92); color: #fff; padding: 11px 20px;
  border-radius: 10px; font-size: 14px; z-index: 200; max-width: 84%; text-align: center;
}
.loading-mask {
  position: fixed; inset: 0; background: rgba(255,255,255,.5); z-index: 150;
  display: flex; align-items: center; justify-content: center;
}
.spinner {
  width: 34px; height: 34px; border: 3px solid var(--line);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* ---------- PC 宽屏适配 ---------- */
@media (min-width: 720px) {
  .agent-grid { grid-template-columns: repeat(3, 1fr); }
  .home-body, .mine-body { max-width: 860px; margin: 0 auto; }
  .auth-wrap { max-width: 420px; margin: 0 auto; padding-top: 90px; }
  .tabbar { display: none !important; }
  .bubble { max-width: 70%; }
}
