/* ==========================================================
   栗子成长记录 · 样式表
   风格：清新治愈、简约可爱、卡片式布局
   ========================================================== */

:root {
  --bg: #fdf8f3;
  --bg-soft: #fff6ee;
  --card: #ffffff;
  --ink: #3d332b;
  --ink-soft: #6d6055;
  --muted: #9c9084;
  --line: #f0e7dd;
  --brand: #f08a4b;
  --brand-deep: #e0742f;
  --brand-soft: #fff1e5;
  --mint: #56a894;
  --mint-soft: #e8f5f1;
  --warn: #e0a02c;
  --warn-soft: #fdf3e0;
  --danger: #e2585e;
  --danger-soft: #fdecec;
  --radius: 18px;
  --shadow: 0 6px 20px rgba(180, 150, 120, 0.10);
  --shadow-hover: 0 10px 28px rgba(180, 150, 120, 0.18);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, #fff3e5 0%, transparent 42%),
    radial-gradient(circle at 88% 4%, #eaf6f2 0%, transparent 38%),
    var(--bg);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 700; }
p { margin: 0; }

/* ---------------- 顶部导航 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 253, 250, 0.92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  font-size: 22px;
  background: linear-gradient(140deg, #ffe6cf, #ffd2b0);
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px #fff;
}
.brand h1 { font-size: 18px; letter-spacing: 0.4px; }
.brand p { font-size: 12px; color: var(--muted); }

.nav { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-btn {
  position: relative;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}
.nav-btn:hover { background: var(--brand-soft); color: var(--brand-deep); }
.nav-btn.is-active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 6px 14px rgba(240, 138, 75, 0.32);
}
.nav-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}

/* ---------------- 布局 ---------------- */
.main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 24px 80px;
}

.view { display: none; animation: fade 0.25s ease; }
.view.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.grid-home {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 20px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-head h2 { font-size: 16px; }

.sub-title {
  font-size: 13px;
  color: var(--muted);
  margin: 18px 0 10px;
  font-weight: 600;
}

.muted { color: var(--muted); font-size: 12px; }
.hint {
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

.pill {
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
}

/* ---------------- 按钮 ---------------- */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.16s ease;
}
.btn:hover { border-color: #e6d8c8; box-shadow: var(--shadow); transform: translateY(-1px); }
.btn:active { transform: none; }

.btn-primary {
  background: linear-gradient(140deg, #f79b5c, var(--brand));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(240, 138, 75, 0.30);
}
.btn-primary:hover { background: linear-gradient(140deg, var(--brand), var(--brand-deep)); }

.btn-ghost { background: var(--bg-soft); border-color: transparent; color: var(--ink-soft); }
.btn-danger-ghost { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 10px; }

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

/* ---------------- 表单 ---------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.form-grid .span-2 { grid-column: 1 / -1; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fffdfb;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(240, 138, 75, 0.14);
  background: #fff;
}
input[readonly] { background: #f6f1eb; color: var(--muted); }
textarea { resize: vertical; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-top: 14px;
}
.inline-form label { min-width: 140px; }
.inline-form .grow { flex: 1 1 200px; }

/* ---------------- 档案 ---------------- */
.profile-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 14px;
}
.avatar {
  width: 60px; height: 60px;
  display: grid; place-items: center;
  font-size: 30px;
  background: linear-gradient(140deg, #fff0e0, #ffe0c6);
  border-radius: 20px;
}
.profile-name { font-size: 20px; font-weight: 700; }
.profile-sub { font-size: 13px; color: var(--ink-soft); }
.profile-age { font-size: 12px; color: var(--brand-deep); margin-top: 4px; font-weight: 600; }

.info-list { margin: 0; display: grid; gap: 10px; }
.info-list > div {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  font-size: 14px;
}
.info-list dt { color: var(--muted); font-weight: 600; }
.info-list dd { margin: 0; color: var(--ink); white-space: pre-wrap; word-break: break-word; }

/* ---------------- 待办提醒 ---------------- */
.reminder-list { display: grid; gap: 10px; }
.reminder {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border-left: 4px solid var(--line);
  background: var(--bg-soft);
}
.reminder.is-overdue { background: var(--danger-soft); border-left-color: var(--danger); }
.reminder.is-soon { background: var(--warn-soft); border-left-color: var(--warn); }
.reminder.is-done { background: var(--mint-soft); border-left-color: var(--mint); }
.reminder-icon { font-size: 18px; line-height: 1.4; }
.reminder-body { flex: 1; min-width: 0; }
.reminder-kind { font-size: 12px; color: var(--muted); font-weight: 600; }
.reminder-title { font-weight: 700; font-size: 14px; }
.reminder-meta { font-size: 12px; color: var(--ink-soft); }
.reminder-days { font-size: 12px; font-weight: 700; white-space: nowrap; }
.is-overdue .reminder-days { color: var(--danger); }
.is-soon .reminder-days { color: var(--warn); }
.is-done .reminder-days { color: var(--mint); }

.calendar-list { display: grid; gap: 8px; }
.calendar-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #fbf7f2;
}
.calendar-item .cal-date { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------------- 统计 ---------------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-num { font-size: 24px; font-weight: 700; color: var(--brand-deep); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--muted); }

/* ---------------- 图表 ---------------- */
.chart-wrap { position: relative; width: 100%; min-height: 260px; }
#weightChart { width: 100%; height: 260px; display: block; }
.chart-empty {
  display: grid;
  place-items: center;
  min-height: 260px;
  color: var(--muted);
  font-size: 14px;
  background: repeating-linear-gradient(45deg, #fdfaf6, #fdfaf6 12px, #faf4ed 12px, #faf4ed 24px);
  border-radius: 14px;
  text-align: center;
  padding: 24px;
}

.mini-list { display: grid; gap: 8px; margin-top: 14px; }
.mini-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #fbf7f2;
}
.mini-item .mini-date { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 96px; }
.mini-item .mini-value { font-weight: 700; color: var(--brand-deep); }
.mini-item .mini-remark { color: var(--ink-soft); flex: 1; }

/* ---------------- 记录列表 ---------------- */
.record-list { display: grid; gap: 12px; }
.record {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: #fffdfb;
  transition: box-shadow 0.16s ease;
}
.record:hover { box-shadow: var(--shadow); }
.record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.record-time { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.record-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 13px;
  color: var(--ink-soft);
}
.record-fields b { color: var(--ink); font-weight: 600; }
.record-remark {
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--bg-soft);
  padding: 8px 12px;
  border-radius: 10px;
}

.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-deep);
}
.tag-mint { background: var(--mint-soft); color: #2f7a68; }
.tag-warn { background: var(--warn-soft); color: #a3741a; }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-plain { background: #f2eee9; color: var(--ink-soft); }

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 34px 16px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: repeating-linear-gradient(45deg, #fdfaf6, #fdfaf6 12px, #faf4ed 12px, #faf4ed 24px);
}

/* ---------------- Tabs / Chips ---------------- */
.tabs { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.16s ease;
}
.tab:hover { border-color: var(--brand); color: var(--brand-deep); }
.tab.is-active { background: var(--brand); border-color: transparent; color: #fff; box-shadow: 0 6px 14px rgba(240, 138, 75, 0.28); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.16s ease;
}
.chip:hover { border-color: var(--brand); color: var(--brand-deep); }
.chip.is-active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-deep); }

