/* ============================================================
   内容盒子 · 移动优先样式
   ============================================================ */

/* ---------- 新版本提示条 ---------- */

.update-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(8px + env(safe-area-inset-top, 0px));
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  width: calc(100% - 24px);
  max-width: 520px;
  padding: 11px 12px 11px 16px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
}

.update-bar.hidden {
  display: none;
}

.update-text {
  flex: 1;
  min-width: 0;
}

.update-btn {
  flex-shrink: 0;
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f8f8fb;
  --surface-3: #eeeef3;
  --text: #14141b;
  --text-2: #6e6e7c;
  --text-3: #a0a0ae;
  --border: #e6e6ee;
  --accent: #5757d6;
  --accent-2: #8b5cf6;
  --accent-soft: #ededfc;
  --danger: #e5484d;
  --danger-soft: #fdeced;
  --star: #f5a623;
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 43, 0.05);
  --shadow: 0 2px 8px rgba(20, 20, 43, 0.07), 0 12px 32px rgba(20, 20, 43, 0.06);
  --shadow-lg: 0 -8px 40px rgba(20, 20, 43, 0.14);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e13;
    --surface: #1a1a22;
    --surface-2: #202029;
    --surface-3: #2a2a35;
    --text: #f2f2f7;
    --text-2: #9c9cae;
    --text-3: #6b6b7d;
    --border: #2c2c38;
    --accent: #7b7bf0;
    --accent-2: #a78bfa;
    --accent-soft: #23233a;
    --danger: #ff6369;
    --danger-soft: #2e1a1c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 -8px 40px rgba(0, 0, 0, 0.55);
  }
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: 16px;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

.hidden {
  display: none !important;
}

/* ---------- 通用组件 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 48px;
  padding: 0 20px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  transition: transform 0.12s, opacity 0.12s, background 0.15s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.975);
}

.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  width: 100%;
  box-shadow: 0 4px 16px rgba(87, 87, 214, 0.28);
}

.btn-ghost {
  background: var(--surface-3);
  color: var(--text);
}

.btn-ghost-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.input:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.input::placeholder {
  color: var(--text-3);
}

.field {
  margin-bottom: 12px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 7px;
}

.field-error {
  font-size: 13px;
  color: var(--danger);
  margin-top: 6px;
  min-height: 0;
}

/* ---------- 启动 ---------- */

.boot {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg);
  z-index: 300;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.boot-text {
  font-size: 14px;
  color: var(--text-2);
}

/* ---------- 登录 ---------- */

.auth-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 22px calc(28px + var(--safe-bottom));
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 19px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 28px rgba(87, 87, 214, 0.3);
}

.auth-title {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin: 0 0 6px;
}

.auth-sub {
  font-size: 14px;
  color: var(--text-2);
  margin: 0;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  box-shadow: var(--shadow);
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-3);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}

/* 邮箱页签内的登录方式切换（验证码 / 密码） */
.mode-seg {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.mode-btn {
  flex: 1;
  padding: 8px 4px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}

.mode-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
  background: rgba(124, 58, 237, 0.06);
}

