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

:root {
  --bg: #000;
  --surface: #101013;
  --surface2: #1c1c20;
  --text: #f5f5f7;
  --muted: #8e8e93;
  --accent: #e0724a;
  --chart: #dd6a40;
  --hairline: #ffffff1a;
  --radius: 12px;
}

body {
  background: #000;
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", "Segoe UI", sans-serif;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.phone {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--hairline);
  border-right: 1px solid var(--hairline);
}

#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px 10px;
  position: sticky;
  top: 0;
  background: #000000e6;
  backdrop-filter: blur(20px);
  z-index: 5;
}

.brand { font-weight: 700; font-size: 17px; letter-spacing: -0.4px; }
.brand-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.group-hero {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  cursor: zoom-in;
}
.group-pic {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--hairline);
  flex-shrink: 0;
}

.who {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--surface2);
  font-size: 16px;
  cursor: pointer;
  padding: 0;
}

main { flex: 1; padding: 4px 0 90px; overflow-y: auto; }

/* Content that isn't edge-to-edge gets a gutter */
h2, h3, .card, .member-row, .empty, label, .btn, .form-block { margin-left: 16px; margin-right: 16px; }

h2 { font-size: 22px; letter-spacing: -0.4px; margin-top: 8px; margin-bottom: 12px; font-weight: 700; }
h3 {
  font-size: 13px;
  color: var(--muted);
  margin-top: 24px;
  margin-bottom: 8px;
  font-weight: 600;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
}
.card:active { background: var(--surface2); }
.card .title { font-weight: 600; font-size: 16px; }
.card .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.pill {
  display: inline-block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.fab {
  position: fixed;
  bottom: 84px;
  right: max(calc(50vw - 215px + 16px), 16px);
  width: 50px; height: 50px;
  border-radius: 50%;
  background: var(--text);
  color: #000;
  font-size: 26px;
  border: none;
  cursor: pointer;
  z-index: 6;
  line-height: 1;
}

.tabbar {
  position: fixed;
  bottom: 0;
  width: 100%;
  max-width: 430px;
  display: flex;
  background: #000000e6;
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--hairline);
  padding: 10px 0 18px;
  z-index: 5;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 21px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.tab span { font-size: 10px; font-weight: 500; }
.tab.active { color: var(--text); }

/* Forms */
label { display: block; font-size: 13px; color: var(--muted); margin-top: 16px; margin-bottom: 6px; font-weight: 500; }
input[type="text"], input[type="date"] {
  width: calc(100% - 32px);
  margin-left: 16px;
  background: var(--surface);
  border: none;
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 16px;
  outline: none;
}
input:focus { background: var(--surface2); }
#habits input, .form-block input { width: 100%; margin-left: 0; }
#habits { margin: 0 16px; }
input[type="file"] { margin-left: 16px; color: var(--muted); font-size: 13px; }

.btn {
  width: calc(100% - 32px);
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 20px;
}
.btn.ghost { background: var(--surface2); color: var(--text); margin-top: 8px; }
.btn:disabled { opacity: 0.4; }

.back {
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  padding: 8px 16px;
  font-weight: 500;
}

/* Rows */
.member-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.member-row .goal { font-size: 14px; margin-top: 3px; }
.member-row .name { font-weight: 600; font-size: 15px; }
.habit { font-size: 13px; color: var(--muted); margin-top: 3px; }

.tap { cursor: pointer; }
.habit-line { display: flex; align-items: center; gap: 10px; margin-top: 8px; cursor: pointer; }
.check {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}
.check.mine { border-color: var(--accent); cursor: pointer; }
.check.done { background: var(--accent); border-color: var(--accent); }
.habit-text { font-size: 14px; }
.habit-text.done { color: var(--muted); text-decoration: line-through; }
.sub-time { color: var(--muted); font-size: 11px; font-weight: 400; }
.evidence-photo { max-width: 100%; border-radius: 10px; margin-top: 8px; }

/* Story strip */
.story-strip {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--hairline);
  scrollbar-width: none;
}
.story {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  flex-shrink: 0;
}
.story .avatar { width: 56px; height: 56px; font-size: 26px; }

/* Feed | Activity segmented control */
.seg {
  display: flex;
  margin: 10px 16px;
  background: var(--surface);
  border-radius: 10px;
  padding: 3px;
}
.seg button {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}
.seg button.on { background: var(--surface2); color: var(--text); }