#timelineFilters { margin-bottom: 16px; }

/* ---------------- 相册 ---------------- */

/* ---------------- 云同步 ---------------- */
.readonly-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(140deg, #eef7f4, #e6f2ff);
  border: 1px solid #d8e9e3;
  color: #2f6b5c;
  font-size: 13px;
  font-weight: 600;
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 18px;
}
.readonly-banner .ro-icon { font-size: 18px; }

/* 只读模式下，所有"能改数据"的入口都藏起来 */
body.is-readonly .edit-only { display: none !important; }

.divider {
  border: none;
  border-top: 1px dashed var(--line);
  margin: 20px 0 16px;
}
.sync-box {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 14px;
  padding: 16px;
}
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1 1 auto; min-width: 0; }
.input-with-btn .btn { white-space: nowrap; }
.sync-status {
  font-size: 13px;
  font-weight: 600;
  color: var(--mint);
  align-self: center;
}
.sync-status.is-error { color: var(--danger); }
.sync-box code {
  background: #fff;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 12px;
}

.upload-area {
  border: 2px dashed #f0d9c4;
  border-radius: 16px;
  background: var(--bg-soft);
  padding: 26px;
  text-align: center;
  cursor: pointer;
  transition: all 0.16s ease;
}
.upload-area:hover, .upload-area.is-drag { border-color: var(--brand); background: #fff4e9; }
.upload-text { font-weight: 700; color: var(--brand-deep); margin-bottom: 4px; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.photo-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  position: relative;
  transition: box-shadow 0.16s ease, transform 0.16s ease;
}
.photo-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.photo-card img {
  width: 100%;
  height: 170px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
  background: #f5efe8;
}
.photo-info { padding: 10px 12px; display: grid; gap: 4px; }
.photo-date { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.photo-remark { font-size: 12px; color: var(--ink-soft); word-break: break-word; }
.photo-del {
  position: absolute;
  top: 8px; right: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  color: var(--danger);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* ---------------- 时间线 ---------------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 7px; top: 6px; bottom: 6px;
  width: 2px;
  background: linear-gradient(to bottom, #ffe0c2, #e6f2ee);
  border-radius: 2px;
}
.tl-item { position: relative; padding: 0 0 18px 4px; }
.tl-dot {
  position: absolute;
  left: -26px; top: 5px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand);
  box-shadow: 0 0 0 3px #fff;
}
.tl-dot.t-mint { border-color: var(--mint); }
.tl-dot.t-warn { border-color: var(--warn); }
.tl-dot.t-plain { border-color: #d9cfc4; }
.tl-date { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-title { font-size: 14px; font-weight: 700; }
.tl-desc { font-size: 13px; color: var(--ink-soft); }
.tl-thumb {
  margin-top: 8px;
  width: 132px; height: 100px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  cursor: zoom-in;
}

/* ---------------- 预览 / 弹窗 / 提示 ---------------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(38, 30, 24, 0.86);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 40px;
  gap: 12px;
  grid-template-rows: 1fr auto;
  text-align: center;
}
.lightbox img { max-width: 100%; max-height: 82vh; border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.lightbox p { color: #f4ece4; font-size: 13px; }
.lightbox-close {
  position: absolute;
  top: 22px; right: 26px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border: none;
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(38, 30, 24, 0.45);
  display: grid;
  place-items: center;
  z-index: 90;
  padding: 24px;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: min(420px, 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.24);
}
.modal h3 { font-size: 16px; margin-bottom: 8px; }
.modal p { font-size: 14px; color: var(--ink-soft); margin-bottom: 18px; }

.toast-wrap {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(61, 51, 43, 0.94);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
  animation: toastIn 0.22s ease;
}
.toast.is-error { background: rgba(200, 60, 66, 0.95); }
.toast.is-ok { background: rgba(60, 140, 118, 0.95); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------------- 响应式（电脑为主，小屏也能看） ---------------- */
@media (max-width: 900px) {
  .grid-home { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .topbar-inner { flex-direction: column; align-items: flex-start; }
}
