/* ============================================================
   Kuthon – Design System v2
   深色 · 玻璃态 · 流畅动效 · 移动优先
   ============================================================ */

/* ── CSS Variables ── */
:root {
  /* Core Palette */
  --bg-base:      #0d1117;
  --bg-primary:   #161b22;
  --bg-secondary: #1c2333;
  --bg-card:      #1e2a3a;
  --bg-card2:     #243042;
  --bg-input:     #1a2332;
  --bg-hover:     #253344;
  --bg-active:    #2a3a50;

  /* Accent – Kuthon Blue */
  --accent:       #4f8ef7;
  --accent-light: #74aaff;
  --accent-dark:  #2d6fd4;
  --accent-glow:  rgba(79,142,247,0.28);
  --accent-dim:   rgba(79,142,247,0.12);
  --accent-dim2:  rgba(79,142,247,0.06);

  /* Text */
  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #484f58;
  --text-link:      #58a6ff;

  /* System Colors */
  --success:  #3fb950;
  --warning:  #e3b341;
  --danger:   #f85149;
  --online:   #3fb950;
  --purple:   #bc8cff;
  --teal:     #39d353;

  /* Borders */
  --border:       rgba(255,255,255,0.08);
  --border-light: rgba(255,255,255,0.05);
  --border-focus: var(--accent);

  /* Chat Bubbles */
  --bubble-out:       #1a3a6e;
  --bubble-out-deep:  #152f5a;
  --bubble-in:        #1e2a3a;
  --bubble-text:      #e6edf3;

  /* Layout */
  --nav-height:  56px;
  --tab-height:  64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Radius */
  --r-xs:   4px;
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   18px;
  --r-xl:   24px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-sm:  0 1px 8px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 48px rgba(0,0,0,0.6);
  --shadow-accent: 0 4px 20px rgba(79,142,247,0.3);

  /* Motion */
  --ease:       cubic-bezier(0.4,0,0.2,1);
  --ease-spring:cubic-bezier(0.34,1.56,0.64,1);
  --t-fast:  0.12s;
  --t-base:  0.2s;
  --t-slow:  0.35s;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

a    { color: inherit; text-decoration: none; }
img  { max-width: 100%; display: block; }
input, textarea, select, button { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; }
ul { list-style: none; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── App Shell ── */
#app {
  display: flex; flex-direction: column;
  height: 100dvh; /* dynamic viewport height */
  overflow: hidden;
  position: relative;
  background: var(--bg-base);
}

/* ── NavBar ── */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: var(--nav-height);
  background: rgba(22,27,34,0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 12px;
  gap: 10px;
}
.navbar-back {
  width: 40px; height: 40px; border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-size: 20px;
  transition: background var(--t-base) var(--ease), transform var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.navbar-back:hover  { background: var(--accent-dim); }
.navbar-back:active { transform: scale(0.9); }

.navbar-title { flex: 1; min-width: 0; }
.navbar-title h1 {
  font-size: 17px; font-weight: 700; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -0.2px;
}
.navbar-title .subtitle {
  font-size: 12px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.navbar-actions { display: flex; gap: 2px; flex-shrink: 0; }
.navbar-btn {
  width: 40px; height: 40px; border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 18px;
  transition: all var(--t-base) var(--ease);
  position: relative;
}
.navbar-btn:hover  { background: var(--bg-hover); color: var(--text-primary); }
.navbar-btn:active { transform: scale(0.9); }
.navbar-btn.active { color: var(--accent); }

/* Connection status indicator */
.conn-indicator {
  position: fixed; top: var(--nav-height); left: 0; right: 0; z-index: 199;
  background: var(--warning); color: #000;
  font-size: 12px; font-weight: 600; text-align: center;
  padding: 5px 16px;
  animation: slideDown 0.3s var(--ease);
}
.conn-indicator.reconnecting { background: var(--danger); color: #fff; }
@keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Main Content ── */
.main-content {
  flex: 1;
  overflow-y: auto; overflow-x: hidden;
  padding-top: var(--nav-height);
  padding-bottom: calc(var(--tab-height) + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
.main-content::-webkit-scrollbar { width: 3px; }
.main-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* ── TabBar ── */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  height: calc(var(--tab-height) + var(--safe-bottom));
  background: rgba(22,27,34,0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border);
  display: flex; align-items: flex-start;
  padding: 6px 4px 0;
  padding-bottom: var(--safe-bottom);
}

.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; padding: 6px 0 4px;
  min-height: 50px;
  border-radius: var(--r-md);
  color: var(--text-muted); transition: color var(--t-base) var(--ease);
  position: relative; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tab-item:active { opacity: 0.7; }
.tab-icon {
  font-size: 22px; line-height: 1;
  transition: transform var(--t-base) var(--ease-spring);
}
.tab-item.active .tab-icon { transform: scale(1.12); }
.tab-label { font-size: 10px; font-weight: 600; letter-spacing: 0.2px; transition: color var(--t-base) var(--ease); }
.tab-item.active { color: var(--accent); }

/* Active tab underline indicator */
.tab-item.active::before {
  content: '';
  position: absolute; top: 0; left: 20%; right: 20%;
  height: 2px; background: var(--accent);
  border-radius: 0 0 2px 2px;
  animation: tabIn 0.25s var(--ease-spring);
}
@keyframes tabIn { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.tab-badge {
  position: absolute; top: 3px; right: calc(50% - 20px);
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 800; border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--bg-base);
  animation: badgePop 0.3s var(--ease-spring);
}
@keyframes badgePop { from { transform: scale(0); } to { transform: scale(1); } }

/* ── Page Transitions ── */
.slide-enter-active { transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease); }
.slide-leave-active { transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.slide-enter-from  { opacity: 0; transform: translateX(16px); }
.slide-leave-to    { opacity: 0; transform: translateX(-8px); }

/* ── Container ── */
.page { min-height: calc(100dvh - var(--nav-height) - var(--tab-height)); }
.container { max-width: 640px; margin: 0 auto; padding: 0 16px; }

/* ── Auth Pages ── */
.auth-page {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  min-height: calc(100dvh - var(--nav-height) - var(--tab-height));
  padding: 32px 24px 40px;
}
.auth-logo {
  font-size: 60px; margin-bottom: 16px;
  filter: drop-shadow(0 0 24px rgba(79,142,247,0.6));
  animation: float 3s ease-in-out infinite;
}
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }

.auth-title {
  font-size: 30px; font-weight: 800; color: var(--text-primary);
  margin-bottom: 8px; letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-subtitle { font-size: 14px; color: var(--text-secondary); margin-bottom: 36px; text-align: center; }
.auth-form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.auth-switch { margin-top: 22px; font-size: 13px; color: var(--text-secondary); text-align: center; }
.auth-switch a { color: var(--accent); font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }

/* ── Form Elements ── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; color: var(--text-secondary); font-weight: 600; letter-spacing: 0.2px; }
.form-input {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  color: var(--text-primary); font-size: 15px;
  transition: border-color var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease), background var(--t-base) var(--ease);
  width: 100%;
  outline: none;
}
.form-input:hover  { border-color: rgba(255,255,255,0.15); }
.form-input:focus  { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); background: rgba(26,35,50,0.9); }
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.form-error { font-size: 12px; color: var(--danger); display: flex; align-items: center; gap: 4px; }
.form-error::before { content: '⚠'; }
.form-hint  { font-size: 12px; color: var(--text-muted); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 20px; border-radius: var(--r-md);
  font-size: 15px; font-weight: 600;
  transition: all var(--t-base) var(--ease);
  white-space: nowrap; position: relative; overflow: hidden;
  cursor: pointer; outline: none;
  -webkit-tap-highlight-color: transparent;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--t-fast) var(--ease);
}
.btn:active::after { background: rgba(255,255,255,0.08); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; border: none;
}
.btn-primary:hover { box-shadow: var(--shadow-accent); transform: translateY(-1px); filter: brightness(1.08); }
.btn-primary:active { transform: translateY(0); box-shadow: none; }
.btn-primary:disabled { background: var(--bg-card2); color: var(--text-muted); box-shadow: none; transform: none; cursor: not-allowed; filter: none; }

.btn-secondary {
  background: var(--bg-card); color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: rgba(255,255,255,0.15); }

.btn-danger { background: linear-gradient(135deg, var(--danger), #c0392b); color: #fff; border: none; }
.btn-danger:hover { filter: brightness(1.1); transform: translateY(-1px); }

.btn-ghost { color: var(--accent); background: transparent; }
.btn-ghost:hover { background: var(--accent-dim); }

.btn-full { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: var(--r-sm); }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: var(--r-xs); }

/* ── Card ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* Glassmorphism card */
.glass-card {
  background: rgba(30,42,58,0.7);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--r-lg);
}

/* ── Section ── */
.section { padding: 16px; }
.section-title {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1.2px;
  margin-bottom: 10px; padding: 0 4px;
}

/* ── Settings List ── */
.settings-list {
  display: flex; flex-direction: column;
  background: var(--bg-card); border-radius: var(--r-lg);
  overflow: hidden; border: 1px solid var(--border);
}
.settings-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-bottom: 1px solid var(--border-light);
  transition: background var(--t-base) var(--ease); cursor: pointer;
  min-height: 56px;
  -webkit-tap-highlight-color: transparent;
}
.settings-item:last-child { border-bottom: none; }
.settings-item:hover  { background: var(--bg-hover); }
.settings-item:active { background: var(--bg-active); }
.settings-item-icon { font-size: 20px; width: 28px; text-align: center; flex-shrink: 0; }
.settings-item-body { flex: 1; min-width: 0; }
.settings-item-label { font-size: 15px; color: var(--text-primary); font-weight: 500; }
.settings-item-value { font-size: 12px; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.settings-item-arrow { color: var(--text-muted); font-size: 18px; font-weight: 300; }

/* ── Avatar ── */
.avatar {
  border-radius: var(--r-pill); object-fit: cover;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; flex-shrink: 0;
}
.avatar-sm  { width: 36px; height: 36px; font-size: 14px; }
.avatar-md  { width: 48px; height: 48px; font-size: 18px; }
.avatar-lg  { width: 64px; height: 64px; font-size: 24px; }
.avatar-xl  { width: 90px; height: 90px; font-size: 34px; }
.avatar img { width: 100%; height: 100%; border-radius: var(--r-pill); object-fit: cover; }

/* ── Chat List ── */
.chat-list { display: flex; flex-direction: column; }
.chat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border-light);
  transition: background var(--t-base) var(--ease); cursor: pointer;
  min-height: 72px;
  -webkit-tap-highlight-color: transparent;
}
.chat-item:hover  { background: var(--bg-hover); }
.chat-item:active { background: var(--bg-active); }
.chat-item-avatar { position: relative; flex-shrink: 0; }
.chat-item-body { flex: 1; min-width: 0; }
.chat-item-row { display: flex; align-items: center; gap: 8px; }
.chat-item-name { font-size: 15px; font-weight: 600; color: var(--text-primary); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.chat-item-preview { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
.chat-item-unread {
  min-width: 20px; height: 20px; border-radius: var(--r-pill);
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px; flex-shrink: 0;
}

/* ── Chat Room ── */
.chat-room {
  display: flex; flex-direction: column;
  height: calc(100dvh - var(--nav-height));
  position: relative;
}
.chat-messages {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 12px 10px 8px;
  display: flex; flex-direction: column; gap: 2px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

/* Message group */
.msg-group { display: flex; gap: 8px; max-width: 82%; animation: msgIn 0.2s var(--ease); }
.msg-group.out { flex-direction: row-reverse; margin-left: auto; }
.msg-group.in  { margin-right: auto; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Bubbles */
.bubble {
  padding: 9px 13px; border-radius: var(--r-lg);
  font-size: 14px; line-height: 1.55; word-break: break-word;
  position: relative; max-width: 100%;
  transition: opacity var(--t-fast);
}
.bubble.out {
  background: linear-gradient(135deg, #1e4080, var(--bubble-out));
  color: var(--bubble-text);
  border-radius: var(--r-lg) var(--r-lg) 4px var(--r-lg);
  box-shadow: 0 1px 8px rgba(30,64,128,0.4);
}
.bubble.in {
  background: var(--bubble-in);
  color: var(--bubble-text);
  border-radius: var(--r-lg) var(--r-lg) var(--r-lg) 4px;
  border: 1px solid var(--border-light);
}
.bubble-time { font-size: 10px; opacity: 0.5; margin-top: 4px; text-align: right; }
.bubble img { border-radius: var(--r-md); max-width: 220px; cursor: zoom-in; transition: opacity var(--t-base); }
.bubble img:hover { opacity: 0.9; }
.bubble.loading { opacity: 0.5; }

/* Decrypt states */
.decrypt-placeholder {
  color: var(--text-muted);
  font-style: italic;
  font-size: 12px;
  animation: decrypt-pulse 1.2s ease-in-out infinite;
}
@keyframes decrypt-pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 1; }
}
.decrypt-failed { color: var(--danger); font-size: 12px; }

/* Message text reveal transition */
.msg-reveal-enter-active { animation: msgReveal 0.25s var(--ease); }
.msg-reveal-leave-active  { animation: msgReveal 0.15s var(--ease) reverse; }
@keyframes msgReveal { from { opacity: 0; filter: blur(4px); } to { opacity: 1; filter: blur(0); } }

/* Date separator */
.chat-date-sep { text-align: center; margin: 14px 0 10px; }
.chat-date-sep span {
  font-size: 11px; color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 3px 12px; border-radius: var(--r-pill);
}

/* ── Chat Input Bar ── */
.chat-input-bar {
  padding: 10px 12px;
  padding-bottom: calc(10px + var(--safe-bottom));
  background: rgba(22,27,34,0.95);
  border-top: 1px solid var(--border);
  display: flex; align-items: flex-end; gap: 10px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.chat-input-wrap {
  flex: 1;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 22px;
  display: flex; align-items: flex-end; padding: 8px 14px; gap: 8px;
  transition: border-color var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
}
.chat-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.chat-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 15px; resize: none;
  max-height: 120px; min-height: 24px; line-height: 1.5;
  scrollbar-width: none; padding: 0;
}
.chat-input::-webkit-scrollbar { display: none; }
.chat-input::placeholder { color: var(--text-muted); }
.chat-attach-btn {
  color: var(--text-secondary); font-size: 20px;
  padding: 0 0 2px; transition: color var(--t-base) var(--ease);
  cursor: pointer; flex-shrink: 0;
  min-width: 24px; min-height: 24px;
  display: flex; align-items: center;
}
.chat-attach-btn:hover { color: var(--accent); }

.chat-send-btn {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-base) var(--ease-spring);
  box-shadow: 0 2px 12px rgba(79,142,247,0.4);
}
.chat-send-btn:hover:not(:disabled) { transform: scale(1.08); box-shadow: var(--shadow-accent); }
.chat-send-btn:active:not(:disabled) { transform: scale(0.94); }
.chat-send-btn:disabled {
  background: var(--bg-card2); color: var(--text-muted);
  box-shadow: none; transform: none; cursor: not-allowed;
}

/* ── Search Bar ── */
.search-bar {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--r-pill);
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; margin: 12px 16px;
  transition: border-color var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
}
.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.search-bar-icon { color: var(--text-muted); font-size: 16px; flex-shrink: 0; }
.search-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 15px;
}
.search-input::placeholder { color: var(--text-muted); }

/* ── User Card ── */
.user-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border-light);
  cursor: pointer; transition: background var(--t-base) var(--ease);
  min-height: 72px;
  -webkit-tap-highlight-color: transparent;
}
.user-card:hover  { background: var(--bg-hover); }
.user-card:active { background: var(--bg-active); }
.user-card-body { flex: 1; min-width: 0; }
.user-card-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.user-card-bio  { font-size: 13px; color: var(--text-secondary); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card-id   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Profile ── */
.profile-header {
  display: flex; flex-direction: column; align-items: center;
  padding: 32px 16px 24px;
  background: linear-gradient(180deg, rgba(79,142,247,0.08) 0%, transparent 100%);
  border-bottom: 1px solid var(--border-light);
  position: relative;
}
.profile-header::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-dim), transparent);
}
.profile-avatar-wrap {
  position: relative; margin-bottom: 16px; cursor: pointer;
}
.profile-avatar-wrap .edit-overlay {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--t-base) var(--ease); font-size: 22px;
}
.profile-avatar-wrap:hover .edit-overlay { opacity: 1; }
.profile-name { font-size: 22px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.3px; }
.profile-uid  { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.profile-bio  { font-size: 14px; color: var(--text-secondary); margin-top: 10px; text-align: center; max-width: 280px; line-height: 1.5; }

/* ── Key Box ── */
.key-box {
  background: var(--bg-input);
  border-radius: var(--r-md); padding: 12px 14px;
  font-family: 'SF Mono', 'Fira Code', monospace; font-size: 11px;
  color: var(--text-secondary); word-break: break-all;
  border: 1px solid var(--border); max-height: 100px; overflow-y: auto;
  line-height: 1.6;
}

/* ── Notification Item ── */
.notif-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border-light);
  transition: background var(--t-base) var(--ease);
  min-height: 72px;
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item-body { flex: 1; }
.notif-item-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.notif-item-msg  { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.notif-item-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.notif-item-actions { display: flex; gap: 8px; margin-top: 10px; }

.notif-badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: var(--r-pill); margin-left: 6px;
  vertical-align: middle;
}
.notif-badge.pending  { background: rgba(79,142,247,0.15); color: var(--accent); }
.notif-badge.accepted { background: rgba(63,185,80,0.15); color: var(--success); }
.notif-badge.rejected { background: rgba(248,81,73,0.12); color: var(--danger); }

