:root {
  /* 金融风格主色：深海军蓝 + 金色点缀 */
  --blue: #2b4acb;
  --blue-2: #4a63db;
  --blue-d: #1f38a8;
  --gold: #f3c35b;
  --ink: #14171f;
  --ink-2: #5c667a;
  --ink-3: #9aa4b6;
  --line: rgba(16, 24, 40, 0.07);
  --bg: #eef1f6;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

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

html,
body {
  height: 100%;
  overflow: hidden; /* 禁止整页滚动与橡皮筋，App 里只有内容区滚动 */
  overscroll-behavior: none;
  /* 默认底色跟页面主色一致：万一视口高度算出偏差，底部露出的是一条浅色而不是深灰块 */
  background: #fff;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "HarmonyOS Sans SC",
    "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation; /* 干掉双击缩放与 300ms 延迟 */
}

button {
  font: inherit;
  color: inherit;
}

/* ---------- 应用外壳 ---------- */
/* 默认铺满整个屏幕；只有键盘真的弹出时，才由 html.kb-open 切到 JS 算出的"看得见的高度"。
     以前是无条件用 --app-h，一旦 WebKit 没把 visualViewport 还原回来，
     外壳就永远矮一截，屏幕底部露出一条灰边（图片预览浮层同样被算矮）。 */
#app {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: 100vh;
  height: 100dvh;
  /* dvh 不可靠：iOS 从别的网页/新标签返回时，Safari 的工具栏状态变了但 dvh 不重算，
       外壳会停在旧高度，屏幕底部露出一条白边。这里用脚本采样到的真实视口高度覆盖它。 */
  height: var(--vh100, 100dvh);
  background: #fff;
  overflow: hidden;
}
html.kb-open #app {
  top: var(--app-top, 0px);
  height: var(--app-h, 100dvh);
}
/* 老浏览器没有 dvh（iOS < 15.4 等）：退回用脚本算的高度，免得 100vh 把输入框顶到工具栏后面 */
@supports not (height: 100dvh) {
  #app {
    top: var(--app-top, 0px);
    height: var(--app-h, 100vh);
  }
  html.kb-open #app {
    top: var(--app-top, 0px);
    height: var(--app-h, 100vh);
  }
}

#stack {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
}
.view.active {
  display: flex;
}

/* 聊天详情：从右侧滑入，盖住 tabbar */
.view[data-view="chat"] {
  display: flex;
  z-index: 20;
  background: var(--bg);
  transform: translateX(100%);
  visibility: hidden;
  box-shadow: -8px 0 26px rgba(16, 24, 40, 0.13);
  transition:
    transform 0.28s cubic-bezier(0.32, 0.8, 0.26, 1),
    visibility 0.28s;
}
.view[data-view="chat"].active {
  transform: none;
  visibility: visible;
}

/* ---------- 顶部页头（列表 / 通讯录 / 借钱 / 我的） ---------- */
.page-hd {
  flex-shrink: 0;
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: calc(var(--safe-t) + 10px) calc(14px + var(--safe-r)) 10px calc(16px + var(--safe-l));
  background: #fff;
  border-bottom: 1px solid var(--line);
}
/* APK 沉浸式状态栏：将状态栏空间纳入页头，保持标题与背景连成一体。 */
html.sxq-in-app .page-hd,
html.sxq-in-app .chat-hd {
  padding-top: calc(var(--android-status, 24px) + 10px);
}
.brand {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.pill {
  font-style: normal;
  font-size: 10px;
  font-weight: 600;
  color: var(--blue);
  background: #eef3ff;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.3px;
}
.hd-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.hd-btn {
  width: 38px;
  height: 38px;
  border: none;
  background: none;
  border-radius: 50%;
  color: #38404f;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.16s ease,
    transform 0.12s ease;
}
.hd-btn:active {
  background: #f1f3f7;
  transform: scale(0.92);
}

/* 搜索条 */
.search-bar {
  display: none;
  flex: 1;
  align-items: center;
  gap: 8px;
}
.page-hd.searching .brand,
.page-hd.searching .hd-actions {
  display: none;
}
.page-hd.searching .search-bar {
  display: flex;
}
.search-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: #f2f4f8;
  border-radius: 16px;
  padding: 8px 14px;
  font-size: 15px;
  color: var(--ink);
  -webkit-user-select: text;
  user-select: text;
}
.search-cancel {
  border: none;
  background: none;
  color: var(--blue);
  font-size: 14.5px;
  padding: 4px 2px;
}

