/* ============================================
   家事通云端版 v3.1 - 全面打磨
   ============================================ */

:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-light: #14b8a6;
  --primary-bg: #f0fdfa;
  --bg: #f8f8f5;
  --surface: #ffffff;
  --text: #1c1917;
  --text-secondary: #78716c;
  --text-tertiary: #a8a29e;
  --border: #e7e5e4;
  --border-light: #f5f5f4;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --info: #3b82f6;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --font-base: 16px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body.font-large { --font-base: 19px; }
body.font-xlarge { --font-base: 22px; }

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: var(--font-base); }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', 'PingFang SC', 'Noto Sans SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  line-height: 1.6;
}

.page { width: 100%; height: 100dvh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ============================================
   登录页 - 温暖渐变背景
   ============================================ */
#loginPage {
  background: linear-gradient(160deg, #f0fdfa 0%, #e0f2f1 30%, #f5f5f0 70%, #fef3c7 100%);
}
.login-box {
  max-width: 360px; width: 90%; margin: auto; padding: 2rem;
  text-align: center;
}
.logo {
  font-size: 4rem; margin-bottom: 0.5rem;
  animation: logoFloat 3s ease-in-out infinite;
}
@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.login-box h1 { font-size: 1.8rem; color: var(--primary-dark); margin-bottom: 0.25rem; font-weight: 700; letter-spacing: 0.02em; }
.subtitle { color: var(--text-secondary); margin-bottom: 2rem; font-size: 0.9rem; }

.form-group { margin-bottom: 1rem; text-align: left; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.3rem; font-weight: 500; }
.form-group input, .form-group select {
  width: 100%; padding: 0.8rem 1rem; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 1rem; background: var(--surface);
  color: var(--text); outline: none; transition: all var(--transition);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.04);
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.1), inset 0 1px 2px rgba(0,0,0,0.04);
}
.form-group input::placeholder { color: var(--text-tertiary); }

.btn {
  padding: 0.7rem 1.25rem; border: none; border-radius: var(--radius-sm);
  font-size: 0.9rem; cursor: pointer; transition: all var(--transition);
  font-weight: 600; user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(13,148,136,0.3); }
.btn-primary:active { background: var(--primary-dark); box-shadow: none; }
.btn-secondary { background: var(--border-light); color: var(--text); }
.btn-secondary:active { background: var(--border); }
.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:active { background: var(--primary-bg); }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; border-radius: var(--radius-xs); }
.btn-block { width: 100%; padding: 0.9rem; font-size: 1rem; }
.tip { margin-top: 1.25rem; font-size: 0.8rem; color: var(--text-tertiary); }

/* ============================================
   顶部栏
   ============================================ */