/* ── Empty State ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 60px 32px; gap: 12px;
  animation: fadeUp 0.4s var(--ease);
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.empty-icon  { font-size: 56px; opacity: 0.25; }
.empty-title { font-size: 18px; font-weight: 600; color: var(--text-secondary); }
.empty-desc  { font-size: 14px; color: var(--text-muted); text-align: center; line-height: 1.5; max-width: 240px; }

/* ── Toast ── */
.toast-container {
  position: fixed; top: calc(var(--nav-height) + 10px);
  left: 50%; transform: translateX(-50%);
  z-index: 999; display: flex; flex-direction: column;
  gap: 8px; pointer-events: none;
  max-width: 90vw;
}
.toast {
  background: rgba(28,35,50,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text-primary);
  padding: 10px 20px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  white-space: nowrap;
  pointer-events: all; cursor: pointer;
  animation: toastIn 0.25s var(--ease-spring);
}
.toast.success { border-color: rgba(63,185,80,0.4); color: var(--success); }
.toast.error   { border-color: rgba(248,81,73,0.4); color: var(--danger); }
.toast.warning { border-color: rgba(227,179,65,0.4); color: var(--warning); }
@keyframes toastIn { from { opacity:0; transform: translateY(-12px) scale(0.9); } to { opacity:1; transform: none; } }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 300;
  padding-bottom: var(--safe-bottom);
  animation: overlayIn 0.2s var(--ease);
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal-sheet {
  background: var(--bg-secondary);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%; max-width: 600px;
  max-height: 85dvh; overflow-y: auto;
  padding: 0 20px 24px;
  border: 1px solid var(--border);
  border-bottom: none;
  animation: sheetUp 0.28s var(--ease-spring);
}
@keyframes sheetUp { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-handle {
  width: 36px; height: 4px; background: rgba(255,255,255,0.12);
  border-radius: 2px; margin: 14px auto 18px;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; letter-spacing: -0.2px; }

/* ── Loading Spinner ── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid rgba(255,255,255,0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 40px auto;
}
.spinner-sm { width: 22px; height: 22px; border-width: 2px; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Chip / Tag ── */
.chip { display: inline-block; padding: 3px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; }
.chip-accent { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(79,142,247,0.2); }
.chip-success { background: rgba(63,185,80,0.12); color: var(--success); }
.chip-danger  { background: rgba(248,81,73,0.12); color: var(--danger); }

/* ── Image Viewer ── */
.img-viewer {
  position: fixed; inset: 0; background: rgba(0,0,0,0.95);
  z-index: 400; display: flex; align-items: center; justify-content: center;
  cursor: zoom-out; animation: overlayIn 0.2s var(--ease);
}
.img-viewer img { max-width: 95vw; max-height: 90dvh; object-fit: contain; border-radius: var(--r-md); }
.img-viewer-close {
  position: absolute; top: 20px; right: 20px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.15); color: #fff; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t-base);
}
.img-viewer-close:hover { background: rgba(255,255,255,0.25); }

