:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #6a737d;
  --line: #e4e7eb;
  --accent: #16a34a;
  --accent-dark: #15803d;
  --ring: rgba(22, 163, 74, .25);
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 4px 14px rgba(0, 0, 0, .04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.plain { color: inherit; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.wrap.narrow { max-width: 620px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { font-size: 17px; font-weight: 700; }
.brand .sub { margin-left: 10px; font-size: 13px; font-weight: 500; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; padding: 8px 16px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .15s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent-dark); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); color: #fff; }
.btn.big { padding: 12px 28px; font-size: 16px; }
.btn:disabled { opacity: .6; cursor: wait; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px;
}

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 56px 20px; margin-top: 28px; }
.empty-emoji { font-size: 52px; margin-bottom: 8px; }
.empty h1 { font-size: 22px; margin: 0 0 8px; }
.empty p { color: var(--muted); margin: 0 0 20px; }

/* ---------- stats ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin: 20px 0 14px;
}
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 8px; text-align: center;
}
.stat .num { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.streak { background: linear-gradient(135deg, #fff, #f0fdf4); border-color: #bbf7d0; }
.stat.streak .num { color: var(--accent-dark); }

/* ---------- today banner ---------- */
.today-banner {
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px;
  font-size: 15px; font-weight: 600;
}
.today-banner.done { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.today-banner.todo { background: #fffbeb; border: 1px solid #fde68a; color: #b45309; }

/* ---------- heatmap ---------- */
.heatmap-card h3 { margin: 0 0 12px; font-size: 15px; }
.heatmap-wrap { overflow-x: auto; padding-bottom: 4px; }
.heatmap {
  display: grid;
  grid-template-rows: repeat(7, 12px);
  grid-auto-flow: column;
  grid-auto-columns: 12px;
  gap: 3px;
  width: max-content;
}
.heatmap span { width: 12px; height: 12px; border-radius: 3px; }
.hl0 { background: #ebedf0; } .hl1 { background: #9be9a8; }
.hl2 { background: #40c463; } .hl3 { background: #30a14e; }
.hl4 { background: #216e39; } .hlx { background: transparent; }
.legend {
  display: flex; align-items: center; gap: 3px;
  justify-content: flex-end; font-size: 11px; color: var(--muted); margin-top: 6px;
}
.legend span { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend span:first-of-type { margin-left: 6px; }

/* ---------- feed ---------- */
.day-group { margin: 22px 0; }
.day-group h2 {
  font-size: 17px; margin: 0 0 10px;
  display: flex; align-items: baseline; gap: 8px;
}
.day-group .count { font-size: 12px; font-weight: 500; color: var(--muted); }
.checkin { margin-bottom: 12px; }
.checkin .meta { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.checkin .meta time { font-size: 13px; color: var(--muted); }
.badge {
  font-size: 13px; font-weight: 700; padding: 3px 10px;
  border-radius: 999px;
}
.badge.author { background: #f3e8ff; color: #7e22ce; }
.b-diet .badge { background: #fef3c7; color: #b45309; }
.b-exercise .badge { background: #dbeafe; color: #1d4ed8; }
.b-both .badge { background: #dcfce7; color: #15803d; }
.text { margin: 4px 0 8px; white-space: pre-wrap; word-break: break-word; }

.photos { display: grid; gap: 6px; }
.photos img {
  width: 100%; object-fit: cover; border-radius: 10px;
  cursor: zoom-in; background: #f0f0f0;
}
.photos.n1 img { max-width: 460px; max-height: 420px; }
.photos.n1 { grid-template-columns: minmax(0, 460px); }
.photos.n2, .photos.n3, .photos.n4 { grid-template-columns: 1fr 1fr; }
.photos img { aspect-ratio: 1 / 1; }
.photos.n1 img { aspect-ratio: auto; }

/* ---------- lightbox ---------- */
#lightbox {
  display: none; position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .82);
  align-items: center; justify-content: center; cursor: zoom-out;
}
#lightbox.open { display: flex; }
#lightbox img { max-width: 94vw; max-height: 94vh; border-radius: 8px; }

/* ---------- form ---------- */
.form-card h1 { margin: 2px 0 16px; font-size: 22px; }
.field { margin-bottom: 18px; }
.field > label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 7px; }
textarea, input[type="password"], input[type="file"] {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: 10px;
  font: inherit; background: #fff; color: var(--ink);
}
textarea:focus, input[type="password"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
textarea { resize: vertical; min-height: 110px; }
.hint { font-size: 12px; color: var(--muted); text-align: right; margin-top: 3px; }

.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-item input { display: none; }
.seg-item span {
  display: inline-block; padding: 8px 16px;
  border: 1.5px solid var(--line); border-radius: 999px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all .12s;
}
.seg-item input:checked + span {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

.preview { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumb { position: relative; width: 84px; height: 84px; }
.thumb img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; }
.thumb span {
  position: absolute; bottom: 3px; right: 3px;
  background: rgba(0, 0, 0, .55); color: #fff;
  font-size: 10px; padding: 1px 5px; border-radius: 4px;
}
.msg { color: #dc2626; font-size: 14px; min-height: 20px; margin: 10px 0 0; font-weight: 600; }

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 32px 0 28px; }

/* ---------- club banner ---------- */
.club-banner {
  margin: 18px 0 14px; padding: 22px 16px;
  text-align: center;
  background: linear-gradient(120deg, #f0fdf4 0%, #eff6ff 60%, #fdf4ff 100%);
  border: 1px solid #bbf7d0; border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.club-banner.slim { margin-top: 16px; padding: 14px 16px; }
.club-name { font-size: 24px; font-weight: 800; letter-spacing: 1px; }
.club-banner.slim .club-name { font-size: 19px; }
.club-slogans { display: flex; gap: 10px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.club-banner.slim .club-slogans { margin-top: 6px; }
.chip {
  padding: 5px 18px; border-radius: 999px;
  background: rgba(255, 255, 255, .85); border: 1px solid var(--line);
  font-size: 15px; font-weight: 700;
}

@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat .num { font-size: 22px; }
  .brand .sub { display: none; }
  .photos.n2, .photos.n3, .photos.n4 { grid-template-columns: 1fr 1fr; }
}
