:root {
  --bg: #D6EAED;
  --card: #FFFFFF;
  --border: #C5DEE2;
  --cyan: #008B9C;
  --cyan-hover: #006E7D;
  --cyan-light: #E0F4F7;
  --cyan-dark: #005F6B;
  --text: #1A2E30;
  --muted: #5E7E82;
  --upvote: #008B9C;
  --downvote: #7193FF;
  --tag-bg: #EBF5F7;
  --nav-bg: #FFFFFF;
  --flair: #00A8BB;
  --green: #2DC97A;
  --gold: #FFB000;
}

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

body {
  font-family: 'IBM Plex Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── NAV ── */
nav {
  background: var(--nav-bg);
  border-bottom: 2px solid var(--cyan);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0,139,156,.12);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
}

.logo-img {
  height: 36px;
  width: auto;
}

.nav-links {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}

.nav-link {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  transition: background .15s, color .15s;
  text-decoration: none;
}

.nav-link:hover { background: var(--tag-bg); color: var(--text); }
.nav-link.active { background: var(--tag-bg); color: var(--cyan); }

.nav-search {
  flex: 1;
  max-width: 690px;
  margin: 0 auto;
}

.nav-search input {
  width: 100%;
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  font-family: inherit;
  background: var(--tag-bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s, background .15s;
}

.nav-search input:focus { border-color: var(--cyan); background: white; }

.nav-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.btn {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid;
  font-family: inherit;
  transition: all .15s;
}

.btn-outline { border-color: var(--cyan); color: var(--cyan); background: transparent; }
.btn-outline:hover { background: var(--cyan-light); }
.btn-fill { border-color: var(--cyan); color: white; background: var(--cyan); }
.btn-fill:hover { background: var(--cyan-hover); border-color: var(--cyan-hover); }

/* ── LAYOUT ── */
.page { display: none; }
.page.active { display: block; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

/* Full-width container for home page feed */
.container-full {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 24px;
}

.feed { flex: 1; min-width: 0; }
.sidebar { width: 312px; flex-shrink: 0; }

/* ── SORT BAR ── */
.sort-bar {
  background: white;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
  border: 1px solid var(--border);
}

.sort-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
  transition: background .1s, color .1s;
}

.sort-btn:hover, .sort-btn.active { background: var(--tag-bg); color: var(--cyan); }

/* ── POST CARD ── */
.post-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 10px;
  display: flex;
  cursor: pointer;
  transition: border-color .1s, box-shadow .1s;
  overflow: hidden;
}

.post-card:hover { border-color: var(--cyan); box-shadow: 0 2px 8px rgba(0,139,156,.1); }

.vote-col {
  width: 44px;
  background: #F0F8FA;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  gap: 4px;
  flex-shrink: 0;
}

.vote-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 2px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  transition: color .1s, background .1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vote-btn:hover { color: var(--upvote); background: rgba(0,139,156,.1); }
.vote-btn.down:hover { color: var(--downvote); background: rgba(113,147,255,.08); }
.vote-btn.voted-up { color: var(--upvote); }
.vote-btn.voted-down { color: var(--downvote); }

.vote-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
}

.post-body { flex: 1; padding: 8px 12px; min-width: 0; }

.post-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.post-meta strong { color: var(--text); }

.post-flair {
  display: inline-block;
  background: var(--cyan);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  margin-left: 6px;
}

.post-title { font-size: 18px; font-weight: 500; color: var(--text); margin-bottom: 8px; line-height: 1.3; }

.post-preview {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 8px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-actions { display: flex; gap: 4px; }

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
  transition: background .1s, color .1s;
}

.action-btn:hover { background: var(--tag-bg); color: var(--cyan); }

.award {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(255,176,0,.15);
  color: var(--gold);
  margin-left: 6px;
}

/* ── SIDEBAR ── */
.sidebar-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 16px;
}

.sidebar-header {
  background: linear-gradient(135deg, #00B4CA 0%, #006E7D 100%);
  padding: 20px 16px;
}

.sidebar-header h3 { font-size: 15px; font-weight: 700; color: white; margin-bottom: 4px; }
.sidebar-header p { font-size: 13px; color: rgba(255,255,255,.8); }

.sidebar-body { padding: 14px; }
.sidebar-body p { font-size: 14px; line-height: 1.5; color: var(--text); margin-bottom: 12px; }

.sidebar-stat { display: flex; justify-content: space-between; margin-bottom: 16px; }
.stat-item { text-align: center; }
.stat-num { font-size: 18px; font-weight: 700; color: var(--cyan); }
.stat-label { font-size: 12px; color: var(--muted); }

/* ── ABOUT PAGE ── */
.about-hero {
  background: linear-gradient(135deg, #007A8C 0%, #00B4CA 60%, #00D4C8 100%);
  border-radius: 6px;
  padding: 48px 40px;
  margin-bottom: 16px;
  color: white;
}

.about-hero h1 { font-size: 36px; font-weight: 700; margin-bottom: 12px; }
.about-hero p { font-size: 18px; opacity: .9; max-width: 600px; line-height: 1.6; }

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.about-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  border-top: 3px solid var(--cyan);
}

.about-card-icon { font-size: 28px; margin-bottom: 8px; }
.about-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; color: var(--cyan-dark); }
.about-card p { font-size: 14px; color: var(--muted); line-height: 1.5; }