.tab {
  flex: 1;
  height: 38px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  transition: background 0.18s, color 0.18s;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.code-row {
  display: flex;
  gap: 10px;
}

.code-row .input {
  flex: 1;
  min-width: 0;
}

.code-btn {
  height: 50px;
  padding: 0 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.code-btn:disabled {
  color: var(--text-3);
  background: var(--surface-3);
}

.auth-hint {
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.6;
  margin: 14px 2px 0;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-3);
  font-size: 12.5px;
  margin: 18px 0;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-wechat {
  width: 100%;
  background: #07c160;
  color: #fff;
}

/* 微信内一键登录（置顶大按钮） */
.wx-big {
  padding: 14px;
  font-size: 16.5px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(7, 193, 96, 0.28);
}
.wx-cap {
  margin: 9px 0 0;
  font-size: 12.5px;
  color: var(--text-3);
  text-align: center;
}
.wx-alt-link {
  display: block;
  margin: 16px auto 0;
  background: none;
  border: none;
  padding: 6px 10px;
  font-size: 13.5px;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.auth-error {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13.5px;
  line-height: 1.5;
}

/* ---------- 主界面 ---------- */

.view {
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.topbar.scrolled {
  border-bottom-color: var(--border);
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.topbar-title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  transition: transform 0.12s;
}

/* 内容页左上角的返回按钮：醒目的蓝紫色胶囊 */
.viewer-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  padding: 0 14px 0 11px;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(87, 87, 214, 0.35);
  transition: transform 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.viewer-back:active {
  transform: scale(0.93);
}

.icon-btn:active {
  transform: scale(0.93);
}

.search-box {
  position: relative;
}

.search-box svg {
  position: absolute;
  left: auto;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 40px;
  padding: 0 42px 0 14px;
  border-radius: 11px;
  border: none;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  outline: none;
}

.search-input::placeholder {
  color: var(--text-3);
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 16px 4px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

/* 称呼抽屉：多行排列，可收起/展开 */
.apel-bar {
  padding: 0 16px;
}

/* 「家庭树」独立行 / 「称呼」开关独立行 */
.ftree-row {
  padding-bottom: 0;
}

.apel-toggle-row {
  padding: 8px 0 2px;
}

/* 行首「称呼」开关：点它展开/收起 */
.apel-head {
  background: var(--accent-soft);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.apel-hint {
  font-size: 12px;
  font-weight: 500;
}

.apel-arrow {
  font-size: 11px;
}

.apel-chips {
  flex-wrap: wrap;
  overflow-x: visible;
  padding: 8px 0 4px;
}

/* 称呼分类行（直系本姓 / 外系女系 / 母系 / 老婆系 / 家族）+ 称呼列表行：各占满一行 */
.apel-chips > .apel-groups,
.apel-chips > .apel-list {
  flex: 0 0 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
}

.apel-chips > .apel-list {
  padding-top: 4px;
}

/* 分类按钮：比称呼小一号，虚线框区分「分类」与「称呼」 */
.chip-sub2 {
  height: 27px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px dashed var(--border);
  box-shadow: none;
}

.chip-sub2.active {
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
}

.chip-sub2 .chip-count {
  font-size: 11px;
}

/* 设置里的称呼编辑器：按分类分块（直系本姓/外系女系/母系/老婆系/家族），块头可点开/收起 */
/* 块头：灰字加黑（提示词除外），点击可收起/展开 */
.apel-egroup-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-1, #17181a);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background 0.16s, color 0.16s;
}

.apel-egroup-head:active {
  transform: scale(0.96);
}

.apel-egroup.open .apel-egroup-head {
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
}

.apel-egroup-head .apel-gtri {
  font-size: 10px;
}

.apel-egroup-head .apel-gcnt {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.55;
  color: var(--text-1, #17181a);
}

.apel-eitems {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 8px;
}

/* 关键：flex 布局会压过 hidden 属性的默认 display:none，必须显式声明才能收起 */
.apel-eitems[hidden] {
  display: none;
}

/* 编辑器里的称呼 chips：灰字加黑（选中/删除态除外） */
.apel-eitems .cat-opt {
  color: var(--text-1, #17181a);
}

.apel-eitems .cat-opt.active {
  color: var(--accent);
}

.apel-eitems .cat-opt.rel-opt.del {
  color: var(--danger);
}

/* 收起时只显示两行，其余收起；点「称呼 ▸」展开全部 */
.apel-chips.collapsed {
  max-height: 86px;
  overflow: hidden;
}

/* 行尾 ＋ 新增称呼 */
.chip-add {
  border: 1.5px dashed var(--border);
  background: transparent;
  color: var(--text-2);
  font-weight: 700;
  font-size: 16px;
}

.chip {
  flex-shrink: 0;
  height: 33px;
  padding: 0 14px;
  border-radius: 17px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.16s, color 0.16s, transform 0.12s;
}

.chip:active {
  transform: scale(0.95);
}

.chip.active {
  background: var(--text);
  color: var(--bg);
}

.chip-count {
  font-size: 11.5px;
  opacity: 0.6;
}

.chips-sub {
  padding-top: 7px;
}

.chips-sub .chip {
  height: 29px;
  padding: 0 12px;
  font-size: 12.5px;
  background: var(--surface-2);
  box-shadow: none;
  border: 1px solid var(--border);
}

.chips-sub .chip.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* 「称呼」开关行：左侧称呼开关，右侧排序切换 */
.apel-headline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.apel-headline .apel-toggle-row {
  flex: 0 0 auto;
}

.sort-row {
  margin-left: auto;
  padding: 7px 0 2px;
}

/* 联系人列表的拼音分组字母（L / W / Z …） */
.py-letter {
  margin: 10px 2px 0;
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.py-letter:first-child {
  margin-top: 2px;
}

.card-tag-sub {
  background: var(--surface-3);
  color: var(--text-2);
}

.card-more {
  margin-left: auto;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  border-radius: 8px;
  flex-shrink: 0;
  align-self: center;
}

.cat-x {
  margin-left: 5px;
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
}

/* 分类编辑模式：改名 / 移动 / 删除 操作区 */
.cat-edit-ops {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.cat-edit-btn {
  flex: 1;
  height: 38px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cat-edit-btn:active {
  background: var(--surface-2);
}

.cat-edit-btn.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}

/* ---------- 分页页码 ---------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 0 4px;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.page-btn:active {
  background: var(--surface-2);
}

.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.page-btn.page-nav {
  font-size: 16px;
  line-height: 1;
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.page-ellipsis {
  min-width: 18px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* ---------- 卡片列表 ---------- */

.list {
  padding: 10px 16px calc(120px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.13s, box-shadow 0.16s;
  position: relative;
}

.card:active {
  transform: scale(0.985);
  box-shadow: var(--shadow);
}

.card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  justify-content: center;
  padding-right: 30px;
}

.card-title {
  font-size: 15.5px;
  font-weight: 650;
  line-height: 1.35;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-3);
  min-width: 0;
}

.card-tag {
  padding: 1.5px 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 11.5px;
  flex-shrink: 0;
}

.card-host {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-note {
  font-size: 12.5px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.card-thumb {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 11px;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--surface-3);
  user-select: none;
}

.card-thumb-letter {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

.card-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-star {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  border-radius: 8px;
}

.card-star.on {
  color: var(--star);
}

.empty {
  padding: 68px 32px;
  text-align: center;
  color: var(--text-2);
}

.empty-icon {
  width: 66px;
  height: 66px;
  margin: 0 auto 16px;
  border-radius: 20px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  color: var(--text-3);
}

.empty-title {
  font-size: 16px;
  font-weight: 650;
  color: var(--text);
  margin: 0 0 6px;
}

.empty-sub {
  font-size: 13.5px;
  margin: 0;
  line-height: 1.6;
}

/* ---------- 底部版块导航 ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 49;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.05);
}

.tab-item {
  flex: 1;
  height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}

.tab-item svg {
  width: 21px;
  height: 21px;
}

.tab-item.active {
  color: var(--accent);
}

.tab-item:active {
  transform: scale(0.94);
}

/* ---------- 健康版块（同源 iframe 承载「康衡 · 家庭健康管理」） ---------- */

.health-host {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: calc(56px + var(--safe-bottom));
  z-index: 30;
  background: var(--bg);
}

.health-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #f2f6fa;
}

/* ---------- 记事本 ---------- */

.note-card {
  padding: 13px 14px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  position: relative;
  transition: transform 0.13s;
}

.note-card:active {
  transform: scale(0.985);
}

.note-title {
  font-size: 15.5px;
  font-weight: 650;
  margin: 0 0 5px;
  line-height: 1.4;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-body {
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.6;
  margin: 0 0 7px;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
}

.note-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-3);
}

/* 事件提醒行 */
.note-event {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 2px 0 8px;
  padding: 8px 11px;
  background: var(--accent-soft);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--text-2);
}

.nev-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nev-btn {
  flex: none;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 999px;
}

/* 联系人备注记录 */
.clog-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  background: var(--surface-2);
  border-radius: 10px;
}

.clog-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.clog-text {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.clog-time {
  font-size: 11.5px;
  color: var(--text-3);
}

/* 待保存的新增项 */
.clog-new {
  outline: 1.5px dashed var(--accent);
  outline-offset: -1.5px;
}

.clog-pend {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
  border-radius: 999px;
  padding: 1px 7px;
  margin-right: 6px;
  vertical-align: middle;
}

.note-thumbs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  margin: 2px 0 8px;
  scrollbar-width: none;
}

.note-thumbs::-webkit-scrollbar {
  display: none;
}

.note-thumb {
  width: 54px;
  height: 54px;
  border-radius: 10px;
  background: var(--surface-2);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
  color: var(--text-3);
  cursor: pointer;
}

.note-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 编辑抽屉里的附件选择 */
.attach-row {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  scrollbar-width: none;
  min-height: 40px;
  align-items: center;
}

.attach-row::-webkit-scrollbar {
  display: none;
}

.attach-thumb {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 10px;
  background: var(--surface-2);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
  color: var(--text-3);
}

.attach-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attach-x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 10px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.note-more {
  margin-left: auto;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  border-radius: 8px;
  flex-shrink: 0;
}

/* ---------- 人际关系 ---------- */

.contact-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  position: relative;
  transition: transform 0.13s;
}

.contact-top {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* 名字下方的记录内容 */
.ctext {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding-left: 2px;
}

.contact-thumbs {
  margin: 0;
}

/* 「XX相关」入口按钮 */
.clog-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1.5px dashed var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
}

.clog-btn-name {
  font-weight: 600;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clog-btn-cnt {
  flex: none;
  font-size: 11.5px;
  color: var(--text-3);
}

.contact-card:active {
  transform: scale(0.985);
}

.contact-avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.contact-main {
  min-width: 0;
  flex: 1;
}

.contact-name {
  font-size: 15.5px;
  font-weight: 650;
  margin: 0 0 4px;
  line-height: 1.35;
  word-break: break-word;
}

.contact-info {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-3);
  min-width: 0;
  flex-wrap: wrap;
}

.contact-more {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  border-radius: 8px;
  flex-shrink: 0;
}

/* 推荐星标：亮的为已推荐到首页 */
.contact-star {
  font-size: 17px;
  line-height: 1;
  color: var(--text-3);
}

.contact-star.on {
  color: #f5a623;
}

/* 上下移位按钮 */
.contact-move {
  font-size: 9px;
  line-height: 1;
  color: var(--text-3);
  height: 16px;
}

/* ---------- 悬浮按钮 ---------- */

.fab {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  right: auto;
  bottom: calc(74px + var(--safe-bottom));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.45);
  z-index: 50;
  transition: transform 0.14s;
}

.fab:active {
  transform: translateX(-50%) scale(0.92);
}

/* ---------- AI 问答浮窗 ---------- */

.fab-ai {
  position: fixed;
  right: calc(14px + env(safe-area-inset-right, 0px));
  left: auto;
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  height: 40px;
  padding: 0 14px 0 12px;
  border-radius: 21px;
  border: none;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.45);
  z-index: 51;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: transform 0.14s;
}

.fab-ai-text {
  line-height: 1;
}

.fab-ai:active {
  transform: translateY(-50%) scale(0.93);
}

.ai-scrim {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 20, 0.42);
  z-index: 150;
  animation: fade 0.2s ease;
}

.ai-panel {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + var(--safe-bottom));
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  z-index: 151;
  padding-bottom: var(--safe-bottom);
  animation: ai-up 0.24s ease;
}

@keyframes ai-up {
  from {
    transform: translate(-50%, 26px);
    opacity: 0.5;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

.ai-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 14px 10px 18px;
}

.ai-title {
  flex: 1;
  min-width: 0;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
}

.ai-head-btn {
  flex-shrink: 0;
  height: 32px;
  padding: 0 12px;
  border: none;
  border-radius: 9px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.ai-head-btn:active {
  background: var(--border);
}

.ai-head-close {
  width: 32px;
  padding: 0;
  font-size: 15px;
}

.ai-body {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-empty {
  margin: auto;
  text-align: center;
  color: var(--text-3);
  padding: 22px 0;
}

.ai-empty-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
}

.ai-empty-sub {
  font-size: 12.5px;
  line-height: 1.6;
}

.ai-msg {
  display: flex;
}

.ai-msg.user {
  justify-content: flex-end;
}

.ai-bubble {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 15px;
  font-size: 14px;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.ai-msg.user .ai-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.ai-msg.ai .ai-bubble {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
  font-size: 16px;
  line-height: 1.7;
}

.ai-typing {
  display: inline-flex;
  gap: 4px;
  padding: 3px 0;
}

.ai-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  animation: ai-blink 1.2s infinite ease-in-out;
}

.ai-typing i:nth-child(2) {
  animation-delay: 0.18s;
}

.ai-typing i:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes ai-blink {
  0%,
  70%,
  100% {
    opacity: 0.3;
  }
  35% {
    opacity: 1;
  }
}

.ai-foot {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
}

.ai-input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
}

.ai-input:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.ai-send {
  flex-shrink: 0;
  height: 42px;
  padding: 0 18px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.ai-send:active {
  filter: brightness(0.94);
}

.ai-send.stop {
  background: var(--danger);
}

.ai-send:disabled {
  opacity: 0.55;
}

/* ---------- 底部抽屉 ---------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 20, 0.45);
  z-index: 100;
  animation: fade 0.2s ease;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 110;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
  padding: 8px 18px calc(20px + var(--safe-bottom));
  max-height: 92dvh;
  overflow-y: auto;
  animation: slideUp 0.26s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
}

.sheet-grip {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  margin: 8px auto 14px;
}

.sheet-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 16px;
}

.cat-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* 编辑模式：每个分类左右各一个移动箭头 */
.cat-unit {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.cat-move {
  width: 26px;
  height: 34px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--accent);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.cat-move:active {
  background: var(--surface-2);
}

.cat-move.ghost {
  visibility: hidden;
}

/* 子分类块头部的「管理」按钮 */
.sub-manage-btn {
  border: none;
  background: none;
  padding: 0;
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cat-opt {
  height: 34px;
  padding: 0 13px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  transition: all 0.15s;
}

.cat-opt.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* 关系辈分：删除模式下变红提示 */
.cat-opt.rel-opt.del {
  border-color: var(--danger);
  color: var(--danger);
  background: transparent;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.sheet-actions .btn {
  flex: 1;
}

/* ---------- 内容查看器 ---------- */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.22s ease;
}

/* 音乐浮窗：离开查看器后继续播放 */
#audio-float {
  position: fixed;
  left: auto;
  right: 10px;
  bottom: 80px;
  width: auto;
  max-width: 46vw;
  z-index: 250;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
  padding: 3px 4px 3px 10px;
}

.af-head {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 0;
}

.af-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.af-close {
  border: none;
  background: var(--text);
  color: var(--surface);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  flex: none;
  cursor: pointer;
  padding: 0;
}

.af-audio {
  display: none;
}

@keyframes slideIn {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
}

.viewer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-top) + 8px) 12px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.viewer-head-title {
  flex: 1;
  min-width: 0;
}

.viewer-head-title h2 {
  font-size: 15px;
  font-weight: 650;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-head-title p {
  font-size: 11.5px;
  color: var(--text-3);
  margin: 1px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.embed-frame {
  width: 100%;
  border: none;
  background: #000;
  display: block;
}

.embed-media {
  width: 100%;
  display: block;
  background: #000;
  max-height: 62dvh;
}

.embed-fallback {
  padding: 44px 26px;
  text-align: center;
}

.embed-fallback-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 22px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  color: var(--text-3);
}

.embed-fallback h3 {
  font-size: 17px;
  margin: 0 0 8px;
}

.embed-fallback p {
  font-size: 14px;
  color: var(--text-2);
  margin: 0 0 22px;
  line-height: 1.65;
}

.viewer-info {
  padding: 16px 18px calc(28px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.viewer-info-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13.5px;
  margin-bottom: 10px;
}

.viewer-info-row .k {
  color: var(--text-3);
  flex-shrink: 0;
  width: 52px;
}

.viewer-info-row .v {
  color: var(--text);
  word-break: break-all;
  flex: 1;
}

.viewer-note {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.viewer-btns {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.viewer-btns .btn {
  flex: 1;
  height: 44px;
  font-size: 14.5px;
}

.viewer-hint {
  margin: 0 18px 14px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.6;
  border: 1px solid var(--border);
}

/* ---------- 连播控制条 ---------- */

.queue-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 18px 14px;
  padding: 9px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.q-btn {
  flex: none;
  min-width: 44px;
  height: 38px;
  padding: 0 10px;
  border: none;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-1);
  font-size: 15px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.q-btn.q-disabled {
  opacity: 0.35;
}

.q-btn.q-auto {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-3);
}

.q-btn.q-auto.on {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}

.q-mid {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-align: center;
}

.q-pos {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.q-next-name {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%) translateY(12px);
  z-index: 400;
  max-width: 84vw;
  padding: 11px 18px;
  border-radius: 12px;
  background: rgba(24, 24, 34, 0.93);
  color: #fff;
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  backdrop-filter: blur(10px);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 640px) {
  .list {
    max-width: 620px;
    margin: 0 auto;
  }
  .chips,
  .topbar {
    max-width: 620px;
    margin-left: auto;
    margin-right: auto;
  }
}

/* ===== 我的页面 ===== */
.me-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 16px;
}

.me-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent-soft, #efe9ff);
  color: var(--accent, #7c5cff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  flex-shrink: 0;
}

.me-info {
  min-width: 0;
}

.me-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.me-sub {
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 3px;
}

.me-stats {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-top: 12px;
  padding: 14px 0;
}

.me-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.me-stat + .me-stat {
  border-left: 1px solid var(--border);
}

.me-stat b {
  font-size: 18px;
  color: var(--text);
}

.me-stat span {
  font-size: 12px;
  color: var(--text-3);
}

.me-ver {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 18px;
}

/* ===== 家庭树 / 结构树通用 ===== */
.tree-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 90px;
}

.tree-gen {
  margin-bottom: 4px;
}

.tree-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 2px 2px 10px;
}

.tree-gen-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-2);
  margin: 10px 2px 8px;
}

