:root {
  --bg: #fffaf2;
  --fg: #2a1f14;
  --muted: #7a6a55;
  --accent: #c0392b;
  --border: #e6d8c2;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--accent);
  text-decoration: none;
}
.topbar nav { display: flex; gap: 0.75rem; align-items: center; }
.topbar .who { color: var(--muted); }
.inline { display: inline; margin: 0; }
.linkish {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
}
main { max-width: 720px; margin: 1.5rem auto; padding: 0 1rem; }
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card.narrow { max-width: 360px; margin: 3rem auto; }
form label { display: block; margin: 0.75rem 0; }
form input {
  display: block;
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
}
button[type=submit] {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.55rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}
.error {
  background: #fde9e7;
  border: 1px solid #f5b8b2;
  color: #7a1d12;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
}
.muted { color: var(--muted); }

.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.feed-header h1 { margin: 0; font-size: 1.25rem; }
.btn {
  background: var(--accent);
  color: #fff;
  padding: 0.45rem 0.8rem;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.95rem;
}
.post-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  overflow: hidden;
}
.post-card header {
  padding: 0.65rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
}
.post-card .who { color: var(--fg); text-decoration: none; font-weight: 600; }
.post-card .who:hover { text-decoration: underline; }
.post-card .dot { color: var(--muted); }
.post-card img:not(.avatar) {
  display: block;
  width: 100%;
  height: auto;
  background: #f4ebda;
}
.post-card .meta {
  padding: 0.5rem 0.9rem 0;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.post-card .count { font-weight: 600; }
.like-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  cursor: pointer;
  font: inherit;
  color: var(--fg);
}
.like-btn.liked { color: var(--accent); border-color: var(--accent); }
.like-btn:hover { background: #fdf3ef; }
.comment-link {
  color: var(--muted);
  text-decoration: none;
}
.comment-link:hover { color: var(--fg); }

.comment {
  border-top: 1px solid var(--border);
  padding: 0.6rem 0;
}
.comment header {
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
}
.comment .who {
  color: var(--fg);
  text-decoration: none;
  font-weight: 600;
}
.comment p { margin: 0; white-space: pre-wrap; }

.comment-form { margin-top: 1rem; }
.comment-form button { margin-top: 0.5rem; }
.comment-edit-form textarea { margin-bottom: 0.5rem; }

.actions {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
}
.action {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.5rem;
  font-size: 0.85rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}
.action:hover { color: var(--fg); }
.action.danger { color: #b53a2a; border-color: #f3c2bc; }
.action.danger:hover { background: #fdf3ef; }
.row { display: flex; gap: 0.5rem; align-items: center; }
.cancel {
  color: var(--muted);
  text-decoration: none;
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
}
.edit-thumb {
  max-width: 100%;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}
.post-card header { gap: 0.4rem; }
.post-card header .actions { font-size: 0.85rem; }

.profile-header h1 { margin: 0 0 0.5rem; }
.profile-header .totals {
  display: flex;
  gap: 2rem;
  color: var(--muted);
}
.profile-header .totals .big {
  display: block;
  font-size: 1.6rem;
  color: var(--fg);
  font-weight: 700;
}
.badge {
  background: #fde9e7;
  color: var(--accent);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  vertical-align: middle;
}

.leaderboard {
  width: 100%;
  border-collapse: collapse;
}
.leaderboard th, .leaderboard td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.leaderboard th { color: var(--muted); font-weight: 600; }
.leaderboard .num { text-align: right; font-variant-numeric: tabular-nums; }
.leaderboard tr:last-child td { border-bottom: none; }
.leaderboard .who { color: var(--fg); text-decoration: none; font-weight: 600; }
.leaderboard .who:hover { text-decoration: underline; }
.post-card .note {
  padding: 0.25rem 0.9rem 0.9rem;
  margin: 0;
  white-space: pre-wrap;
}
textarea {
  display: block;
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
  resize: vertical;
}

.success {
  background: #e7f7e9;
  border: 1px solid #b2e5bb;
  color: #1d6630;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
}
.user-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed var(--border);
}
.user-row:last-of-type {
  border-bottom: none;
  margin-bottom: 0.75rem;
}
.user-row input {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  margin: 0;
}
.pw-form {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  margin: 0;
}
.pw-form input {
  width: 10rem;
  padding: 0.2rem 0.4rem;
  margin: 0;
  font-size: 0.85rem;
}
.pw-status {
  font-size: 0.85rem;
  color: #1d6630;
}

/* avatars */
.avatar {
  display: inline-block;
  border-radius: 50%;
  object-fit: cover;
  background: #f4ebda;
  border: 1px solid var(--border);
  flex: 0 0 auto;
  overflow: hidden;
  vertical-align: middle;
  line-height: 1;
}
.avatar-xs { width: 22px; height: 22px; font-size: 14px; }
.avatar-sm { width: 32px; height: 32px; font-size: 18px; }
.avatar-lg { width: 128px; height: 128px; font-size: 64px; }
.avatar.placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.who-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: inherit;
}
.who-link:hover .who { text-decoration: underline; }
.topbar .who-link { color: var(--muted); }
.leaderboard .who-link { color: var(--fg); font-weight: 600; }

.profile-top {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.profile-top h1 { margin: 0 0 0.4rem; }

.avatar-edit {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--border);
}
.avatar-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.avatar-form input[type=file] {
  flex: 1 1 auto;
  width: auto;
  padding: 0.3rem;
  margin: 0;
}

