/* ============ 设计令牌 ============ */
:root {
  --bg: #f4f2ee;
  --bg-deep: #eeebe5;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --surface-3: #f1eee8;
  --line: #e6e2da;
  --line-strong: #d8d3c9;
  --text: #1c1d1e;
  --text-2: #45484b;
  --muted: #70747a;
  --faint: #9aa0a6;
  --accent: #2f6b5a;
  --accent-2: #3f8a72;
  --accent-soft: #e7f1ec;
  --accent-ink: #1f4e41;
  --star: #c08a2e;
  --star-soft: #fbf1dd;
  --danger: #b5402f;
  --danger-soft: #fbeae7;
  --ok: #2f7d55;
  --shadow-sm: 0 1px 2px rgba(24, 32, 28, .05), 0 2px 8px rgba(24, 32, 28, .04);
  --shadow-md: 0 10px 30px rgba(24, 32, 28, .10), 0 2px 8px rgba(24, 32, 28, .05);
  --shadow-lg: 0 24px 70px rgba(18, 24, 21, .18);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --sidebar-w: 268px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "HarmonyOS Sans SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  --bg: #141618;
  --bg-deep: #101213;
  --surface: #1c1f21;
  --surface-2: #181b1d;
  --surface-3: #232729;
  --line: #2a2f32;
  --line-strong: #363c40;
  --text: #eceae5;
  --text-2: #c3c2bc;
  --muted: #93999e;
  --faint: #6d7378;
  --accent-soft: #1e3330;
  --accent-ink: #a8d5c6;
  --star-soft: #33280f;
  --danger-soft: #3a211d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, .45);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
img { max-width: 100%; }
::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============ 图标 ============ */
.icon { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }

/* ============ 布局 ============ */
#app { min-height: 100vh; }
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--surface-2); border-right: 1px solid var(--line);
  padding: 18px 14px 14px; gap: 4px; overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 14px; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; overflow: hidden; box-shadow: var(--shadow-sm); }
.brand-mark img { width: 100%; height: 100%; }
.brand-name { font-size: 15.5px; font-weight: 650; letter-spacing: .2px; line-height: 1.25; }
.brand-sub { font-size: 11.5px; color: var(--faint); letter-spacing: .3px; }

