* { box-sizing: border-box; }
.hidden { display: none !important; }
:root {
  --bg-0: #0b0715;
  --bg-1: #1b1233;
  --purple-1: #7c3aed;
  --purple-2: #c084fc;
  --purple-3: #a855f7;
  --text: #f3f0fa;
  --text-dim: #a99fc2;
  --card: rgba(255, 255, 255, 0.04);
  --card-border: rgba(192, 132, 252, 0.18);
  --cl-changelog: #a855f7;
  --cl-update: #38bdf8;
  --cl-announcement: #fbbf24;
}
html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 50% 0%, var(--bg-1) 0%, var(--bg-0) 55%, #060409 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6vh 1.5rem 3rem;
  overflow-x: hidden;
  position: relative;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(500px circle at 15% 20%, rgba(124, 58, 237, 0.16), transparent 60%),
    radial-gradient(600px circle at 85% 75%, rgba(192, 132, 252, 0.12), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
.wrap { position: relative; z-index: 1; width: 100%; max-width: 720px; display: flex; flex-direction: column; align-items: center; }

.hero { text-align: center; margin-bottom: 2.25rem; }
.hero a { display: inline-block; }
.hero img {
  width: 84px;
  height: 84px;
  margin-bottom: 1rem;
  filter: drop-shadow(0 0 34px rgba(168, 85, 247, 0.5));
}
.hero h1 {
  font-size: clamp(1.9rem, 5.5vw, 2.6rem);
  margin: 0 0 0.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #e9d5ff, var(--purple-2) 45%, var(--purple-1));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p { color: var(--text-dim); font-size: 1rem; margin: 0; }

.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 2rem;
}
.filter-btn {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.filter-btn:hover { border-color: rgba(192, 132, 252, 0.5); color: var(--text); }
.filter-btn.active {
  background: rgba(124, 58, 237, 0.35);
  border-color: rgba(192, 132, 252, 0.6);
  color: var(--text);
}

.board { display: flex; flex-direction: column; gap: 1rem; width: 100%; }

.post {
  position: relative;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 1.5rem 1.6rem;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.post-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.post-link:hover, .post-link:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(192, 132, 252, 0.5);
  background: rgba(124, 58, 237, 0.08);
}
.post-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}
.badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}
.badge.changelog { color: var(--cl-changelog); background: rgba(168, 85, 247, 0.15); border: 1px solid rgba(168, 85, 247, 0.35); }
.badge.update { color: var(--cl-update); background: rgba(56, 189, 248, 0.15); border: 1px solid rgba(56, 189, 248, 0.35); }
.badge.announcement { color: var(--cl-announcement); background: rgba(251, 191, 36, 0.15); border: 1px solid rgba(251, 191, 36, 0.35); }
.pin { font-size: 0.75rem; color: var(--purple-2); }
.post-date { font-size: 0.78rem; color: var(--text-dim); margin-left: auto; }
.post h2 { margin: 0 0 0.5rem; font-size: 1.2rem; font-weight: 700; }
.post p { margin: 0; color: var(--text-dim); font-size: 0.95rem; line-height: 1.55; white-space: pre-wrap; }
.read-more { color: var(--purple-2); font-size: 0.85rem; font-weight: 600; margin-top: 0.6rem; display: inline-block; }

.empty, .error-msg { text-align: center; color: var(--text-dim); padding: 2rem 0; }

.back-link { color: var(--text-dim); text-decoration: none; font-size: 0.85rem; margin-bottom: 1.25rem; align-self: flex-start; }
.back-link:hover { color: var(--text); }

/* ---------- Reactions ---------- */

