:root {
  --bg: #f8f6f2;
  --card: #fffdfa;
  --text: #37322d;
  --muted: #9c948a;
  --line: #ece5db;
  --accent: #43685a;
  --accent-deep: #355449;
  --accent-soft: #e9f0ec;
  --gold: #b3915f;
  --green: #6b8f6b;
  --red: #c05f4e;
  --shadow: 0 1px 3px rgba(55, 50, 45, 0.04), 0 10px 30px rgba(55, 50, 45, 0.06);
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 84px; line-height: 1.75; }

.btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  background: transparent;
  color: var(--text);
  transition: all 0.15s;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--text); color: #faf8f4; }
.btn.primary:hover { background: #000; box-shadow: 0 4px 14px rgba(55, 50, 45, 0.22); }
.btn.ghost { border-color: var(--line); color: var(--muted); }
.btn.ghost:hover { border-color: var(--muted); color: var(--text); }
.btn.danger { background: #f7ece8; color: var(--red); }
.btn.wide { width: 100%; padding: 11px; font-size: 14px; }
.btn.small { padding: 4px 11px; font-size: 12px; letter-spacing: 0.2px; }

/* ---- 登录页 ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1100px 520px at 85% -10%, rgba(179, 145, 95, 0.10) 0%, transparent 60%),
    radial-gradient(900px 500px at 8% 110%, rgba(67, 104, 90, 0.08) 0%, transparent 55%),
    var(--bg);
}
.login-card {
  width: min(92vw, 370px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 44px 38px 38px;
  text-align: center;
}
.login-heart { font-size: 30px; margin-bottom: 12px; opacity: 0.85; }
.login-card h1 {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 3px;
  margin: 0 0 8px;
}
.login-sub { color: var(--muted); font-size: 12.5px; letter-spacing: 1px; margin: 0 0 26px; }
.login-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.pick-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 2px;
  transition: all 0.15s;
}
.pick-btn:hover { border-color: var(--accent); color: var(--accent-deep); }
.pick-btn.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
}
.login-card input {
  width: 100%;
  text-align: center;
  padding: 11px;
  margin-bottom: 14px;
  font-size: 14px;
  letter-spacing: 4px;
}
.login-error { color: var(--red); font-size: 13px; margin: 14px 0 0; }

/* ---- 顶栏 ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 60px;
  padding: 0 26px;
  background: rgba(248, 246, 242, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 3px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.brand #site-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-badge {
  display: inline-block;
  font-family: "PingFang SC", sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--accent-deep);
  border: 1px solid var(--accent-soft);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 10px;
  margin-left: 10px;
  vertical-align: 2px;
}
.tabs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 1px;
  padding: 20px 13px 16px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--gold); }
.icon-btn {
  border: none;
  background: transparent;
  font-size: 15px;
  padding: 7px 9px;
  border-radius: 8px;
  color: var(--muted);
  transition: all 0.15s;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--text); }

/* ---- 通用 ---- */
.container { max-width: 900px; margin: 0 auto; padding: 30px 22px 60px; }
.view-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 2px;
  margin: 4px 0 16px;
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.toolbar select { padding: 7px 10px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 16px;
  animation: fadeUp 0.3s ease-out;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.empty {
  color: var(--muted);
  text-align: center;
  padding: 52px 10px;
  font-size: 13.5px;
  line-height: 2;
  letter-spacing: 1px;
}
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---- 时间线卡片（重要时刻 / 碎碎念） ---- */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 14px;
  bottom: 14px;
  width: 1px;
  background: linear-gradient(to bottom, var(--gold), var(--line));
}
.event-card { position: relative; }
.event-card::before {
  content: "";
  position: absolute;
  left: -28px;
  top: 28px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--card);
  border: 1.5px solid var(--gold);
  box-shadow: 0 0 0 3px var(--bg);
}
.event-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.event-date {
  font-family: var(--serif);
  color: var(--gold);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 1px;
}
.event-actions { display: flex; gap: 2px; }
.event-actions button {
  border: none;
  background: transparent;
  font-size: 14px;
  padding: 3px 6px;
  border-radius: 6px;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s;
}
.event-actions button:hover { opacity: 1; background: var(--accent-soft); }
.event-card h3 {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  margin: 4px 0 10px;
  letter-spacing: 1px;
}
.event-desc {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
  color: #4d463f;
}
.recorder-tag {
  display: inline-block;
  font-size: 11.5px;
  letter-spacing: 1px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: 12px;
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.photo-grid img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 10px;
  cursor: zoom-in;
  transition: transform 0.2s, box-shadow 0.2s;
}
.photo-grid img:hover { transform: scale(1.02); box-shadow: 0 6px 18px rgba(55, 50, 45, 0.15); }
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.video-grid video {
  width: 100%;
  max-height: 300px;
  border-radius: 10px;
  background: #111;
  display: block;
}
.upload-progress {
  font-size: 12.5px;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 8px;
}

/* ---- 统计卡片 ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat-label { color: var(--muted); font-size: 12px; letter-spacing: 1px; margin-bottom: 6px; }
.stat-value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat-value.red { color: var(--red); }
.stat-value.green { color: var(--green); }
.stat-edit {
  float: right;
  border: none;
  background: transparent;
  font-size: 12px;
  color: var(--muted);
  padding: 2px;
  opacity: 0.6;
}
.stat-edit:hover { opacity: 1; color: var(--accent-deep); }

.progress-track {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 14px;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #8aa99b, var(--accent));
  transition: width 0.35s;
}
.progress-fill.over { background: linear-gradient(90deg, #d99a86, var(--red)); }
.progress-note { font-size: 11.5px; color: var(--muted); margin-top: 8px; letter-spacing: 0.5px; }

/* ---- 分类条 ---- */
.cat-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.cat-name { width: 52px; font-size: 12.5px; color: var(--muted); text-align: right; }
.cat-track { flex: 1; height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.cat-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #a8bdb2, var(--accent)); }
.cat-amount { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- 个人预算 ---- */
.person-budget { padding: 12px 0 4px; }
.person-budget + .person-budget { border-top: 1px dashed var(--line); margin-top: 10px; }
.person-budget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.person-name {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--accent-deep);
  min-width: 52px;
}
.person-actions { display: flex; gap: 6px; }
.budget-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.budget-tables .card { margin-bottom: 0; }
@media (max-width: 720px) {
  .budget-tables { grid-template-columns: 1fr; }
}

/* ---- 手机适配 ---- */
@media (max-width: 720px) {
  .topbar {
    height: auto;
    padding: 10px 12px 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }
  .brand {
    font-size: 13.5px;
    letter-spacing: 2px;
    padding: 0 2px;
  }
  .user-badge {
    font-size: 11px;
    margin-left: 0;
    flex-shrink: 0;
  }
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 2px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    padding: 9px 11px 8px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .icon-btn { padding: 6px 7px; flex-shrink: 0; }
  .container { padding: 16px 12px 48px; }
  .view-title { font-size: 17px; letter-spacing: 1.5px; }
  .card { padding: 16px; }
  .login-card { padding: 34px 24px 30px; }
  .login-card h1 { font-size: 18px; letter-spacing: 2px; }
  .modal { padding: 22px 18px; }
  .modal .row2 { grid-template-columns: 1fr; }
  .stat-card { padding: 13px 14px; }
  .budget-tables .card { overflow-x: auto; }
  .month-table { min-width: 330px; }
  .toolbar select { max-width: 140px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .expense-form { grid-template-columns: 1fr; }
  .expense-form .btn { justify-self: stretch; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .video-grid { grid-template-columns: 1fr; }
  .wish-actions .btn { width: 100%; }
  .toolbar { margin-bottom: 14px; }
}

/* ---- 月份表 ---- */
.month-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.month-table th, .month-table td {
  padding: 9px 6px;
  text-align: right;
  border-bottom: 1px solid var(--line);
}
.month-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 1px;
}
.month-table th:first-child, .month-table td:first-child { text-align: left; }
.month-table tr.clickable { cursor: pointer; }
.month-table tr.clickable:hover td { background: #fbf7f1; }
.pos { color: var(--green); }
.neg { color: var(--red); font-weight: 700; }

/* ---- 记一笔表单 ---- */
.expense-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.expense-form .wide { grid-column: 1 / -1; }
.expense-form .btn { justify-self: end; align-self: end; }
@media (max-width: 640px) {
  .expense-form { grid-template-columns: 1fr 1fr; }
}
.expense-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 4px;
  border-bottom: 1px dashed var(--line);
}
.expense-item:last-child { border-bottom: none; }
.expense-cat {
  display: inline-block;
  font-size: 11.5px;
  letter-spacing: 0.5px;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 6px;
  padding: 1px 8px;
  margin-right: 6px;
}
.expense-note { color: var(--muted); font-size: 12.5px; }
.split-note { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.expense-who {
  display: inline-block;
  font-size: 11.5px;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 6px;
  padding: 1px 8px;
  margin-right: 4px;
}
.expense-who.me { background: var(--accent); border-color: var(--accent); color: #fff; }
.expense-amount { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.expense-del {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 6px;
  opacity: 0.6;
}
.expense-del:hover { opacity: 1; background: #f7ece8; color: var(--red); }

/* ---- 愿望 ---- */
.wish-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.wish-main { flex: 1; min-width: 0; }
.wish-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; letter-spacing: 0.5px; }
.wish-note { color: var(--muted); font-size: 13px; line-height: 1.8; white-space: pre-wrap; }
.wish-meta { font-size: 12px; color: var(--gold); margin-top: 6px; letter-spacing: 0.5px; }
.wish-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.done-card .wish-title { color: var(--muted); text-decoration: line-through; font-weight: 500; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 14px;
}
.section-head h2 {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 2px;
  margin: 0;
}
.count-badge {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
}

/* ---- 弹窗 ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(55, 50, 45, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
  backdrop-filter: blur(2px);
}
.modal {
  width: min(94vw, 580px);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(55, 50, 45, 0.22);
  padding: 28px;
  animation: pop 0.18s ease-out;
}
@keyframes pop {
  from { transform: scale(0.97); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal h3 {
  font-family: var(--serif);
  margin: 0 0 20px;
  font-size: 16px;
  letter-spacing: 2px;
}
.modal .field { margin-bottom: 14px; }
.modal .field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.modal .field input, .modal .field select, .modal .field textarea { width: 100%; }
.modal .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.preview-cell, .video-cell { position: relative; }
.preview-cell img { width: 100%; height: 90px; object-fit: cover; border-radius: 8px; }
.video-cell video { width: 100%; max-height: 160px; border-radius: 8px; background: #111; display: block; }
.preview-x {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(55, 50, 45, 0.68);
  color: #fff;
  font-size: 11px;
  line-height: 1;
}

/* ---- 灯箱 / toast / 页脚 ---- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(25, 21, 18, 0.93);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 92vh; border-radius: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  background: rgba(55, 50, 45, 0.94);
  color: #faf8f4;
  font-size: 13px;
  letter-spacing: 0.5px;
  padding: 10px 22px;
  border-radius: 999px;
  z-index: 80;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  animation: pop 0.15s ease-out;
}

.site-foot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 2px;
  padding: 28px 0 40px;
}