/* ── Divider ── */
.divider { height: 1px; background: var(--border-light); margin: 0; }

/* ── Gender ── */
.gender-male   { color: #58a6ff; }
.gender-female { color: #ec4899; }

/* ── Gender Options ── */
.gender-options { display: flex; gap: 8px; flex-wrap: wrap; }
.gender-opt {
  padding: 8px 18px; border-radius: var(--r-pill);
  border: 1.5px solid var(--border); font-size: 13px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--t-base) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.gender-opt:hover   { border-color: rgba(255,255,255,0.2); background: var(--bg-hover); }
.gender-opt.selected { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ── Toggle Switch ── */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; }
.toggle-label { font-size: 15px; color: var(--text-primary); font-weight: 500; }
.toggle-sub   { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.toggle-switch {
  width: 46px; height: 26px; border-radius: 13px;
  background: var(--bg-card2); border: 1.5px solid var(--border);
  position: relative; cursor: pointer;
  transition: background var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
  flex-shrink: 0;
}
.toggle-switch.on { background: var(--accent); border-color: var(--accent-dark); }
.toggle-knob {
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  position: absolute; top: 3px; left: 3px;
  transition: transform var(--t-base) var(--ease-spring);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.toggle-switch.on .toggle-knob { transform: translateX(20px); }

/* ── FAB ── */
.fab-btn {
  position: fixed; bottom: calc(var(--tab-height) + var(--safe-bottom) + 16px); right: 16px;
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-accent);
  transition: all var(--t-base) var(--ease-spring);
  z-index: 50;
  -webkit-tap-highlight-color: transparent;
}
.fab-btn:hover  { transform: scale(1.1) rotate(5deg); box-shadow: 0 6px 28px rgba(79,142,247,0.5); }
.fab-btn:active { transform: scale(0.96); }

/* ── Page Header ── */
.page-header-padding { padding-top: 16px; }

/* ── Copy button ── */
.copy-btn { font-size: 12px; color: var(--accent); cursor: pointer; margin-left: 6px; font-weight: 600; }
.copy-btn:hover { text-decoration: underline; }

/* ── Scroll to bottom btn ── */
.scroll-bottom-btn {
  position: absolute; bottom: 76px; right: 16px;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm); transition: all var(--t-base) var(--ease);
  z-index: 10;
}
.scroll-bottom-btn:hover { background: var(--bg-hover); color: var(--accent); }

/* ═══════════════════════════════════════════════
   社群 (Community) Styles
   ═══════════════════════════════════════════════ */

.group-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border-light);
  cursor: pointer; transition: background var(--t-base) var(--ease);
  min-height: 72px;
  -webkit-tap-highlight-color: transparent;
}
.group-card:hover  { background: var(--bg-hover); }
.group-card:active { background: var(--bg-active); }

