:root {
  --bg: #faf6ef;
  --surface: #ffffff;
  --surface-2: #f5efe5;
  --text: #2d2a26;
  --muted: #8a8378;
  --border: #efe7db;
  --accent: #f28c28;
  --accent-strong: #e07f16;
  --accent-soft: #fdeed8;
  --danger: #e64545;
  --success: #2fa96b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(45, 42, 38, 0.06), 0 4px 14px rgba(45, 42, 38, 0.06);
  --maxw: 760px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 1rem; }

/* ---------- top nav ---------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topnav-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  margin-right: auto;
  cursor: pointer;
}
.brand .paw { font-size: 1.35rem; }
.nav-links { display: flex; align-items: center; gap: 2px; }
.nav-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 999px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { color: var(--accent-strong); background: var(--accent-soft); }
.nav-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--surface-2);
}

/* ---------- layout ---------- */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 80px;
}
.page-title { font-size: 1.4rem; font-weight: 800; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 20px; }

/* ---------- cards / surface ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 16px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text);
  transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-outline { background: transparent; border-color: var(--border); }
.btn-outline:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.icon-btn {
  border: 0;
  background: transparent;
  padding: 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  transition: color .15s, background .15s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.liked { color: var(--danger); }
.icon-btn.saved { color: var(--accent-strong); }
.icon-btn .count { font-variant-numeric: tabular-nums; }

/* ---------- forms ---------- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 700; margin-bottom: 6px; color: var(--muted); }
.form-group input, .form-group textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-error {
  background: #fdeaea;
  color: #a13333;
  border: 1px solid #f5c6c6;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}
.form-hint { color: var(--muted); font-size: 0.82rem; margin-top: 6px; }

/* ---------- auth screens ---------- */
.auth-wrap { max-width: 420px; margin: 24px auto; }
.auth-card { padding: 28px; }
.auth-card h1 { margin: 0 0 4px; font-size: 1.5rem; }
.auth-card .sub { color: var(--muted); margin: 0 0 22px; }
.auth-switch { text-align: center; margin-top: 18px; color: var(--muted); font-size: 0.92rem; }
.auth-switch a { color: var(--accent-strong); font-weight: 700; cursor: pointer; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.82rem; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- feed cards ---------- */
.feed-card { overflow: hidden; padding: 0; }
.feed-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; }
.feed-head .avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
  background: var(--surface-2); border: 1px solid var(--border);
}
.feed-head .names { min-width: 0; }
.feed-head .name { font-weight: 700; font-size: 0.95rem; }
.feed-head .name:hover { color: var(--accent-strong); }
.feed-head .meta { color: var(--muted); font-size: 0.78rem; }
.feed-media {
  width: 100%;
  background: var(--surface-2);
  cursor: pointer;
  max-height: 520px;
  object-fit: contain;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.feed-actions { display: flex; align-items: center; gap: 6px; padding: 6px 12px; }
.feed-actions .spacer { flex: 1; }
.feed-caption { padding: 0 14px 14px; font-size: 0.95rem; }
.feed-caption .catname { font-weight: 800; }
.feed-caption .location { color: var(--muted); font-size: 0.82rem; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  margin-left: 6px;
  vertical-align: middle;
}

/* ---------- empty / loading ---------- */
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty .big { font-size: 2.4rem; display: block; margin-bottom: 10px; }
.spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 40px auto;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- profile ---------- */
.profile-head { display: flex; gap: 20px; align-items: center; }
.profile-avatar {
  width: 96px; height: 96px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--border); background: var(--surface-2);
}
.profile-name { font-size: 1.5rem; font-weight: 800; margin: 0; }
.profile-handle { color: var(--muted); margin: 2px 0 10px; }
.profile-stats { display: flex; gap: 22px; margin: 14px 0; }
.stat { text-align: center; }
.stat .num { font-size: 1.2rem; font-weight: 800; display: block; }
.stat .lbl { font-size: 0.78rem; color: var(--muted); }
.profile-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- grid ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid-item { border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); cursor: pointer; aspect-ratio: 1 / 1; }
.grid-item img { width: 100%; height: 100%; object-fit: cover; }
.grid-item .grid-name { padding: 4px 8px; font-size: 0.78rem; font-weight: 700; background: rgba(255,255,255,.9); }

/* ---------- leaderboard ---------- */
.lb-row { display: flex; align-items: center; gap: 14px; padding: 12px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.lb-row:last-child { border-bottom: 0; }
.lb-rank { width: 34px; text-align: center; font-weight: 800; font-size: 1.05rem; color: var(--muted); }
.lb-rank.top { color: var(--accent-strong); }
.lb-row .avatar { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.lb-row .name { font-weight: 700; }
.lb-row .sub { color: var(--muted); font-size: 0.8rem; }
.lb-row .pts { margin-left: auto; font-weight: 800; color: var(--accent-strong); }

/* ---------- achievements ---------- */
.ach-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.ach {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px;
  display: flex; gap: 12px; align-items: center; background: var(--surface);
}
.ach .icon { font-size: 1.8rem; }
.ach .title { font-weight: 700; font-size: 0.92rem; }
.ach .desc { color: var(--muted); font-size: 0.78rem; }
.ach.locked { opacity: .55; filter: grayscale(.8); }

/* ---------- comments ---------- */
.comment { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: 0; }
.comment .avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.comment .body { min-width: 0; flex: 1; }
.comment .uname { font-weight: 700; font-size: 0.9rem; }
.comment .txt { font-size: 0.93rem; white-space: pre-wrap; word-break: break-word; }
.comment .meta { color: var(--muted); font-size: 0.78rem; display: flex; gap: 12px; align-items: center; }
.comment .likebtn { border: 0; background: transparent; color: var(--muted); font-size: 0.8rem; font-weight: 600; padding: 2px 4px; }
.comment .likebtn.liked { color: var(--danger); }
.comment-form { display: flex; gap: 10px; margin-top: 14px; }
.comment-form input { flex: 1; border: 1px solid var(--border); border-radius: 999px; padding: 10px 16px; outline: none; }
.comment-form input:focus { border-color: var(--accent); }

/* ---------- responsive ---------- */
@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .ach-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }
  .profile-head { flex-direction: column; text-align: center; }
  .profile-stats { justify-content: center; }
  .nav-link span.label { display: none; }
  .nav-link { padding: 10px; }
}
