/* ============================================================
   环聊IM · 设计系统 v2.1
   墨黑底 + 紫青羽光，夜间调性，克制留白
   ============================================================ */

:root {
  --brand-1: #EDC15C;
  --brand-2: #B07C1E;
  --brand-grad: linear-gradient(135deg, #F1D488 0%, #D9A93F 48%, #B07C1E 100%);
  --danger: #FF5C6C;
  --warn: #FFB454;

  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 32px;

  --ease: cubic-bezier(.32, .72, 0, 1);
  --dur: .28s;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

html[data-theme="dark"] {
  --bg: #080B10;
  --bg-grad: radial-gradient(120% 70% at 50% 0%, #16203A 0%, #0A0E15 55%, #070A0F 100%);
  --surface: #111723;
  --surface-2: #18202E;
  --surface-3: #212B3C;
  --line: rgba(255, 255, 255, .075);
  --line-strong: rgba(255, 255, 255, .14);
  --text: #E9EEF7;
  --text-2: #96A1B4;
  --text-3: #6B7688;
  --bubble-in: #18202E;
  --bubble-out: linear-gradient(135deg, #E8C368 0%, #C08A2D 100%);
  --bubble-out-text: #2A1D04;
  --soft: rgba(237, 193, 92, .14);
  --soft-mint: rgba(42, 217, 190, .13);
  --shadow: 0 22px 60px rgba(0, 0, 0, .6);
  --frame: rgba(255, 255, 255, .06);
  --mask: rgba(4, 6, 10, .72);
  --glow: rgba(217, 169, 63, .30);
}

html[data-theme="light"] {
  --bg: #F4F6FB;
  --bg-grad: radial-gradient(120% 70% at 50% 0%, #E8ECFA 0%, #F4F6FB 60%, #F7F9FD 100%);
  --surface: #FFFFFF;
  --surface-2: #F2F5FB;
  --surface-3: #E8EDF7;
  --line: rgba(14, 20, 34, .075);
  --line-strong: rgba(14, 20, 34, .14);
  --text: #0E1422;
  --text-2: #5C6779;
  --text-3: #8B95A7;
  --bubble-in: #FFFFFF;
  --bubble-out: linear-gradient(135deg, #DCAF45 0%, #B07C1E 100%);
  --bubble-out-text: #FFFFFF;
  --soft: rgba(176, 124, 30, .12);
  --soft-mint: rgba(20, 190, 165, .12);
  --shadow: 0 18px 44px rgba(22, 30, 54, .12);
  --frame: rgba(14, 20, 34, .07);
  --mask: rgba(18, 24, 38, .42);
  --glow: rgba(176, 124, 30, .20);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background .35s var(--ease), color .35s var(--ease);
}

button, input, textarea { font: inherit; color: inherit; border: none; background: none; outline: none; }
button { cursor: pointer; }
ul { list-style: none; }
svg { display: block; }

/* ---------- 设备外壳 ---------- */
.device {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--bg-grad);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: -30% -20% auto -20%;
  height: 60%;
  background: radial-gradient(closest-side, var(--glow), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

@media (min-width: 720px) {
  body { background: #05070B; display: grid; place-items: center; }
  html[data-theme="light"] body { background: #E6EAF3; }
  .app-shell {
    width: 414px;
    height: min(880px, 94vh);
    border-radius: 42px;
    border: 1px solid var(--frame);
    box-shadow: 0 40px 90px rgba(0, 0, 0, .55), 0 0 0 10px rgba(255, 255, 255, .02);
  }
  .app-shell::after {
    content: "";
    position: absolute;
    top: 10px; left: 50%;
    transform: translateX(-50%);
    width: 108px; height: 24px;
    border-radius: 0 0 16px 16px;
    background: rgba(0, 0, 0, .55);
    z-index: 60;
    pointer-events: none;
  }
  .screen { padding-top: 26px; }
  #guide, .screen--flush { padding-top: 26px; }
  #splash .splash-foot { bottom: 26px; }
}

/* ---------- 屏幕 ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
  background: var(--bg-grad);
  padding-top: var(--safe-t);
}
.screen.active { display: flex; animation: screenIn .32s var(--ease); }
@keyframes screenIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.screen--center { align-items: center; justify-content: center; text-align: center; padding: 32px 28px; }
.screen--pad { padding-left: 22px; padding-right: 22px; }
.screen--flush-top { padding-left: 0; padding-right: 0; }
.screen--flush { padding: 0; }

/* ---------- 品牌标记 ---------- */
.brand-mark {
  width: 64px; height: 64px;
  border-radius: 20px;
  background: url("../icons/icon-512.png") center / cover no-repeat;
  box-shadow: 0 12px 30px var(--glow), inset 0 0 0 1px rgba(255, 255, 255, .08);
  flex: none;
}
.brand-mark--lg { width: 76px; height: 76px; border-radius: 24px; }
.brand-mark--xl { width: 104px; height: 104px; border-radius: 32px; }

/* ---------- 启动页 ---------- */
#splash { z-index: 50; background: var(--bg-grad); }
.splash-glow {
  position: absolute; top: 26%; left: 50%;
  width: 300px; height: 300px; transform: translateX(-50%);
  background: radial-gradient(closest-side, var(--glow), transparent 70%);
  filter: blur(14px);
  animation: breathe 4s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: .55; transform: translateX(-50%) scale(1); } 50% { opacity: 1; transform: translateX(-50%) scale(1.12); } }

.brand-name {
  margin-top: 22px;
  font-size: 34px;
  font-weight: 650;
  letter-spacing: .32em;
  text-indent: .32em;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-tag { margin-top: 10px; color: var(--text-2); font-size: 13.5px; letter-spacing: .06em; }
.splash-bar { width: 128px; height: 3px; margin-top: 44px; border-radius: 3px; background: var(--line-strong); overflow: hidden; }
.splash-bar i { display: block; height: 100%; width: 40%; border-radius: 3px; background: var(--brand-grad); animation: load 1.3s var(--ease) forwards; }
@keyframes load { from { width: 6%; } to { width: 100%; } }
.splash-foot { position: absolute; bottom: 34px; left: 0; right: 0; font-size: 11px; letter-spacing: .22em; color: var(--text-3); }

/* ---------- 引导页 ---------- */
#guide { justify-content: space-between; }
.guide-track { display: flex; width: 300%; flex: 1; transition: transform .42s var(--ease); }
.guide-slide {
  width: 33.3333%;
  padding: 0 34px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}
.guide-art {
  width: 100%;
  height: 210px;
  border-radius: var(--r-lg);
  margin-bottom: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.guide-art::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(60% 60% at 50% 40%, var(--soft), transparent 70%);
}
.guide-art::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 96px; height: 96px;
  transform: translate(-50%, -50%);
  background: var(--brand-grad);
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-size: contain; mask-size: contain;
  opacity: .92;
}
.guide-art[data-art="lock"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round'%3E%3Crect x='4.5' y='10' width='15' height='10.5' rx='3'/%3E%3Cpath d='M8 10V7.5a4 4 0 018 0V10'/%3E%3Ccircle cx='12' cy='15.2' r='1.3' fill='%23000'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round'%3E%3Crect x='4.5' y='10' width='15' height='10.5' rx='3'/%3E%3Cpath d='M8 10V7.5a4 4 0 018 0V10'/%3E%3Ccircle cx='12' cy='15.2' r='1.3' fill='%23000'/%3E%3C/svg%3E");
}
.guide-art[data-art="burn"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3c1.6 3.4 4.8 4.8 4.8 8.4a4.8 4.8 0 01-9.6 0c0-1.5.5-2.6 1.4-3.6.4 1 1.1 1.7 2.1 1.9C10.4 7.7 11 5.2 12 3z'/%3E%3Cpath d='M6 20h12'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3c1.6 3.4 4.8 4.8 4.8 8.4a4.8 4.8 0 01-9.6 0c0-1.5.5-2.6 1.4-3.6.4 1 1.1 1.7 2.1 1.9C10.4 7.7 11 5.2 12 3z'/%3E%3Cpath d='M6 20h12'/%3E%3C/svg%3E");
}
.guide-art[data-art="calm"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M20 14.5A8.2 8.2 0 019.5 4a8.5 8.5 0 1010.5 10.5z'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M20 14.5A8.2 8.2 0 019.5 4a8.5 8.5 0 1010.5 10.5z'/%3E%3C/svg%3E");
}
.guide-slide h2 { font-size: 23px; font-weight: 640; letter-spacing: .01em; }
.guide-slide p { margin-top: 12px; color: var(--text-2); font-size: 14.5px; line-height: 1.72; max-width: 32ch; }

.guide-foot { padding: 0 34px calc(30px + var(--safe-b)); }
.dots { display: flex; gap: 7px; margin-bottom: 22px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); transition: all .3s var(--ease); }
.dots i.on { width: 22px; border-radius: 4px; background: var(--brand-1); }
.guide-actions { display: flex; gap: 10px; }
.guide-actions .btn--primary { flex: 1; }

/* ---------- 按钮 ---------- */
.btn {
  border-radius: 14px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 560;
  transition: transform .18s var(--ease), opacity .2s, background .2s;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--brand-grad); color: #fff; box-shadow: 0 12px 28px var(--glow); }
.btn--ghost { background: var(--surface-2); color: var(--text-2); }
.btn--block { width: 100%; margin-top: 6px; }
.btn--danger { background: rgba(255, 92, 108, .14); color: var(--danger); }
.btn--code {
  flex: none;
  padding: 9px 14px;
  font-size: 13px;
  border-radius: 11px;
  background: var(--soft);
  color: var(--brand-1);
  white-space: nowrap;
}
.btn--code:disabled { opacity: .5; }

.link-btn { color: var(--brand-1); font-size: 12.5px; }

/* ---------- 登录页 ---------- */
#login { align-items: center; text-align: center; }
.login-title { margin-top: 20px; font-size: 25px; font-weight: 640; letter-spacing: .02em; }
.login-sub { margin-top: 8px; color: var(--text-3); font-size: 12.5px; }
.field { width: 100%; text-align: left; margin-top: 22px; }
.field label { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 9px; letter-spacing: .06em; }
.field-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 4px 6px 4px 16px;
  transition: border-color .2s;
}
.field-row:focus-within { border-color: rgba(142, 124, 255, .5); }
.field-row input { flex: 1; padding: 13px 0; font-size: 16px; letter-spacing: .04em; background: none; min-width: 0; }
.field-row input::placeholder { color: var(--text-3); font-size: 14.5px; letter-spacing: 0; }
.field-prefix { color: var(--text-2); font-size: 14px; padding-right: 10px; border-right: 1px solid var(--line); }
.check { display: flex; gap: 9px; align-items: flex-start; margin: 20px 0 22px; font-size: 12.5px; color: var(--text-2); text-align: left; }
.check input { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--brand-1); flex: none; }
.login-note { margin-top: 18px; font-size: 11.5px; color: var(--text-3); line-height: 1.6; }

/* ---------- 页头 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 10px;
  position: relative; z-index: 5;
  flex: none;
}
.topbar--bare { height: 12px; padding: 0; }
.topbar-main { display: flex; align-items: center; gap: 8px; }
.topbar-title { font-size: 22px; font-weight: 650; letter-spacing: .01em; }
.topbar-badge {
  font-size: 11px; font-weight: 600; color: #fff;
  background: var(--brand-grad); border-radius: 9px; padding: 2px 7px;
  display: none;
}
.topbar-badge.on { display: inline-block; }
.topbar-actions { display: flex; gap: 4px; }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 13px;
  color: var(--text-2);
  transition: background .18s, color .18s, transform .16s;
}
.icon-btn:active { transform: scale(.92); background: var(--surface-2); }
.icon-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 搜索条 ---------- */
.searchbar {
  display: none;
  align-items: center;
  gap: 10px;
  margin: 0 16px 10px;
  padding: 0 6px 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  flex: none;
}
.searchbar.on { display: flex; animation: screenIn .22s var(--ease); }
.searchbar-ico { width: 17px; height: 17px; fill: none; stroke: var(--text-3); stroke-width: 1.9; stroke-linecap: round; }
.searchbar input { flex: 1; padding: 11px 0; font-size: 14px; min-width: 0; }
.searchbar input::placeholder { color: var(--text-3); }
.searchbar-x { font-size: 13px; color: var(--brand-1); padding: 8px 10px; }

/* ---------- 滚动区 ---------- */
.scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 16px calc(96px + var(--safe-b));
  scrollbar-width: none;
}
.scroll::-webkit-scrollbar { display: none; }

/* ---------- 会话列表 ---------- */
.chat-list { display: flex; flex-direction: column; gap: 2px; }
.chat-item {
  display: flex; align-items: center; gap: 13px;
  padding: 12px;
  border-radius: var(--r-md);
  position: relative;
  transition: background .18s;
  cursor: pointer;
}
.chat-item:active { background: var(--surface-2); }
.chat-item.pinned { background: linear-gradient(90deg, var(--soft), transparent 65%); }

.avatar {
  width: 50px; height: 50px; flex: none;
  border-radius: 17px;
  display: grid; place-items: center;
  font-size: 17px; font-weight: 600; color: #fff;
  letter-spacing: .02em;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.avatar--lg { width: 62px; height: 62px; border-radius: 21px; font-size: 21px; }
.avatar--sm { width: 32px; height: 32px; border-radius: 11px; font-size: 12px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.chat-main { flex: 1; min-width: 0; }
.chat-line1 { display: flex; align-items: baseline; gap: 8px; }
.chat-name { font-size: 15.5px; font-weight: 560; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-time { font-size: 11.5px; color: var(--text-3); flex: none; }
.chat-line2 { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.chat-preview {
  flex: 1; min-width: 0;
  font-size: 13px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-preview .burn-tag { color: var(--warn); }
.unread {
  flex: none;
  min-width: 19px; height: 19px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--brand-grad);
  color: #fff; font-size: 11px; font-weight: 600;
  display: grid; place-items: center;
}
.mute-ico { width: 13px; height: 13px; fill: none; stroke: var(--text-3); stroke-width: 2; flex: none; }

.empty { text-align: center; color: var(--text-3); font-size: 13px; padding: 60px 0; }
.empty-mark {
  display: block; width: 46px; height: 46px; margin: 0 auto 14px;
  border-radius: 16px; border: 1px dashed var(--line-strong);
}

/* ---------- 通讯录 ---------- */
.entry-group { background: var(--surface); border-radius: var(--r-md); overflow: hidden; margin-bottom: 14px; border: 1px solid var(--line); }
.entry {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 13px 14px; text-align: left;
  border-bottom: 1px solid var(--line);
  transition: background .16s;
}
.entry:last-child { border-bottom: none; }
.entry:active { background: var(--surface-2); }
.entry-ico {
  width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center; flex: none;
}
.entry-ico svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.entry-ico--violet { background: var(--soft); color: var(--brand-1); }
.entry-ico--mint { background: var(--soft-mint); color: var(--brand-2); }
.entry-label { flex: 1; font-size: 15px; }
.entry-meta { font-size: 12.5px; color: var(--text-3); }
.chev { width: 8px; height: 8px; border-right: 1.6px solid var(--text-3); border-top: 1.6px solid var(--text-3); transform: rotate(45deg); margin-right: 4px; flex: none; }

.scroll-sect { margin-top: 4px; }
.sect-label { font-size: 12px; color: var(--text-3); padding: 10px 12px 6px; letter-spacing: .08em; }

/* ---------- 发现 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 14px;
}
.card--feed { padding-bottom: 6px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text-2); letter-spacing: .06em; }

.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.feed-item:first-child { border-top: none; }
.feed-body { flex: 1; min-width: 0; }
.feed-who { font-size: 13.5px; font-weight: 560; color: var(--brand-1); }
.feed-text { margin-top: 5px; font-size: 14px; line-height: 1.62; color: var(--text); }
.feed-meta { display: flex; align-items: center; gap: 14px; margin-top: 9px; font-size: 12px; color: var(--text-3); }
.feed-like { display: flex; align-items: center; gap: 5px; color: var(--text-3); transition: color .2s; }
.feed-like.liked { color: var(--danger); }
.feed-like svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.feed-like.liked svg { fill: currentColor; }

.channel-list { display: flex; flex-direction: column; }
.channel {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-top: 1px solid var(--line);
  text-align: left; width: 100%;
}
.channel:first-child { border-top: none; }
.channel-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 16px; flex: none; }
.channel-name { flex: 1; font-size: 14.5px; }
.channel-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.channel-follow {
  font-size: 12px; padding: 6px 13px; border-radius: 10px;
  background: var(--soft); color: var(--brand-1); flex: none;
}
.channel-follow.on { background: transparent; color: var(--text-3); box-shadow: inset 0 0 0 1px var(--line-strong); }
.discover-note { text-align: center; font-size: 11.5px; color: var(--text-3); padding: 8px 0 20px; }

/* ---------- 我 ---------- */
.profile-card {
  display: flex; align-items: center; gap: 15px;
  padding: 6px 4px 20px;
}
.profile-info { flex: 1; min-width: 0; }
.profile-info h3 { font-size: 19px; font-weight: 620; }
.profile-info p { font-size: 12px; color: var(--text-3); margin-top: 4px; letter-spacing: .04em; }

.stat-row {
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 15px 0;
  margin-bottom: 16px;
}
.stat { text-align: center; position: relative; }
.stat + .stat::before {
  content: ""; position: absolute; left: 0; top: 12%; bottom: 12%;
  width: 1px; background: var(--line);
}
.stat b { display: block; font-size: 20px; font-weight: 640; letter-spacing: -.01em; }
.stat span { font-size: 11.5px; color: var(--text-3); }
.version-note { text-align: center; font-size: 11px; color: var(--text-3); padding: 12px 0 24px; letter-spacing: .05em; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: absolute;
  left: 12px; right: 12px; bottom: calc(10px + var(--safe-b));
  height: 62px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  z-index: 40;
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-size: 10.5px; position: relative;
  transition: color .2s;
}
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform .22s var(--ease); }
.tab.active { color: var(--brand-1); }
.tab.active svg { transform: translateY(-1px) scale(1.06); }
.tab-dot {
  position: absolute; top: 9px; right: calc(50% - 15px);
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); display: none;
  box-shadow: 0 0 0 2px var(--surface);
}
.tab-dot.on { display: block; }

/* ---------- 页面容器 ---------- */
.page { display: none; flex-direction: column; flex: 1; min-height: 0; }
.page.active { display: flex; animation: screenIn .26s var(--ease); }

/* ---------- 聊天页 ---------- */
#chat { z-index: 30; background: var(--bg-grad); }
.chat-header {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  flex: none;
}
.chat-who { flex: 1; min-width: 0; text-align: center; }
.chat-who h3 { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-who p { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.chat-who p.online { color: var(--brand-2); }

.burn-banner {
  display: flex; align-items: center; gap: 7px;
  margin: 10px 16px 0;
  padding: 9px 13px;
  border-radius: 12px;
  background: rgba(255, 180, 84, .1);
  color: var(--warn);
  font-size: 11.5px;
  flex: none;
}
.burn-banner svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; flex: none; }

.msg-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px 8px;
  scrollbar-width: none;
  display: flex; flex-direction: column;
}
.msg-scroll::-webkit-scrollbar { display: none; }
.msg-list { display: flex; flex-direction: column; gap: 12px; margin-top: auto; }

.day-divider { text-align: center; font-size: 11px; color: var(--text-3); padding: 8px 0 4px; }

.msg { display: flex; gap: 9px; align-items: flex-end; max-width: 100%; }
.msg--out { flex-direction: row-reverse; }
.msg-body { max-width: 76%; display: flex; flex-direction: column; gap: 4px; }
.msg--out .msg-body { align-items: flex-end; }

.bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
  animation: bubbleIn .24s var(--ease);
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
.msg--in .bubble { background: var(--bubble-in); border-bottom-left-radius: 6px; box-shadow: inset 0 0 0 1px var(--line); }
.msg--out .bubble { background: var(--bubble-out); color: var(--bubble-out-text); border-bottom-right-radius: 6px; }
.bubble img { max-width: 100%; border-radius: 12px; display: block; }
.bubble audio { width: 190px; height: 34px; display: block; }
.bubble--media { padding: 5px; background: var(--surface-2) !important; }

.msg-time { font-size: 10.5px; color: var(--text-3); padding: 0 4px; display: flex; align-items: center; gap: 5px; }
.msg-state { color: var(--brand-2); }

.bubble--burn { box-shadow: inset 0 0 0 1px rgba(255, 180, 84, .4); }
.bubble--burn .burn-dot { color: var(--warn); font-size: 11px; margin-left: 6px; }
.bubble--burning { animation: burnOut .9s var(--ease) forwards; }
@keyframes burnOut {
  0% { filter: blur(0); opacity: 1; }
  60% { filter: blur(3px); opacity: .5; }
  100% { filter: blur(8px); opacity: 0; transform: scale(.94); }
}
.msg--burned .bubble {
  background: transparent !important;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--text-3) !important;
  font-size: 12.5px;
  font-style: italic;
}

.typing { display: flex; gap: 4px; padding: 10px 16px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-3);
  animation: typing 1.1s infinite;
}
.typing i:nth-child(2) { animation-delay: .16s; }
.typing i:nth-child(3) { animation-delay: .32s; }
@keyframes typing { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

/* ---------- 输入区 ---------- */
.composer {
  flex: none;
  padding: 8px 12px calc(10px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
}
.composer-row { display: flex; align-items: flex-end; gap: 2px; }
.composer-row .icon-btn { width: 36px; height: 40px; }
.composer-row .icon-btn svg { width: 20px; height: 20px; }
#msgInput {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 9px 12px;
  margin: 0 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.45;
  resize: none;
  transition: border-color .2s;
  scrollbar-width: none;
}
#msgInput::-webkit-scrollbar { display: none; }
#msgInput:focus { border-color: rgba(142, 124, 255, .45); }
#msgInput::placeholder { color: var(--text-3); }

.send-btn {
  width: 40px; height: 40px; flex: none;
  border-radius: 14px;
  display: grid; place-items: center;
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 8px 20px var(--glow);
  transition: transform .16s var(--ease), opacity .2s;
}
.send-btn:active { transform: scale(.9); }
.send-btn svg { width: 19px; height: 19px; fill: currentColor; stroke: none; margin-right: 2px; }
.send-btn.idle { opacity: .38; box-shadow: none; }

.emoji-panel {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 10px 4px 4px;
  max-height: 168px;
  overflow-y: auto;
}
.emoji-panel button {
  height: 36px;
  font-size: 20px;
  border-radius: 10px;
  transition: background .15s;
}
.emoji-panel button:active { background: var(--surface-2); }

/* ---------- 设置页 ---------- */
.set-group { margin-bottom: 20px; }
.set-label { font-size: 11.5px; color: var(--text-3); letter-spacing: .1em; padding: 0 6px 8px; }
.set-row {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 14px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: none;
  text-align: left;
}
.set-row:first-of-type { border-radius: var(--r-md) var(--r-md) 0 0; }
.set-row:last-of-type { border-bottom: 1px solid var(--line); border-radius: 0 0 var(--r-md) var(--r-md); }
.set-row:only-of-type { border-radius: var(--r-md); border-bottom: 1px solid var(--line); }
.set-row--btn:active { background: var(--surface-2); }
.set-text { flex: 1; min-width: 0; }
.set-text b { display: block; font-size: 14.5px; font-weight: 500; }
.set-text span { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.set-row--danger .set-text b { color: var(--danger); }
.set-foot { font-size: 11.5px; color: var(--text-3); line-height: 1.75; padding: 4px 8px 30px; }

.switch { position: relative; width: 46px; height: 27px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch i {
  position: absolute; inset: 0;
  border-radius: 14px;
  background: var(--surface-3);
  transition: background .24s;
}
.switch i::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
  transition: transform .24s var(--ease);
}
.switch input:checked + i { background: linear-gradient(135deg, #DCAF45, #B07C1E); }
.switch input:checked + i::after { transform: translateX(19px); }

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  left: 50%; bottom: 110px;
  transform: translate(-50%, 12px);
  max-width: 78%;
  padding: 11px 18px;
  border-radius: 14px;
  background: color-mix(in srgb, #0B0F16 88%, transparent);
  color: #EDF1F8;
  font-size: 13px;
  text-align: center;
  backdrop-filter: blur(16px);
  opacity: 0;
  pointer-events: none;
  transition: all .28s var(--ease);
  z-index: 90;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 弹窗 ---------- */
.dialog-mask, .sheet-mask {
  position: absolute; inset: 0;
  background: var(--mask);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 80;
  display: flex;
  animation: fade .22s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.dialog-mask { align-items: center; justify-content: center; padding: 30px; }
.dialog {
  width: 100%;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px 20px 16px;
  box-shadow: var(--shadow);
  animation: pop .26s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.dialog h3 { font-size: 17px; font-weight: 620; text-align: center; }
.dialog p { margin-top: 10px; font-size: 13.5px; color: var(--text-2); line-height: 1.65; text-align: center; }
.dialog-input { margin-top: 16px; }
.dialog-input input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 15px;
}
.dialog-actions { display: flex; gap: 10px; margin-top: 20px; }
.dialog-actions .btn { flex: 1; padding: 12px; font-size: 14.5px; }

.sheet-mask { align-items: flex-end; }
.sheet {
  width: 100%;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 20px 14px calc(14px + var(--safe-b));
  border-top: 1px solid var(--line-strong);
  animation: slideUp .3s var(--ease);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-title { font-size: 12px; color: var(--text-3); text-align: center; padding-bottom: 12px; }
.sheet-items { display: flex; flex-direction: column; }
.sheet-item {
  padding: 15px;
  font-size: 15.5px;
  border-radius: 12px;
  text-align: center;
  transition: background .16s;
}
.sheet-item:active { background: var(--surface-2); }
.sheet-item--danger { color: var(--danger); }
.sheet-cancel {
  width: 100%;
  margin-top: 8px;
  padding: 15px;
  font-size: 15.5px;
  color: var(--text-2);
  background: var(--surface-2);
  border-radius: 14px;
}

[hidden] { display: none !important; }

/* ============================================================
   v3.0 服务端版新增样式：连接状态 / 在线 / 管理面板 / 通话
   ============================================================ */

.conn-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-3);
  transition: background .3s, box-shadow .3s;
  flex: none;
}
.conn-dot.on { background: #2AD9BE; box-shadow: 0 0 8px rgba(42, 217, 190, .8); }

.avatar { position: relative; }
.online-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #2AD9BE;
  border: 2.5px solid var(--bg);
}

.presence-tag { font-size: 11px; color: var(--text-3); flex: none; }
.presence-tag.on { color: #2AD9BE; }

.login-err {
  width: 100%; margin-top: 14px;
  padding: 9px 13px; border-radius: 11px;
  background: rgba(255, 92, 108, .12);
  color: var(--danger); font-size: 12.5px; text-align: left;
}

.dialog p { white-space: pre-line; }

/* 管理员 */
.admin-list { list-style: none; margin: 4px 0 16px; }
.admin-row {
  display: flex; align-items: center; gap: 11px;
  padding: 12px; margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.admin-main { flex: 1; min-width: 0; }
.admin-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14.5px; font-weight: 560; }
.admin-sub {
  margin-top: 3px; font-size: 11.5px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.admin-more { width: 34px; height: 34px; flex: none; }
.chip { font-size: 9.5px; padding: 1px 6px; border-radius: 6px; font-weight: 500; letter-spacing: .02em; }
.chip--gold { background: var(--soft); color: var(--brand-1); }
.chip--muted { background: rgba(255, 92, 108, .12); color: var(--danger); }
.chip--on { background: rgba(42, 217, 190, .14); color: #2AD9BE; }

.bubble--call {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13.5px; opacity: .92;
}

/* 通话 */
.screen--call {
  background: #05070A;
  z-index: 70;
  padding: 0;
  overflow: hidden;
}
#remoteVideo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: #05070A;
  display: none;
}
#localVideo {
  position: absolute;
  right: 16px; top: calc(74px + var(--safe-t));
  width: 104px; height: 148px;
  border-radius: 18px;
  object-fit: cover;
  background: #10141C;
  border: 1px solid rgba(255, 255, 255, .18);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .5);
  z-index: 3;
}
.screen--call:not(.is-video) #localVideo { display: none; }

.call-top {
  position: absolute; top: calc(30px + var(--safe-t)); left: 0; right: 0;
  text-align: center; z-index: 4;
}
.call-name { font-size: 20px; font-weight: 620; color: #fff; letter-spacing: .02em; }
.call-status { margin-top: 7px; font-size: 13px; color: rgba(255, 255, 255, .62); letter-spacing: .04em; }

.call-avatar-wrap {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 1;
}
.avatar--xl { width: 108px; height: 108px; border-radius: 36px; font-size: 40px; }

.call-actions {
  position: absolute; left: 0; right: 0;
  bottom: calc(46px + var(--safe-b));
  display: flex; align-items: flex-end; justify-content: center;
  gap: 30px; z-index: 5;
}
.call-btn {
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  color: rgba(255, 255, 255, .82); font-size: 11px;
}
.call-btn svg {
  width: 56px; height: 56px; padding: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .13);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  fill: none; stroke: #fff; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
  transition: background .2s, transform .16s;
}
.call-btn:active svg { transform: scale(.92); }
.call-btn.off svg { background: rgba(255, 255, 255, .92); stroke: #10141C; }
.call-btn--end svg { background: #FF4D5E; stroke: #fff; box-shadow: 0 10px 26px rgba(255, 77, 94, .45); }

.call-mask {
  position: absolute; inset: 0;
  background: rgba(4, 6, 10, .84);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 85;
  display: flex; align-items: center; justify-content: center;
  animation: fade .2s var(--ease);
}
.incoming-card {
  width: 78%; max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 26px;
  padding: 28px 22px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: pop .26s var(--ease);
}
.incoming-card .avatar--lg { margin: 0 auto; }
.incoming-card h3 { margin-top: 14px; font-size: 19px; font-weight: 620; }
.incoming-card p { margin-top: 5px; font-size: 12.5px; color: var(--text-3); }
.incoming-actions { display: flex; gap: 12px; margin-top: 22px; }
.incoming-actions .btn { flex: 1; padding: 13px; }
