/* ================================================================
   GLOBAL RESET & VARIABLES
================================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --clr-primary:      #6366f1;
  --clr-primary-dark: #4f46e5;
  --clr-bg:           #f1f5f9;
  --clr-surface:      #ffffff;
  --clr-border:       #e2e8f0;
  --clr-text:         #1e293b;
  --clr-muted:        #64748b;
  --clr-hot:          #f97316;
  --clr-pin:          #6366f1;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.07);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.15);

  --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;

  --navbar-h: 64px;
  --transition: .18s ease;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--clr-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul {
  list-style: none;
}

img {
  max-width: 100%;
}

/* ================================================================
   UTILITIES
================================================================ */
.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 20px;
}

.w-full { width: 100%; }

/* ================================================================
   BUTTONS
================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), transform var(--transition);
  white-space: nowrap;
}

.btn:active { transform: scale(.97); }

.btn--primary {
  background: var(--clr-primary);
  color: #fff;
}

.btn--primary:hover {
  background: var(--clr-primary-dark);
  text-decoration: none;
}

.btn--outline {
  background: transparent;
  border-color: var(--clr-border);
  color: var(--clr-text);
}

.btn--outline:hover {
  border-color: var(--clr-primary);
  color: var(--clr-primary);
  text-decoration: none;
}

/* ================================================================
   AVATAR
================================================================ */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
  user-select: none;
}

.avatar--sm {
  width: 32px;
  height: 32px;
  font-size: .8rem;
}

/* ================================================================
   NAVBAR
================================================================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--navbar-h);
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  box-shadow: var(--shadow-sm);
}

.navbar__inner {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 24px;
}

.navbar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-icon  { font-size: 1.5rem; }
.brand-name  { font-size: 1.2rem; font-weight: 800; color: var(--clr-primary); }

.navbar__links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  color: var(--clr-muted);
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
  background: #ede9fe;
  color: var(--clr-primary);
  text-decoration: none;
}

.navbar__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--clr-text);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}

/* Mobile menu */
.mobile-menu {
  display: none;
  flex-direction: column;
  gap: 8px;
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  padding: 16px 20px;
  z-index: 99;
}

.mobile-menu.open {
  display: flex;
}

.mobile-menu hr {
  border: none;
  border-top: 1px solid var(--clr-border);
}

/* ================================================================
   HERO BANNER
================================================================ */
.hero {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 60%, #a78bfa 100%);
  padding: 72px 0 56px;
  color: #fff;
  text-align: center;
}

.hero__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.hero__title {
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.5px;
}

.hero__sub {
  font-size: 1.05rem;
  opacity: .9;
  max-width: 540px;
}

.hero__search {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 520px;
  margin-top: 8px;
}

.search-input {
  flex: 1;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: .95rem;
  outline: none;
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  box-shadow: 0 0 0 3px rgba(255,255,255,.4);
}

/* ================================================================
   STATS BAR
================================================================ */
.stats-bar {
  background: var(--clr-primary-dark);
  color: #fff;
  padding: 14px 0;
}

.stats-bar__inner {
  display: flex;
  justify-content: center;
  gap: 48px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat__number {
  font-size: 1.4rem;
  font-weight: 800;
}

.stat__label {
  font-size: .75rem;
  opacity: .8;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ================================================================
   MAIN CONTENT GRID
================================================================ */
.main-content {
  padding: 32px 0 48px;
}

.main-content__grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 28px;
  align-items: start;
}

/* ================================================================
   FILTER TABS
================================================================ */
.filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-tab {
  padding: 6px 16px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid var(--clr-border);
  background: var(--clr-surface);
  color: var(--clr-muted);
  transition: all var(--transition);
}

.filter-tab:hover {
  border-color: var(--clr-primary);
  color: var(--clr-primary);
}

.filter-tab.active {
  background: var(--clr-primary);
  border-color: var(--clr-primary);
  color: #fff;
}

/* ================================================================
   CATEGORY CARDS
================================================================ */
.categories {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 32px;
}

.category-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
}

.category-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.category-card__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
  color: #fff;
}

.category-card__body {
  flex: 1;
  min-width: 0;
}

.category-card__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--clr-text);
  margin-bottom: 2px;
}

.category-card__desc {
  font-size: .82rem;
  color: var(--clr-muted);
}

.category-card__stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: .78rem;
  color: var(--clr-muted);
  flex-shrink: 0;
}

/* Hidden state for filter */
.category-card.hidden {
  display: none;
}

/* ================================================================
   SECTION HEADER
================================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.link-all {
  font-size: .85rem;
  font-weight: 600;
}

/* ================================================================
   THREAD LIST
================================================================ */
.thread-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--clr-surface);
}

