/* ==========================================================================
   宝宝成长 · 样式
   手机优先，桌面端居中显示为一条 560px 的"手机"。
   ========================================================================== */

:root {
  --bg: #fbf6f1;
  --surface: #ffffff;
  --surface-2: #fff9f5;
  --ink: #2e2622;
  --ink-2: #5f534c;
  --muted: #a2948c;
  --brand: #ef6f4c;
  --brand-dark: #d95a38;
  --brand-soft: #ffece3;
  --line: #f1e7e0;
  --shadow-sm: 0 1px 2px rgba(60, 40, 30, 0.04), 0 4px 12px rgba(60, 40, 30, 0.04);
  --shadow-md: 0 8px 28px rgba(80, 50, 35, 0.12);
  --radius: 20px;
  --tab-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

input,
textarea,
select {
  font-family: inherit;
  font-size: 16px; /* 小于 16px 时 iOS 会自动放大页面 */
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(var(--tab-h) + var(--safe-b));
}

/* ============================ 局域网提示条 ============================ */

.net-tip {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 14px 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff5e6;
  border: 1px solid #ffe2bd;
  color: #7a5220;
  font-size: 12.5px;
  line-height: 1.45;
}

.net-tip .ico {
  font-size: 15px;
  flex: none;
}

.net-tip div {
  flex: 1;
  min-width: 0;
}

.net-tip a {
  color: #d2601f;
  font-weight: 600;
  word-break: break-all;
}

.net-tip .x {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #b98a4e;
  font-size: 15px;
  display: grid;
  place-items: center;
}

/* ============================ 顶部栏 ============================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  background: rgba(251, 246, 241, 0.86);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}

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

.topbar-title h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title p {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.avatar-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--brand-soft);
  display: grid;
  place-items: center;
  font-size: 17px;
  flex: none;
  border: 1px solid var(--line);
}

.avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================ 时间轴 ============================ */

.timeline {
  padding: 4px 14px 24px;
}

.day-group + .day-group {
  margin-top: 6px;
}

.day-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 4px 10px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.day-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.day-label .age-tag {
  color: var(--brand);
  background: var(--brand-soft);
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 14px 8px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.card-author {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.card-time {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}

.type-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  flex: none;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 4px;
}

.card-text {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.card-text:empty {
  display: none;
}

/* --------- 照片网格 --------- */

.photo-grid {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
  border-radius: 14px;
  overflow: hidden;
}

.photo-grid.n1 {
  grid-template-columns: 1fr;
  max-height: 420px;
}

.photo-grid.n2,
.photo-grid.n4 {
  grid-template-columns: 1fr 1fr;
}

.photo-grid.n3,
.photo-grid.n5,
.photo-grid.n6,
.photo-grid.n7,
.photo-grid.n8,
.photo-grid.n9 {
  grid-template-columns: repeat(3, 1fr);
}

.photo-grid.n3 .ph:first-child {
  grid-column: span 2;
  grid-row: span 2;
}

.photo-grid.n5 .ph:first-child {
  grid-column: span 2;
  grid-row: span 2;
}

.ph {
  position: relative;
  background: var(--brand-soft);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  cursor: pointer;
}

.photo-grid.n1 .ph {
  aspect-ratio: 4 / 3;
  max-height: 420px;
}

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

.ph img.loaded {
  opacity: 1;
}

.ph .video-badge {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  font-size: 26px;
  pointer-events: none;
}

.ph .video-badge span {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  font-size: 16px;
  padding-left: 3px;
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  border-top: 1px solid var(--line);
  padding: 6px 0 4px;
}

.act {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--ink-2);
}

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

.act.on {
  color: var(--brand);
}

.act .ico {
  font-size: 15px;
  line-height: 1;
}

/* ============================ 空状态 ============================ */

.empty {
  text-align: center;
  padding: 60px 30px;
  color: var(--muted);
}

.empty .big {
  font-size: 46px;
  margin-bottom: 10px;
}

.empty h3 {
  margin: 0 0 6px;
  color: var(--ink-2);
  font-size: 16px;
}

.empty p {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
}

/* ============================ 悬浮按钮 ============================ */

.fab {
  position: fixed;
  right: max(18px, calc(50% - 280px + 18px));
  bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(140deg, #ff8a63, var(--brand));
  color: #fff;
  font-size: 28px;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 26px rgba(239, 111, 76, 0.38);
  z-index: 30;
  transition: transform 0.16s ease;
}

.fab:active {
  transform: scale(0.93);
}

/* ============================ 底部导航 ============================ */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}

.tabbar-inner {
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  display: flex;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
}

.tab .ico {
  font-size: 20px;
  line-height: 1;
  filter: grayscale(1) opacity(0.55);
  transition: filter 0.15s;
}

.tab.on {
  color: var(--brand);
}

.tab.on .ico {
  filter: none;
}

/* ============================ 底部弹层 ============================ */

.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(40, 25, 18, 0.42);
  z-index: 40;
  opacity: 0;
  transition: opacity 0.22s;
  backdrop-filter: blur(2px);
}

.sheet-mask.show {
  opacity: 1;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  max-width: 560px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 8px 16px calc(16px + var(--safe-b));
  transform: translateY(105%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet.show {
  transform: translateY(0);
}

.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: #e6dcd5;
  margin: 4px auto 12px;
}

.sheet h2 {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 700;
}

/* ============================ 表单 ============================ */

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.input,
.textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.input:focus,
.textarea:focus {
  border-color: var(--brand);
  background: #fff;
}

.textarea {
  resize: none;
  min-height: 96px;
  line-height: 1.6;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.12s;
}

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

.btn:disabled {
  opacity: 0.55;
}

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

.btn.plain {
  background: transparent;
  color: var(--ink-2);
  border: 1.5px solid var(--line);
}

.btn.danger {
  background: #fff1ee;
  color: #d64545;
}

.btn.sm {
  width: auto;
  padding: 9px 16px;
  font-size: 13.5px;
  border-radius: 11px;
}

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

.row > * {
  flex: 1;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

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

.chip {
  flex: none;
  padding: 8px 14px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
}

.chip.on {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-dark);
  font-weight: 600;
}

/* ============================ 登录页 ============================ */

.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 30px 26px calc(30px + var(--safe-b));
  max-width: 460px;
  margin: 0 auto;
}

/* ============================ 步骤说明 ============================ */

.steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
}