/* Post grid: edge to edge, hairline gaps */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5px;
  margin-top: 2px;
}
.tile { position: relative; aspect-ratio: 1; cursor: pointer; background: var(--surface); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-text {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 20px;
  padding: 10px;
  text-align: center;
}
.tile-text span { font-size: 11px; color: var(--muted); line-height: 1.35; overflow: hidden; }
.tile-badge { position: absolute; top: 6px; right: 6px; font-size: 13px; filter: drop-shadow(0 1px 2px #000); }
.tile-comments {
  position: absolute; bottom: 6px; right: 6px;
  font-size: 10px;
  background: #000000b3;
  border-radius: 999px;
  padding: 2px 7px;
}

/* Post: Instagram anatomy, edge to edge */
.post { margin-bottom: 8px; }
.post-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.post-head .avatar { width: 34px; height: 34px; font-size: 17px; }
.post-head .name { font-weight: 600; font-size: 14px; }
.post-head .sub { color: var(--muted); font-size: 12px; }
.post-photo { width: 100%; display: block; }
.post-note { padding: 10px 16px 0; font-size: 14px; line-height: 1.4; }
.post-note b { margin-right: 5px; }

/* Three-dot menu */
.menu-wrap { margin-left: auto; position: relative; }
.dots {
  background: none;
  border: none;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  letter-spacing: 1px;
}
.menu {
  position: absolute;
  right: 0;
  top: 28px;
  background: var(--surface2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  overflow: hidden;
  z-index: 10;
  min-width: 160px;
}
.menu button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: #ff453a;
  font-size: 14px;
  font-weight: 500;
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
}
.menu button:active { background: var(--surface); }

/* Comments */
.comments { padding: 6px 16px 14px; }
.comment { font-size: 14px; margin-top: 6px; line-height: 1.4; }
.comment b { font-weight: 600; margin-right: 5px; }
.del-comment {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  margin-left: 6px;
  padding: 0 4px;
  opacity: 0.6;
}
/* Post action row: heart + comment bubble */
.action-row { display: flex; gap: 14px; padding: 10px 16px 0; }
.action {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
}
.action svg { display: block; }
.action:active svg { transform: scale(0.85); }
.liked-by { padding: 8px 16px 0; font-size: 14px; }
.liked-by b { font-weight: 600; }

/* Instagram-style comment row: bare input, text "Post" button */
.comment-row {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: 10px;
  align-items: center;
}
.comment-row[hidden] { display: none; }
.comment-row input {
  flex: 1;
  width: auto;
  margin-left: 0;
  padding: 0;
  font-size: 15px;
  border-radius: 0;
  background: none;
}
.comment-row input::placeholder { color: var(--muted); }
.comment-row input:focus { background: none; }
.comment-send {
  background: none;
  border: none;
  color: #d1d1d6;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.bell {
  position: relative;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 2px;
  display: flex;
}
.badge {
  position: absolute;
  top: -3px; right: -5px;
  background: #ff3040;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 5px;
  line-height: 1.3;
}
.notif-unread { border-left: 2px solid var(--accent); }
.fan-name { color: var(--muted); }
.fan-name::after {
  content: "fan";
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--surface2);
  border-radius: 4px;
  padding: 1px 4px;
  margin: 0 5px 0 4px;
  vertical-align: 1px;
}

/* Habit week dots */
.week-dots { display: flex; gap: 12px; justify-content: center; padding: 10px 16px 0; }
.week-dots span { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.week-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--surface2); }
.week-dots i.on { background: var(--accent); }
.week-dots b { font-size: 10px; color: var(--muted); font-weight: 500; }

/* Perfect-day celebration */
.celebrate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #e0724a26, transparent 70%);
  pointer-events: none;
}
.celebrate-text {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -1px;
  text-shadow: 0 4px 30px #e0724a88;
}

/* Confetti */
.confetti {
  position: fixed;
  width: 7px;
  height: 10px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 50;
}

/* Challenge page: participant progress + fun facts */
.part-row { align-items: flex-start; }
.progress-row { display: flex; align-items: center; gap: 8px; margin: 6px 0 3px; }
.progress-row .bar-track { height: 6px; }
.progress-row .bar-val { width: 36px; font-size: 12px; }
.fact {
  display: flex; align-items: center; gap: 10px;
  margin: 0 16px; padding: 9px 0;
  border-bottom: 1px solid var(--surface2);
  font-size: 14px;
}
.fact:last-child { border-bottom: none; }
.fact-icon { width: 22px; text-align: center; }
.fact-label { color: var(--muted); flex: 1; }
.fact-val { font-weight: 600; text-align: right; }

.goal-link {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}
.post-head .goal-link + .menu-wrap { margin-left: 10px; }

/* Disclosure row (Apple-style "where to go next") */
.disclosure {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 16px;
  padding: 13px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
}
.disclosure:active { background: var(--surface2); }
.disclosure .chev { color: var(--muted); font-size: 17px; }

