/* ===================================================================
   MO Chat · 界面样式
   =================================================================== */
:root {
  --bg: #0b1020;
  --bg-2: #0e1426;
  --surface: #131b2e;
  --surface-2: #18223a;
  --surface-3: #1f2b47;
  --surface-hover: #202c49;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .13);
  --text: #e9eefb;
  --text-2: #a2aecd;
  --text-3: #6e7d9e;
  --brand: #5b7cfa;
  --brand-2: #9b5cf6;
  --brand-soft: rgba(91, 124, 250, .16);
  /* v1.4.5 引用框专用中性灰（不随品牌色变化） */
  --quote-bg: #232c3f;
  --quote-bg-hover: #2c364c;
  --quote-line: #4c5870;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --shadow: 0 20px 60px rgba(0, 0, 0, .42);
  --shadow-sm: 0 6px 20px rgba(0, 0, 0, .22);
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --rail-w: 76px;
  --side-w: 328px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
}

[data-theme="light"] {
  --bg: #f3f6fd;
  --bg-2: #eef2fb;
  --surface: #ffffff;
  --surface-2: #f5f7fc;
  --surface-3: #eaeef8;
  --surface-hover: #eef2fb;
  --line: rgba(24, 40, 82, .08);
  --line-2: rgba(24, 40, 82, .14);
  --text: #1b2540;
  --text-2: #5f6c8c;
  --text-3: #8a97b4;
  --quote-bg: #e6e9f0;
  --quote-bg-hover: #dce0ea;
  --quote-line: #98a3b9;
  --brand-soft: rgba(91, 124, 250, .11);
  --shadow: 0 20px 60px rgba(30, 50, 100, .14);
  --shadow-sm: 0 6px 20px rgba(30, 50, 100, .1);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.55;
}
/* 登录/注册态：整页可滚动，鼠标放在页面任意位置滚轮都有效（浏览器原生滚动条） */
body.auth-mode { overflow-y: auto; overflow-x: hidden; }
body.auth-mode::-webkit-scrollbar { width: 12px; }
body.auth-mode::-webkit-scrollbar-thumb { background: #3a4668; border-radius: 10px; border: 3px solid #0e1426; }
body.auth-mode::-webkit-scrollbar-track { background: #0e1426; }

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
/* 移动端点击可靠性：消除 300ms 延迟，并让任意带 data-action 的元素都能产生可冒泡的 click */
button, [data-action], [data-auth-tab], [data-tab], .list-item, .pick-item, .mo-act, .tab {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
input, textarea { -webkit-user-select: text; user-select: text; }
input, textarea { outline: none; }
.hidden { display: none !important; }
/* 文件选择器不能用 display:none（部分移动浏览器不会弹出选择框），改为移出视口但保持可激活 */
#hiddenFilePicker {
  position: fixed; left: -9999px; top: 0; width: 1px; height: 1px;
  opacity: 0; pointer-events: none; border: 0; padding: 0; margin: 0;
}
.ic { flex: none; display: block; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 20px; border: 2px solid transparent; background-clip: padding-box; }
::selection { background: var(--brand); color: #fff; }

/* ---------------- 通用组件 ---------------- */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 600; padding: 11px 20px; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(91, 124, 250, .3);
  transition: transform .18s, box-shadow .18s, opacity .18s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(91, 124, 250, .42); }
.btn-primary:active { transform: translateY(0) scale(.98); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-block { width: 100%; padding: 13px 20px; }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 11px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--line);
  transition: .18s; font-weight: 500;
}
.btn-ghost:hover { color: var(--text); background: var(--surface-3); }
.btn-danger { color: var(--red); background: rgba(248, 113, 113, .1); border: 1px solid rgba(248, 113, 113, .2); }
.btn-danger:hover { background: rgba(248, 113, 113, .18); color: var(--red); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 11px; display: inline-flex;
  align-items: center; justify-content: center; color: var(--text-2); transition: .18s; flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.avatar {
  border-radius: 50%; object-fit: cover; background: var(--surface-3);
  display: block; flex: none; border: 1px solid var(--line);
}
.avatar-fallback {
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; flex: none; letter-spacing: 0;
  line-height: 1; text-align: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.avatar-wrap { position: relative; flex: none; }
.avatar-wrap .presence {
  position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--text-3); border: 2.5px solid var(--surface);
}
.avatar-wrap .presence.online { background: var(--green); }

.badge {
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.tag {
  font-size: 11px; padding: 3px 9px; border-radius: 20px;
  background: var(--brand-soft); color: var(--brand); font-weight: 600;
}
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; height: 100%; color: var(--text-3); text-align: center; padding: 40px;
}
.empty-state .empty-ic {
  width: 76px; height: 76px; border-radius: 24px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--brand); border: 1px solid var(--line);
}
.empty-state h3 { margin: 4px 0 0; color: var(--text); font-size: 16px; font-weight: 600; }
.empty-state p { margin: 0; font-size: 13px; max-width: 280px; }

/* ---------------- 登录页 ---------------- */
/* 登录 / 注册页恒定深色（恢复旧版观感），与聊天页主题互不干扰：
   在 #auth 上重定义一套深色变量，内部所有 var(--...) 组件自动变深，
   不受 html[data-theme] 影响；聊天页仍默认浅色、可一键切黑夜。 */
#auth {
  --bg: #0b1020;
  --bg-2: #0e1426;
  --surface: #131b2e;
  --surface-2: #18223a;
  --surface-3: #1f2b47;
  --surface-hover: #202c49;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .13);
  --text: #e9eefb;
  --text-2: #a2aecd;
  --text-3: #6e7d9e;
  --brand-soft: rgba(91, 124, 250, .16);
  --shadow: 0 20px 60px rgba(0, 0, 0, .42);
  --shadow-sm: 0 6px 20px rgba(0, 0, 0, .22);
  background: var(--bg-2);
  color: var(--text);
}
/* 整页长高而不是锁死 100dvh，内容超出时浏览器原生滚动条一定出现 */
#auth.auth { height: auto; min-height: 100dvh; }
.auth { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(430px, .92fr); height: 100dvh; }
.auth-visual {
  position: relative; overflow: hidden; min-height: 100dvh; background: #0a0f20;
  background-image: radial-gradient(1100px 620px at 18% 8%, #1d2a5e 0%, transparent 60%),
                    radial-gradient(900px 700px at 88% 92%, #3a1e63 0%, transparent 62%),
                    linear-gradient(155deg, #0b1226, #0a0e1c);
}
.visual-grid {
  position: absolute; inset: 0; opacity: .22;
  background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, #000, transparent 85%);
}
.visual-glow { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; }
.glow-a { width: 420px; height: 420px; background: #3355dd; left: -90px; top: -110px; }
.glow-b { width: 380px; height: 380px; background: #8a3fd6; right: -100px; bottom: -120px; opacity: .38; }
.visual-inner {
  position: relative; z-index: 2; height: 100%; padding: clamp(36px, 5vw, 72px);
  display: flex; flex-direction: column;
}
.brand-lockup { display: flex; align-items: center; gap: 13px; }
.brand-name { font-size: 21px; font-weight: 750; letter-spacing: .3px; color: #fff; }
.visual-copy { margin-top: auto; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 9px; font-size: 11px; font-weight: 700;
  letter-spacing: .18em; color: #9fb2ff; border: 1px solid rgba(159,178,255,.25);
  background: rgba(91,124,250,.1); padding: 7px 14px; border-radius: 30px;
}
.eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }
.visual-copy h1 { font-size: clamp(34px, 3.7vw, 56px); line-height: 1.25; font-weight: 750; color: #fff; margin: 26px 0 16px; letter-spacing: -1px; }
.visual-copy h1 em { font-style: normal; background: linear-gradient(100deg, #8fa9ff, #d7a2ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.visual-copy p { color: #a9b6d4; font-size: 15px; max-width: 470px; margin: 0; line-height: 1.8; }
.feature-list { list-style: none; padding: 0; margin: 44px 0 34px; display: grid; gap: 22px; }
.feature-list li { display: flex; gap: 15px; align-items: center; }
.feat-ic {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); color: #a9bcff;
}
.feature-list b { display: block; color: #eef2ff; font-size: 14px; font-weight: 650; }
.visual-foot {
  margin-top: auto; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.09);
  color: #8391b4; font-size: 12.5px; display: flex; align-items: center; gap: 9px;
}
.auth-panel {
  background: var(--bg-2); display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start; padding: 40px 32px; position: relative;
  /* 不再依赖面板内部的细滚动条：由 body.auth-mode 整页滚动，
     低分辨率 / 系统缩放 125% 时鼠标放在任意位置滚轮都能上下移动。 */
  overflow: visible;
}
.auth-card {
  width: min(410px, 100%); flex: none; margin: 0 auto; padding: 24px 0 32px;
  animation: fadeUp .5s ease both;
}
.auth-mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 34px; font-size: 19px; }
.auth-head h2 { margin: 0 0 8px; font-size: 28px; font-weight: 700; letter-spacing: -.5px; }
.auth-head p { margin: 0; color: var(--text-3); font-size: 13.5px; }
.auth-tabs { display: flex; position: relative; margin: 24px 0 20px; border-bottom: 1px solid var(--line); }
.auth-tabs .tab {
  flex: 1; padding: 12px 0; color: var(--text-3); font-weight: 600; font-size: 14px; transition: .2s;
}
.auth-tabs .tab.active { color: var(--text); }
.tab-ink {
  position: absolute; bottom: -1px; height: 2px; width: 50%; left: 0; border-radius: 2px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.auth-tabs[data-active="register"] .tab-ink { transform: translateX(100%); }
.auth-form { display: grid; gap: 15px; }
/* 注册页字段更多，单独压缩间距，保证 768px 高屏幕也能完整显示 */
#registerForm.auth-form { gap: 11px; }
#registerForm .input-wrap { height: 44px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.input-wrap {
  display: flex; align-items: center; gap: 11px; padding: 0 14px; height: 48px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; transition: .2s;
}
.input-wrap:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input-ic { color: var(--text-3); display: flex; }
.input-wrap input { flex: 1; border: 0; background: none; min-width: 0; color: var(--text); }
.input-wrap input::placeholder { color: var(--text-3); }
.form-row { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); cursor: pointer; }
.check input { accent-color: var(--brand); width: 15px; height: 15px; }
.form-hint { color: var(--text-3); font-size: 11.5px; display: inline-flex; align-items: center; gap: 5px; }
.form-hint.ok { color: var(--green); }
.form-hint.err { color: var(--red); }
.auth-note {
  margin-top: 26px; padding: 13px 15px; border-radius: 12px; font-size: 12px; line-height: 1.6;
  background: var(--surface); border: 1px solid var(--line); color: var(--text-3);
  display: flex; gap: 9px; align-items: flex-start;
}
.auth-note .ic { margin-top: 1px; color: var(--brand); }
.auth-copyright { position: absolute; bottom: 26px; color: var(--text-3); font-size: 11.5px; letter-spacing: .04em; }

/* ---------------- 主框架 ---------------- */
.shell { display: grid; grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr); height: 100dvh; background: var(--bg); }
.shell.full-stage { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
.shell.full-stage .sidebar { display: none; }

.rail {
  background: var(--bg-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; padding: 20px 0 18px; gap: 26px; z-index: 5;
}
.rail-logo { display: grid; place-items: center; filter: drop-shadow(0 6px 16px rgba(91,124,250,.35)); }
.rail-nav { display: flex; flex-direction: column; gap: 10px; width: 100%; align-items: center; }
.rail-btn {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  color: var(--text-3); position: relative; transition: .2s;
}
.rail-btn:hover { color: var(--text); background: var(--surface-2); }
.rail-btn.active { color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 8px 22px rgba(91,124,250,.36); }
.rail-btn.active::before {
  content: ''; position: absolute; left: -15px; width: 3px; height: 20px; border-radius: 0 4px 4px 0;
  background: linear-gradient(var(--brand), var(--brand-2));
}
.rail-btn.small { width: 40px; height: 40px; }
.rail-bottom { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; }
/* v1.4.5：按钮内 inline-block 头像受行框基线影响会偏下，文字跟着偏；改成 grid 居中 */
.rail-me {
  width: 42px; height: 42px; border-radius: 50%; padding: 0; overflow: hidden;
  border: 2px solid transparent; transition: .2s;
  display: grid; place-items: center; line-height: 0;
}
.rail-me .avatar-wrap { display: block; }
.rail-me:hover { border-color: var(--brand); }
.rail-badge { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg-2); }

.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.side-head { padding: 22px 20px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.side-head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.side-head .side-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.side-actions { display: flex; gap: 6px; }
.side-search { padding: 0 16px 12px; }
.search-box {
  display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 12px;
  border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-3);
}
.search-box:focus-within { border-color: var(--brand); }
.search-box input { flex: 1; min-width: 0; background: none; border: 0; color: var(--text); font-size: 13px; }
.search-box input::placeholder { color: var(--text-3); }
.side-scroll { flex: 1; overflow-y: auto; padding: 4px 10px 18px; }
.side-section-title { padding: 14px 10px 8px; font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--text-3); }

.list-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px;
  border-radius: 13px; text-align: left; transition: .16s; position: relative; min-width: 0;
}
.list-item:hover { background: var(--surface-2); }
.list-item.active { background: var(--brand-soft); }
.list-item.active::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 3px; background: var(--brand); }
.li-main { flex: 1; min-width: 0; }
.li-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.li-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-time { font-size: 11px; color: var(--text-3); flex: none; }
.li-sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.li-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.li-meta { display: flex; align-items: center; gap: 6px; }

/* ---------------- 聊天 ---------------- */
.stage { min-width: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.chat { display: flex; flex-direction: column; height: 100%; }
.chat-head {
  height: 72px; flex: none; padding: 0 24px; display: flex; align-items: center; gap: 13px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.chat-head .ch-main { flex: 1; min-width: 0; }
.chat-head .ch-name { font-weight: 650; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.chat-head .ch-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; display: flex; align-items: center; gap: 6px; }
.chat-head .ch-sub .online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.chat-head .ch-sub .offline-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.back-btn { display: none; }

/* v1.4.5：去掉全局 scroll-behavior:smooth。程序化 scrollTop 赋值会变成动画，
   多次重建叠加后表现为打开会话时滚动条乱跳 2~3 秒；跳转原消息改用 scrollIntoView 显式 smooth。 */
.chat-body { flex: 1; overflow-y: auto; padding: 22px clamp(16px, 3vw, 40px) 10px; scroll-behavior: auto; position: relative; overflow-anchor: none; }
.chat-body::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .35;
  background-image: radial-gradient(circle at 20% 10%, rgba(91,124,250,.07), transparent 45%), radial-gradient(circle at 85% 90%, rgba(155,92,246,.07), transparent 45%);
}
.day-sep { text-align: center; margin: 16px 0 22px; }
.day-sep span { font-size: 11.5px; color: var(--text-3); background: var(--surface-2); padding: 5px 12px; border-radius: 20px; }
.msg-row { display: flex; gap: 10px; margin: 0 0 18px; align-items: flex-start; animation: fadeUp .25s ease both; }
.msg-row.mine { flex-direction: row-reverse; }
.msg-av { width: 36px; height: 36px; border-radius: 12px; }
.msg-col { max-width: min(600px, 74%); min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.msg-row.mine .msg-col { align-items: flex-end; }
.msg-sender { font-size: 11.5px; color: var(--text-3); padding: 0 4px; }
.msg-line { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.msg-row.mine .msg-line { flex-direction: row-reverse; }
.msg-stack { display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
.msg-row.mine .msg-stack { align-items: flex-end; }
.bubble {
  padding: 10px 14px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text); font-size: 14px; line-height: 1.65; word-break: break-word; white-space: pre-wrap;
  box-shadow: var(--shadow-sm); max-width: 100%;
}
.msg-row.mine .bubble {
  background: linear-gradient(125deg, var(--brand), #7c68fa); color: #fff; border-color: transparent;
  border-bottom-right-radius: 5px;
}
.msg-row:not(.mine) .bubble { border-bottom-left-radius: 5px; }
.bubble a { color: inherit; text-decoration: underline; }
.msg-row.mine .bubble a { color: #eaf0ff; }
.bubble.revoked { color: var(--text-3); font-style: italic; background: transparent; border: 1px dashed var(--line-2); box-shadow: none; font-size: 12.5px; }
.msg-media { padding: 5px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; box-shadow: var(--shadow-sm); }
.msg-row.mine .msg-media { background: rgba(91,124,250,.2); }
.msg-media img, .msg-media video { display: block; max-width: min(320px, 100%); max-height: 260px; border-radius: 12px; cursor: zoom-in; }
.msg-media video { background: #000; }
.file-card {
  display: flex; align-items: center; gap: 12px; min-width: 230px; max-width: 320px;
  padding: 11px 13px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.msg-row.mine .file-card { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.18); }
.file-ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.file-info { flex: 1; min-width: 0; }
.file-info b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info small { color: var(--text-3); font-size: 11.5px; }
.msg-row.mine .file-info small { color: rgba(255,255,255,.7); }
.msg-foot { font-size: 10.5px; color: var(--text-3); display: flex; align-items: center; gap: 7px; padding: 0 3px; }
.msg-revoke { opacity: 0; transition: .15s; color: var(--text-3); font-size: 11px; }
.msg-row:hover .msg-revoke { opacity: 1; }
.msg-revoke:hover { color: var(--red); }
.typing-hint { height: 20px; padding: 0 clamp(16px, 3vw, 40px); font-size: 11.5px; color: var(--brand); }

.chat-compose { flex: none; padding: 10px clamp(16px, 3vw, 40px) 20px; position: relative; }
.compose-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; transition: .2s;
}
.compose-box:focus-within { border-color: var(--line-2); box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.compose-tools { display: flex; align-items: center; gap: 2px; padding: 8px 10px 0; }
.compose-tools .tool-tip { margin-left: auto; font-size: 11px; color: var(--text-3); padding-right: 8px; }
.compose-box textarea {
  width: 100%; border: 0; background: none; resize: none; padding: 8px 16px 4px;
  min-height: 52px; max-height: 160px; line-height: 1.6; color: var(--text); font-size: 14px;
}
.compose-box textarea::placeholder { color: var(--text-3); }
.compose-foot { display: flex; align-items: center; justify-content: space-between; padding: 4px 12px 11px 16px; }
.compose-foot .hint { font-size: 11px; color: var(--text-3); }
/* v1.4.5：组合 emoji（✌️ / ❤️ 等）会把 1fr 列撑宽，导致最后一列悬空在背景之外。
   minmax(0,1fr) + 固定格宽 + overflow:hidden 保证 8 列永远完整落在面板内。 */
.emoji-panel {
  position: absolute; bottom: calc(100% - 6px); left: 12px;
  width: 320px; max-width: calc(100vw - 32px); padding: 10px; box-sizing: border-box;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; z-index: 20;
  overflow: hidden; animation: fadeUp .18s ease both;
}
.emoji-panel .emoji-cell {
  width: 100%; min-width: 0; height: 32px; padding: 0; border-radius: 8px;
  font-size: 17px; line-height: 1; white-space: nowrap; overflow: hidden;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Symbola', sans-serif;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.emoji-panel .emoji-cell:hover { background: var(--surface-3); }
.drop-mask {
  position: absolute; inset: 0; z-index: 30; display: grid; place-items: center;
  background: rgba(11,16,32,.78); border: 2px dashed var(--brand); border-radius: 18px;
  color: #fff; font-size: 15px; font-weight: 600; gap: 10px; backdrop-filter: blur(4px);
}

/* ---------------- v1.4.5 引用消息：中性灰框 + 单行「昵称：内容」 ---------------- */
/* v1.4.6（修订）：气泡文字始终不可选中，不做任何「解锁」状态。移动端长按不会同时唤起
   系统「选择文字 / 全选」菜单，引用菜单也不会被挤掉。系统自带的复制 / 全选只在
   「消息操作」弹窗里对展示的消息内容可用（见 .quote-menu p），不自行实现这些功能。 */
.msg-row { -webkit-touch-callout: none; }
.msg-row .bubble, .msg-row .msg-quote, .msg-row .msg-sender, .msg-row .file-info {
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.msg-quote {
  display: block; width: fit-content; max-width: 100%; min-width: 0;
  padding: 6px 10px; border-radius: 8px;
  background: var(--quote-bg); border: 1px solid var(--line); border-left: 3px solid var(--quote-line);
  color: var(--text-2); text-align: left;
  font-size: 12px; line-height: 1.5; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.msg-quote:hover { background: var(--quote-bg-hover); }
.msg-quote .mq-line { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.msg-quote b { color: var(--text); font-weight: 650; }
/* 自己发的消息同样用灰色引用框，不再叠品牌蓝紫 */
.msg-row.mine .msg-quote { background: var(--quote-bg); border-color: var(--line); border-left-color: var(--quote-line); color: var(--text-2); }
.msg-row.mine .msg-quote b { color: var(--text); }
.msg-row.mine .msg-quote:hover { background: var(--quote-bg-hover); }
.quote-bar {
  display: flex; align-items: center; gap: 10px; margin: 8px 12px 0; padding: 9px 11px;
  border-radius: 10px; background: var(--quote-bg); border: 1px solid var(--line);
}
.quote-bar .qb-line { width: 3px; align-self: stretch; flex: none; border-radius: 3px; background: var(--quote-line); }
.quote-bar .qb-main { flex: 1; min-width: 0; }
.quote-bar .qb-text { display: block; color: var(--text-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quote-bar .qb-text b { color: var(--text); font-weight: 650; }
.quote-bar .icon-btn { flex: none; color: var(--text-3); }
.quote-bar .icon-btn:hover { color: var(--red); }
.quote-menu { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.quote-menu .qm-who { color: var(--brand); font-size: 12px; font-weight: 650; }
/* v1.4.6（修订）：打开「消息操作」后，这里展示完整消息内容，可用系统自带的复制 / 全选；
   弹窗关闭即无可选副本，气泡始终不可选。 */
.quote-menu p {
  margin: 6px 0 0; font-size: 13.5px; color: var(--text); line-height: 1.6; word-break: break-word;
  max-height: min(38dvh, 220px); overflow-y: auto; -webkit-overflow-scrolling: touch;
  user-select: text; -webkit-user-select: text; -webkit-touch-callout: default;
}
.quote-flash { animation: quoteFlash 1.1s ease both; }
@keyframes quoteFlash {
  0%, 100% { background: transparent; }
  25%, 65% { background: rgba(91,124,250,.13); }
}
@media (max-width: 520px) {
  .msg-quote .mq-line { max-width: min(220px, 60vw); }
  .quote-bar { margin: 8px 8px 0; }
}

/* ---------------- 非好友提示条 ---------------- */
.not-friend-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px clamp(16px, 3vw, 40px); background: rgba(251,191,36,.1);
  border-top: 1px solid rgba(251,191,36,.22); color: var(--text-2); font-size: 12.5px;
}
.not-friend-bar span { flex: 1; min-width: 180px; }
.not-friend-bar .btn-ghost { padding: 5px 10px; font-size: 12px; white-space: nowrap; }
@media (max-width: 860px) { .not-friend-bar { padding: 9px 12px; } }

/* ---------------- 待发送附件 / 上传进度 ---------------- */
.pending-area { display: none; flex-direction: column; gap: 6px; padding: 8px 12px 0; }
.pending-area.has-items { display: flex; }
.pending-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); animation: fadeUp .18s ease both;
}
.pending-item .pi-ic {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center;
  border-radius: 9px; background: var(--brand-soft); color: var(--brand);
}
.pending-item .pi-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pending-item .pi-body b { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-item .pi-body small { font-size: 11px; color: var(--text-3); }
.pending-item .pi-pct { font-size: 11.5px; color: var(--brand); font-weight: 700; min-width: 34px; text-align: right; }
.pending-item .pi-bar { display: block; height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: 3px; }
.pending-item .pi-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .18s ease; }
.pending-item .pi-check { color: var(--green); display: flex; }
.pending-item.error { border-color: rgba(248,113,113,.35); }
.pending-item.error .pi-body small { color: var(--red); }
.pending-item .icon-btn { flex: none; color: var(--text-3); }
.pending-item .icon-btn:hover { color: var(--red); }

/* ---------------- 语音消息 ---------------- */
.voice-rec {
  display: flex; align-items: center; gap: 10px; margin: 8px 12px 0; padding: 10px 12px;
  border-radius: 12px; background: rgba(248,113,113,.09); border: 1px solid rgba(248,113,113,.28);
}
.voice-rec.hidden { display: none; }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); animation: recPulse 1s infinite; flex: none; }
@keyframes recPulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.75); } }
.rec-label { font-size: 12px; color: var(--red); font-weight: 600; white-space: nowrap; }
.rec-time { font-size: 11.5px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rec-wave { display: flex; align-items: center; gap: 2px; height: 20px; flex: 1; overflow: hidden; }
.rec-wave i { width: 3px; height: 6px; border-radius: 2px; background: var(--brand); animation: recWave .8s ease-in-out infinite alternate; }
@keyframes recWave { from { height: 5px; opacity: .5; } to { height: 18px; opacity: 1; } }
.voice-rec .btn-ghost, .voice-rec .btn-primary { padding: 6px 12px; font-size: 12px; white-space: nowrap; }
.voice-bubble {
  display: flex; align-items: center; gap: 9px; min-width: 92px; max-width: 220px;
  cursor: pointer; user-select: none; padding: 10px 12px !important;
}
.voice-play { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.16); }
.msg-row.mine .voice-bubble .voice-play { background: rgba(255,255,255,.2); }
.voice-wave { display: flex; align-items: center; gap: 2px; height: 20px; flex: 1; overflow: hidden; }
.voice-wave i { width: 2.5px; border-radius: 2px; background: currentColor; opacity: .55; }
.voice-bubble.playing .voice-wave i { animation: recWave .6s ease-in-out infinite alternate; opacity: .95; }
.voice-dur { font-size: 11.5px; opacity: .8; font-variant-numeric: tabular-nums; }
.voice-bubble audio { display: none; }
.msg-system { display: flex; justify-content: center; margin: 8px 0; }
.msg-system span {
  max-width: 78%; padding: 5px 12px; border-radius: 999px; font-size: 11.5px;
  color: var(--text-3); background: var(--surface-2); border: 1px solid var(--line); text-align: center;
}

/* ---------------- 管理员独立页面 ---------------- */
.admin-page { height: 100%; overflow-y: auto; padding: 30px 34px 44px; }
.admin-wrap { max-width: 960px; margin: 0 auto; }
.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.admin-eyebrow {
  display: inline-flex; align-items: center; gap: 7px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .16em; color: var(--brand); background: var(--brand-soft);
  border: 1px solid rgba(91,124,250,.22); padding: 5px 11px; border-radius: 30px;
}
.admin-head h2 { margin: 12px 0 5px; font-size: 25px; font-weight: 720; letter-spacing: -.5px; }
.admin-head p { margin: 0; color: var(--text-3); font-size: 13px; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 11px; margin-bottom: 18px; }
.admin-stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 15px 17px; display: grid; gap: 3px;
}
.admin-stat .as-ic { color: var(--brand); margin-bottom: 3px; }
.admin-stat b { font-size: 23px; font-weight: 720; letter-spacing: -.5px; }
.admin-stat small { color: var(--text-3); font-size: 11.5px; }
.admin-page .set-card { margin-bottom: 16px; }
.admin-users { display: grid; gap: 6px; max-height: 340px; overflow-y: auto; }
.admin-user {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px;
  border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line);
}
.admin-user .au-av { flex: none; }
.admin-user .au-main { flex: 1; min-width: 0; }
.admin-user b { display: block; font-size: 13.5px; font-weight: 620; }
.admin-user small { display: block; color: var(--text-3); font-size: 11px; margin-top: 2px; }
.admin-user .au-on { color: var(--green); }
.tag-admin {
  display: inline-block; font-size: 10px; font-weight: 700; color: var(--brand);
  background: var(--brand-soft); border-radius: 6px; padding: 2px 6px; margin-left: 6px; vertical-align: 1px;
}
.admin-server { display: grid; gap: 7px; }
.admin-kv {
  display: flex; justify-content: space-between; gap: 12px; padding: 8px 2px;
  border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.admin-kv:last-child { border-bottom: 0; }
.admin-kv span { color: var(--text-3); }
.admin-kv b { font-weight: 600; }

/* ---------------- 邀请码管理 ---------------- */
.invite-list { max-height: 260px; overflow-y: auto; display: grid; gap: 6px; padding: 2px 0 4px; }
.invite-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line);
}
.invite-row .iv-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; font-weight: 700; letter-spacing: .02em; }
.invite-row.used .iv-code { color: var(--text-3); text-decoration: line-through; }
.invite-row .iv-main { flex: 1; min-width: 0; }
.invite-row small { display: block; color: var(--text-3); font-size: 11px; margin-top: 2px; }
.invite-row .iv-state { font-size: 11px; font-weight: 600; color: var(--green); white-space: nowrap; }
.invite-row.used .iv-state { color: var(--text-3); }

/* ---------------- 群成员管理 ---------------- */
.member-row .rm-btn { margin-left: auto; flex: none; }
.member-row .tag { margin-left: 6px; }

/* ---------------- 通讯录 ---------------- */
.contact-detail { max-width: 560px; margin: 8vh auto 0; padding: 0 24px; animation: fadeUp .3s ease both; }
.cd-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 34px; text-align: center; box-shadow: var(--shadow); }
.cd-card .cd-avatar { margin: 0 auto 18px; }
.cd-card h2 { margin: 0 0 4px; font-size: 22px; }
.cd-card .cd-account { color: var(--text-3); font-size: 12.5px; }
.cd-card .cd-sign { color: var(--text-2); margin: 14px 0 0; font-size: 13.5px; }
.cd-meta { display: flex; justify-content: center; gap: 10px; margin: 18px 0 24px; flex-wrap: wrap; }
.cd-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.req-card {
  display: flex; gap: 12px; align-items: center; padding: 13px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 10px;
}
.req-main { flex: 1; min-width: 0; }
.req-main b { font-size: 13.5px; }
.req-main p { margin: 2px 0 0; font-size: 12px; color: var(--text-3); }
.req-actions { display: flex; gap: 6px; }

/* ---------------- 朋友圈 ---------------- */
.moments-view { width: 100%; height: 100%; overflow-y: auto; }
.moments-inner { max-width: 720px; margin: 0 auto; padding: 26px 22px 80px; }
.mo-hero {
  position: relative; border-radius: var(--r-lg); overflow: hidden; margin-bottom: 20px;
  background: linear-gradient(120deg, #263b86, #5b3f9e 60%, #7a4bc4);
  min-height: 190px; box-shadow: var(--shadow);
}
.mo-hero::after {
  content: ''; position: absolute; width: 340px; height: 340px; right: -60px; top: -160px;
  border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.18), transparent 70%);
}
.mo-hero-inner { position: relative; z-index: 2; padding: 28px 28px 24px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; min-height: 190px; }
.mo-hero h1 { margin: 0 0 6px; font-size: 23px; color: #fff; font-weight: 700; }
.mo-hero p { margin: 0; color: rgba(255,255,255,.72); font-size: 12.5px; }
.mo-hero .me-line { display: flex; align-items: center; gap: 12px; margin-top: 22px; }
.mo-hero .me-line b { color: #fff; font-size: 14px; }
.mo-hero .me-line small { display: block; color: rgba(255,255,255,.65); font-size: 11.5px; }
.mo-hero .avatar, .mo-hero .avatar-fallback { border: 2px solid rgba(255,255,255,.55); }
.mo-compose { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.mo-compose textarea {
  width: 100%; min-height: 62px; border: 0; background: none; resize: vertical;
  color: var(--text); font-size: 14px; line-height: 1.6; padding: 4px;
}
.mo-compose textarea::placeholder { color: var(--text-3); }
.mo-compose-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.mo-preview { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.mo-preview .thumb { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; }
.mo-preview img { width: 100%; height: 100%; object-fit: cover; }
.mo-preview .rm { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; }
.feed-title { display: flex; align-items: center; justify-content: space-between; margin: 26px 4px 14px; }
.feed-title h3 { margin: 0; font-size: 15px; font-weight: 650; }
.feed-title span { font-size: 12px; color: var(--text-3); }
.mo-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px 20px; margin-bottom: 14px; box-shadow: var(--shadow-sm); animation: fadeUp .3s ease both;
}
.mo-head { display: flex; gap: 11px; align-items: center; }
.mo-head .mh-main { flex: 1; min-width: 0; }
.mo-head b { font-size: 14px; font-weight: 650; }
.mo-head time { display: block; font-size: 11.5px; color: var(--text-3); }
.mo-text { margin: 13px 0 0; font-size: 14px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
.mo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 13px; max-width: 460px; }
.mo-grid.one { grid-template-columns: minmax(0, 1fr); max-width: 340px; }
.mo-grid.two { grid-template-columns: repeat(2, 1fr); max-width: 320px; }
.mo-grid img, .mo-grid video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; cursor: zoom-in; display: block; background: var(--surface-3); }
.mo-grid.one img { aspect-ratio: 16/10; }
.mo-actions { display: flex; align-items: center; gap: 6px; margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); }
.mo-act {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 9px;
  color: var(--text-3); font-size: 12.5px; transition: .16s;
}
.mo-act:hover { color: var(--text); background: var(--surface-2); }
.mo-act.liked { color: var(--red); }
.mo-act.liked .ic { fill: currentColor; }
.mo-likes { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.mo-likes .ic { color: var(--red); }
.mo-comments { margin-top: 10px; background: var(--surface-2); border-radius: 12px; padding: 10px 13px; display: grid; gap: 7px; }
.mo-comments .cm { font-size: 13px; line-height: 1.55; }
.mo-comments .cm b { color: var(--brand); font-weight: 600; margin-right: 5px; }
.mo-comment-input { display: flex; gap: 8px; margin-top: 10px; }
.mo-comment-input input { flex: 1; min-width: 0; height: 36px; padding: 0 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; }
.mo-comment-input input:focus { border-color: var(--brand); }

/* ---------------- 朋友圈可见性（v1.4.3） ---------------- */
.mo-vis {
  display: inline-flex; align-items: center; gap: 4px; margin-left: 8px;
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; vertical-align: middle;
}
.mo-vis svg { width: 11px; height: 11px; }
.mo-vis.friends { background: rgba(91,124,250,.13); color: var(--brand); }
.mo-vis.public { background: rgba(52,211,153,.15); color: #34d399; }
[data-theme="light"] .mo-vis.public { color: #1f9d73; }
.mo-visibility {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 0 2px; border-top: 1px dashed var(--line); margin-top: 12px;
}
.mo-vis-label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 12.5px; margin-right: 4px; }
.mo-vis-opt {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 20px;
  border: 1px solid var(--line-2); color: var(--text-2); font-size: 12.5px; background: var(--surface);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.mo-vis-opt.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.mo-tools-left { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mo-tip { font-size: 11.5px; color: var(--text-3); }

/* ---------------- 设置 ---------------- */
.settings-view { width: 100%; height: 100%; overflow-y: auto; }
.settings-inner { max-width: 720px; margin: 0 auto; padding: 34px 22px 80px; }
.settings-inner > h1 { margin: 0 0 6px; font-size: 24px; }
.settings-inner > p { margin: 0 0 26px; color: var(--text-3); font-size: 13px; }
.set-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.set-card h3 { margin: 0 0 16px; font-size: 14px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.set-card h3 .ic { color: var(--brand); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.set-row:first-of-type { border-top: 0; }
.set-row .sr-main { flex: 1; min-width: 0; }
.set-row b { display: block; font-size: 13.5px; font-weight: 600; }
.set-row small { color: var(--text-3); font-size: 12px; }
.set-input { height: 38px; padding: 0 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); min-width: 180px; }
.set-input:focus { border-color: var(--brand); }
.set-avatar-line { display: flex; align-items: center; gap: 16px; }
.enc-badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 20px; background: rgba(52,211,153,.1); color: var(--green); font-size: 12px; font-weight: 600; }

/* ---------------- v1.4.4 个人信息页 / 主题开关 / 朋友圈资料入口 ---------------- */
.mo-avatar-btn, .mo-name-btn {
  display: inline-flex; align-items: center; cursor: pointer; border-radius: 10px;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: .16s;
}
.mo-avatar-btn { flex: none; min-width: 42px; min-height: 42px; }
.mo-avatar-btn:hover { opacity: .82; }
.mo-name-btn { max-width: 100%; }
.mo-name-btn b { transition: color .16s; }
.mo-name-btn:hover b { color: var(--brand); }
.profile-card { border: 0; box-shadow: none; background: transparent; padding: 6px 2px 2px; }
.profile-self { display: inline-flex; align-items: center; gap: 7px; color: var(--text-3); font-size: 12.5px; }
.profile-hint { margin-top: 12px; color: var(--text-3); font-size: 12px; }
/* v1.4.6 外观：拨杆式主题选择。左「白天模式」右「黑夜模式」，滑块停在哪边就是哪种主题 */
.theme-toggle {
  position: relative; flex: none; width: 208px; height: 42px; padding: 3px; box-sizing: border-box;
  display: inline-flex; align-items: center; border-radius: 999px; overflow: hidden;
  background: var(--surface-3); border: 1px solid var(--line-2);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: pan-y; cursor: pointer;
}
.tt-thumb {
  position: absolute; z-index: 0; top: 3px; left: 3px;
  width: calc(50% - 3px); height: 34px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-2);
  box-shadow: 0 2px 10px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.12);
  transition: transform .26s cubic-bezier(.2,.8,.2,1); pointer-events: none;
}
.theme-toggle.is-dark .tt-thumb { transform: translateX(100%); }
[data-theme="dark"] .tt-thumb { background: #2b3754; border-color: rgba(255,255,255,.2); }
.tt-label {
  position: relative; z-index: 1; flex: 1 1 50%; min-width: 0; height: 100%; padding: 0 4px;
  border: 0; border-radius: 999px; background: transparent; color: var(--text-3);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  cursor: pointer; transition: color .2s; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.tt-label.active { color: var(--text); }
.tt-label:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.theme-toggle:focus-within { border-color: var(--brand); }
@media (max-width: 520px) {
  .set-row { flex-wrap: wrap; }
  .theme-toggle { width: min(208px, 100%); }
}

/* ---------------- 弹窗 / 提示 / 预览 ---------------- */
.modal-root { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-mask { position: absolute; inset: 0; background: rgba(5, 8, 18, .72); backdrop-filter: blur(6px); animation: fadeIn .18s ease both; }
.modal {
  position: relative; width: min(480px, 100%); max-height: min(86dvh, 760px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  box-shadow: var(--shadow); animation: popIn .22s cubic-bezier(.2,.8,.3,1) both; overflow: hidden;
}
.modal.wide { width: min(620px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 650; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; }
.modal-body .field { display: block; margin-bottom: 15px; }
.modal-body .field:last-child { margin-bottom: 0; }
.modal-body .field > span { display: block; font-size: 12.5px; color: var(--text-2); font-weight: 600; margin-bottom: 7px; }
.modal-body .input-wrap { background: var(--surface-2); }
.pick-list { display: grid; gap: 6px; max-height: 330px; overflow-y: auto; }
.pick-item { display: flex; align-items: center; gap: 11px; padding: 10px; border-radius: 12px; transition: .15s; width: 100%; text-align: left; }
.pick-item:hover { background: var(--surface-2); }
.pick-item.selected { background: var(--brand-soft); }
.pick-item .pi-main { flex: 1; min-width: 0; }
.pick-item b { display: block; font-size: 13.5px; }
.pick-item small { color: var(--text-3); font-size: 12px; }
.pick-check { color: var(--brand); }

.toast-wrap { position: fixed; top: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 9px; padding: 10px 16px; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--line-2); color: var(--text);
  box-shadow: var(--shadow); font-size: 13px; animation: toastIn .25s ease both; max-width: 88vw;
}
.toast .ic { color: var(--brand); }
.toast.success .ic { color: var(--green); }
.toast.error .ic { color: var(--red); }

.lightbox { position: fixed; inset: 0; z-index: 150; background: rgba(3, 5, 12, .94); display: grid; place-items: center; padding: 30px; animation: fadeIn .2s ease both; }
.lightbox img, .lightbox video { max-width: 94vw; max-height: 88dvh; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.lightbox .lb-close { position: absolute; top: 22px; right: 24px; width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.1); color: #fff; display: grid; place-items: center; }
.lightbox .lb-close:hover { background: rgba(255,255,255,.2); }
.lightbox .lb-dl { position: absolute; bottom: 24px; right: 24px; }

/* ---------------- 动画 ---------------- */
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: translateY(0) } }
@keyframes popIn { from { opacity: 0; transform: scale(.94) translateY(10px) } to { opacity: 1; transform: scale(1) translateY(0) } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px) } to { opacity: 1; transform: translateY(0) } }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .4 } }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  :root { --side-w: 290px; }
  .auth { grid-template-columns: minmax(0, 1fr) minmax(390px, .9fr); }
}
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-mobile-brand { display: flex; }
  .auth-panel { background: var(--bg); justify-content: flex-start; min-height: 100dvh; }
  .shell { grid-template-columns: 62px minmax(0, 1fr); }
  .shell.full-stage { grid-template-columns: 62px minmax(0, 1fr); }
  .shell .stage { display: none; }
  .shell.show-stage .sidebar { display: none; }
  .shell.show-stage .stage { display: flex; }
  .shell.full-stage .stage { display: flex; }
  .back-btn { display: inline-flex; }
  .rail { padding: 14px 0; gap: 18px; }
  .rail-btn { width: 42px; height: 42px; }
  .rail-btn.active::before { left: -10px; }
  .chat-head { padding: 0 12px; height: 62px; }
  .chat-body { padding: 16px 12px 8px; }
  .chat-compose { padding: 8px 12px 14px; }
  .msg-col { max-width: 82%; }
  .moments-inner, .settings-inner { padding: 16px 12px 70px; }
  .mo-hero-inner { padding: 22px 18px; min-height: 160px; }
  .mo-hero { min-height: 160px; }
  .contact-detail { margin-top: 4vh; }
}
@media (max-width: 460px) {
  .auth-panel { padding: 24px 20px; }
  .auth-card { margin: 0 auto; padding: 16px 0 32px; }
  .auth-card { width: 100%; }
  .mo-grid { grid-template-columns: repeat(3, 1fr); }
  .cd-card { padding: 24px 18px; }
  .file-card { min-width: 200px; }
}

/* 管理页面移动端 */
@media (max-width: 720px) {
  .admin-page { padding: 18px 14px 32px; }
  .admin-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===================================================================
   移动端全面适配（v1.4.3）
   —— 安全区 / 软键盘 / 窄屏折行 / 触摸目标 / iOS 输入不缩放
   =================================================================== */
:root { --app-h: 100dvh; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px); }

@media (max-width: 860px) {
  /* 软键盘弹出时由 JS 把可视高度写入 --app-h，界面整体收缩，输入栏不会被键盘盖住 */
  .shell { height: var(--app-h); min-height: 0; }
  .chat, .sidebar, .stage, .chat-body, .side-scroll,
  .moments-view, .settings-view, .admin-page { min-height: 0; }
  .chat-body, .side-scroll, .moments-view, .settings-view, .admin-page {
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  }
  /* iOS Safari：输入字号 < 16px 会在聚焦时自动放大整页 */
  input, textarea, select { font-size: 16px !important; }
  .search-box input, .mo-comment-input input, .set-input,
  .input-wrap input, .compose-box textarea, .mo-compose textarea { font-size: 16px !important; }
  /* 触摸目标不小于 40px */
  .icon-btn, .rail-btn, .mo-act, .mo-vis-opt, .btn-ghost, .btn-primary,
  .list-item, .pick-item, [data-auth-tab], [data-tab] { min-height: 40px; }
  .compose-tools .icon-btn { min-width: 40px; }
  .mo-act { padding: 8px 12px; }
  /* 底部安全区：输入栏 / 侧栏 / 导航不被 Home 指示条遮挡 */
  .chat-compose { padding-bottom: calc(14px + var(--safe-b)); }
  .rail { padding-bottom: calc(14px + var(--safe-b)); padding-top: calc(14px + var(--safe-t)); }
  .moments-inner, .settings-inner { padding-bottom: calc(70px + var(--safe-b)); }
  .admin-page { padding-bottom: calc(32px + var(--safe-b)); }
  /* 顶部安全区：提示条 / 图片预览关闭按钮 */
  .toast-wrap { top: calc(12px + var(--safe-t)); }
  .lightbox .lb-close { top: calc(16px + var(--safe-t)); right: calc(16px + env(safe-area-inset-right, 0px)); }
  .lightbox .lb-dl { bottom: calc(20px + var(--safe-b)); }
  /* 窄屏折行，避免任何横向溢出 */
  .side-head { padding: 16px 12px 10px; flex-wrap: wrap; }
  .side-actions { flex-wrap: wrap; }
  .side-search { padding: 0 12px 10px; }
  .side-scroll { padding: 4px 8px calc(18px + var(--safe-b)); }
  .chat-head { padding: 0 10px; gap: 9px; }
  .chat-head .ch-name { font-size: 14px; }
  .chat-head .ch-sub { font-size: 11px; }
  .chat-body { padding: 12px 10px 6px; }
  .chat-compose { padding: 8px 10px calc(12px + var(--safe-b)); }
  .compose-foot .hint { display: none; }        /* 手机上 Enter 发送提示无意义且挤占空间 */
  .compose-tools { flex-wrap: wrap; }
  .compose-tools .tool-tip { display: none; }
  .emoji-panel { width: min(320px, calc(100vw - 32px)); left: 8px; }
  .voice-rec { flex-wrap: wrap; margin: 8px 8px 0; }
  .voice-rec .btn-ghost, .voice-rec .btn-primary { flex: 1; }
  .msg-col { max-width: 84%; }
  .msg-media img, .msg-media video { max-width: min(240px, 100%); }
  .file-card { min-width: 0; width: min(260px, 100%); max-width: 100%; }
  .mo-hero-inner { flex-direction: column; align-items: flex-start; gap: 14px; }
  .mo-hero .me-line { margin-top: 14px; }
  .mo-hero h1 { font-size: 21px; }
  .moments-inner, .settings-inner { padding-left: 12px; padding-right: 12px; }
  .mo-card { padding: 15px 14px; }
  .mo-compose { padding: 13px; }
  .mo-compose-foot { flex-wrap: wrap; }
  .mo-tools-left { flex: 1 1 100%; }
  .mo-compose-foot .btn-primary { margin-left: auto; }
  .mo-tip { display: none; }
  .mo-visibility { gap: 6px; }
  .mo-vis-label { width: 100%; }
  .mo-vis-opt { flex: 1; justify-content: center; padding: 8px 8px; }
  .mo-comment-input input { height: 42px; }
  .mo-grid { max-width: 100%; }
  .set-card { padding: 16px 14px; }
  .set-row { flex-wrap: wrap; gap: 8px; }
  .set-input { min-width: 0; width: 100%; }
  .set-avatar-line { flex-wrap: wrap; }
  .admin-page { padding-left: 12px; padding-right: 12px; }
  .admin-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .admin-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .invite-row { flex-wrap: wrap; }
  .invite-row .iv-main { flex: 1 1 60%; }
  .invite-row .iv-code { font-size: 12px; word-break: break-all; }
  .admin-kv { flex-wrap: wrap; }
  .contact-detail { padding: 0 12px; margin-top: 2vh; }
  .cd-card { padding: 22px 15px; }
  .cd-btns { flex-direction: column; }
  .cd-btns > * { width: 100%; }
  .req-card { flex-wrap: wrap; }
  .req-actions { flex: 1 1 100%; }
  .req-actions > * { flex: 1; }
  /* 弹窗：键盘弹出时仍完整可见，内容可滚动，按钮折行 */
  .modal-root { padding: calc(10px + var(--safe-t)) 10px calc(10px + var(--safe-b)); align-items: center; }
  .modal { width: 100%; max-height: calc(var(--app-h) - 24px); border-radius: 16px; }
  .modal-head { padding: 14px 15px; }
  .modal-body { padding: 15px; }
  .modal-foot { padding: 12px 15px calc(12px + var(--safe-b)); flex-wrap: wrap; }
  .modal-foot > * { flex: 1 1 auto; }
  .modal-body .input-wrap { height: 46px; }
  .pick-list { max-height: min(46dvh, 320px); }
  .lightbox { padding: 12px; }
  .toast { max-width: 92vw; word-break: break-word; }
  .not-friend-bar { padding: 9px 10px; gap: 6px; }
  .not-friend-bar span { min-width: 100%; }
}

/* 更窄的机型（iPhone SE / 老安卓） */
@media (max-width: 380px) {
  .rail { gap: 8px; }
  .rail-nav { gap: 4px; }
  .rail-btn { width: 40px; height: 40px; }
  .rail-bottom { gap: 4px; }
  .side-head h2 { font-size: 17px; }
  .list-item { gap: 9px; padding: 9px 8px; }
  .msg-col { max-width: 88%; }
  .mo-actions { gap: 2px; }
  .mo-act { padding: 7px 8px; font-size: 12px; }
  .admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-stat { padding: 12px; }
  .admin-stat b { font-size: 19px; }
}

/* 横屏 / 矮屏（手机横过来看聊天） */
@media (max-width: 860px) and (max-height: 500px) {
  .rail { gap: 6px; padding-top: 8px; padding-bottom: 8px; }
  .rail-nav { gap: 2px; }
  .rail-btn { width: 36px; height: 36px; }
  .rail-logo svg { width: 28px; height: 28px; }
  .chat-head { height: 48px; }
  .typing-hint { display: none; }
  .chat-compose { padding-top: 4px; padding-bottom: calc(6px + var(--safe-b)); }
  .compose-box textarea { min-height: 36px; padding: 4px 12px; }
  .compose-tools { padding-top: 2px; }
  .compose-foot { padding: 2px 10px 7px 12px; }
  .mo-hero { min-height: 120px; }
  .mo-hero-inner { min-height: 120px; padding: 14px 16px; }
  .modal { max-height: calc(var(--app-h) - 12px); }
}