.step b:first-child {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  display: grid;
  place-items: center;
  margin-top: 1px;
}

.auth-logo {
  width: 78px;
  height: 78px;
  border-radius: 26px;
  background: linear-gradient(145deg, #ffb08f, var(--brand));
  display: grid;
  place-items: center;
  font-size: 38px;
  margin: 0 auto 18px;
  box-shadow: 0 14px 34px rgba(239, 111, 76, 0.32);
}

.auth h1 {
  text-align: center;
  font-size: 23px;
  margin: 0 0 6px;
  letter-spacing: -0.4px;
}

.auth .sub {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 0 26px;
}

.auth-switch {
  text-align: center;
  margin-top: 18px;
  font-size: 13.5px;
  color: var(--muted);
}

.auth-switch button {
  color: var(--brand);
  font-weight: 600;
  padding: 4px;
}

/* ============================ 相册 ============================ */

.album-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 0 12px 6px;
}

.album-grid .ph {
  aspect-ratio: 1 / 1;
  border-radius: 4px;
}

.album-month {
  padding: 16px 16px 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

/* ============================ 我的 ============================ */

.me-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 18px;
}

.me-avatar {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--brand-soft);
  display: grid;
  place-items: center;
  font-size: 26px;
  overflow: hidden;
  flex: none;
}

.me-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.me-head h2 {
  margin: 0;
  font-size: 18px;
}

.me-head p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.list {
  background: var(--surface);
  border-radius: 18px;
  margin: 0 14px 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  width: 100%;
  text-align: left;
}

.list-item + .list-item {
  border-top: 1px solid var(--line);
}

.list-item .ico {
  font-size: 18px;
  width: 26px;
  text-align: center;
}

.list-item .label {
  flex: 1;
  font-size: 14.5px;
}

.list-item .value {
  font-size: 13px;
  color: var(--muted);
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item .chev {
  color: #cfc4bd;
  font-size: 14px;
}

.section-title {
  padding: 18px 20px 8px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ============================ 全屏看图 ============================ */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #0b0908;
  display: flex;
  flex-direction: column;
  animation: fade-in 0.18s;
}

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

.viewer-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: linear-gradient(rgba(0, 0, 0, 0.5), transparent);
  color: #fff;
  font-size: 13px;
}

.viewer-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 20px;
  display: grid;
  place-items: center;
}

.viewer-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: pan-y;
}

.viewer-stage img,
.viewer-stage video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.2s;
}

.viewer-dots {
  display: flex;
  gap: 5px;
  justify-content: center;
  padding: 10px 0 calc(14px + var(--safe-b));
}

.viewer-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}

.viewer-dots i.on {
  background: #fff;
  width: 14px;
  border-radius: 99px;
}

/* ============================ 提示条 ============================ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + var(--safe-b) + 26px);
  transform: translate(-50%, 14px);
  background: rgba(46, 38, 34, 0.94);
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  max-width: 80vw;
  text-align: center;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

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

/* ============================ 上传进度条 ============================ */

.upload-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
  width: min(420px, calc(100vw - 32px));
  background: rgba(46, 38, 34, 0.94);
  color: #fff;
  border-radius: 14px;
  padding: 10px 14px;
  z-index: 80;
  font-size: 12.5px;
  display: none;
}

.upload-bar.show {
  display: block;
}

.upload-bar .track {
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 9px;
  margin-top: 7px;
  overflow: hidden;
}

.upload-bar .fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ffb08f, #ff7a52);
  border-radius: 9px;
  transition: width 0.2s;
}

/* ============================ 加载 ============================ */

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.skeleton {
  background: linear-gradient(90deg, #f3eae3 25%, #faf4ef 37%, #f3eae3 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 12px;
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}

.loading-more {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  padding: 16px;
}

/* ============================ 选择照片 ============================ */

.picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.picker-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
}

.picker-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.picker-cell .rm {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  display: grid;
  place-items: center;
}

.picker-add {
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: 1.5px dashed #e2d5cb;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 24px;
  background: var(--surface-2);
}

/* ============================ 评论 ============================ */

.comment {
  display: flex;
  gap: 9px;
  padding: 9px 0;
}

.comment-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-soft);
  display: grid;
  place-items: center;
  font-size: 13px;
  flex: none;
  overflow: hidden;
}

.comment-body {
  flex: 1;
  min-width: 0;
}

.comment-name {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 1px;
}

.comment-text {
  font-size: 14px;
  word-break: break-word;
}

.comment-bar {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.comment-bar input {
  flex: 1;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  border-radius: 99px;
  padding: 9px 14px;
  outline: none;
}

/* ============================ 其他 ============================ */

.hint {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.65;
}

.mono {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  letter-spacing: 1.5px;
}

.invite-box {
  text-align: center;
  padding: 6px 0 2px;
}

.invite-code {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 6px;
  color: var(--brand-dark);
  margin: 6px 0 4px;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 14px 0;
}

.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 11.5px;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
