:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #23232b;
  --muted: #8b8b98;
  --primary: #ff7eb3;
  --primary-dark: #e85d97;
  --primary-soft: #ffeef5;
  --border: #ececf2;
  --shadow: 0 1px 3px rgba(20, 20, 40, 0.06), 0 6px 18px rgba(20, 20, 40, 0.04);
  --radius: 16px;
  --tabbar-h: 60px;
}

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

/* 关键：确保 hidden 属性始终生效（否则被 .field 的 display:flex 覆盖，导致
   睡觉/尿布/吃药等类型错误地显示“结束时间/数量”字段）。 */
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top, 0));
  background: linear-gradient(135deg, #ff9ec7, #ff7eb3);
  color: #fff; box-shadow: 0 2px 10px rgba(232, 93, 151, 0.25);
}
.appbar .brand { font-size: 18px; font-weight: 700; letter-spacing: .5px; flex: 0 0 auto; }
/* 右侧：宝宝切换 + 退出登录。退出放在顶栏，任何页面都一眼可见、一键可达 */
.appbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; justify-content: flex-end; }
.child-switch {
  border: none; background: rgba(255,255,255,.22); color: #fff;
  padding: 4px 14px; border-radius: 14px; font-size: 13px; cursor: pointer;
  max-width: 100%; min-width: 0; display: flex; flex-direction: row; align-items: center;
  gap: 8px; line-height: 1.25;
}
.child-switch .cs-text { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; min-width: 0; }
/* 头像位：有头像显示照片，没有则用 👶 占位 —— 顶栏这个圆位始终在 */
.cs-avatar {
  position: relative; width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: rgba(255,255,255,.45); border: 1.5px solid rgba(255,255,255,.7);
}
.cs-avatar .child-avatar-img { width: 100%; height: 100%; border: none; border-radius: 0; }
.cs-avatar-ph { font-size: 15px; line-height: 1; }
.child-avatar-img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; display: block; flex: 0 0 auto; border: 1.5px solid rgba(255,255,255,.7); }
.top-logout {
  flex: 0 0 auto; border: 1px solid rgba(255,255,255,.65); background: rgba(255,255,255,.14);
  color: #fff; font-size: 12px; padding: 6px 10px; border-radius: 999px; cursor: pointer;
}
.top-logout:active { background: rgba(255,255,255,.4); }
.child-switch #childName { font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.child-switch .child-age { font-size: 11px; opacity: .92; }
.child-age:empty { display: none; }
.child-switch:active { background: rgba(255,255,255,.35); }

/* ---------- 布局 ---------- */
.container { max-width: 680px; margin: 0 auto; padding: 12px 12px calc(var(--tabbar-h) + 24px); }
.page { display: none; }
.page.active { display: block; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12px; }
.section-title { font-size: 14px; color: var(--muted); margin: 18px 6px 10px; font-weight: 600; }
.link-btn {
  display: block; width: 100%; margin: 10px 0 0; padding: 8px; border: none;
  background: transparent; color: var(--primary-dark); font-size: 14px; cursor: pointer;
}

