/* 手机端聊天 App — 日语界面，陌陌风「附近的人」 */
:root {
  --blue: #1e8fff;
  --blue-dark: #1677d8;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #8a8f99;
  --red: #ff4d4f;
  --online: #3ecf6f;
  --radius: 14px;
  --tab-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* 外层容器：居中显示成手机样式（桌面预览友好） */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 30px rgba(0,0,0,.08);
}

/* 顶部栏 */
.topbar {
  background: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid #f0f0f0;
}
.topbar .title { font-size: 19px; font-weight: 700; }
.topbar .actions { display: flex; align-items: center; gap: 14px; }
.topbar .actions .btn {
  font-size: 14px; color: var(--blue); font-weight: 600; cursor: pointer;
  background: none; border: none; border-radius: 0; padding: 0;
  box-shadow: none; appearance: none; -webkit-appearance: none;
  display: inline-flex; align-items: center; white-space: nowrap; flex: none;
}
/* 通用按钮（避免浏览器默认 outset 黑边） */
.btn {
  border: none;
  border-radius: 22px;
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
  transition: filter .15s;
}
.btn:active { filter: brightness(.92); }
button { font-family: inherit; }
.topbar .icon-btn { width: 26px; height: 26px; display: grid; place-items: center; cursor: pointer; }
.topbar .icon-btn svg { width: 22px; height: 22px; }

/* 页面容器 */
.page { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(var(--tab-h) + var(--safe-b) + 8px); }
.page.hidden { display: none; }

/* 搜索栏 */
.searchbar { padding: 10px 14px; }
.searchbar input {
  width: 100%; border: none; background: #eef1f5; border-radius: 22px;
  padding: 10px 16px 10px 40px; font-size: 14px; outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a8f99' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 14px center;
}