.reactions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.5rem 0 0; }
.reaction-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}
.reaction-btn:hover { border-color: rgba(192, 132, 252, 0.5); }
.reaction-btn.mine { background: rgba(124, 58, 237, 0.3); border-color: rgba(192, 132, 252, 0.6); }
.reaction-btn .count { font-size: 0.8rem; color: var(--text-dim); font-weight: 600; }
.reaction-btn.mine .count { color: var(--text); }
.reaction-add {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.reaction-add-wrap { position: relative; }
.reaction-btn.add-btn { font-weight: 700; padding: 0.35rem 0.85rem; }

/* position:fixed + JS-computed top/left (see toggleEmojiPicker) rather than
   anchored to the flex-wrap reactions row, so it can never render off the
   edge of a wrapped row or overflow the page. */
.emoji-picker {
  position: fixed;
  z-index: 50;
  width: 340px;
  max-height: min(420px, 70vh);
  background: #150f24;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 0.75rem;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.emoji-picker-top { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.emoji-search {
  flex: 1;
  min-width: 0;
  background: #0f0a1a;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  color: var(--text);
  font-size: 0.85rem;
}
.emoji-search:focus { outline: none; border-color: var(--purple-1); }
.emoji-close {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.emoji-close:hover { color: var(--text); border-color: rgba(192, 132, 252, 0.5); }

.emoji-tabs {
  display: flex;
  gap: 0.2rem;
  overflow-x: auto;
  flex-shrink: 0;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--card-border);
}
.emoji-tab {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 1.05rem;
  cursor: pointer;
  opacity: 0.6;
}
.emoji-tab:hover { opacity: 0.9; background: rgba(192, 132, 252, 0.12); }
.emoji-tab.active { opacity: 1; background: rgba(124, 58, 237, 0.3); }

.emoji-grid-scroll {
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(192, 132, 252, 0.4) transparent;
}
.emoji-grid-scroll::-webkit-scrollbar { width: 8px; }
.emoji-grid-scroll::-webkit-scrollbar-track { background: transparent; }
.emoji-grid-scroll::-webkit-scrollbar-thumb { background: rgba(192, 132, 252, 0.35); border-radius: 8px; }
.emoji-grid-scroll::-webkit-scrollbar-thumb:hover { background: rgba(192, 132, 252, 0.55); }
.emoji-category-header {
  position: sticky;
  top: 0;
  background: #150f24;
  color: var(--purple-2);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.1rem 0.5rem;
  margin-bottom: 0.3rem;
  border-bottom: 1px solid var(--card-border);
  z-index: 1;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.1rem;
}
.emoji-option {
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.35rem 0;
  cursor: pointer;
  transition: background 0.12s ease;
}
.emoji-option:hover { background: rgba(192, 132, 252, 0.18); }

/* ---------- Comments ---------- */

.comments-section { width: 100%; margin-top: 2rem; }
.comments-section h3 { font-size: 1.05rem; margin: 0 0 1rem; }
.comment-list { display: flex; flex-direction: column; gap: 0.9rem; margin-bottom: 1.5rem; }
.comment-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 0.9rem 1.1rem;
}
.comment-meta { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.35rem; }
.comment-author { font-weight: 700; font-size: 0.85rem; }
.comment-date { font-size: 0.72rem; color: var(--text-dim); }
.comment-body { font-size: 0.9rem; color: var(--text-dim); line-height: 1.5; white-space: pre-wrap; margin: 0; }
.no-comments { color: var(--text-dim); font-size: 0.9rem; }

.comment-form { display: flex; flex-direction: column; gap: 0.6rem; }
.comment-form input, .comment-form textarea {
  background: #0f0a1a;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  width: 100%;
}
.comment-form textarea { resize: vertical; min-height: 80px; }
.comment-form button {
  align-self: flex-start;
  background: linear-gradient(135deg, var(--purple-1), var(--purple-2));
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.comment-form button:hover { filter: brightness(1.1); }
.comment-form button:disabled { opacity: 0.6; cursor: default; }

footer {
  position: relative;
  z-index: 1;
  margin-top: 3rem;
  color: var(--text-dim);
  font-size: 0.82rem;
  text-align: center;
}
footer a { color: var(--purple-2); text-decoration: none; }
footer a:hover { text-decoration: underline; }