/* ---------- 日期导航 ---------- */
.date-nav-wrap { position: relative; }
.date-nav { display: flex; align-items: center; gap: 8px; padding: 10px; }
.icon-btn {
  width: 38px; height: 38px; border: none; border-radius: 11px; flex: 0 0 auto;
  background: var(--bg); color: var(--primary-dark); font-size: 20px; line-height: 1; cursor: pointer;
}
.icon-btn:active { background: var(--primary-soft); }
.date-input { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 11px; padding: 8px 10px; font-size: 15px; background: #fff; color: var(--text); }
.date-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  cursor: pointer; text-align: left; font-weight: 600;
}
.date-btn .d-right { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
/* 当前这一天有记录时，按钮上会亮一个小圆点 */
.date-btn .d-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.date-btn .d-dot[hidden] { display: none; }
.date-btn .d-cal { font-size: 14px; opacity: .7; }

/* ---------- 日历弹层 ---------- */
.cal-pop {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60;
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 14px 36px rgba(20,20,40,.16); padding: 10px 12px 10px;
}
.cal-pop[hidden] { display: none; }
.cal-head { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.cal-title { flex: 1; text-align: center; font-weight: 700; font-size: 15px; }
.cal-nav {
  width: 32px; height: 32px; flex: 0 0 auto; border: none; border-radius: 9px;
  background: var(--bg); color: var(--primary-dark); font-size: 15px; line-height: 1; cursor: pointer;
}
.cal-nav:active { background: var(--primary-soft); }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 2px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-cell {
  position: relative; border: none; background: transparent; color: var(--text);
  border-radius: 11px; padding: 7px 0 13px; font-size: 14px; cursor: pointer; font-family: inherit;
}
.cal-cell.out { color: #c9c9d4; }
.cal-cell.today { box-shadow: inset 0 0 0 1.5px var(--primary); }
.cal-cell.sel { background: var(--primary); color: #fff; font-weight: 700; }
/* 有记录的日期：数字下方一个圆点 */
.cal-cell.has-rec::after {
  content: ''; position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--primary);
}
.cal-cell.sel.has-rec::after { background: #fff; }
.cal-cell:not(.sel):active { background: var(--primary-soft); }
.cal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.cal-legend { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.cal-legend i { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); display: inline-block; }
.cal-foot .text-btn { padding: 6px 12px; font-size: 13px; }
.text-btn {
  border: 1px solid var(--border); background: #fff; color: var(--primary-dark);
  border-radius: 11px; padding: 8px 14px; font-size: 14px; cursor: pointer; flex: 0 0 auto;
}
.text-btn:active { background: var(--primary-soft); }

/* ---------- 计时条 ---------- */
.timer-banner {
  margin-top: 12px; padding: 14px 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, #8e7cc3, #a58fd6); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow);
}
.timer-banner .tb-text { font-size: 15px; }
.timer-banner .tb-time { font-size: 20px; font-weight: 700; }
.timer-banner button {
  border: none; background: rgba(255,255,255,.25); color: #fff; padding: 8px 16px;
  border-radius: 999px; font-size: 14px; cursor: pointer;
}

/* ---------- 空家庭引导 ---------- */
/* 新注册账号是独立家庭、一个宝宝都没有：给一块明确的引导，
   免得面对满屏「暂无记录」不知所措。 */
.setup-banner {
  margin-top: 12px; padding: 14px 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, #ffe9f3, #fff6fa);
  border: 1px solid #ffd7e7; color: #8a3f63;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
}
.setup-banner .sb-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.setup-banner .sb-text strong { font-size: 15px; }
.setup-banner .sb-text span { font-size: 12.5px; opacity: .85; }
.setup-banner .sb-btn {
  flex: 0 0 auto; border: none; background: var(--primary); color: #fff;
  padding: 9px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.setup-banner .sb-btn:active { background: var(--primary-dark); }

/* ---------- 距上次 ---------- */
/* 用网格自动换行而不是横向滚动：卡片数量随类型编辑里勾选的「显示在距上次」增减，
   网格会把它们均分到可用宽度内、多出来的一行换到下一排，
   不会出现最后一张被右边缘裁掉的情况。 */
.since-bar {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  margin-top: 0;
}
.since-chip {
  background: var(--card); border-radius: 14px; padding: 10px 8px;
  box-shadow: var(--shadow); min-width: 0; text-align: center; cursor: help;
}
.since-chip .sc-top { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; justify-content: center; white-space: nowrap; }
.since-chip .sc-val { font-size: 15px; font-weight: 700; margin-top: 2px; }
/* 第三行：上次记录的具体时间，让「距上次」这排数字的含义一眼可懂 */
.since-chip .sc-sub { font-size: 11px; color: var(--muted); margin-top: 1px; line-height: 1.25; }
.since-chip .sc-sub:empty { display: none; }
.since-chip .sc-warn { font-size: 11px; color: #e8734a; margin-top: 1px; line-height: 1.25; }
.since-chip.warn .sc-val { color: #e8734a; }
.section-title .muted { font-weight: 400; font-size: 12px; }

/* ---------- 快捷记录 ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick-btn {
  border: none; border-radius: var(--radius); padding: 14px 6px; cursor: pointer;
  background: var(--card); box-shadow: var(--shadow); display: flex; flex-direction: column;
  align-items: center; gap: 6px; transition: transform .08s ease;
}
.quick-btn:active { transform: scale(.96); }
.quick-btn .ico { font-size: 26px; line-height: 1; }
.quick-btn .lbl { font-size: 13px; font-weight: 600; }
.quick-btn .bar { width: 22px; height: 3px; border-radius: 2px; }

/* ---------- 筛选 chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--border); background: #fff; color: var(--muted);
  padding: 6px 14px; border-radius: 999px; font-size: 13px; cursor: pointer;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- 记录列表 ---------- */
.event-list { list-style: none; margin: 0; padding: 0; }
.event-item {
  background: var(--card); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow);
  margin-bottom: 10px; display: flex; align-items: center; gap: 12px; border-left: 4px solid var(--border);
}
.event-item .e-ico { font-size: 22px; flex: 0 0 auto; }
.event-item .e-main { flex: 1; min-width: 0; }
.event-item .e-title { font-weight: 600; font-size: 15px; }
/* 跨夜标记：跟在标题后面，提示这条记录是从上一天开始的。 */
.e-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted, #8b8b98);
  background: rgba(127, 127, 140, 0.12);
  border-radius: 8px;
  vertical-align: middle;
}

/* 记录人：只在多人家庭出现，放得比时间更弱，不抢主信息。 */
.e-author-line { margin-top: 3px; }
.e-author {
  display: inline-block;
  font-size: 11px;
  color: var(--muted, #8b8b98);
}
.e-author::before { content: '✍️ '; opacity: .75; }

.event-item .e-meta { font-size: 13px; color: var(--muted); margin-top: 1px; word-break: break-word; }
.event-item .e-actions { display: flex; gap: 6px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }
.e-actions button {
  border: none; background: var(--bg); border-radius: 9px; width: auto; min-width: 32px; height: 32px;
  padding: 0 8px; font-size: 14px; line-height: 1; white-space: nowrap; cursor: pointer;
}
.e-actions button:active { background: var(--primary-soft); }
.empty-tip { text-align: center; color: var(--muted); padding: 28px 0; font-size: 14px; }
/* ---------- 关于 / 版本 ---------- */
.about-card { display: flex; flex-direction: column; gap: 10px; }
.about-row { display: flex; align-items: center; gap: 12px; }
.about-logo { font-size: 30px; line-height: 1; }
.about-info { flex: 1; min-width: 0; }
.about-name { font-size: 15px; font-weight: 600; }
.about-name b { color: var(--primary-dark); font-weight: 700; }
.about-card p { margin: 0; }
.about-card .text-btn { align-self: flex-start; }

/* 成长历史：把「10.3kg · 80cm」这种裸数字加上「体重/身高」说明 */
.event-item .e-meta .g-k { color: var(--muted); }
.event-item .e-meta .g-v { color: var(--text); font-weight: 600; }
.event-item .e-meta .g-d { color: #3f9c74; margin-left: 2px; }
/* 记录里的照片缩略图：在列表里也能一眼看出「这条拍了药」 */
.event-item .e-photos { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.event-item .e-photos img {
  width: 54px; height: 54px; object-fit: cover; border-radius: 9px;
  border: 1px solid var(--border); cursor: pointer; background: var(--bg);
}
.event-item .e-photos img:active { opacity: .8; }

/* ---------- 统计 ---------- */
.range-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.range-tabs button {
  flex: 1; border: 1px solid var(--border); background: #fff; color: var(--muted);
  padding: 9px 0; border-radius: 12px; font-size: 14px; cursor: pointer;
}
.range-tabs button.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.custom-range { display: flex; align-items: center; gap: 8px; margin: 0 2px 10px; flex-wrap: wrap; }
.custom-range input[type="number"] { width: 72px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; }
.custom-range .cr-apply { padding: 7px 16px; border-radius: 10px; border: none; background: var(--primary); color: #fff; font-size: 14px; cursor: pointer; }
.range-caption { margin: -4px 4px 12px; font-size: 12px; color: var(--muted); }

.stat-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-cards .stat {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
}
.stat .v { font-size: 20px; font-weight: 700; }
.stat .k { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat .sub { font-size: 12px; color: var(--muted); }

.chart-card { padding: 14px; margin-top: 12px; }
.chart-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .empty { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 0; }

.counts-table { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.counts-table .ct-row { display: flex; justify-content: space-between; background: var(--bg); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.counts-table .ct-row b { font-weight: 700; }

/* ---------- 宝宝头像与档案 ---------- */
.child-item .child-avatar {
  width: 46px; height: 46px; flex: 0 0 auto; border-radius: 50%; overflow: hidden;
  background: var(--primary-soft); display: flex; align-items: center; justify-content: center;
  font-size: 23px; line-height: 1; cursor: pointer;
}
.child-item .child-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.event-item .e-meta .g-line { margin-top: 2px; }

.avatar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.avatar-box {
  width: 72px; height: 72px; flex: 0 0 auto; border-radius: 50%; overflow: hidden;
  background: var(--primary-soft); display: flex; align-items: center; justify-content: center;
  font-size: 34px; line-height: 1; border: 2px solid #fff; box-shadow: var(--shadow);
}
.avatar-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-ops { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; }
.avatar-ops .text-btn { padding: 7px 13px; font-size: 13px; }
.avatar-ops .field-hint { line-height: 1.35; }

/* ---------- 表单 ---------- */
.form-card { padding: 14px; margin-top: 6px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1.4fr 1fr 56px; gap: 10px; align-items: end; }

/* 设置首页：卡片式导航列表（对齐安卓端 settings_page.dart 的 ListTile 卡片） */
.nav-card { padding: 0; overflow: hidden; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 14px;
  border: none;
  border-top: 1px solid var(--border);
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.nav-item:first-child { border-top: none; }
.nav-item:active { background: var(--primary-soft); }
/* 手机号/微信这两行会把绑定表单塞进右侧，行内容可能换行，允许 flex 折行 */
.nav-item.static { cursor: default; flex-wrap: wrap; }
.nav-item.static:active { background: transparent; }
.nav-item .link-right.grow { flex: 1 1 100%; margin-top: 8px; }
.nav-item .ni-ico { font-size: 20px; width: 26px; text-align: center; flex: 0 0 auto; }
.nav-item .ni-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-item .ni-title { font-weight: 700; font-size: 15px; }
.nav-item .ni-sub { font-size: 13px; color: var(--muted); }
.nav-item .ni-arrow { font-size: 22px; color: var(--muted); flex: 0 0 auto; line-height: 1; }
.nav-item .link-right { flex: 0 0 auto; }
.danger-text { color: #d8426f; }
.nav-item .link-right button, .nav-item .link-right a {
  padding: 7px 12px;
  font-size: 13px;
}

/* 设置子页（从设置首页点进去）：返回按钮 + 内容 */
.subpage { padding-top: 2px; }
.subback {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  padding: 2px 6px 8px;
  cursor: pointer;
}
.subback:active { opacity: .6; }

/* 类型与单位管理（布局对齐安卓端 types_page.dart） */
.readonly-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin: 0 6px 10px; }
.readonly-card .ro-ico { font-size: 20px; flex: 0 0 auto; }
.readonly-card .ro-title { font-weight: 700; font-size: 15px; }
.type-group {
  list-style: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding: 10px 6px 2px;
  letter-spacing: .3px;
}
.type-group:first-child { padding-top: 2px; }
.color-swatch {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #8b8b98;
}
/* 类型行尾的「⭐常用」星标按钮 */
.star-btn {
  border: none;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  padding: 6px 2px;
  cursor: pointer;
  filter: grayscale(1);
  opacity: .45;
}
.star-btn.on { filter: none; opacity: 1; }
/* 类型行尾的启用开关（比弹窗里的窄一些，省地方） */
.mini-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: 0 0 auto; }
.mini-switch input { opacity: 0; width: 0; height: 0; }
.mini-switch .slider { position: absolute; inset: 0; background: #cfcfd8; border-radius: 999px; transition: .18s; cursor: pointer; }
.mini-switch .slider::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: .18s;
}
.mini-switch input:checked + .slider { background: var(--primary); }
.mini-switch input:checked + .slider::before { transform: translateX(18px); }
/* 类型行：可点整行进入编辑 */
.type-row { cursor: pointer; }
.type-row.disabled { cursor: default; opacity: .8; }
/* 行尾的行内删除：和星标一样是行内小图标按钮，不抢「点整行编辑」的戏 */
.type-row .icon-btn.danger {
  width: auto; height: auto; padding: 6px 2px; background: transparent;
  font-size: 16px; color: #d8426f; opacity: .75;
}
.type-row .icon-btn.danger:active { opacity: 1; background: transparent; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 13px; color: var(--muted); }
.field-hint { font-size: 12px; color: var(--muted); font-style: normal; line-height: 1.4; }
.field input, .field select {
  border: 1px solid var(--border); border-radius: 11px; padding: 10px 12px; font-size: 15px;
  background: #fff; color: var(--text); width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.primary-btn {
  width: 100%; border: none; background: var(--primary); color: #fff; border-radius: 12px;
  padding: 12px; font-size: 16px; font-weight: 600; cursor: pointer; margin-bottom: 8px;
}
.primary-btn:active { background: var(--primary-dark); }

/* ---------- 成长 ---------- */
#page-growth .stat-cards { margin-bottom: 4px; }

/* ---------- 底栏 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0));
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1; border: none; background: transparent; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px;
}
.tab .ti { font-size: 19px; line-height: 1; filter: grayscale(1) opacity(.6); }
.tab.active { color: var(--primary-dark); font-weight: 600; }
.tab.active .ti { filter: none; }

/* ---------- 弹窗 ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(30,30,40,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal-backdrop[hidden] { display: none; }
.modal { background: #fff; width: 100%; max-width: 520px; border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0)); animation: slideUp .2s ease; max-height: 92vh; overflow-y: auto; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal h3 { margin: 0 0 14px; font-size: 18px; }
.type-badge { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 14px; font-weight: 600; }
.type-badge .ico { font-size: 22px; }
.chip-group { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-group .kchip { border: 1px solid var(--border); background: #fff; color: var(--muted); padding: 7px 16px; border-radius: 999px; font-size: 14px; cursor: pointer; }
.chip-group .kchip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
/* 备注快捷短语：比普通 chips 更轻，避免喧宾夺主 */
.note-chips { margin-top: 2px; }
.note-chips .kchip { padding: 5px 12px; font-size: 13px; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions .primary-btn { margin-bottom: 0; flex: 1; }
.modal-actions .text-btn { flex: 0 0 auto; }

/* ---------- 照片（表单里的拍照/相册 + 大图查看） ---------- */
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-actions .text-btn { flex: 1 1 auto; }
.photo-actions .text-btn:disabled { opacity: .45; cursor: not-allowed; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.photo-grid .ph-item { position: relative; width: 74px; height: 74px; }
.photo-grid .ph-item img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 11px;
  border: 1px solid var(--border); cursor: pointer; background: var(--bg);
}
.photo-grid .ph-del {
  position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; line-height: 1;
  border: none; border-radius: 50%; background: rgba(35,35,43,.86); color: #fff;
  font-size: 12px; cursor: pointer; padding: 0;
}
.lightbox {
  position: fixed; inset: 0; z-index: 400; background: rgba(12,12,16,.94);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 22px;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 78vh; border-radius: 12px; object-fit: contain; }
.lightbox .lb-close {
  position: absolute; top: calc(14px + env(safe-area-inset-top, 0)); right: 14px;
  width: 38px; height: 38px; border: none; border-radius: 50%;
  background: rgba(255,255,255,.18); color: #fff; font-size: 16px; cursor: pointer;
}
.lightbox .lb-open { color: #ffd7e8; font-size: 13px; text-decoration: none; }

/* ---------- 登录 ---------- */
.auth-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(160deg, #ff9ec7, #ff7eb3 55%, #f786c4);
}
.auth-card {
  width: 100%; max-width: 380px; background: #fff; border-radius: 22px;
  padding: 26px 22px; text-align: center;
  box-shadow: 0 18px 50px rgba(180, 60, 110, .28);
}
.auth-logo { font-size: 42px; line-height: 1; }
.auth-title { margin: 8px 0 4px; font-size: 20px; }
.auth-sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.auth-card .field { text-align: left; }
.auth-tip { margin: 8px 0 0; line-height: 1.5; }
/* 登录 / 注册时「绑定已有账号 / 创建新账号」的选择块 */
.choice-box { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); text-align: left; }
.choice-box:first-of-type { border-top: none; }
.choice-label { font-weight: 700; font-size: 14px; text-align: center; margin-bottom: 10px; }
.choice-box .field { margin-top: 10px; }
/* 后台「微信登录配置」卡片标题 */
.wx-config-card .switch-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }

/* ---------- 账号（设置页第一屏，退出登录放在最显眼处） ---------- */
.account-card { padding: 14px; }
.account-row { display: flex; align-items: center; gap: 12px; }
.account-avatar {
  width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%;
  background: var(--primary-soft); display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.account-info { flex: 1; min-width: 0; }
.account-name { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn {
  flex: 0 0 auto; border: 1px solid #ffc2d4; background: #fff5f8; color: #d8426f;
  border-radius: 11px; padding: 9px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.logout-btn:active { background: #ffe4ee; }

/* ---------- 登录 / 注册 标签 ---------- */
.auth-tabs { display: flex; gap: 6px; margin: 0 0 14px; background: #f1f1f6; border-radius: 12px; padding: 4px; }
.auth-tab {
  flex: 1; border: none; background: transparent; color: var(--muted);
  border-radius: 9px; padding: 9px 0; font-size: 14px; font-weight: 600; cursor: pointer;
}
.auth-tab.active { background: #fff; color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* ---------- 登录方式切换（账号密码 / 手机号 / 微信） ---------- */
.auth-methods { display: flex; gap: 6px; margin-bottom: 10px; }
.auth-methods .auth-tab { flex: 1; }
/* 主按钮下方的次级操作（如「使用密码登录」）：做成醒目的描边按钮。
   原来只是一行 13px 粉色小字，太不起眼，用户反馈「不太明显」。 */
.auth-switch {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; margin-top: 10px; padding: 11px 12px;
  border: 1px solid #ffb3cf; border-radius: 12px;
  background: #ffe9f2; color: var(--primary-dark);
  font-size: 14.5px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.auth-switch:active { background: #ffdbe8; border-color: var(--primary-dark); }
/* 低调的纯文字链接（如「没有账号？去注册」） */
.auth-link {
  display: block; width: 100%; margin-top: 10px; padding: 4px;
  border: none; background: none; color: var(--primary);
  font-size: 13px; font-family: inherit; text-align: center; cursor: pointer;
}
.code-row { display: flex; gap: 8px; align-items: stretch; }
.code-row input { flex: 1; min-width: 0; }
.code-btn {
  flex: 0 0 auto; padding: 0 12px; border: 1px solid var(--primary); background: #fff; color: var(--primary);
  border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.code-btn:disabled { opacity: .5; cursor: not-allowed; }
.wechat-btn { background: #07c160; border-color: #07c160; color: #fff; }
.wechat-btn:hover { background: #06ad56; }

/* 登录页布局：手机号 / 账号密码 / 微信 选中的那个是「主登录区」，
   「其他登录方式」固定放卡片最下方（所有表单与说明之后），避免它在微信或账号密码
   模式下跑到主按钮上方，看起来像主次颠倒。 */
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 22px 0 12px; color: var(--muted); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-alt { display: flex; gap: 10px; }
.alt-btn {
  flex: 1; border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 11px; padding: 11px 0; font-size: 14px; font-weight: 600; cursor: pointer;
}
.alt-btn:hover { border-color: var(--primary); color: var(--primary); }
.alt-btn.active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.alt-btn.wechat-alt { color: #07c160; border-color: #9be3bd; }
.alt-btn.wechat-alt:hover { background: #ecfaf1; }
/* 账号密码关闭时的管理员应急提示（置于账号密码表单内） */
.auth-note { margin: 10px 0 0; font-size: 12px; line-height: 1.5; color: #b8860b; background: #fff8e6; border: 1px solid #ffe3a3; border-radius: 9px; padding: 8px 10px; }
/* 后台「注册与登录」页的账号安全风险提示 */
.admin-risk { margin: 12px 0 0; font-size: 12.5px; line-height: 1.6; border-radius: 9px; padding: 10px 12px; }
.admin-risk.warn { color: #8a5a00; background: #fff4dc; border: 1px solid #ffd98a; }
.admin-risk.info { color: #3a6ea5; background: #eef5fc; border: 1px solid #cfe1f5; }

/* ---------- 关联登录方式（设置首页的导航行内） ---------- */
.link-right { flex: 0 0 auto; }
.link-right.grow { flex: 1 1 auto; min-width: 0; }
.link-phone-form { display: grid; grid-template-columns: 1fr; gap: 8px; width: 100%; margin-top: 6px; }
.link-code-row { display: flex; gap: 8px; }
.link-input { width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; font-size: 14px; background: #fff; color: var(--text); }
.link-code { flex: 1; min-width: 0; }
.link-bind-btn { width: 100%; }
.danger-link { color: #d8426f; border-color: #ffc2d4; }

/* ---------- 开关（允许自助注册等） ---------- */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.switch-label { font-weight: 600; font-size: 15px; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; cursor: pointer; background: #d7d7e0; border-radius: 999px; transition: background .2s;
}
.slider::before {
  content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px;
  background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ---------- toast ---------- */
/* 轻提示：圆角卡片。原来用胶囊圆角（999px），长文案换行时会被拉成怪异的
   大圆/椭圆（微信未配置那条提示就是这么显示的），改为固定圆角的卡片，
   多行也不会变形，并配上柔和阴影与随长度自适应的停留时长。 */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px);
  transform: translateX(-50%); z-index: 500;
  max-width: min(86vw, 360px);
  padding: 12px 16px; border-radius: 14px;
  background: rgba(38, 38, 48, .95); color: #fff;
  font-size: 14px; line-height: 1.55; text-align: center;
  box-shadow: 0 10px 28px rgba(20, 20, 40, .3);
  animation: toastIn .18s ease-out;
}
.toast.ok { background: rgba(22, 120, 68, .96); }
.toast.warn { background: rgba(143, 98, 12, .96); }
.toast.err { background: rgba(170, 46, 68, .96); }
.toast[hidden] { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (min-width: 560px) {
  .modal { border-radius: 20px; margin-bottom: 24px; }
  .modal-backdrop { align-items: center; }
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ---- 家庭共享 ---- */
.space-head { display: flex; align-items: center; gap: 12px; }
.space-ico { font-size: 28px; line-height: 1; flex: 0 0 auto; }
.space-info { flex: 1; min-width: 0; }
.space-info .account-name { font-size: 15px; font-weight: 600; }
/* 家庭成员列表：一行一个成员，创建者看得见「移出」按钮 */
.space-members { margin: 10px 0 0; }
.mem-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--border);
}
.mem-row:first-child { border-top: none; }
.mem-ico { font-size: 18px; flex: 0 0 auto; }
.mem-name { flex: 1; min-width: 0; font-size: 14px; display: flex; flex-direction: column; gap: 2px; }
.mem-tag { font-size: 12px; color: var(--muted); }
.space-members .danger-link { flex: 0 0 auto; padding: 6px 10px; font-size: 13px; }
.space-card #sp_memberNote { margin: 8px 0 0; line-height: 1.5; }
.invite-box { background: var(--bg); border-radius: 12px; padding: 10px 12px; margin: 12px 0; }
.invite-code-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.invite-code-row code {
  font-size: 20px; font-weight: 700; letter-spacing: 3px; color: var(--primary-dark);
  background: #fff; border: 1px dashed var(--border); border-radius: 10px; padding: 6px 12px;
}
.invite-code-row .text-btn { padding: 6px 12px; font-size: 13px; }
.join-box { border-top: 1px solid var(--border); padding-top: 12px; }
.danger-btn { color: #d9484c; border-color: #f3c9cb; margin-top: 8px; }
.join-box .primary-btn { margin-top: 10px; }
.switch-row.inline { justify-content: flex-start; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 0; }
.switch-row.inline input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 auto; }
.pending-card { text-align: center; }.pending-card { text-align: center; }
.pending-card .primary-btn { margin-top: 14px; }

.danger-btn { color: #c0392b; }
.danger-btn { color: #c0392b; }

/* ---- 导出数据（按身份区分文案） ---- */
.export-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.export-role {
  display: inline-block; font-size: 12px; font-weight: 600;
  color: var(--primary-dark); background: var(--primary-soft, #fff0f5);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px;
}
/* 整库备份按钮被隐藏时（非管理员），它上面的容器不该留下一段空隙 */
#backupBlock { margin-bottom: 10px; }
#backupBlock.hide { display: none; }
.export-note {
  font-size: 12.5px; line-height: 1.6; border-radius: 10px;
  padding: 9px 12px; margin: 0 0 4px; border: 1px solid var(--border);
  background: var(--bg); color: var(--muted);
}
.export-note.info { color: #6b6b6b; }
.export-note.ok { color: #2f7d4f; background: #f2faf5; border-color: #cfe8d8; }
.export-sep {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 10px; font-size: 12px; color: var(--muted);
}
.export-sep::before, .export-sep::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.export-card-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
#sub-export .text-btn { text-align: left; line-height: 1.5; }