/* Profile */
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 16px 4px; }
.profile-head .avatar { width: 80px; height: 80px; font-size: 38px; }
.profile-head .name { font-size: 20px; font-weight: 700; }
.avatar-edit { position: relative; cursor: pointer; display: block; }
.avatar-edit-badge {
  position: absolute; right: -2px; bottom: -2px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent, #e0724a); color: #fff; font-size: 13px; display: flex; align-items: center; justify-content: center;
  border: 2px solid #000;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 12px 16px 4px;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  padding: 12px 0;
}
.stat { text-align: center; }
.stat-num { font-size: 17px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* Profile picker */
.overlay {
  position: fixed;
  inset: 0;
  background: #000000f5;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.overlay h2 { font-size: 21px; margin: 0; }
.picker { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; padding: 0 20px; }
.picker button {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
}
.picker .avatar { width: 70px; height: 70px; font-size: 32px; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 14px; line-height: 1.5; }

/* Week day selector */
.day-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin: 4px 16px 12px;
}
.day {
  background: none;
  border: none;
  border-radius: 10px;
  color: var(--muted);
  padding: 8px 0 9px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
}
.day b { font-size: 15px; font-weight: 600; color: var(--text); }
.day.today b { color: var(--accent); }
.day.sel { background: var(--surface2); }

/* Habit rows */
.habit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 16px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--hairline);
}
.habit-row:last-child { border-bottom: none; }

/* Suggestion chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 16px; }
.chip {
  background: var(--surface);
  border: none;
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
}
.chip:active { background: var(--surface2); }
#prev-habits { margin-top: 4px; }
#prev-habits .chip.sel { background: var(--accent); color: #fff; }
#prev-habits .chip:not(.sel) { opacity: 0.5; text-decoration: line-through; }

/* Avatar initials */
.avatar { font-weight: 600; font-family: -apple-system, sans-serif; }
.who { font-weight: 700; font-size: 14px; }

/* Tile kind label (text-only posts) */
.tile-kind { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

/* Mini check dot (profile habit list) */
.mini-check {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--surface2);
  margin-right: 8px;
  vertical-align: 1px;
}
.mini-check.on { background: var(--accent); }

/* Stats: activity chart */
.chart { display: block; }
.chart-val { fill: var(--text); font-size: 10px; font-weight: 600; }
.chart-day { fill: var(--muted); font-size: 9px; }

/* Stats: habit completion bars */
.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 16px;
  padding: 10px 0;
}
.bar-label { width: 110px; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 4px; border-radius: 4px; background: var(--surface2); overflow: hidden; }
.bar { display: block; height: 100%; border-radius: 4px; background: var(--chart); }
.bar-val { width: 28px; text-align: right; font-size: 13px; font-weight: 600; }

/* Fuzzy suggestion dropdown */
.suggest {
  margin: 4px 16px 0;
  background: var(--surface2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  overflow: hidden;
}
#habits .suggest, .habit-row .suggest { margin-left: 0; margin-right: 0; }
.habit-row { flex-wrap: wrap; }
.habit-row .suggest { flex-basis: 100%; order: 10; }
.suggest button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--hairline);
  color: var(--text);
  font-size: 14px;
  padding: 11px 14px;
  text-align: left;
  cursor: pointer;
}
.suggest button:last-child { border-bottom: none; }
.suggest button:hover { background: var(--surface); }

.mention-box { margin: 4px 16px 0; }
.mention-box button { display: flex; align-items: center; gap: 10px; }
.mention-box .avatar { width: 28px; height: 28px; font-size: 13px; }

/* Statistics: weekly habit grid */
.stat-text { font-size: 15px; line-height: 1.2; padding-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hgrid { margin: 18px 16px 0; padding: 12px 12px 6px; border-radius: 14px; background: var(--surface, #111); }
.hgrid.current { border: 1px solid var(--accent); }
.hgrid-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-weight: 600; }
.hgrid-sub { color: var(--muted); font-size: 12px; font-weight: 500; }
.hgrid-row { display: grid; grid-template-columns: 1fr repeat(7, 26px); align-items: center; column-gap: 4px; height: 30px; }
.hgrid-label { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px; }
.hgrid-days b { text-align: center; font-size: 11px; color: var(--muted); font-weight: 500; }
.hgrid-days b.today { color: var(--accent); }
.hgrid-row i { width: 16px; height: 16px; border-radius: 50%; justify-self: center; background: var(--surface2, #222); }
.hgrid-row i.on { background: var(--accent); }
.hgrid-row i.miss { background: transparent; border: 1.5px solid var(--surface2, #333); box-sizing: border-box; }
.hgrid-row i.future { opacity: 0.25; }
.hgrid-row i.today:not(.on) { border-color: var(--accent); opacity: 1; }