.sidebar-search { position: relative; margin: 2px 4px 10px; }
.sidebar-search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.sidebar-search input {
  width: 100%; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); padding: 0 34px 0 34px; font-size: 13px; outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.sidebar-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sidebar-search kbd {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font: 11px var(--mono); color: var(--faint); background: var(--surface-3);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px;
}
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; overflow-x: hidden; flex: 1; padding-bottom: 8px; }
.nav-group-label { font-size: 11px; color: var(--faint); letter-spacing: .6px; padding: 12px 12px 4px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 9px;
  color: var(--text-2); cursor: pointer; border: 0; background: transparent; text-align: left;
  font-size: 13.5px; transition: background .15s, color .15s; min-height: 34px;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-item .count { margin-left: auto; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.nav-item.active .count { color: var(--accent); }
.nav-sub { padding-left: 22px; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.nav-foot { flex: 0 0 auto; border-top: 1px solid var(--line); padding: 8px 0 6px; display: flex; flex-direction: column; gap: 2px; }

.main { min-width: 0; height: 100vh; overflow-y: auto; overflow-x: hidden; background: var(--bg); }
.main > #view { min-height: 100%; width: 100%; max-width: 1120px; margin: 0 auto; }
.flush { padding: 0 !important; height: 100%; display: flex; flex-direction: column; overflow: hidden; }

.mobile-nav { display: none; }

/* ============ 顶栏 / 页面 ============ */
.page { padding: 20px 26px 40px; min-height: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.page-title { font-size: 22px; font-weight: 660; letter-spacing: -.3px; margin: 0; }
.page-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.head-actions { display: flex; gap: 8px; align-items: center; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 13px; font-weight: 520;
  transition: background .16s, border-color .16s, color .16s, transform .1s, box-shadow .16s;
  white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--surface-3); color: var(--text); }
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 18px rgba(47, 107, 90, .22); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--danger); border-color: transparent; background: var(--danger-soft); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 14.5px; border-radius: 12px; }
.btn.icon-only { width: 36px; padding: 0; }
.btn.icon-only.sm { width: 30px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-quiet { background: var(--surface-3); border-color: transparent; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 0; background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.star.on { color: var(--star); }
.icon-btn.star.on svg { fill: var(--star); stroke: var(--star); }

/* ============ 表单 ============ */
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 10px;
  padding: 9px 12px; outline: none; font-size: 13.5px; transition: border-color .16s, box-shadow .16s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-soft); }
.textarea { min-height: 84px; resize: vertical; line-height: 1.6; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12.5px; color: var(--muted); font-weight: 520; }
.field .help { font-size: 11.5px; color: var(--faint); }
.field .err { font-size: 11.5px; color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .span2 { grid-column: span 2; }
.search-input-wrap { position: relative; }
.search-input-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search-input-wrap .input { padding-left: 38px; }

.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.checkbox input { appearance: none; width: 17px; height: 17px; border-radius: 5px; border: 1.5px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.checkbox input:checked { background: var(--accent); border-color: var(--accent); }
.checkbox input:checked::after { content: ""; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px, -1px); }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 10px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 12.5px; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 560; }

.toggle { position: relative; width: 42px; height: 24px; border-radius: 99px; background: var(--line-strong); border: 0; cursor: pointer; transition: background .2s; flex: 0 0 auto; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.toggle[aria-checked="true"] { background: var(--accent); }
.toggle[aria-checked="true"]::after { transform: translateX(18px); }

/* ============ 卡片 / 通用块 ============ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px 20px; }
.section { margin-top: 22px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 10px; }
.section-title { font-size: 13px; font-weight: 640; color: var(--text-2); letter-spacing: .3px; display: flex; align-items: center; gap: 7px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.hr { height: 1px; background: var(--line); border: 0; margin: 14px 0; }

/* ============ 头像 / 标签 / 徽章 ============ */
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  font-weight: 620; font-size: 15px; color: #fff; background: var(--accent); overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); letter-spacing: .5px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 66px; height: 66px; font-size: 24px; }
.avatar.xl { width: 86px; height: 86px; font-size: 31px; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.tiny { width: 22px; height: 22px; font-size: 10px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -8px; border: 2px solid var(--surface); }

.tag {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 5px;
  font-size: 11px; font-weight: 520; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
  border: 1px solid transparent;
}
.tag.tinted { background: color-mix(in srgb, var(--tag-color, var(--accent)) 13%, var(--surface)); color: color-mix(in srgb, var(--tag-color, var(--accent)) 78%, var(--text)); border-color: color-mix(in srgb, var(--tag-color, var(--accent)) 22%, transparent); }
.tag.star { background: var(--star-soft); color: var(--star); }
.badge { height: 19px; padding: 0 6px; border-radius: 5px; font-size: 10.5px; display: inline-flex; align-items: center; gap: 3px; background: var(--surface-3); color: var(--muted); }
.badge.accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.gold { background: var(--star-soft); color: var(--star); }

/* ============ 联系人列表 ============ */
.contacts-page { display: flex; flex-direction: column; height: 100%; }
.contacts-toolbar { display: flex; flex-direction: column; gap: 10px; padding: 16px 24px 0; position: sticky; top: 0; z-index: 20; background: var(--bg); }
.toolbar-top { display: flex; align-items: center; gap: 10px; }
.toolbar-title { font-size: 20px; font-weight: 660; letter-spacing: -.3px; }
.toolbar-title .count { font-size: 12px; color: var(--faint); font-weight: 500; margin-left: 6px; }
.toolbar-search { flex: 0 1 440px; max-width: 460px; }
.toolbar-search .input { height: 38px; border-radius: 10px; }
.chip-bar { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip-bar::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 12px; cursor: pointer;
  white-space: nowrap; transition: all .15s;
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--accent-ink); font-weight: 560; }
.chip .x { opacity: .65; font-size: 13px; }
.scope-line { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.scope-line b { color: var(--text); font-weight: 600; }
.toolbar-actions { display: flex; align-items: center; gap: 6px; }

.star-strip { display: flex; gap: 8px; overflow-x: auto; padding: 12px 24px 2px; scrollbar-width: none; }
.star-strip::-webkit-scrollbar { display: none; }
.star-card { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; flex: 0 0 auto; transition: all .15s; }
.star-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.star-card .name { font-weight: 560; font-size: 12.5px; }
.star-card .icon { color: var(--star); }

.list-wrap { flex: 1; padding: 4px 12px 40px; }
.letter-head {
  position: sticky; top: 0; z-index: 8; display: flex; align-items: center; gap: 8px;
  padding: 14px 12px 5px; font-weight: 700; font-size: 13px; color: var(--text-2);
  background: linear-gradient(var(--bg) 75%, transparent);
}
.letter-head span.line { flex: 1; height: 1px; background: var(--line); }
.row-item {
  display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px; cursor: pointer; transition: background .14s; position: relative;
}
.row-item:hover { background: var(--surface); box-shadow: var(--shadow-sm); }
.row-item .main-line { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-name { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14.5px; letter-spacing: .2px; }
.row-name .nick { font-weight: 400; color: var(--faint); font-size: 12px; }
.row-sub { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); flex: 0 0 auto; }
.row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; max-width: 210px; }
.row-phone { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.row-side { display: none; }
.sel-box { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; }
.row-item.selected .sel-box { background: var(--accent); border-color: var(--accent); color: #fff; }
.row-item.selected { background: var(--accent-soft); }

.alpha-index { position: sticky; right: 0; top: 40%; transform: translateY(-40%); align-self: flex-end; display: flex; flex-direction: column; gap: 1px; padding: 4px 6px; z-index: 15; }
.alpha-index button { width: 18px; height: 16px; border: 0; background: transparent; font-size: 10px; color: var(--faint); cursor: pointer; border-radius: 4px; font-weight: 600; padding: 0; }
.alpha-index button:hover { background: var(--surface-3); color: var(--accent); }

.list-foot { padding: 18px 24px 30px; color: var(--faint); font-size: 12px; display: flex; justify-content: space-between; border-top: 1px solid var(--line); margin-top: 10px; }

/* ============ 详情抽屉 ============ */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(18, 24, 21, .32); backdrop-filter: blur(2px); z-index: 60; opacity: 0; animation: fadeIn .2s forwards; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 430px; max-width: 94vw; background: var(--surface);
  z-index: 61; box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: slideIn .26s cubic-bezier(.2, .8, .3, 1); border-left: 1px solid var(--line);
}
.drawer-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.drawer-close { position: absolute; top: 12px; right: 12px; }
.profile { display: flex; gap: 14px; align-items: center; }
.profile .info { min-width: 0; flex: 1; }
.profile-name { font-size: 23px; font-weight: 660; letter-spacing: -.3px; display: flex; align-items: center; gap: 8px; }
.profile-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.quick-actions { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.qa {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; color: var(--text-2); cursor: pointer;
  transition: all .15s;
}
.qa:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.drawer-body { flex: 1; overflow-y: auto; padding: 6px 20px 30px; }
.drawer-foot { padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 8px; background: var(--surface-2); }
.info-block { padding: 14px 0; border-bottom: 1px solid var(--line); }
.info-block:last-child { border-bottom: 0; }
.info-title { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--faint); letter-spacing: .4px; margin-bottom: 8px; text-transform: uppercase; }
.info-line { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0; font-size: 13.5px; }
.info-line .k { color: var(--muted); width: 64px; flex: 0 0 auto; font-size: 12.5px; }
.info-line .v { flex: 1; min-width: 0; word-break: break-all; }
.info-line .copy { opacity: .55; }
.info-line:hover .copy { opacity: 1; }
.note-item { padding: 9px 0; border-bottom: 1px dashed var(--line); }
.note-item:last-child { border-bottom: 0; }
.note-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--faint); margin-bottom: 2px; }
.note-text { font-size: 13px; color: var(--text-2); white-space: pre-wrap; }
.note-add { display: flex; gap: 6px; margin-top: 8px; }
.note-add .input { height: 36px; }

/* ============ 今日 ============ */
.hero {
  position: relative; overflow: hidden; border-radius: var(--r-xl); padding: 26px 28px;
  background: linear-gradient(135deg, #274f46 0%, #2f6b5a 52%, #4a8a76 100%); color: #eef6f2;
  box-shadow: 0 18px 44px rgba(31, 78, 65, .28);
}
html[data-theme="dark"] .hero { background: linear-gradient(135deg, #1c3a33, #27564a 60%, #31695a); }
.hero::after { content: ""; position: absolute; right: -60px; top: -80px; width: 300px; height: 300px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.14), transparent 65%); }
.hero-date { font-size: 12.5px; letter-spacing: 1px; opacity: .78; }
.hero-title { font-size: 30px; font-weight: 660; letter-spacing: -.5px; margin-top: 6px; }
.hero-sub { font-size: 13px; opacity: .8; margin-top: 6px; }
.hero-stats { display: flex; gap: 26px; margin-top: 22px; position: relative; z-index: 1; flex-wrap: wrap; }
.hero-stat b { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.hero-stat span { display: block; font-size: 11.5px; opacity: .72; letter-spacing: .3px; }
.today-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; margin-top: 18px; }
.today-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.stat b { font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; display: block; }
.stat span { font-size: 11.5px; color: var(--muted); }
.bday-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.bday-item:last-child { border-bottom: 0; }
.bday-date { width: 42px; flex: 0 0 auto; text-align: center; font-size: 11px; color: var(--faint); }
.bday-date b { display: block; font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums; }
.bday-date.today b, .bday-date.today { color: var(--accent); }
.bday-name { font-weight: 560; font-size: 13.5px; }
.hl-today { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin: 4px 0; }
.task-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.task-item:hover { background: var(--surface-3); }
.task-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.task-dot.warn { background: var(--star); }
.task-dot.danger { background: var(--danger); }

/* ============ 整理 / 设置 ============ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 9px 14px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 13.5px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--accent-ink); border-bottom-color: var(--accent); font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.list-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 560; font-size: 13.5px; }
.list-row .sub { font-size: 11.5px; color: var(--faint); }
.drag-handle { color: var(--faint); cursor: grab; }
.dup-card { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; margin-bottom: 12px; }
.dup-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: 12.5px; }
.dup-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0; }
.dup-person { padding: 12px 14px; cursor: pointer; }
.dup-person + .dup-person { border-left: 1px solid var(--line); }
.dup-person:hover { background: var(--surface-2); }
.dup-name { font-weight: 620; font-size: 14.5px; }
.dup-line { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cmp-row { display: grid; grid-template-columns: 82px 1fr; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.cmp-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.cmp-row .k { color: var(--faint); font-size: 11.5px; }
.cmp-choice { border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px; cursor: pointer; background: var(--surface); color: var(--text-2); font-size: 11.5px; text-align: left; }
.cmp-choice.sel { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .icon { width: 46px; height: 46px; opacity: .4; margin-bottom: 10px; }
.empty h3 { margin: 0 0 4px; font-size: 16px; color: var(--text-2); font-weight: 600; }
.empty p { margin: 0 0 14px; font-size: 12.5px; }

.setting-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 14px; overflow: hidden; }
.setting-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .grow { flex: 1; min-width: 0; }
.setting-row .title { font-weight: 560; font-size: 13.5px; }
.setting-row .sub { font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.theme-pick { display: flex; gap: 8px; }
.theme-swatch { width: 46px; height: 34px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; overflow: hidden; display: flex; }
.theme-swatch span { flex: 1; }
.theme-swatch.active { border-color: var(--accent); }
.accent-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.accent-dot.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }
.field-type { font: 10.5px var(--mono); color: var(--faint); background: var(--surface-3); padding: 2px 6px; border-radius: 5px; }
.mount-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; background: var(--surface-3); font-size: 11.5px; cursor: pointer; user-select: none; }
.mount-chip.on { background: var(--accent-soft); color: var(--accent-ink); }

/* ============ 弹窗 / Toast ============ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(18, 24, 21, .38); backdrop-filter: blur(3px); z-index: 80; display: grid; place-items: center; padding: 20px; animation: fadeIn .18s; }
.modal {
  width: min(680px, 100%); max-height: min(88vh, 900px); background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: popIn .2s cubic-bezier(.2,.8,.3,1);
}
.modal.wide { width: min(860px, 100%); }
.modal.narrow { width: min(440px, 100%); }
.modal-head { padding: 16px 20px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 16px; font-weight: 640; }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); }

.toast-root { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(520px, calc(100vw - 32px)); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px;
  background: #202826; color: #f1f5f2; border-radius: 12px; box-shadow: var(--shadow-md); font-size: 12.5px;
  animation: toastIn .22s cubic-bezier(.2,.8,.3,1); max-width: 100%;
}
.toast.success { background: #1f3f34; }
.toast.error { background: #4a2320; }
.toast .msg { flex: 1; }
.toast .undo { border: 0; background: transparent; color: #ffd76e; font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.toast .undo:hover { background: rgba(255,255,255,.1); }
.toast .close { border: 0; background: transparent; color: rgba(255,255,255,.7); cursor: pointer; padding: 2px 4px; }
.toast.leaving { animation: toastOut .18s forwards; }

/* 选择条 */
.selection-bar {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-lg);
  border-radius: 999px; padding: 7px 8px; display: flex; align-items: center; gap: 4px; z-index: 55;
}
.selection-bar .sel-count { font-size: 12px; padding: 0 8px; color: var(--muted); }
.selection-bar .btn { height: 32px; border-radius: 999px; }
.sel-active .mobile-nav { display: none !important; }

/* 登录 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1200px 600px at 15% -10%, #e4efe9, transparent 60%),
  radial-gradient(900px 500px at 90% 110%, #efe7d9, transparent 55%), var(--bg); }
html[data-theme="dark"] .login-wrap { background: radial-gradient(1200px 600px at 15% -10%, #1b2e28, transparent 60%), var(--bg); }
.login-card { width: min(400px, 100%); padding: 32px 30px 26px; border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.login-logo { width: 54px; height: 54px; border-radius: 15px; overflow: hidden; box-shadow: var(--shadow-md); margin-bottom: 18px; }
.login-title { font-size: 24px; font-weight: 680; letter-spacing: -.5px; margin: 0 0 4px; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-hint { margin-top: 14px; padding: 10px 12px; border-radius: 9px; background: var(--surface-3); font-size: 11.5px; color: var(--muted); }
.login-foot { margin-top: 18px; text-align: center; font-size: 11.5px; color: var(--faint); }

/* 编辑器 */
.editor-paste { border: 1px dashed var(--line-strong); border-radius: 12px; padding: 12px; background: var(--surface-2); margin-bottom: 16px; }
.paste-hint { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.paste-area { width: 100%; min-height: 58px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 9px 10px; font-size: 13px; outline: none; resize: vertical; }
.paste-area:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.phone-row { display: flex; gap: 6px; margin-bottom: 7px; }
.phone-row .label-input { width: 82px; flex: 0 0 auto; }
.phone-row .value-input { flex: 1; }
.more-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); font-size: 12.5px; padding: 8px 0; user-select: none; }
.more-toggle:hover { color: var(--text); }
.more-body { margin-top: 6px; }
.sticky-foot { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 8px; justify-content: flex-end; z-index: 5; }