.thread-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--clr-border);
  transition: background var(--transition);
}

.thread-item:last-child {
  border-bottom: none;
}

.thread-item:hover {
  background: #f8fafc;
}

.thread-item.pinned {
  background: #f5f3ff;
}

.thread-item.pinned:hover {
  background: #ede9fe;
}

.thread-item.hot {
  background: #fff7ed;
}

.thread-item.hot:hover {
  background: #ffedd5;
}

.thread-item__avatar {
  flex-shrink: 0;
}

.thread-item__body {
  flex: 1;
  min-width: 0;
}

.thread-item__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.badge--pinned {
  background: #ede9fe;
  color: var(--clr-pin);
}

.badge--hot {
  background: #ffedd5;
  color: var(--clr-hot);
}

.badge--cat {
  background: #f1f5f9;
  color: var(--clr-muted);
}

.thread-item__title {
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-item__title a {
  color: var(--clr-text);
  text-decoration: none;
}

.thread-item__title a:hover {
  color: var(--clr-primary);
  text-decoration: none;
}

.thread-item__info {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .78rem;
  color: var(--clr-muted);
  margin-top: 4px;
}

.thread-item__counts {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.count-box {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .8rem;
  color: var(--clr-muted);
  background: #f1f5f9;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.count-box .icon {
  font-size: .85rem;
}

/* Hidden threads (load more) */
.thread-item.extra-hidden {
  display: none;
}

/* Load More */
.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

/* ================================================================
   SIDEBAR
================================================================ */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: calc(var(--navbar-h) + 20px);
}

.sidebar-widget {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 18px;
}

.widget-title {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: 14px;
}

/* CTA widget */
.cta-widget p {
  font-size: .85rem;
  color: var(--clr-muted);
  margin-bottom: 14px;
}

/* User list */
.user-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-list__item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-list__info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.user-name  { font-size: .85rem; font-weight: 600; }
.user-posts { font-size: .75rem; color: var(--clr-muted); }

.user-rank {
  font-size: .9rem;
  font-weight: 700;
  color: var(--clr-muted);
  width: 24px;
  text-align: center;
}

/* Online avatars */
.online-avatars {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.online-count {
  background: #e2e8f0;
  color: var(--clr-muted);
  font-size: .7rem;
  font-weight: 700;
}

/* Tag cloud */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 4px 10px;
  background: #f1f5f9;
  border-radius: 999px;
  font-size: .78rem;
  color: var(--clr-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.tag:hover {
  background: var(--clr-primary);
  color: #fff;
}

/* ================================================================
   FOOTER
================================================================ */
.footer {
  background: #1e293b;
  color: #94a3b8;
}

.footer__inner {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  padding-top: 48px;
  padding-bottom: 48px;
}

.footer__brand .brand-name { color: #fff; }
.footer__tagline {
  margin-top: 8px;
  font-size: .85rem;
  color: #64748b;
}

.footer__links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer__links h4 {
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}

.footer__links a {
  font-size: .85rem;
  color: #94a3b8;
  transition: color var(--transition);
}

.footer__links a:hover {
  color: #fff;
  text-decoration: none;
}

.footer__bottom {
  border-top: 1px solid #334155;
  padding: 16px 0;
  text-align: center;
  font-size: .8rem;
}

/* ================================================================
   MODAL
================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  padding: 16px;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--clr-surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(.97);
  transition: transform .22s ease;
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--clr-border);
}

.modal__header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal__close {
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--clr-muted);
  line-height: 1;
  transition: color var(--transition);
  padding: 0 4px;
}

.modal__close:hover { color: var(--clr-text); }

.modal__body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--clr-text);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 12px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--clr-surface);
  color: var(--clr-text);
  resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--clr-border);
}

/* ================================================================
   TOAST
================================================================ */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 300;
  background: #1e293b;
  color: #fff;
  padding: 12px 22px;
  border-radius: var(--radius-md);
  font-size: .9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ================================================================
   RESPONSIVE
================================================================ */
@media (max-width: 1024px) {
  .main-content__grid {
    grid-template-columns: 1fr 280px;
  }
}

@media (max-width: 860px) {
  .main-content__grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .footer__inner {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .navbar__links,
  .navbar__actions {
    display: none;
  }

  .hamburger {
    display: flex;
    margin-left: auto;
  }

  .hero {
    padding: 48px 0 40px;
  }

  .hero__search {
    flex-direction: column;
  }

  .stats-bar__inner {
    gap: 28px;
  }

  .thread-item__counts {
    display: none;
  }

  .footer__inner {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .category-card__stats {
    display: none;
  }
}