.group-avatar {
  border-radius: var(--r-md); overflow: hidden; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800;
}
.group-avatar img { width: 100%; height: 100%; object-fit: cover; }

.group-card-body { flex: 1; min-width: 0; }
.group-card-name { font-size: 15px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-card-meta { font-size: 12px; color: var(--text-secondary); margin-top: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.group-card-desc { font-size: 12px; color: var(--text-muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.group-header {
  display: flex; flex-direction: column; align-items: center;
  padding: 28px 16px 24px;
  background: linear-gradient(180deg, rgba(79,142,247,0.07) 0%, transparent 100%);
  border-bottom: 1px solid var(--border-light);
  position: relative;
}
.group-header::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-dim), transparent);
}
.group-header-avatar {
  width: 80px; height: 80px; border-radius: var(--r-lg); overflow: hidden;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 800; color: #fff;
  margin-bottom: 14px;
  box-shadow: 0 4px 20px rgba(79,142,247,0.3);
}
.group-header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.group-header-name { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.group-header-id   { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.group-header-desc { font-size: 14px; color: var(--text-secondary); margin-top: 10px; text-align: center; max-width: 300px; line-height: 1.5; }
.group-header-stats { display: flex; gap: 32px; margin-top: 16px; }
.group-stat { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.group-stat-val { font-size: 20px; font-weight: 800; color: var(--text-primary); }
.group-stat-label { font-size: 11px; color: var(--text-muted); font-weight: 500; }

/* Sender name in group chat */
.bubble-sender-name {
  font-size: 11px; color: var(--accent-light); font-weight: 700;
  margin-bottom: 4px; padding-left: 2px;
}
.msg-group.out .bubble-sender-name { display: none; }

/* Role badges */
.role-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: var(--r-pill); margin-left: 5px;
  vertical-align: middle;
}
.role-badge.owner { background: rgba(227,179,65,0.2); color: var(--warning); border: 1px solid rgba(227,179,65,0.3); }
.role-badge.admin { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(79,142,247,0.2); }

/* Member row */
.member-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border-light);
  transition: background var(--t-base) var(--ease); min-height: 68px;
}
.member-row:hover { background: var(--bg-hover); }
.member-row-body { flex: 1; min-width: 0; }
.member-row-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.member-row-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.member-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Announcement */
.announcement-item {
  background: var(--bg-card); border-radius: var(--r-md);
  padding: 14px 16px; margin-bottom: 10px;
  border-left: 3px solid var(--accent);
  transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
}
.announcement-item:hover { transform: translateX(3px); box-shadow: var(--shadow-sm); }
.announcement-author { font-size: 12px; color: var(--accent); margin-bottom: 7px; font-weight: 700; }
.announcement-content { font-size: 14px; color: var(--text-primary); line-height: 1.65; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word; }
.announcement-time { font-size: 11px; color: var(--text-muted); margin-top: 10px; text-align: right; }

/* Group tabs */
.group-tabs { display: flex; background: var(--bg-secondary); border-bottom: 1px solid var(--border); }
.group-tab {
  flex: 1; padding: 14px; text-align: center;
  font-size: 14px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; transition: all var(--t-base) var(--ease);
  border-bottom: 2px solid transparent;
  -webkit-tap-highlight-color: transparent;
}
.group-tab:hover  { color: var(--text-secondary); background: var(--bg-hover); }
.group-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Status indicators */
.group-lock { font-size: 11px; color: var(--text-muted); }
.muted-badge { font-size: 10px; background: rgba(248,81,73,0.12); color: var(--danger); padding: 1px 6px; border-radius: var(--r-pill); margin-left: 4px; font-weight: 600; }
.join-pending { font-size: 13px; color: var(--warning); font-style: italic; text-align: center; padding: 12px 0; }
.group-join-btn { padding: 6px 14px; font-size: 12px; }

/* Group chat room */
.group-chat-room { display: flex; flex-direction: column; height: calc(100dvh - var(--nav-height)); }

/* ── Responsive ── */
@media (min-width: 640px) {
  .main-content { display: flex; justify-content: center; }
  .main-content > * { width: 100%; max-width: 640px; }
}