/* 导入 */
.wizard-step { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 12px; color: var(--faint); }
.wizard-step b { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--surface-3); font-weight: 600; color: var(--muted); }
.wizard-step b.on { background: var(--accent); color: #fff; }
.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.map-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.map-row .k { width: 62px; color: var(--muted); flex: 0 0 auto; }
.map-row .select { height: 32px; padding: 4px 8px; font-size: 12px; }
.table-preview { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; }
.table-preview table { border-collapse: collapse; width: 100%; font-size: 11.5px; }
.table-preview th, .table-preview td { padding: 6px 9px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table-preview th { background: var(--surface-2); position: sticky; top: 0; }
.table-preview tr:last-child td { border-bottom: 0; }

/* 骨架屏 */
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }

/* 动画 */
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideIn { from { transform: translateX(24px); opacity: .6 } to { transform: none; opacity: 1 } }
@keyframes popIn { from { transform: scale(.97); opacity: .7 } to { transform: scale(1); opacity: 1 } }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes toastOut { to { transform: translateY(8px); opacity: 0 } }
@keyframes shimmer { from { background-position: 100% 0 } to { background-position: 0 0 } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* 紧凑密度 */
html[data-density="compact"] .row-item { padding-top: 7px; padding-bottom: 7px; }
html[data-density="compact"] .letter-head { padding-top: 10px; }

/* ============ 响应式 ============ */
@media (max-width: 1120px) {
  :root { --sidebar-w: 236px; }
  .row-meta { max-width: 160px; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { height: auto; min-height: 100vh; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .page { padding: calc(14px + env(safe-area-inset-top)) 16px 24px; }
  .flush { height: auto; overflow: visible; }
  .mobile-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px) saturate(1.2);
    border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
    color: var(--muted); font-size: 11px; border-radius: 10px; border: 0; background: transparent; cursor: pointer;
  }
  .mobile-nav a.active { color: var(--accent); }
  .mobile-nav a .icon { width: 20px; height: 20px; }
  .mobile-nav a.active .icon { color: var(--accent); }

  .contacts-page { height: auto; }
  .contacts-toolbar { padding: 12px 14px 0; position: sticky; top: 0; }
  .toolbar-top { flex-wrap: wrap; }
  .toolbar-title { font-size: 18px; }
  .toolbar-search { order: 3; flex-basis: 100%; max-width: none; }
  .toolbar-top .spacer { display: none; }
  .toolbar-actions { margin-left: auto; }
  .sort-select { display: none; }
  .star-strip { padding: 10px 14px 0; }
  .list-wrap { padding: 0 6px 20px; }
  .letter-head { position: static; top: auto; }
  .row-item { grid-template-columns: 42px minmax(0, 1fr) auto; padding: 9px 10px; gap: 9px; }
  .row-item .avatar { width: 40px; height: 40px; }
  .row-meta { max-width: 92px; }
  .row-phone { font-size: 12px; }
  .row-tags { display: none; }
  .alpha-index { display: none; }
  .today-grid { grid-template-columns: 1fr; }
  .hero { padding: 22px 20px; }
  .hero-title { font-size: 26px; }
  .hero-stats { gap: 20px; }
  .stat-row { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .modal-backdrop { padding: 0; place-items: end center; }
  .modal, .modal.wide, .modal.narrow { width: 100%; max-height: 94vh; border-radius: 22px 22px 0 0; }
  .drawer { width: 100%; max-width: 100%; }
  .drawer-head { padding-top: calc(16px + env(safe-area-inset-top)); }
  .quick-actions { gap: 6px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .qa { justify-content: center; padding: 0 6px; }
  .selection-bar { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .setting-row { flex-wrap: wrap; row-gap: 10px; }
  .setting-row .grow { flex: 1 1 160px; }
  .login-card { padding: 26px 22px 22px; }
  .dup-body { grid-template-columns: 1fr; }
  .dup-person + .dup-person { border-left: 0; border-top: 1px solid var(--line); }
  .map-grid { grid-template-columns: 1fr; }
}

@media (min-width: 1600px) {
  :root { --sidebar-w: 292px; }
  .page { padding: 24px 40px 48px; }
  .contacts-toolbar { padding: 20px 32px 0; }
  .star-strip { padding: 14px 32px 2px; }
  .row-item { padding: 11px 14px; }
}