.app-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  color: white; padding: 0.65rem 1rem; display: flex;
  justify-content: space-between; align-items: center;
  flex-shrink: 0; box-shadow: var(--shadow-md);
}
.header-left, .header-right { display: flex; align-items: center; gap: 0.5rem; }
.family-name { font-weight: 600; font-size: 1rem; cursor: pointer; }
.icon-btn {
  background: rgba(255,255,255,0.15); border: none; color: white;
  width: 2.1rem; height: 2.1rem; border-radius: 50%; cursor: pointer;
  font-size: 0.85rem; display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.icon-btn:active { background: rgba(255,255,255,0.3); }
.font-btn { font-weight: 800; font-size: 0.95rem; font-family: serif; }

/* 下拉菜单 */
.dropdown-menu {
  position: absolute; top: 3.2rem; left: 0.5rem; right: 0.5rem;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); z-index: 100; overflow: hidden;
  max-height: 70vh; overflow-y: auto;
  animation: menuIn 0.2s ease;
}
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.menu-header {
  padding: 0.75rem 1rem; font-weight: 600; font-size: 0.85rem;
  color: var(--text-tertiary); border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.menu-divider { height: 1px; background: var(--border-light); margin: 0.15rem 0; }
.menu-item {
  padding: 0.8rem 1rem; cursor: pointer; font-size: 0.9rem;
  transition: background var(--transition);
}
.menu-item:active { background: var(--primary-bg); }
.menu-danger { color: var(--danger); }
.menu-family-item {
  padding: 0.65rem 1rem; cursor: pointer; font-size: 0.9rem;
  display: flex; justify-content: space-between; align-items: center;
  transition: background var(--transition);
}
.menu-family-item:active { background: var(--primary-bg); }
.menu-family-item.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.menu-family-item .role-badge {
  font-size: 0.7rem; padding: 0.1rem 0.5rem; border-radius: 1rem;
  background: var(--primary-bg); color: var(--primary); font-weight: 500;
}

/* ============================================
   底部标签栏
   ============================================ */
.tab-bar {
  display: flex; background: var(--surface);
  border-top: 1px solid var(--border-light); flex-shrink: 0; z-index: 10;
  padding-bottom: 1px;
}
.tab-btn {
  flex: 1; padding: 0.4rem 0 0.35rem; border: none; background: none;
  color: var(--text-tertiary); cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  gap: 0.1rem; font-size: 0.62rem; transition: color var(--transition);
  position: relative;
}
.tab-btn.active { color: var(--primary); }
.tab-btn.active::before {
  content: ''; position: absolute; top: 0; left: 25%; right: 25%;
  height: 2px; background: var(--primary); border-radius: 0 0 2px 2px;
}
.tab-icon { font-size: 1.25rem; line-height: 1; }
.tab-badge {
  position: absolute; top: 0.15rem; right: 0.4rem;
  min-width: 1rem; height: 1rem; padding: 0 0.25rem;
  background: var(--danger); color: white; font-size: 0.55rem;
  border-radius: 0.5rem; display: flex; align-items: center; justify-content: center;
  font-weight: 700; line-height: 1;
}

/* ============================================
   标签内容区
   ============================================ */
.tab-content { display: none; flex: 1; overflow: hidden; flex-direction: column; }
.tab-content.active { display: flex; }

/* ============================================
   AI 聊天页
   ============================================ */
.chat-container {
  flex: 1; overflow-y: auto; padding: 0.75rem;
  display: flex; flex-direction: column; gap: 0.6rem;
  scroll-behavior: smooth;
}

.welcome-card {
  background: var(--surface);
  border-radius: var(--radius); padding: 1.25rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.welcome-card h3 { color: var(--primary-dark); margin-bottom: 0.4rem; font-size: 1.05rem; }
.welcome-card p { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.4rem; }

.quick-examples { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.quick-examples button {
  padding: 0.45rem 0.85rem; border: 1.5px solid var(--primary);
  border-radius: 1.25rem; background: var(--primary-bg); color: var(--primary);
  font-size: 0.8rem; cursor: pointer; font-weight: 500;
  transition: all var(--transition);
}
.quick-examples button:active { background: var(--primary); color: white; }

/* 消息气泡 */
.message {
  max-width: 82%; padding: 0.75rem 1rem; border-radius: 1.1rem;
  font-size: 0.9rem; line-height: 1.55; animation: msgIn 0.3s ease;
  word-break: break-word; white-space: pre-wrap;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(13,148,136,0.2);
}
.message.ai {
  align-self: flex-start; background: var(--surface);
  border-bottom-left-radius: 4px; box-shadow: var(--shadow);
}
.message.system {
  align-self: center; background: var(--border-light); color: var(--text-secondary);
  font-size: 0.72rem; padding: 0.25rem 0.75rem; white-space: nowrap;
  border-radius: 1rem;
}
.message.loading { display: flex; align-items: center; gap: 0.5rem; color: var(--text-secondary); }

.spinner {
  width: 1rem; height: 1rem; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 确认卡片 */
.confirm-card {
  background: #fffbeb; border: 1.5px solid #fcd34d;
  border-radius: var(--radius-sm); padding: 0.85rem;
  margin-top: 0.5rem; font-size: 0.85rem;
  white-space: normal; box-shadow: 0 1px 4px rgba(245,158,11,0.1);
}
.confirm-card p { color: #92400e; margin-bottom: 0.5rem; line-height: 1.5; }
.confirm-actions { display: flex; gap: 0.5rem; margin-top: 0.65rem; }
.confirm-actions .btn { flex: 1; padding: 0.55rem; font-size: 0.85rem; }

/* 快捷栏 */
.quick-bar {
  display: flex; gap: 0.5rem; padding: 0.45rem 0.75rem;
  overflow-x: auto; background: var(--surface);
  border-top: 1px solid var(--border-light); flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.quick-bar button {
  white-space: nowrap; padding: 0.35rem 0.8rem;
  border: 1px solid var(--border); border-radius: 1.25rem;
  background: var(--surface); font-size: 0.78rem;
  color: var(--text-secondary); cursor: pointer; font-weight: 500;
}
.quick-bar button:active { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); }

/* 输入区 */
.input-area, .message-input-area {
  display: flex; gap: 0.5rem; padding: 0.55rem 0.75rem;
  background: var(--surface); border-top: 1px solid var(--border-light);
  align-items: center; flex-shrink: 0;
}
.input-area input, .message-input-area input {
  flex: 1; padding: 0.6rem 1rem; border: 1.5px solid var(--border);
  border-radius: 1.5rem; font-size: 0.9rem; outline: none;
  transition: all var(--transition);
  background: var(--border-light);
}
.input-area input:focus, .message-input-area input:focus {
  border-color: var(--primary); background: var(--surface);
}

.voice-btn {
  width: 2.3rem; height: 2.3rem; border-radius: 50%; border: none;
  background: var(--border-light); color: var(--text-secondary);
  font-size: 1rem; cursor: pointer; flex-shrink: 0;
  transition: all var(--transition);
}
.voice-btn:active { background: var(--primary-bg); color: var(--primary); }
.send-btn {
  width: 2.3rem; height: 2.3rem; border-radius: 50%; border: none;
  background: var(--primary); color: white; font-size: 0.8rem;
  cursor: pointer; flex-shrink: 0; box-shadow: 0 2px 6px rgba(13,148,136,0.3);
  transition: all var(--transition);
}
.send-btn:active { background: var(--primary-dark); box-shadow: none; transform: scale(0.93); }

/* ============================================
   族谱页
   ============================================ */
.genealogy-header {
  padding: 0.6rem 0.6rem; display: flex;
  justify-content: space-between; align-items: center; gap: 0.4rem;
  background: var(--surface); border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.genealogy-search { flex: 1; }
.genealogy-search input {
  width: 100%; padding: 0.4rem 0.7rem; border: 1.5px solid var(--border);
  border-radius: 1.25rem; font-size: 0.82rem; outline: none;
  background: var(--border-light); transition: all var(--transition);
}
.genealogy-search input:focus { border-color: var(--primary); background: var(--surface); }
.genealogy-stats { font-size: 0.85rem; color: var(--text-secondary); font-weight: 500; }
.genealogy-actions { display: flex; gap: 0.4rem; }

.genealogy-tree-view, .member-list {
  flex: 1; overflow-y: auto; padding: 0.6rem;
}

/* 世代分组视图 */
.gen-group { margin-bottom: 0.8rem; }
.gen-group-header {
  font-size: 0.78rem; color: var(--text-secondary); font-weight: 600;
  padding: 0.25rem 0.6rem; margin-bottom: 0.4rem;
  border-left: 3px solid var(--primary); background: var(--primary-bg);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  display: inline-block;
}
.gen-group-cards { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.gen-member-card {
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 0.7rem; box-shadow: var(--shadow); flex: 1;
  min-width: calc(50% - 0.5rem); max-width: 100%;
  cursor: pointer; transition: all var(--transition);
  position: relative; border: 1px solid var(--border-light);
}
.gen-member-card:active { transform: scale(0.97); box-shadow: var(--shadow-md); }
.gen-member-card .card-top { display: flex; align-items: center; gap: 0.6rem; }
.gen-member-card .card-avatar {
  width: 2.2rem; height: 2.2rem; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.85rem; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(13,148,136,0.2);
}
.gen-member-card.male .card-avatar { background: linear-gradient(135deg, #3b82f6, #60a5fa); box-shadow: 0 2px 6px rgba(59,130,246,0.2); }
.gen-member-card.female .card-avatar { background: linear-gradient(135deg, #ec4899, #f472b6); box-shadow: 0 2px 6px rgba(236,72,153,0.2); }
.gen-member-card .card-name { font-weight: 600; font-size: 0.92rem; }
.gen-member-card .card-meta { font-size: 0.72rem; color: var(--text-tertiary); margin-top: 0.15rem; }
.gen-member-card .card-actions {
  position: absolute; top: 0.4rem; right: 0.4rem;
  display: flex; gap: 0.2rem;
}
.gen-member-card .card-action-btn {
  width: 1.4rem; height: 1.4rem; border-radius: 50%;
  border: none; background: rgba(0,0,0,0.04); color: var(--text-tertiary);
  font-size: 0.6rem; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: all var(--transition);
}
.gen-member-card .card-action-btn:active { background: var(--danger); color: white; }

/* 树形结构 */
.tree-container {
  display: flex;
  justify-content: center;
  padding: 0.8rem 0.3rem;
  min-width: fit-content;
}
.tree-root {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.tree-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.tree-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.5rem;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 4rem;
  max-width: 5.5rem;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.tree-card:active { transform: scale(0.97); box-shadow: var(--shadow-md); border-color: var(--primary); }
.tree-avatar {
  width: 2.2rem; height: 2.2rem; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.85rem; margin-bottom: 0.2rem;
  box-shadow: 0 2px 6px rgba(13,148,136,0.2);
}
.tree-card.male .tree-avatar { background: linear-gradient(135deg, #3b82f6, #60a5fa); box-shadow: 0 2px 6px rgba(59,130,246,0.2); }
.tree-card.female .tree-avatar { background: linear-gradient(135deg, #ec4899, #f472b6); box-shadow: 0 2px 6px rgba(236,72,153,0.2); }
.tree-name { font-weight: 600; font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tree-meta { font-size: 0.6rem; color: var(--text-tertiary); margin-top: 0.05rem; }
.tree-toggle {
  position: absolute; bottom: -0.45rem; left: 50%;
  transform: translateX(-50%);
  min-width: 1.2rem; height: 1.2rem; border-radius: 50%;
  border: none; background: var(--primary); color: white;
  font-size: 0.55rem; cursor: pointer; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  padding: 0 0.2rem; line-height: 1;
  box-shadow: 0 1px 4px rgba(13,148,136,0.3);
}
.tree-toggle:active { background: var(--primary-dark); }
/* 子节点容器 */
.tree-children {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1.4rem;
  padding-top: 0.6rem;
  position: relative;
}
/* 父节点到子节点组的垂直线 */
.tree-children::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  width: 2px; height: 0.6rem;
  background: linear-gradient(to bottom, var(--border), var(--primary-light));
  transform: translateX(-50%);
}
/* 每个子节点顶部的垂直线 */
.tree-node > .tree-children > .tree-node::before {
  content: '';
  position: absolute;
  top: -1.4rem; left: 50%;
  width: 2px; height: 1.4rem;
  background: linear-gradient(to bottom, var(--primary-light), var(--border));
  transform: translateX(-50%);
}

/* 列表视图 */
.member-list .member-card,
.task-list .task-card,
.message-list .msg-card {
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 0.8rem; margin-bottom: 0.4rem; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 0.7rem;
  border: 1px solid var(--border-light);
  transition: all var(--transition);
}
.member-avatar {
  width: 2.4rem; height: 2.4rem; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.9rem; flex-shrink: 0;
}
.member-info, .task-info { flex: 1; min-width: 0; }
.member-name, .task-title { font-weight: 600; font-size: 0.92rem; }
.member-meta, .task-meta { font-size: 0.78rem; color: var(--text-tertiary); margin-top: 0.1rem; }

/* ============================================
   事务页
   ============================================ */
.tasks-header {
  padding: 0.65rem 0.75rem; display: flex;
  justify-content: space-between; align-items: center;
  background: var(--surface); border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.task-tabs { display: flex; gap: 0.2rem; }
.task-tab-btn {
  padding: 0.3rem 0.55rem; border: none; border-radius: var(--radius-xs);
  background: var(--border-light); font-size: 0.75rem; color: var(--text-secondary);
  cursor: pointer; transition: all var(--transition); font-weight: 500;
}
.task-tab-btn.active { background: var(--primary); color: white; }

.task-list { flex: 1; overflow-y: auto; padding: 0.6rem; }
.task-card { cursor: default; }
.task-info { flex: 1; }
.task-title { font-weight: 600; font-size: 0.92rem; }
.task-meta { font-size: 0.78rem; color: var(--text-tertiary); margin-top: 0.1rem; }

.task-status {
  padding: 0.2rem 0.55rem; border-radius: 1rem; font-size: 0.68rem;
  font-weight: 600; flex-shrink: 0;
}
.status-pending { background: #fef3c7; color: #92400e; }
.status-in_progress { background: #dbeafe; color: #1e40af; }
.status-completed { background: #dcfce7; color: #166534; }
.status-cancelled { background: var(--border-light); color: var(--text-tertiary); }

.task-card-actions {
  display: flex; gap: 0.4rem; margin-top: 0.45rem;
  padding-top: 0.45rem; border-top: 1px solid var(--border-light);
}
.task-card-actions .btn { flex: 1; padding: 0.3rem; font-size: 0.75rem; }

/* ============================================
   消息页
   ============================================ */
.messages-header {
  padding: 0.7rem 0.75rem; display: flex;
  justify-content: space-between; align-items: center;
  background: var(--surface); border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.messages-header h3 { font-size: 1rem; font-weight: 600; }
.message-list { flex: 1; overflow-y: auto; padding: 0.6rem; }

.msg-card { align-items: flex-start; }
.msg-card .member-avatar { width: 1.9rem; height: 1.9rem; font-size: 0.75rem; }
.msg-content { flex: 1; min-width: 0; }
.msg-sender { font-weight: 600; font-size: 0.82rem; color: var(--primary); }
.msg-text { font-size: 0.88rem; margin-top: 0.1rem; word-break: break-word; line-height: 1.5; }
.msg-time { font-size: 0.68rem; color: var(--text-tertiary); margin-top: 0.2rem; }

.msg-card.system-msg {
  background: var(--primary-bg); border-left: 3px solid var(--primary);
  padding: 0.45rem 0.7rem; border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}
.msg-card.unread {
  background: linear-gradient(135deg, var(--surface), var(--primary-bg));
  border-left: 3px solid var(--primary);
}
.unread-dot {
  display: inline-block;
  width: 0.45rem; height: 0.45rem;
  background: var(--danger);
  border-radius: 50%;
  margin-left: 0.2rem;
  vertical-align: middle;
}

/* ============================================
   弹窗
   ============================================ */
.modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 200; padding: 0;
}
.modal-content {
  background: var(--surface); width: 100%; max-width: 480px;
  border-radius: var(--radius) var(--radius) 0 0;
  max-height: 85vh; overflow-y: auto; animation: slideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.modal-center { border-radius: var(--radius); align-self: center; max-height: 60vh; }
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  padding: 1rem; display: flex; justify-content: space-between;
  align-items: center; border-bottom: 1px solid var(--border-light);
}
.modal-header h3 { font-size: 1.05rem; font-weight: 600; }
.close-btn {
  background: none; border: none; font-size: 1.4rem;
  color: var(--text-tertiary); cursor: pointer; width: 2rem; height: 2rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: all var(--transition);
}
.close-btn:active { background: var(--border-light); }
.modal-body { padding: 1rem; }
.modal-footer {
  padding: 0.85rem 1rem; display: flex; gap: 0.6rem;
  border-top: 1px solid var(--border-light);
}
.modal-footer .btn { flex: 1; }

.overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35); z-index: 150;
  animation: overlayIn 0.2s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

/* ============================================
   邀请码展示
   ============================================ */
.invite-code-display {
  font-size: 2.2rem; font-weight: 700; letter-spacing: 0.6rem;
  color: var(--primary); padding: 1.2rem;
  background: var(--primary-bg); border-radius: var(--radius);
  font-family: 'Courier New', monospace;
  border: 2px dashed var(--primary);
}

/* ============================================
   Toast
   ============================================ */
.toast {
  position: fixed; bottom: 5.5rem; left: 50%; transform: translateX(-50%);
  background: rgba(28, 25, 23, 0.88); color: white;
  padding: 0.6rem 1.25rem; border-radius: 2rem; font-size: 0.82rem;
  z-index: 300; white-space: nowrap; animation: toastIn 0.3s ease;
  max-width: 80%; text-align: center; overflow: hidden; text-overflow: ellipsis;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-lg);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ============================================
   空状态
   ============================================ */
.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text-tertiary);
}
.empty-state p:first-child { font-size: 2rem; margin-bottom: 0.5rem; }
.empty-state .sub { font-size: 0.8rem; margin-top: 0.3rem; }

/* ============================================
   智能概览面板
   ============================================ */
.dashboard-panel {
  background: var(--surface); padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border-light); flex-shrink: 0;
}
.dash-cards { display: flex; gap: 0.4rem; }
.dash-card {
  flex: 1; text-align: center; padding: 0.45rem 0.2rem;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: all var(--transition); position: relative; overflow: hidden;
}
.dash-card::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
}
.dash-card:active { transform: scale(0.95); }
.dash-num { font-size: 1.3rem; font-weight: 700; line-height: 1.2; }
.dash-label { font-size: 0.6rem; color: var(--text-tertiary); margin-top: 0.1rem; font-weight: 500; }

/* 用固定颜色替代 color-mix（兼容性更好） */
.dash-card[data-color="teal"] { background: #f0fdfa; }
.dash-card[data-color="teal"]::after { background: var(--primary); }
.dash-card[data-color="teal"] .dash-num { color: var(--primary); }

.dash-card[data-color="blue"] { background: #eff6ff; }
.dash-card[data-color="blue"]::after { background: var(--info); }
.dash-card[data-color="blue"] .dash-num { color: var(--info); }

.dash-card[data-color="green"] { background: #f0fdf4; }
.dash-card[data-color="green"]::after { background: var(--success); }
.dash-card[data-color="green"] .dash-num { color: var(--success); }

.dash-card[data-color="amber"] { background: #fffbeb; }
.dash-card[data-color="amber"]::after { background: var(--warning); }
.dash-card[data-color="amber"] .dash-num { color: #d97706; }
.dash-card[data-color="rose"] { background: #fff1f2; }
.dash-card[data-color="rose"]::after { background: var(--danger); }
.dash-card[data-color="rose"] .dash-num { color: var(--danger); }
.dash-card[data-color="purple"] { background: #faf5ff; }
.dash-card[data-color="purple"]::after { background: #9333ea; }
.dash-card[data-color="purple"] .dash-num { color: #9333ea; }

/* ============================================
   AI 智能建议条
   ============================================ */
.suggestions-bar {
  background: #fffdf7; border-bottom: 1px solid #fef3c7;
  padding: 0.35rem 0.6rem; flex-shrink: 0;
}
.suggestions-scroll {
  display: flex; gap: 0.4rem; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.suggestions-scroll::-webkit-scrollbar { display: none; }
.suggestion-chip {
  white-space: nowrap; padding: 0.3rem 0.6rem;
  border-radius: 1rem; font-size: 0.72rem; cursor: pointer;
  display: flex; align-items: center; gap: 0.25rem;
  flex-shrink: 0; border: 1px solid; font-weight: 500;
}
.suggestion-chip.urgent { background: #fef2f2; border-color: #fecaca; color: #dc2626; }
.suggestion-chip.normal { background: #fff7ed; border-color: #fed7aa; color: #c2410c; }
.suggestion-chip.low { background: #f0fdf4; border-color: #bbf7d0; color: #16a34a; }
.suggestion-chip:active { transform: scale(0.95); }

/* ============================================
   新手引导遮罩
   ============================================ */
.guide-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 250;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.3s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.guide-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 2rem 1.5rem; max-width: 320px; width: 90%;
  text-align: center; animation: slideUp 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: var(--shadow-lg);
}
.guide-card h3 { font-size: 1.15rem; color: var(--primary-dark); margin-bottom: 0.7rem; }
.guide-card p { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 1.2rem; line-height: 1.7; }
.guide-steps { text-align: left; margin-bottom: 1.2rem; }
.guide-step { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0; font-size: 0.85rem; }
.guide-step-num {
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--primary); color: white; font-size: 0.72rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-weight: 700;
}

/* ============================================
   成功动画
   ============================================ */
.flash-success {
  animation: flashSuccess 1s ease;
}
@keyframes flashSuccess {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.6); }
  50% { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* 弹窗打开时禁止背景滚动 */
body.modal-open {
  overflow: hidden;
}

/* ============================================
   聊天优化 - 打字效果
   ============================================ */
.message.typing { opacity: 1; }
.typing-dots { display: inline-flex; gap: 4px; vertical-align: middle; margin-right: 4px; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-tertiary); animation: dotBounce 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ============================================
   滚动条美化
   ============================================ */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ============================================
   响应式
   ============================================ */
@media (min-width: 768px) {
  .page {
    max-width: 480px; margin: 0 auto;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    box-shadow: 0 0 40px rgba(0,0,0,0.08);
  }
  .modal { align-items: center; padding: 1rem; }
  .modal-content { border-radius: var(--radius); max-height: 80vh; }
  .gen-member-card { min-width: calc(33.33% - 0.5rem); }
  .dropdown-menu { left: calc(50% - 240px + 0.5rem); right: calc(50% - 240px + 0.5rem); }
}

/* 安全区域适配（iPhone X+） */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .tab-bar { padding-bottom: env(safe-area-inset-bottom); }
  .input-area, .message-input-area { padding-bottom: calc(0.55rem + env(safe-area-inset-bottom)); }
}
