:root {
  --gold: #FFC107;
  --gold-light: #FFD54F;
  --gold-dark: #E09B00;
  --gold-shine: #FFE082;
  --gold-soft: #FFF3C4;
  --gold-grad: linear-gradient(145deg, #FFC107 0%, #E09B00 100%);
  --ink: #1A1A1A;
  --ink-soft: #3A3A3A;
  --paper: #FFF8E7;
  --paper-gold: #FFF3C4;
  --surface: #FFFFFF;
  --border: #E8D9A8;
  --border-gold: #E8D9A8;
  --muted: #8A7A55;
  --danger: #C0392B;
  --success: #2E7D32;
  --shadow: 0 1px 2px rgba(224,155,0,.12), 0 0 0 1px rgba(232,217,168,.5);
  --glow: 0 0 10px rgba(255,193,7,.55), 0 0 2px rgba(224,155,0,.4);
  --radius: 8px;
  --radius-lg: 12px;
  --nav-h: 56px;
  --top-h: 56px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.34;
  min-height: 100%;
}
a { color: var(--gold-dark); text-decoration: none; }
button, input, textarea, select { font: inherit; }
img { max-width: 100%; display: block; }

.app-shell {
  max-width: 680px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + 16px);
}

/* —— Top bar (FB-like) —— */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--top-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 1.2rem; color: var(--gold-dark);
  letter-spacing: -0.02em; flex-shrink: 0;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--gold-grad);
  box-shadow: var(--glow);
  display: grid; place-items: center; color: #fff; font-size: 18px;
}
.top-search {
  flex: 1; display: flex; align-items: center;
  background: var(--paper); border-radius: 999px;
  padding: 8px 14px; gap: 8px; color: var(--ink-soft);
  border: 1px solid transparent;
  cursor: pointer;
}
.top-search:hover { background: var(--gold-soft); }
.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: none; background: var(--paper); cursor: pointer;
  display: grid; place-items: center; font-size: 1.1rem;
}
.icon-btn:hover { background: var(--gold-soft); }