/* ---------- 滚动区 ---------- */
.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  padding-bottom: calc(70px + var(--safe-b));
  scrollbar-width: none;
}
.scroll::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* ---------- 会话列表 ---------- */
.conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  transition: background 0.16s ease;
}
.conv-item:active {
  background: #f4f5f8;
}
.cava {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 13px;
  background: #eef1f7;
  color: var(--blue);
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.cava img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cmain {
  flex: 1;
  min-width: 0;
}
.ctop {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cname {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ctime {
  flex-shrink: 0;
  font-size: 11.5px;
  color: #a2aab8;
}
.cbot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}
.cprev {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  color: #8b95a6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item.unread .cprev {
  color: #6b7686;
}
.cbdg {
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ff3b30;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tagline {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: 5px;
  color: #b26a00;
  background: #fff4e0;
}
.tagline.off {
  color: #7b8494;
  background: #f0f2f6;
}

/* 分区标题 */
.sect-title {
  font-size: 12.5px;
  color: #98a1b0;
  padding: 16px 16px 8px;
  letter-spacing: 0.3px;
}

/* 服务通知卡片（首页版，加大） */
.notice {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 14px;
  padding: 18px 16px;
  background: #f7f9fc;
  border-radius: 16px;
}
.notice-ico {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(160deg, #4a63db, var(--blue));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.notice-main {
  flex: 1;
  min-width: 0;
}
.notice-title {
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.notice-text {
  font-size: 15.5px;
  color: #e02020;
  font-weight: 500;
  margin-top: 5px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.foot-tip {
  text-align: center;
  font-size: 11.5px;
  color: #b3bac6;
  padding: 26px 20px 10px;
  line-height: 1.6;
}

/* ---------- 通用列表单元 ---------- */
.cells {
  background: #fff;
}
.cell {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  width: 100%;
  border: none;
  background: #fff;
  text-align: left;
  position: relative;
}
/* 作者样式 .cell{display:flex} 会盖掉浏览器默认的 [hidden]{display:none}，
     导致 JS 里 wrap.hidden=true 形同虚设（iOS 16.4 以下会看到点了就报错的锁屏通知行） */
.cell[hidden] {
  display: none;
}
.cell:active {
  background: #f4f5f8;
}
.cell + .cell::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 0;
  top: 0;
  height: 1px;
  background: var(--line);
}
.cell-ico {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 8px;
  background: #eef3ff;
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cell-main {
  flex: 1;
  min-width: 0;
  font-size: 15.5px;
}
.cell-sub {
  display: block;
  font-size: 12.5px;
  color: #98a1b0;
  margin-top: 2px;
}
.cell-arrow {
  color: #c6ccd6;
  flex-shrink: 0;
}
.cell-ico.warn {
  background: #fff1e4;
  color: #d97a26;
}

/* 开关 */
.switch {
  width: 46px;
  height: 27px;
  flex-shrink: 0;
  border: none;
  border-radius: 14px;
  background: #dfe3ea;
  position: relative;
  transition: background 0.2s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.2);
  transition: transform 0.22s cubic-bezier(0.3, 0.8, 0.3, 1);
}
.switch.on {
  background: #34c759;
}
.switch.on::after {
  transform: translateX(19px);
}

/* ---------- 通讯录 ---------- */
.contact-card {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 0 16px;
  padding: 16px 15px;
  border-radius: 16px;
  background: linear-gradient(135deg, #23349b 0%, #2b4acb 45%, #4a6ae0 100%);
  box-shadow: 0 9px 22px rgba(43, 74, 203, 0.28);
  position: relative;
  overflow: hidden;
}
.contact-card::after {
  content: "";
  position: absolute;
  right: -34px;
  top: -46px;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
}
.contact-card .cava {
  width: 50px;
  height: 50px;
  border-radius: 15px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6);
}
.contact-name {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #fff;
}
.contact-sub {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.82);
  margin-top: 4px;
}
.contact-go {
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  border: none;
  background: #fff;
  color: var(--blue);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(9, 18, 48, 0.18);
}
.contact-go:active {
  transform: scale(0.95);
}