.tree-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
}

.tree-empty {
  text-align: center;
  color: var(--text-3);
  font-size: 13.5px;
  padding: 30px 16px;
}

.tree-hint {
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  margin-top: 18px;
}

/* ===== 结构树视图：缩进 + 分支收起 ===== */
.st-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 2px 2px 10px;
}
.st-seg {
  display: inline-flex;
  background: var(--surface-3);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.st-seg-btn {
  border: none;
  background: none;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.st-seg-btn.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(20, 20, 43, 0.1);
}
.st-acts {
  display: inline-flex;
  gap: 6px;
}
.st-act {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.st-tree {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 4px;
}
.st-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  min-width: 0;
}
.st-arrow {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 7px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.st-arrow.leaf {
  border: none;
  background: none;
  cursor: default;
  color: var(--text-3);
}
.st-label {
  font-size: 14.5px;
  color: var(--text);
  line-height: 1.45;
  word-break: break-all;
  min-width: 0;
}
.st-sp {
  color: var(--text-2);
  font-size: 13px;
}
.st-badge {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}
.st-kids {
  margin-left: 19px;
  border-left: 1px dashed var(--border);
}

.chip-tree {
  border: 1.5px dashed var(--accent);
  color: var(--accent);
}

/* ===== 家庭树（手动结构树） ===== */
.ft-card {
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 0 0 auto; /* 不被行压缩，宽度按内容自适应，一行放不下横向滑 */
  min-width: 140px;
}

.ft-couple {
  display: flex;
  align-items: stretch;
  gap: 4px;
  position: relative;
}

.ft-couple .ft-block {
  flex: 0 0 auto; /* 按内容自适应，保证称呼/联系人全名显示 */
  min-width: 86px;
}

.ft-couple-link {
  align-self: center;
  color: var(--text-3);
  font-weight: 700;
  flex: 0 0 auto;
}

.ft-block {
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg, rgba(127, 127, 127, 0.06));
}

.ft-block.filled {
  border-style: solid;
  border-color: var(--accent);
}

.ft-cell {
  display: flex;
  width: 100%;
  border: none;
  background: transparent;
  padding: 6px 8px;
  font-size: 12px;
  align-items: center;
  gap: 6px;
  text-align: left;
  min-width: 0;
}

.ft-cell + .ft-cell {
  border-top: 1px solid var(--border);
}

.ft-cell-k {
  color: var(--text-3);
  flex: 0 0 auto;
  font-size: 11px;
}

.ft-cell-v {
  flex: 1;
  min-width: 0;
  max-width: 128px; /* 常见姓名全显；超长手写名截断保护 */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 600;
}

.ft-cell-v.empty {
  color: var(--text-3);
  font-weight: 400;
}

/* 称呼/联系人已填：不显示字样标签，内容稍大加粗 */
.ft-block.filled .ft-cell-v:not(.empty) {
  font-size: 13px;
  font-weight: 600;
}

.ft-ops {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.ft-op {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  border-radius: 8px;
  font-size: 11px;
  padding: 3px 8px;
}

.ft-op-del {
  color: #e5484d;
}

.ft-start {
  margin-top: 12px;
  padding: 10px 24px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.ft-new {
  display: block;
  margin: 18px auto 0;
}

/* 家庭树列表 */
.ftree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 6px 8px;
  margin-bottom: 8px;
}

.ftree-item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border: none;
  background: transparent;
  text-align: left;
  padding: 4px 2px;
}

.ftree-item-main b {
  font-size: 15px;
  color: var(--text);
}

.ftree-item-main span {
  font-size: 12px;
  color: var(--text-3);
}

.ftree-moves {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 0 0 auto;
}

.ftree-moves .ftree-item-op {
  padding: 2px 7px;
  font-size: 10px;
  line-height: 1.2;
}

.ftree-moves .ftree-item-op:disabled {
  opacity: 0.3;
}

.ftree-item-op {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 8px;
  font-size: 13px;
  padding: 5px 9px;
  color: var(--text-2);
}

.ft-picker {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-end;
}

.ft-picker-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.ft-picker-sheet {
  position: relative;
  width: 100%;
  max-height: 72vh;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
}

.ft-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  color: var(--text);
}