.about-team { background: white; border: 1px solid var(--border); border-radius: 6px; padding: 20px; }
.about-team h2 { font-size: 20px; font-weight: 700; margin-bottom: 16px; }

.team-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.team-member { text-align: center; }

.team-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: white;
  font-weight: 700;
}

.team-member h4 { font-size: 14px; font-weight: 700; }
.team-member p { font-size: 12px; color: var(--muted); }

/* ── POSTS PAGE ── */
.posts-header {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.posts-header h2 { font-size: 20px; font-weight: 700; }

.tag-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

.tag {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--muted);
  transition: all .15s;
}

.tag:hover { border-color: var(--cyan); color: var(--cyan); }
.tag.active { border-color: var(--cyan); background: var(--cyan); color: white; }

/* ── CONTACT PAGE ── */
.contact-wrap { display: grid; grid-template-columns: 1fr 320px; gap: 24px; }

.contact-form-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 28px;
}

.contact-form-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.contact-form-card .subtitle { color: var(--muted); font-size: 14px; margin-bottom: 24px; }

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--tag-bg);
  outline: none;
  transition: border-color .15s, background .15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--cyan); background: white; }

.form-group textarea { min-height: 120px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.submit-btn {
  width: 100%;
  padding: 10px;
  background: var(--cyan);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s;
}

.submit-btn:hover { background: var(--cyan-hover); }

.contact-info-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  height: fit-content;
}

.contact-info-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }

.info-item { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }

.info-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--cyan-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.info-text h4 { font-size: 14px; font-weight: 700; }
.info-text p { font-size: 13px; color: var(--muted); }

.success-msg { display: none; text-align: center; padding: 40px; }
.success-msg.show { display: block; }
.success-msg .check { font-size: 48px; margin-bottom: 16px; }
.success-msg h3 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.success-msg p { color: var(--muted); font-size: 14px; }

/* ── TOAST ── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--cyan-dark);
  color: white;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  z-index: 999;
  transition: transform .3s ease;
  pointer-events: none;
}

#toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .about-grid { grid-template-columns: 1fr; }
  .team-grid { grid-template-columns: repeat(2, 1fr); }
  .contact-wrap { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* ── POST PAGE ── */
.post-page-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 24px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 14px;
  padding: 6px 10px;
  border-radius: 4px;
  transition: background .15s, color .15s;
}

.back-link:hover { background: var(--tag-bg); color: var(--cyan); }

.post-full-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 16px;
  display: flex;
}

.post-full-body { flex: 1; padding: 16px 20px; }

.post-full-title {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 12px;
  color: var(--text);
}

.post-full-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 16px;
  white-space: pre-wrap;
}

/* ── COMMENTS ── */
.comments-section { }

.comments-header {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}

.comment-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.comment-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.comment-author {
  font-size: 13px;
  font-weight: 700;
  color: var(--cyan-dark);
}

.comment-time {
  font-size: 12px;
  color: var(--muted);
}

.comment-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 10px;
}

.comment-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.comment-vote {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.comment-vote button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  padding: 2px 4px;
  border-radius: 2px;
  transition: color .1s, background .1s;
}

.comment-vote button:hover { color: var(--upvote); background: rgba(0,139,156,.1); }
.comment-vote button.down:hover { color: var(--downvote); }
.comment-vote button.voted-up { color: var(--upvote); }
.comment-vote button.voted-down { color: var(--downvote); }

.comment-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: inherit;
  transition: background .1s, color .1s;
}

.comment-action-btn:hover { background: var(--tag-bg); color: var(--cyan); }

.reply-indent {
  margin-left: 24px;
  margin-top: 8px;
}

.reply-card {
  background: var(--tag-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-left: 3px solid var(--cyan);
}

.add-comment-box {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
}

.add-comment-box textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--tag-bg);
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}

.add-comment-box textarea:focus { border-color: var(--cyan); background: white; }

.add-comment-box button {
  margin-top: 8px;
  padding: 8px 20px;
  background: var(--cyan);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s;
}

.add-comment-box button:hover { background: var(--cyan-hover); }

.post-card { cursor: pointer; }