/* —— Composer —— */
.composer {
  background: var(--surface);
  margin: 12px 0 0;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.composer-row { display: flex; gap: 10px; align-items: center; }
.composer-input {
  flex: 1; border: none; background: var(--paper);
  border-radius: 999px; padding: 10px 16px; text-align: left;
  color: var(--ink-soft); cursor: pointer; width: 100%;
}
.composer-input:hover { background: var(--gold-soft); }
.composer-actions {
  display: flex; justify-content: space-around;
  border-top: 1px solid var(--border); margin-top: 10px; padding-top: 8px;
}
.composer-action {
  flex: 1; border: none; background: transparent; padding: 8px;
  border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.composer-action:hover { background: var(--paper); }

/* —— Cards / posts —— */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  margin: 12px 0 0;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-pad { padding: 12px 16px; }

.post-head { display: flex; gap: 10px; align-items: flex-start; }
.post-head .meta { flex: 1; min-width: 0; }
.post-head .name { font-weight: 700; color: var(--ink); }
.post-head .name:hover { text-decoration: underline; }
.post-head .sub { font-size: 0.8rem; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.type-badge {
  display: inline-block; font-size: 0.7rem; font-weight: 700;
  padding: 1px 7px; border-radius: 999px;
  background: var(--gold-soft); color: var(--gold-dark);
  border: 1px solid var(--border-gold);
}
.type-badge.personal { background: #E7F3FF; color: #1877F2; border-color: #C6DCF5; }
/* Keep personal distinct but not FB-blue brand — use warm grey */
.type-badge.personal { background: #F0F2F5; color: #4B4F56; border-color: #CED0D4; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(145deg, #FFE08A, var(--gold));
  display: grid; place-items: center;
  font-weight: 800; color: #4a3500; overflow: hidden; flex-shrink: 0;
}
.avatar.lg { width: 72px; height: 72px; font-size: 1.4rem; }
.avatar.sm { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar.code {
  background: #3A3A3A; color: var(--gold-light); font-size: 0.65rem; font-weight: 700;
}
.avatar.author-badge-av {
  background: var(--gold); color: #fff; font-size: 0.7rem;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.post-body { margin: 10px 0 4px; white-space: pre-wrap; font-size: 0.98rem; }
.post-image { margin: 8px -16px 0; background: #000; }
.post-image img { width: 100%; max-height: 420px; object-fit: contain; margin: 0 auto; }

.rating-strip {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; font-size: 0.9rem; color: var(--ink-soft);
  border-bottom: 1px solid var(--border);
}
.stars-inline { color: var(--gold-dark); letter-spacing: 1px; font-weight: 700; text-shadow: var(--glow); }

.action-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  border-top: 1px solid transparent;
  padding: 4px 8px;
}
.action-btn {
  border: none; background: transparent; padding: 10px;
  border-radius: 6px; cursor: pointer; font-weight: 600;
  color: var(--ink-soft); display: flex; align-items: center;
  justify-content: center; gap: 6px;
}
.action-btn:hover { background: var(--paper); }
.action-btn.active { color: var(--gold-dark); }

.rate-panel {
  padding: 8px 16px 12px; border-top: 1px solid var(--border);
  background: var(--paper-gold);
}
.stars { display: inline-flex; gap: 2px; }
.star {
  width: 32px; height: 32px; border: none; background: transparent;
  padding: 0; cursor: pointer; color: #D8C99A; font-size: 26px; line-height: 1;
}
.star.on { color: var(--gold); background: linear-gradient(180deg,#FFC107,#E09B00); -webkit-background-clip: text; background-clip: text; text-shadow: var(--glow); filter: drop-shadow(0 0 4px rgba(255,193,7,.7)); }
.star:disabled { cursor: default; }

/* —— Comments —— */
.comments-panel {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 8px 16px 12px;
}
.comment {
  display: flex; gap: 8px; margin: 8px 0;
}
.comment-bubble {
  background: var(--paper); border-radius: 16px; padding: 8px 12px; flex: 1;
}
.comment-bubble .who {
  font-weight: 700; font-size: 0.85rem; color: var(--ink);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.comment-bubble .who .code { font-family: ui-monospace, monospace; color: var(--gold-dark); }
.badge-author {
  font-size: 0.65rem; font-weight: 800; text-transform: uppercase;
  background: var(--gold); color: #fff; padding: 1px 6px; border-radius: 4px;
}
.comment-actions {
  display: flex; gap: 12px; padding: 2px 8px;
  font-size: 0.75rem; font-weight: 700; color: var(--ink-soft);
}
.comment-actions button {
  border: none; background: none; cursor: pointer;
  font: inherit; font-weight: 700; color: var(--ink-soft); padding: 0;
}
.comment-actions button:hover { text-decoration: underline; }
.replies { margin-left: 40px; }
.comment-form {
  display: flex; gap: 8px; align-items: center; margin-top: 8px;
}
.comment-form input {
  flex: 1; border: none; background: var(--paper);
  border-radius: 999px; padding: 8px 14px;
}
.comment-form button {
  border: none; background: var(--gold); color: #1a1200;
  font-weight: 700; border-radius: 999px; padding: 8px 14px; cursor: pointer;
}

/* —— Bottom nav —— */
.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: min(680px, 100%); height: var(--nav-h);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border); z-index: 40;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); font-size: 0.68rem; font-weight: 600;
}
.bottom-nav a.active { color: var(--gold-dark); border-top: 3px solid var(--gold); }
.bottom-nav .ico { font-size: 1.25rem; line-height: 1; }

/* —— Misc —— */
.btn {
  border: none; border-radius: 6px; padding: 8px 14px;
  cursor: pointer; font-weight: 600;
}
.btn-primary {
  background: var(--gold-grad);
  color: #1a1200;
  box-shadow: var(--glow);
}
.btn-ghost { background: var(--paper); color: var(--ink-soft); }
.btn-sm { padding: 5px 10px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--gold-dark); padding: 4px 0; font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; }

.hero {
  margin: 12px 0 0; padding: 20px 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #FFF6D6, #fff 60%);
  border: 1px solid var(--border-gold);
  box-shadow: var(--shadow);
}
.hero h1 { margin: 0 0 6px; font-size: 1.5rem; }
.hero p { margin: 0; color: var(--ink-soft); }

.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.spread { justify-content: space-between; }
.muted { color: var(--ink-soft); }
.tiny { font-size: 0.8rem; }
.bold { font-weight: 700; }
.hidden { display: none !important; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--gold-soft); border: 1px solid var(--border-gold);
  border-radius: 999px; padding: 2px 8px; font-size: 0.8rem;
  font-weight: 700; color: var(--gold-dark);
}

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 0.8rem; color: var(--ink-soft); font-weight: 600; }
.field input, .field textarea, .field select {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; background: #fff;
}
.field textarea { min-height: 88px; resize: vertical; }

.auth-wrap { padding: 12px 12px 80px; }
.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--paper); padding: 4px; border-radius: 8px; margin-bottom: 12px;
}
.tabs button {
  border: none; background: transparent; padding: 10px;
  border-radius: 6px; font-weight: 700; color: var(--muted); cursor: pointer;
}
.tabs button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

.chip-row {
  display: flex; gap: 8px; overflow-x: auto; padding: 8px 0;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; border: 1px solid var(--border); background: #fff;
  border-radius: 999px; padding: 8px 14px; font-weight: 600;
  color: var(--ink-soft); cursor: pointer;
}
.chip.active {
  background: var(--gold-grad);
  color: #1a1200;
  box-shadow: var(--glow); border-color: transparent;
}

.brand-tile {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.brand-tile:last-child { border-bottom: none; }
.score-badge { margin-left: auto; text-align: right; }
.score-badge .n { font-size: 1.15rem; font-weight: 800; color: var(--gold-dark); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 12px);
  transform: translateX(-50%); background: #050505; color: #fff;
  padding: 10px 16px; border-radius: 999px; font-size: 0.9rem;
  z-index: 50; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }

.cover {
  height: 140px; background: linear-gradient(120deg, #FFE08A, #F5C842 40%, #D4A017);
}
.profile-head { position: relative; }
.profile-avatar-wrap { padding: 0 16px; margin-top: -36px; }
.notif-item {
  display: flex; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.notif-item.unread { background: var(--gold-soft); }
.msg-bubble {
  max-width: 78%; padding: 8px 12px; border-radius: 16px;
  margin: 4px 0; background: var(--paper);
}
.msg-bubble.mine {
  margin-left: auto;
  background: linear-gradient(135deg, #FFE9A8, #F5C842);
}

.page-pad { padding: 0 12px; }

.menu-btn {
  border: none; background: transparent; width: 36px; height: 36px;
  border-radius: 50%; cursor: pointer; color: var(--ink-soft); font-size: 1.2rem;
}
.menu-btn:hover { background: var(--paper); }

.share-hint { font-size: 0.85rem; color: var(--ink-soft); padding: 8px 16px; }