.ft-picker-x {
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--text-2);
  padding: 4px 8px;
}

.ft-picker-search {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  margin-bottom: 8px;
  background: var(--bg, rgba(127, 127, 127, 0.06));
  color: var(--text);
}

.ft-picker-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 120px;
}

.ft-pick-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  text-align: left;
}

.ft-pick-item span {
  color: var(--text-3);
  font-size: 12px;
}

/* ==================== 圈子（宗亲人脉圈） ==================== */

/* 角色徽标 */
.role-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-3);
  vertical-align: middle;
}
.role-badge.role-owner {
  color: #8a5a00;
  background: #fdeecd;
}
.role-badge.role-admin {
  color: var(--accent);
  background: var(--accent-soft);
}

/* 圈卡片 */
.circle-card {
  padding: 14px 16px;
}
.circle-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.circle-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}
.circle-main {
  flex: 1;
  min-width: 0;
}
.circle-name {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.circle-sub {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-2);
}

/* 详情头 */
.circle-detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.circle-detail-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

/* 发布器 */
.composer {
  padding: 12px 14px;
}
.composer .input {
  width: 100%;
  box-sizing: border-box;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  padding: 9px 10px;
}
.composer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  flex-wrap: wrap;
}
.post-pend {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 动态卡片 */
.circle-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0;
}
.post-card {
  padding: 12px 14px;
}
.post-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.post-who {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.post-time {
  flex: 1;
  font-size: 11.5px;
  color: var(--text-3);
}
.post-del {
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 12.5px;
  padding: 2px 4px;
}
.post-body {
  margin-top: 7px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.post-media {
  margin-top: 9px;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--surface-3);
  display: block;
}

/* 成员卡片 */
.members-card {
  padding: 12px 14px;
}
.members-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.members-head h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.circle-code {
  font-size: 12.5px;
  color: var(--text-2);
}
.circle-code b {
  color: var(--accent);
  letter-spacing: 1px;
}
.member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text);
  flex-wrap: wrap;
}
.member-row:last-child {
  border-bottom: none;
}
.member-ops {
  margin-left: auto;
  display: inline-flex;
  gap: 6px;
}

/* 联系人卡片上的圈标签 */
.card-tag-circle {
  color: var(--accent);
  background: var(--accent-soft);
}
