/* 生长记录 · 移动端样式 */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1f2937;
  --ink-2: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --xian: #2563eb;
  --xing: #f59e0b;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--ink-2); font-size: 12px; }

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input {
  font: inherit; width: 100%;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; background: #fff; color: var(--ink);
  outline: none; transition: border-color 0.15s;
}
input:focus { border-color: var(--accent); }

.primary {
  width: 100%; padding: 15px; border-radius: 14px; margin-top: 6px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 16px;
}
.primary:active { opacity: 0.85; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--card);
  border-radius: 20px; box-shadow: var(--shadow); padding: 32px 24px; text-align: center;
}
.login-logo { font-size: 44px; }
.login-card h1 { font-size: 22px; margin: 8px 0 4px; }
.login-sub { color: var(--ink-2); font-size: 13px; margin-bottom: 24px; }
.login-card input { margin-bottom: 12px; text-align: center; }
.code-row { display: flex; gap: 8px; margin-bottom: 16px; }
.code-row input { flex: 1; margin-bottom: 0; letter-spacing: 4px; }
.code-row button {
  white-space: nowrap; padding: 0 14px; border-radius: 12px;
  background: #eff4ff; color: var(--accent); font-weight: 600; font-size: 14px;
}
.code-row button:disabled { color: #9ca3af; background: #f3f4f6; }
.form-msg { min-height: 18px; font-size: 13px; color: #dc2626; margin-top: 10px; }
.form-hint { font-size: 12px; color: var(--ink-2); margin: 4px 0 12px; }

/* ---------- 主视图 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 10px;
  background: var(--bg);
}
.topbar h1 { font-size: 20px; }
.user-email { font-size: 12px; color: var(--ink-2); }
.ghost-btn {
  font-size: 13px; color: var(--ink-2); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 10px; background: #fff;
}
.content { padding: 4px 16px 120px; display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}

/* 筛选 chips */
.chip-row { display: flex; gap: 8px; }
.chip {
  padding: 7px 16px; border-radius: 999px; font-size: 14px;
  background: #fff; color: var(--ink-2); border: 1px solid var(--line);
}
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }

/* 指标分段 */
.seg-row {
  display: flex; background: #f1f3f5; border-radius: 12px; padding: 3px; margin-bottom: 8px;
}
.seg {
  flex: 1; text-align: center; padding: 8px 0; border-radius: 10px;
  font-size: 14px; color: var(--ink-2);
}
.seg.active { background: #fff; color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

/* 时间范围选择 */
.range-row { display: flex; gap: 6px; margin-bottom: 10px; }
.rchip {
  flex: 1; padding: 7px 0; border-radius: 10px;
  background: #f6f7f9; color: var(--ink-2); font-size: 12.5px; border: none;
}
.rchip.active { background: #e8f0fe; color: var(--accent); font-weight: 600; }

/* 图表 */
.chart-box { position: relative; }
.chart-box svg { display: block; width: 100%; height: auto; }
.chart-tip {
  position: absolute; pointer-events: none;
  background: rgba(31, 41, 55, 0.92); color: #fff;
  font-size: 12px; line-height: 1.5; padding: 8px 10px; border-radius: 10px;
  white-space: nowrap; transform: translate(-50%, -110%); z-index: 5;
}
#chart circle.pt { cursor: pointer; transition: r 0.12s; }
#chart circle.pt.sel { r: 6.5px; stroke-width: 3.2; }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px;
  font-size: 11.5px; color: var(--ink-2);
}
.chart-legend .lg { display: inline-block; width: 18px; height: 8px; border-radius: 4px; vertical-align: middle; margin-right: 4px; }
.lg-band { background: rgba(37, 99, 235, 0.14); border: 1px solid rgba(37, 99, 235, 0.3); }

/* 摘要卡 */
.summary-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kid-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.kid-card h3 { font-size: 15px; display: flex; align-items: center; gap: 6px; }
.kid-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.kid-date { font-size: 11.5px; color: var(--ink-2); margin: 2px 0 10px; }
.kid-stat { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 0; }
.kid-stat .label { font-size: 12.5px; color: var(--ink-2); }
.kid-stat .val { font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kid-stat .val small { font-size: 11px; font-weight: 400; color: var(--ink-2); margin-left: 2px; }

.p-badge {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px;
  border-radius: 999px; margin-left: 6px; vertical-align: 2px;
}
.band-下  { background: #fee2e2; color: #b91c1c; }
.band-中下 { background: #ffedd5; color: #c2410c; }
.band-中  { background: #dcfce7; color: #15803d; }
.band-中上 { background: #dbeafe; color: #1d4ed8; }
.band-上  { background: #ede9fe; color: #6d28d9; }

/* 历史记录 */
.list-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.list-head h2 { font-size: 16px; }
.rec-group { margin-bottom: 16px; }
.rec-group-title {
  font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px;
  padding: 6px 0 8px; color: var(--ink);
}
.rec-row {
  display: grid; grid-template-columns: 86px 1fr auto; gap: 10px;
  padding: 12px 2px; border-top: 1px solid #f1f3f5; align-items: center;
}
.rec-when { display: flex; flex-direction: column; gap: 2px; }
.rec-date { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rec-age { font-size: 11px; color: var(--ink-2); }
.rec-data { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; min-width: 0; }
.rec-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.rec-cell .v { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rec-cell .v small { font-size: 10.5px; font-weight: 400; color: var(--ink-2); margin-left: 1px; }
.rec-cell .v.dash { color: #d1d5db; font-weight: 400; }
.rec-cell .p { font-size: 10.5px; }
.rec-cell .p-badge { margin-left: 0; white-space: nowrap; padding: 2px 6px; }
.rec-ops { display: flex; align-items: center; gap: 0; }
.rec-edit, .rec-del { color: #c7ccd4; font-size: 16px; padding: 8px 5px; }
.rec-edit:active { color: var(--accent); }
.rec-del:active { color: #dc2626; }

/* FAB 与弹层 */
.fab {
  position: fixed; right: 20px; bottom: calc(env(safe-area-inset-bottom) + 24px);
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 28px; line-height: 1;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4); z-index: 20;
}
.fab:active { transform: scale(0.95); }

.sheet-mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, 0.4); z-index: 30;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  background: #fff; border-radius: 24px 24px 0 0;
  padding: 10px 24px calc(env(safe-area-inset-bottom) + 24px);
  max-height: 92dvh; overflow-y: auto;
}
.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: #e5e7eb; margin: 6px auto 18px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.sheet-head h2 { font-size: 20px; }
.sheet-close { font-size: 16px; color: #9ca3af; padding: 6px 10px; border-radius: 50%; background: #f3f4f6; }

/* 孩子选择（大按钮） */
.kid-pick { display: flex; gap: 10px; margin-bottom: 20px; }
.kid-pick-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 0; border-radius: 16px; font-size: 16px; font-weight: 600;
  background: #f6f7f9; color: var(--ink-2); border: 2px solid transparent;
  transition: all 0.15s;
}
.kid-pick-btn.active { background: #fff; color: var(--ink); border-color: var(--ink); box-shadow: var(--shadow); }
.kid-pick-btn .kid-dot { width: 10px; height: 10px; }

.field { display: block; margin-bottom: 18px; }
.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 7px; }
.big-input { font-size: 17px; padding: 14px 16px; border-radius: 14px; }

/* 体重 + 单位切换 */
.weight-row { display: flex; gap: 10px; }
.weight-row input { flex: 1; min-width: 0; }
.unit-seg {
  display: flex; background: #f1f3f5; border-radius: 14px; padding: 3px; flex-shrink: 0;
}
.unit {
  padding: 0 16px; border-radius: 11px; font-size: 14.5px; font-weight: 600; color: var(--ink-2);
}
.unit.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px);
  transform: translateX(-50%); z-index: 50;
  background: rgba(31, 41, 55, 0.92); color: #fff;
  font-size: 13px; padding: 10px 18px; border-radius: 999px;
  animation: toastIn 0.2s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; } }

@media (min-width: 560px) {
  .content { max-width: 640px; margin: 0 auto; }
  .topbar { max-width: 640px; margin: 0 auto; width: 100%; }
}