/* 附近的人 卡片 */
.people-list { padding: 0 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: stretch; grid-auto-rows: 1fr; }
.person-card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,.04); position: relative;
  display: flex; flex-direction: column;
}
.person-avatar { width: 100%; aspect-ratio: 3/4; position: relative; background: #eef1f5; display: block; overflow: hidden; }
.person-avatar .init { font-size: 44px; font-weight: 700; color: #fff; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.person-avatar .online-dot { position: absolute; top: 8px; right: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--online); box-shadow: 0 0 0 2px #fff; }
.person-avatar .online-dot.off { background: #c9ced6; }
/* 会员专属边框 */
.person-avatar.member::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 3px solid #fa8c16;
  box-shadow: 0 0 0 2px rgba(250, 140, 22, 0.2);
  border-radius: 0 0 8px 8px;
}
/* 会员昵称标红 */
.member-tag {
  display: inline-block;
  font-size: 10px;
  background: #fa8c16;
  color: #fff;
  padding: 1px 4px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
}
/* 头像优化：更自然的渐变遮罩 */
.person-avatar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0) 70%, rgba(0,0,0,0.25) 100%);
  z-index: 1;
  pointer-events: none;
}
.person-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
  display: block;
}
.person-info { padding: 10px 12px 12px; display: flex; flex-direction: column; flex: 1; position: relative; }
.person-info .name-row { display: flex; align-items: center; gap: 6px; min-height: 21px; overflow: hidden; }
.person-info .name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-info .gender { font-size: 12px; flex: none; }
.person-info .meta { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-info .bio { font-size: 12px; color: #555; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 16px; }
.person-info .dist, .person-avatar .dist { position: absolute; bottom: 8px; left: 8px; right: auto; top: auto; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 10px; line-height: 1.4; z-index: 2; }
.greet-btn {
  margin-top: 8px; width: 100%; background: var(--blue); color: #fff; border: none;
  padding: 7px 0; border-radius: 20px; font-size: 13px; font-weight: 600; cursor: pointer;
  margin-top: auto;
}
.greet-btn:active { background: var(--blue-dark); }

/* 过滤 chips */
.filter-row { display: flex; gap: 8px; padding: 0 14px 10px; overflow-x: auto; }
.filter-row .chip {
  flex: none; padding: 6px 16px; border-radius: 18px; background: #fff; font-size: 13px;
  color: #555; cursor: pointer; border: 1px solid #eee;
}
.filter-row .chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* 会话列表 */
.chat-list { padding: 4px 0; }
.chat-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #fff;
  border-bottom: 1px solid #f5f5f5; cursor: pointer;
}
.chat-avatar { width: 50px; height: 50px; border-radius: 12px; flex: none; display: grid; place-items: center; color: #fff; font-size: 20px; font-weight: 700; position: relative; }
.chat-avatar .dot { position: absolute; bottom: -1px; right: -1px; width: 12px; height: 12px; border-radius: 50%; background: var(--online); box-shadow: 0 0 0 2px #fff; }
.chat-avatar .dot.off { background: #c9ced6; }
.chat-main { flex: 1; min-width: 0; }
.chat-top { display: flex; justify-content: space-between; align-items: center; }
.chat-name { font-size: 16px; font-weight: 600; }
.chat-time { font-size: 11px; color: var(--muted); }
.chat-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 3px; }
.chat-preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 78%; }
.chat-preview.sys { color: #e8873a; }
.badge {
  background: var(--red); color: #fff; font-size: 11px; min-width: 18px; height: 18px;
  border-radius: 9px; display: grid; place-items: center; padding: 0 5px; font-weight: 700;
}

/* 聊天窗 */
.chat-window { position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column; z-index: 20; }
.chat-window.hidden { display: none; }
.chat-window .topbar .back { cursor: pointer; display: flex; align-items: center; gap: 4px; }
.chat-window .topbar .back svg { width: 22px; height: 22px; }
.chat-peer { display: flex; align-items: center; gap: 8px; }
.chat-peer .av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 15px; font-weight: 700; }
.chat-peer .nm { font-size: 16px; font-weight: 600; }
.chat-peer .st { font-size: 11px; color: var(--muted); }

.msgs { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 74%; padding: 10px 14px; border-radius: 18px; font-size: 15px; word-break: break-word; position: relative; }
.msg.mine { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.msg.theirs { align-self: flex-start; background: #fff; border-bottom-left-radius: 4px; }
.msg.system { align-self: center; background: transparent; color: var(--muted); font-size: 12px; padding: 4px; }

.inputbar { display: flex; gap: 8px; padding: 10px 12px calc(10px + var(--safe-b)); background: #fff; border-top: 1px solid #eee; align-items: center; }
.inputbar input { flex: 1; border: none; background: #eef1f5; border-radius: 22px; padding: 10px 16px; font-size: 15px; outline: none; }
.inputbar .send {
  width: 40px; height: 40px; border-radius: 50%; background: var(--blue); color: #fff;
  border: none; display: grid; place-items: center; cursor: pointer; flex: none;
}
.inputbar .send svg { width: 20px; height: 20px; }

/* 动态 */
.moment-card { background: #fff; margin: 0 14px 12px; border-radius: var(--radius); overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.moment-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.moment-av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; }
.moment-name { font-weight: 600; font-size: 15px; }
.moment-time { font-size: 11px; color: var(--muted); }
.moment-body { padding: 0 14px 14px; font-size: 15px; }
.moment-img { width: 100%; height: 200px; margin-top: 10px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-size: 40px; font-weight: 700; }

/* 我的 */
.profile-card { background: #fff; margin: 12px 14px; border-radius: var(--radius); padding: 20px; display: flex; align-items: center; gap: 16px; }
.profile-card .av { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 28px; font-weight: 700; }
.profile-card .nm { font-size: 18px; font-weight: 700; }
.profile-card .id { font-size: 12px; color: var(--muted); }
.menu-list { background: #fff; margin: 0 14px; border-radius: var(--radius); overflow: hidden; }
.menu-item { padding: 14px 16px; border-bottom: 1px solid #f5f5f5; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.menu-item:last-child { border-bottom: none; }
.menu-item .arrow { color: #c9ced6; }
.logout { margin: 20px 14px; background: #fff; border-radius: var(--radius); padding: 14px; text-align: center; color: var(--red); font-weight: 600; cursor: pointer; }

/* 底部 Tab */
.tabbar {
  position: absolute; bottom: 0; left: 0; right: 0; height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b); background: #fff; border-top: 1px solid #eee;
  display: flex; z-index: 15;
}
.tabbar .tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; color: #8a8f99; position: relative; }
.tabbar .tab.active { color: var(--blue); }
.tabbar .tab svg { width: 24px; height: 24px; }
.tabbar .tab .label { font-size: 11px; }
.tabbar .tab .tab-badge {
  position: absolute; top: 6px; left: 50%; margin-left: 6px; background: var(--red);
  color: #fff; font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px;
  display: grid; place-items: center; padding: 0 4px; font-weight: 700;
}

/* 登录 / 注册 */
.auth-screen { position: absolute; inset: 0; background: #fff; z-index: 30; display: flex; flex-direction: column; overflow-y: auto; }
.auth-screen.hidden { display: none; }
.auth-hero { text-align: center; padding: 48px 20px 20px; }
.auth-logo { width: 88px; height: 88px; border-radius: 22px; overflow: hidden; display: grid; place-items: center; margin: 0 auto 16px; background: linear-gradient(135deg, #ff5fa2, #ff9ec4); box-shadow: 0 6px 18px rgba(255,95,162,.28); }
.auth-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.auth-hero h1 { font-size: 22px; font-weight: 800; }
.auth-hero p { color: var(--muted); font-size: 13px; margin-top: 6px; }
.auth-form { padding: 0 28px 30px; }
.auth-form .field { margin-bottom: 14px; }
.auth-form label { display: block; font-size: 13px; color: #555; margin-bottom: 6px; }
.auth-form input, .auth-form select {
  width: 100%; border: 1px solid #e2e5ea; border-radius: 10px; padding: 12px 14px;
  font-size: 15px; outline: none; background: #fafbfc;
}
.auth-form input:focus { border-color: var(--blue); background: #fff; }
.auth-form .primary {
  width: 100%; background: var(--blue); color: #fff; border: none; border-radius: 22px;
  padding: 13px; font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 8px;
}
.auth-form .primary:active { background: var(--blue-dark); }
.auth-form .switch { text-align: center; margin-top: 16px; color: var(--muted); font-size: 13px; }
.auth-form .switch b { color: var(--blue); cursor: pointer; }
.auth-error { color: var(--red); font-size: 13px; margin-bottom: 10px; min-height: 18px; }

/* 头像色板 */
.av-c { background: #f06292; }
.av-c0 { background: #f06292; }
.av-c1 { background: #ba68c8; }
.av-c2 { background: #4fc3f7; }
.av-c3 { background: #4db6ac; }
.av-c4 { background: #ffb74d; }
.av-c5 { background: #7986cb; }
.av-c6 { background: #e57373; }
.av-c7 { background: #81c784; }
.av-self { background: linear-gradient(135deg, #1e8fff, #7cc2ff); }
.av-sys { background: #ff7043; display: grid; place-items: center; color: #fff; font-size: 15px; font-weight: 700; }

/* 空状态 */
.empty { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 14px; }
.empty .big { font-size: 48px; margin-bottom: 10px; }

/* Toast */
.toast {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,.75); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; z-index: 100; pointer-events: none; opacity: 0; transition: opacity .2s;
}
.toast.show { opacity: 1; }

/* 打招呼弹层 */
.sheet-mask { position: absolute; inset: 0; background: rgba(0,0,0,.4); z-index: 40; display: none; }
.sheet-mask.show { display: block; }
.sheet { position: absolute; bottom: 0; left: 0; right: 0; background: #fff; border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + var(--safe-b)); z-index: 41; transform: translateY(100%); transition: transform .25s; }
.sheet.show { transform: translateY(0); }
.limit-sheet { text-align: center; }
.limit-sheet .limit-icon { font-size: 44px; margin: 4px 0 10px; }
.limit-sheet .limit-title { font-weight: 800; font-size: 18px; color: #1f2328; margin-bottom: 10px; }
.limit-sheet .limit-desc { font-size: 14px; color: #5b6572; line-height: 1.6; margin-bottom: 16px; }
.sheet .st { font-weight: 700; font-size: 16px; margin-bottom: 12px; }
.sheet textarea { width: 100%; border: 1px solid #e2e5ea; border-radius: 10px; padding: 12px; font-size: 15px; min-height: 80px; outline: none; resize: none; }
.sheet .send { width: 100%; background: var(--blue); color: #fff; border: none; border-radius: 22px; padding: 12px; font-size: 16px; font-weight: 700; margin-top: 12px; cursor: pointer; }
.sheet .cancel { width: 100%; background: #f0f0f0; color: #555; border: none; border-radius: 22px; padding: 12px; font-size: 15px; margin-top: 8px; cursor: pointer; }

/* 广告（発見页） */
#ad-box { padding: 0 14px 12px; }.ad-banners { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.ad-banner { width: 100%; border-radius: 12px; overflow: hidden; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.ad-banner img { width: 100%; display: block; aspect-ratio: 21/9; object-fit: cover; }
.ad-link-list { background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.ad-link-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid #f5f5f5; cursor: pointer; }
.ad-link-item:last-child { border-bottom: none; }
.ad-link-item:active { background: #fafafa; }
.ad-link-icon { width: 32px; height: 32px; border-radius: 8px; background: #eef1f5; display: grid; place-items: center; font-size: 18px; flex: none; }
.ad-link-title { flex: 1; font-size: 15px; font-weight: 500; }
.ad-link-arrow { color: #c9ced6; font-size: 20px; }

/* 活动卡片（発見页空白处） */
.activity-list { display: flex; flex-direction: column; gap: 12px; margin: 4px 0 14px; }
.activity-card { position: relative; border-radius: 14px; padding: 18px 16px; color: #fff; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.14); overflow: hidden; min-height: 96px; }
.activity-card:active { transform: scale(.985); transition: transform .08s; }
.ac-title { font-size: 17px; font-weight: 700; line-height: 1.35; text-shadow: 0 1px 2px rgba(0,0,0,.15); }
.ac-sub { margin-top: 6px; font-size: 13px; line-height: 1.4; opacity: .94; text-shadow: 0 1px 2px rgba(0,0,0,.12); }
.ac-btn { position: absolute; right: 14px; bottom: 14px; font-size: 12px; font-weight: 700; background: rgba(255,255,255,.22); padding: 6px 14px; border-radius: 999px; backdrop-filter: blur(4px); }


/* 图片头像 */
.avatar-img { border-radius: 12px; overflow: hidden; flex: none; background: #eef1f5; }
.avatar-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.person-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 22%; display: block; }

/* ================= RTL 支持（阿拉伯语 / 乌尔都语 / 波斯语等） ================= */
html[dir="rtl"] body { direction: rtl; }
html[dir="rtl"] .tabbar { direction: rtl; }
html[dir="rtl"] .filter-row { direction: rtl; }
html[dir="rtl"] .msg.mine { align-self: flex-start; }
html[dir="rtl"] .msg.theirs { align-self: flex-end; }
html[dir="rtl"] .topbar .back svg,
html[dir="rtl"] .m-back svg { transform: scaleX(-1); }
html[dir="rtl"] .menu-item .arrow,
html[dir="rtl"] .ad-link-arrow { transform: scaleX(-1); }
html[dir="rtl"] .chat-preview { text-align: right; }
html[dir="rtl"] .person-info { text-align: right; }
html[dir="rtl"] input, html[dir="rtl"] textarea { text-align: right; }
html[dir="rtl"] .searchbar input { text-align: right; }
html[dir="rtl"] .chat-preview { text-align: right; }
html[dir="rtl"] .cs-header, html[dir="rtl"] .cs-input-row { }
html[dir="rtl"] .cs-msg.mine { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .cs-msg.theirs { margin-right: 0; margin-left: auto; }
/* RTL：头像在右、文本左对齐方向反转（依靠 flex 自动翻转，不要 row-reverse） */
html[dir="rtl"] .person-info,
html[dir="rtl"] .name-row,
html[dir="rtl"] .chat-main,
html[dir="rtl"] .chat-top,
html[dir="rtl"] .chat-bottom { direction: rtl; }
/* 消息气泡：自己的在右（RTL 下），对方在左 */
html[dir="rtl"] .msg.mine { align-self: flex-start; }
html[dir="rtl"] .msg.theirs { align-self: flex-end; }
/* 滑动条/滚动条方向 */
html[dir="rtl"] .page, html[dir="rtl"] .chat-list, html[dir="rtl"] .people-list { direction: rtl; }

/* 会员引导弹层主按钮（覆盖 .sheet .send 的默认蓝色） */
.sheet.limit-sheet .send { background: linear-gradient(135deg,#ff9a3c,#fa8c16); }
