/* public/css/app.css - Nexus Design System — Mobile-First */

/* ─── FONTS ──────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ─── CSS VARIABLES ──────────────────────────────────────── */
:root {
  --font-sans: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, monospace;

  /* Spacing */
  --gap-xs: 4px;  --gap-sm: 8px;   --gap-md: 16px;
  --gap-lg: 24px; --gap-xl: 32px;  --gap-2xl: 48px; --gap-3xl: 64px;

  /* Radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 24px; --r-full: 9999px;

  /* Brand */
  --brand:        #5b5ef4;
  --brand-light:  #7879f1;
  --brand-dark:   #4144c8;
  --brand-subtle: rgba(91,94,244,0.1);

  /* Accents */
  --accent-green:  #22c55e;
  --accent-amber:  #f59e0b;
  --accent-red:    #ef4444;
  --accent-cyan:   #06b6d4;
  --accent-purple: #a855f7;
  --accent-pink:   #ec4899;

  /* Transitions */
  --t-fast: 120ms ease; --t-mid: 200ms ease; --t-slow: 350ms ease;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.14), 0 4px 12px rgba(0,0,0,.08);
  --shadow-brand: 0 4px 20px rgba(91,94,244,.35);

  /* Nav heights */
  --nav-h:        56px;
  --bottom-nav-h: 60px;
}

/* ─── LIGHT THEME ────────────────────────────────────────── */
:root, [data-theme="light"] {
  --bg:          #f5f5f7;
  --bg-card:     #ffffff;
  --bg-input:    #f0f0f3;
  --bg-hover:    #f0f0f3;
  --border:      #e2e2e8;
  --border-focus:var(--brand);
  --text:        #111118;
  --text-2:      #52525b;
  --text-3:      #a1a1aa;
  --sidebar-bg:  #ffffff;
  --nav-bg:      rgba(255,255,255,0.95);
}

/* ─── DARK THEME ─────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:          #0e0e12;
  --bg-card:     #18181f;
  --bg-input:    #22222c;
  --bg-hover:    #22222c;
  --border:      #2a2a36;
  --border-focus:var(--brand);
  --text:        #f4f4f6;
  --text-2:      #a1a1aa;
  --text-3:      #52525b;
  --sidebar-bg:  #18181f;
  --nav-bg:      rgba(14,14,18,0.95);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.55);
}

/* ─── RESET ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  /* Account for bottom nav on mobile */
  padding-bottom: env(safe-area-inset-bottom);
  transition: background var(--t-slow), color var(--t-slow);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
a { color: var(--brand); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--brand-light); }
img { max-width: 100%; height: auto; }
button { font-family: var(--font-sans); cursor: pointer; border: none; background: none; -webkit-tap-highlight-color: transparent; }
input, textarea, select { font-family: var(--font-sans); font-size: 16px; /* 16px prevents iOS zoom */ }
svg { display: inline-block; vertical-align: middle; flex-shrink: 0; }
code { font-family: var(--font-mono); font-size: 0.875em; background: var(--bg-input); padding: 2px 6px; border-radius: var(--r-sm); }
pre code { padding: 0; background: transparent; }

/* ─── SCROLLBAR ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ═══════════════════════════════════════════════════════════
   TOP NAV
═══════════════════════════════════════════════════════════ */
.topnav {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h); z-index: 200;
  background: var(--nav-bg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 var(--gap-md);
  gap: var(--gap-sm);
}
.nav-logo {
  display: flex; align-items: center; gap: var(--gap-xs);
  font-weight: 800; font-size: 18px; letter-spacing: -0.5px;
  color: var(--text); white-space: nowrap; flex-shrink: 0;
}
.nav-logo svg { color: var(--brand); }
.nav-search {
  flex: 1; max-width: 420px; position: relative;
}
.nav-search input {
  width: 100%; height: 36px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--r-full); padding: 0 var(--gap-md) 0 38px;
  color: var(--text); outline: none; font-size: 14px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.nav-search input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-subtle); }
.nav-search .search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}
.nav-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-shrink: 0; }
.nav-btn {
  width: 36px; height: 36px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); background: transparent;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative; -webkit-tap-highlight-color: transparent;
}
.nav-btn:hover { background: var(--bg-hover); color: var(--text); }
.nav-btn .badge {
  position: absolute; top: 3px; right: 3px;
  min-width: 15px; height: 15px; padding: 0 3px;
  background: var(--accent-red); color: #fff;
  border-radius: var(--r-full); font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.nav-avatar {
  width: 32px; height: 32px; border-radius: var(--r-full);
  object-fit: cover; cursor: pointer; border: 2px solid transparent;
  transition: border-color var(--t-fast);
}
.nav-avatar:hover { border-color: var(--brand); }

/* Mobile menu btn */
.mobile-menu-btn {
  display: none; width: 36px; height: 36px;
  align-items: center; justify-content: center;
  border-radius: var(--r-md); color: var(--text-2);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   LAYOUT — DESKTOP
═══════════════════════════════════════════════════════════ */
.app-wrap {
  display: flex; min-height: 100vh;
  padding-top: var(--nav-h);
}
.sidebar {
  width: 220px; position: fixed; top: var(--nav-h); left: 0; bottom: 0;
  background: var(--sidebar-bg); border-right: 1px solid var(--border);
  overflow-y: auto; z-index: 100;
  transition: transform var(--t-slow);
}
.main-content {
  flex: 1; margin-left: 220px;
  padding: var(--gap-lg) var(--gap-xl);
  max-width: 1200px;
  min-width: 0;
}
.content-grid {
  display: grid; grid-template-columns: 1fr 280px; gap: var(--gap-xl);
}
.right-panel { position: sticky; top: calc(var(--nav-h) + var(--gap-md)); height: fit-content; }

/* ═══════════════════════════════════════════════════════════
   SIDEBAR NAV
═══════════════════════════════════════════════════════════ */
.sidebar-section { padding: var(--gap-md) 0 var(--gap-sm); }
.sidebar-section:not(:first-child) { border-top: 1px solid var(--border); }
.sidebar-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-3);
  padding: 0 var(--gap-md) var(--gap-xs);
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px var(--gap-md); border-radius: 0;
  color: var(--text-2); font-size: 14px; font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative; -webkit-tap-highlight-color: transparent;
}
.sidebar-link:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-link.active { color: var(--brand); background: var(--brand-subtle); }
.sidebar-link.active::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--brand); border-radius: 0 3px 3px 0;
}
.sidebar-link svg { width: 18px; height: 18px; }
.sidebar-count {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--bg-input); color: var(--text-3);
  padding: 1px 6px; border-radius: var(--r-full);
}

/* ═══════════════════════════════════════════════════════════
   BOTTOM NAV — MOBILE ONLY
═══════════════════════════════════════════════════════════ */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  height: var(--bottom-nav-h);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-inner {
  display: flex; align-items: center; justify-content: space-around;
  height: 100%;
}
.bottom-nav-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; flex: 1; height: 100%;
  color: var(--text-3); font-size: 10px; font-weight: 600;
  transition: color var(--t-fast); position: relative;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}
.bottom-nav-btn svg { width: 22px; height: 22px; }
.bottom-nav-btn.active { color: var(--brand); }
.bottom-nav-btn.active svg { stroke-width: 2.5; }
.bottom-nav-btn .badge {
  position: absolute; top: 6px; left: 50%; margin-left: 4px;
  min-width: 15px; height: 15px; padding: 0 3px;
  background: var(--accent-red); color: #fff;
  border-radius: var(--r-full); font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
/* Center post button */
.bottom-nav-post {
  width: 44px; height: 44px; border-radius: var(--r-full);
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-brand);
  flex-shrink: 0; flex-direction: row; gap: 0;
  font-size: 0;
}
.bottom-nav-post svg { width: 22px; height: 22px; }

/* ═══════════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════════ */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-mid);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  padding: var(--gap-md) var(--gap-lg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: var(--gap-lg); }
.card-title { font-size: 14px; font-weight: 600; color: var(--text); }

/* ═══════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--gap-sm); padding: 9px 18px;
  border-radius: var(--r-md); font-size: 14px; font-weight: 600;
  border: 1.5px solid transparent; cursor: pointer;
  transition: all var(--t-fast); white-space: nowrap;
  outline: none; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  /* Minimum touch target */
  min-height: 40px;
}
.btn:focus-visible { box-shadow: 0 0 0 3px var(--brand-subtle); }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; box-shadow: var(--shadow-brand); }
.btn-secondary { background: var(--bg-input); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: var(--accent-red); color: #fff; border-color: var(--accent-red); }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: var(--r-sm); min-height: 34px; }
.btn-lg { padding: 12px 28px; font-size: 15px; border-radius: var(--r-md); min-height: 48px; }
.btn-icon { padding: 8px; width: 40px; height: 40px; min-height: unset; }
.btn-icon.btn-sm { width: 34px; height: 34px; padding: 5px; min-height: unset; }
.btn svg { width: 16px; height: 16px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn[disabled], .btn.loading { opacity: 0.6; pointer-events: none; }
.btn.loading::after {
  content: ''; width: 14px; height: 14px; border: 2px solid currentColor;
  border-top-color: transparent; border-radius: 50%;
  animation: spin 0.6s linear infinite; margin-left: 4px;
}

/* ═══════════════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════════════ */
.form-group { display: flex; flex-direction: column; gap: var(--gap-xs); margin-bottom: var(--gap-md); }
.form-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.form-input, .form-textarea, .form-select {
  width: 100%; background: var(--bg-input); border: 1.5px solid var(--border);
  border-radius: var(--r-md); padding: 11px 14px; color: var(--text);
  outline: none; font-size: 16px; /* Prevents iOS zoom */
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  appearance: none; -webkit-appearance: none;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-subtle);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-3); }
.form-textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
.form-hint { font-size: 12px; color: var(--text-3); }
.form-error { font-size: 12px; color: var(--accent-red); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-md); }

/* ═══════════════════════════════════════════════════════════
   POST CARDS
═══════════════════════════════════════════════════════════ */
.post-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--gap-md);
  display: flex; gap: var(--gap-sm);
  transition: box-shadow var(--t-mid), border-color var(--t-mid);
}
.post-card:hover { box-shadow: var(--shadow-md); border-color: var(--brand-subtle); }
.post-vote {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding-right: var(--gap-sm); border-right: 1px solid var(--border);
  min-width: 36px; flex-shrink: 0;
}
.vote-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 18px;
  transition: all var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.vote-btn:hover, .vote-btn:active { background: var(--bg-hover); color: var(--text); }
.vote-btn.up.active { color: var(--accent-green); background: rgba(34,197,94,0.1); }
.vote-btn.down.active { color: var(--accent-red); background: rgba(239,68,68,0.1); }
.vote-score { font-size: 12px; font-weight: 700; color: var(--text-2); min-width: 20px; text-align: center; }
.post-body { flex: 1; min-width: 0; }
.post-meta {
  display: flex; align-items: center; gap: var(--gap-xs);
  flex-wrap: wrap; margin-bottom: 6px;
}
.post-category {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 8px; border-radius: var(--r-full);
  background: var(--brand-subtle); color: var(--brand);
}
.post-time { font-size: 12px; color: var(--text-3); }
.post-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  margin-bottom: 4px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-title a { color: inherit; }
.post-title a:hover { color: var(--brand); }
.post-excerpt {
  font-size: 13px; color: var(--text-2); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: var(--gap-xs);
}
.post-footer { display: flex; align-items: center; gap: var(--gap-sm); flex-wrap: wrap; }
.post-stat {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-3);
}
.post-stat svg { width: 13px; height: 13px; }
.post-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag {
  font-size: 11px; padding: 2px 8px; border-radius: var(--r-full);
  background: var(--bg-input); color: var(--text-2); border: 1px solid var(--border);
  transition: all var(--t-fast);
}
.tag:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-subtle); }
.post-author { display: flex; align-items: center; gap: 5px; }
.post-author img { width: 20px; height: 20px; border-radius: var(--r-full); object-fit: cover; }
.post-author span { font-size: 12px; font-weight: 600; color: var(--text-2); }

/* ═══════════════════════════════════════════════════════════
   AVATARS
═══════════════════════════════════════════════════════════ */
.avatar { border-radius: var(--r-full); object-fit: cover; flex-shrink: 0; background: var(--brand-subtle); }
.avatar-sm { width: 28px; height: 28px; }
.avatar-md { width: 40px; height: 40px; }
.avatar-lg { width: 64px; height: 64px; }
.avatar-xl { width: 88px; height: 88px; }

/* ─── VERIFIED ───────────────────────────────────────────── */
.verified-badge { color: var(--brand); display: inline-flex; }
.verified-badge svg { width: 14px; height: 14px; }

/* ─── USER ROW ───────────────────────────────────────────── */
.user-row { display: flex; align-items: center; gap: var(--gap-sm); }
.user-row .username { font-weight: 600; font-size: 14px; color: var(--text); display: flex; align-items: center; gap: 4px; }

/* ═══════════════════════════════════════════════════════════
   COMMENTS
═══════════════════════════════════════════════════════════ */
.comment-list { display: flex; flex-direction: column; gap: 0; }
.comment { padding: var(--gap-md) 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.comment-header { display: flex; align-items: center; gap: var(--gap-sm); margin-bottom: var(--gap-sm); }
.comment-content { font-size: 14px; color: var(--text); line-height: 1.7; padding-left: 40px; }
.comment-content p { margin-bottom: var(--gap-xs); }
.comment-actions { display: flex; align-items: center; gap: var(--gap-sm); padding-left: 40px; margin-top: var(--gap-xs); flex-wrap: wrap; }
.comment-action-btn {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; color: var(--text-3);
  padding: 4px 8px; border-radius: var(--r-sm);
  transition: all var(--t-fast); min-height: 30px;
  -webkit-tap-highlight-color: transparent;
}
.comment-action-btn:hover { color: var(--brand); background: var(--brand-subtle); }
.comment-action-btn.active-up { color: var(--accent-green); }
.comment-action-btn.active-down { color: var(--accent-red); }
.comment-replies { padding-left: 36px; border-left: 2px solid var(--border); margin-top: var(--gap-sm); }

/* ═══════════════════════════════════════════════════════════
   CHAT / MESSAGES
═══════════════════════════════════════════════════════════ */
.chat-layout { display: flex; height: calc(100vh - var(--nav-h)); overflow: hidden; margin-left: 220px; }
.chat-sidebar {
  width: 280px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  background: var(--bg-card); overflow: hidden; flex-shrink: 0;
}
.chat-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.chat-item {
  display: flex; align-items: center; gap: var(--gap-sm);
  padding: 12px var(--gap-md); cursor: pointer;
  transition: background var(--t-fast);
  border-bottom: 1px solid var(--border);
  -webkit-tap-highlight-color: transparent;
}
.chat-item:hover, .chat-item.active { background: var(--bg-hover); }
.chat-item.active { background: var(--brand-subtle); }
.chat-item-info { flex: 1; min-width: 0; }
.chat-item-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.chat-item-preview { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.chat-item-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.chat-item-time { font-size: 11px; color: var(--text-3); }
.chat-unread { min-width: 18px; height: 18px; background: var(--brand); color: #fff; border-radius: var(--r-full); font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.chat-header { padding: var(--gap-sm) var(--gap-md); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: var(--gap-sm); flex-shrink: 0; min-height: 56px; }
.chat-messages { flex: 1; overflow-y: auto; padding: var(--gap-md); display: flex; flex-direction: column; gap: var(--gap-sm); -webkit-overflow-scrolling: touch; }
.message-row { display: flex; align-items: flex-end; gap: var(--gap-xs); }
.message-row.own { flex-direction: row-reverse; }
.message-bubble {
  max-width: 75%; padding: 8px 13px;
  border-radius: 18px; font-size: 14px; line-height: 1.5;
  background: var(--bg-input); color: var(--text);
  border-bottom-left-radius: 4px; word-break: break-word;
}
.message-row.own .message-bubble { background: var(--brand); color: #fff; border-bottom-left-radius: 18px; border-bottom-right-radius: 4px; }
.message-time { font-size: 11px; color: var(--text-3); white-space: nowrap; margin-bottom: 2px; }
.chat-input-area { padding: var(--gap-sm) var(--gap-md); border-top: 1px solid var(--border); flex-shrink: 0; display: flex; gap: var(--gap-sm); align-items: flex-end; }
.chat-input {
  flex: 1; background: var(--bg-input); border: 1.5px solid var(--border);
  border-radius: var(--r-xl); padding: 10px 16px;
  color: var(--text); outline: none; resize: none; max-height: 100px;
  font-family: var(--font-sans); font-size: 15px; line-height: 1.5;
  transition: border-color var(--t-fast); -webkit-overflow-scrolling: touch;
}
.chat-input:focus { border-color: var(--brand); }
.typing-indicator { font-size: 12px; color: var(--text-3); padding: 0 var(--gap-md) 4px; height: 20px; }
.typing-indicator .dots span { display: inline-block; width: 4px; height: 4px; background: var(--text-3); border-radius: 50%; animation: typing-dot 1.4s infinite; margin: 0 1px; }
.typing-indicator .dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-dot { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-3px); } }

/* ═══════════════════════════════════════════════════════════
   TABS
═══════════════════════════════════════════════════════════ */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: var(--gap-lg); overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 10px 16px; font-size: 14px; font-weight: 600;
  color: var(--text-3); border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: all var(--t-fast);
  display: flex; align-items: center; gap: var(--gap-xs);
  white-space: nowrap; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ═══════════════════════════════════════════════════════════
   DROPDOWN
═══════════════════════════════════════════════════════════ */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 200px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); z-index: 1000;
  opacity: 0; pointer-events: none; transform: translateY(-6px);
  transition: opacity var(--t-mid), transform var(--t-mid); overflow: hidden;
}
.dropdown-menu.open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.dropdown-item {
  display: flex; align-items: center; gap: var(--gap-sm);
  padding: 11px var(--gap-md); font-size: 14px; color: var(--text-2);
  cursor: pointer; transition: background var(--t-fast), color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text); }
.dropdown-item.danger:hover { background: rgba(239,68,68,0.08); color: var(--accent-red); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.dropdown-header { padding: var(--gap-md); border-bottom: 1px solid var(--border); }

/* ═══════════════════════════════════════════════════════════
   NOTIFICATIONS
═══════════════════════════════════════════════════════════ */
.notif-menu { min-width: 320px; max-height: 460px; display: flex; flex-direction: column; }
.notif-list { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.notif-item { display: flex; align-items: flex-start; gap: var(--gap-sm); padding: var(--gap-sm) var(--gap-md); cursor: pointer; transition: background var(--t-fast); border-bottom: 1px solid var(--border); -webkit-tap-highlight-color: transparent; }
.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread { background: var(--brand-subtle); }
.notif-icon { width: 32px; height: 32px; border-radius: var(--r-full); display: flex; align-items: center; justify-content: center; background: var(--bg-input); flex-shrink: 0; }
.notif-body { flex: 1; min-width: 0; }
.notif-text { font-size: 13px; color: var(--text); line-height: 1.4; }
.notif-text strong { font-weight: 600; }
.notif-time { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.notif-dot { width: 7px; height: 7px; background: var(--brand); border-radius: 50%; flex-shrink: 0; margin-top: 6px; }

/* ═══════════════════════════════════════════════════════════
   BADGES / PILLS
═══════════════════════════════════════════════════════════ */
.badge-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--r-full); font-size: 12px; font-weight: 600; }
.badge-green  { background: rgba(34,197,94,0.1); color: var(--accent-green); }
.badge-amber  { background: rgba(245,158,11,0.1); color: var(--accent-amber); }
.badge-red    { background: rgba(239,68,68,0.1); color: var(--accent-red); }
.badge-brand  { background: var(--brand-subtle); color: var(--brand); }
.badge-gray   { background: var(--bg-input); color: var(--text-3); }

/* ═══════════════════════════════════════════════════════════
   PROFILE
═══════════════════════════════════════════════════════════ */
.profile-hero {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--gap-lg); margin-bottom: var(--gap-lg);
  display: flex; align-items: flex-start; gap: var(--gap-lg);
  position: relative; overflow: hidden;
}
.profile-hero::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 72px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent-purple) 100%); opacity: 0.08;
}
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: var(--gap-sm); flex-wrap: wrap; margin-bottom: 4px; }
.profile-handle { font-size: 13px; color: var(--text-3); margin-bottom: var(--gap-sm); }
.profile-bio { font-size: 14px; color: var(--text-2); }
.profile-stats { display: flex; gap: var(--gap-lg); margin-top: var(--gap-md); flex-wrap: wrap; }
.profile-stat { text-align: center; }
.profile-stat-val { font-size: 18px; font-weight: 700; color: var(--text); }
.profile-stat-label { font-size: 11px; color: var(--text-3); }

/* ═══════════════════════════════════════════════════════════
   GROUPS
═══════════════════════════════════════════════════════════ */
.group-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--gap-md);
  display: flex; flex-direction: column; gap: var(--gap-sm);
  transition: box-shadow var(--t-mid), border-color var(--t-mid);
}
.group-card:hover { box-shadow: var(--shadow-md); border-color: var(--brand-subtle); }
.group-name { font-size: 15px; font-weight: 700; color: var(--text); }
.group-desc { font-size: 13px; color: var(--text-2); flex: 1; }
.group-meta { display: flex; align-items: center; gap: var(--gap-md); }
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--gap-md); }

/* ═══════════════════════════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════════════════════════ */
.empty-state { display: flex; flex-direction: column; align-items: center; padding: var(--gap-3xl) var(--gap-xl); text-align: center; color: var(--text-3); }
.empty-state svg { width: 56px; height: 56px; margin-bottom: var(--gap-md); opacity: 0.3; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-2); margin-bottom: var(--gap-xs); }
.empty-state p { font-size: 14px; max-width: 280px; }

/* ═══════════════════════════════════════════════════════════
   TOASTS
═══════════════════════════════════════════════════════════ */
.toast-container { position: fixed; bottom: calc(var(--bottom-nav-h) + var(--gap-md)); right: var(--gap-md); display: flex; flex-direction: column; gap: var(--gap-sm); z-index: 9999; }
.toast {
  display: flex; align-items: center; gap: var(--gap-sm);
  padding: 11px 16px; border-radius: var(--r-md);
  background: var(--bg-card); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); min-width: 240px; max-width: 320px;
  font-size: 14px; font-weight: 500; color: var(--text);
  animation: toast-in var(--t-mid) ease;
}
.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error   { border-left: 3px solid var(--accent-red); }
.toast.info    { border-left: 3px solid var(--brand); }
@keyframes toast-in { from { transform: translateX(110%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ═══════════════════════════════════════════════════════════
   LOADING / SKELETON
═══════════════════════════════════════════════════════════ */
.skeleton { background: linear-gradient(90deg, var(--bg-input) 25%, var(--bg-hover) 50%, var(--bg-input) 75%); background-size: 200%; animation: shimmer 1.5s infinite; border-radius: var(--r-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px); z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: var(--gap-md);
  opacity: 0; pointer-events: none; transition: opacity var(--t-mid);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-xl); max-width: 500px; width: 100%; box-shadow: var(--shadow-lg); transform: scale(0.95); transition: transform var(--t-mid); overflow: hidden; }
.modal-overlay.open .modal { transform: scale(1); }
.modal-header { padding: var(--gap-md) var(--gap-lg); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: var(--gap-lg); }
.modal-footer { padding: var(--gap-md) var(--gap-lg); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--gap-sm); }

/* ═══════════════════════════════════════════════════════════
   MISC UTILITIES
═══════════════════════════════════════════════════════════ */
.divider { height: 1px; background: var(--border); margin: var(--gap-md) 0; }
.text-muted { color: var(--text-3); }
.text-sm { font-size: 13px; }
.font-bold { font-weight: 700; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--gap-sm); }
.gap-md { gap: var(--gap-md); }
.mt-md { margin-top: var(--gap-md); }
.mb-md { margin-bottom: var(--gap-md); }
.mb-lg { margin-bottom: var(--gap-lg); }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ─── FEED TOOLBAR ───────────────────────────────────────── */
.feed-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-sm); margin-bottom: var(--gap-md); flex-wrap: wrap; }
.filter-chip { padding: 6px 14px; border-radius: var(--r-full); font-size: 13px; font-weight: 600; border: 1.5px solid var(--border); color: var(--text-2); background: var(--bg-card); transition: all var(--t-fast); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.filter-chip:hover { border-color: var(--brand); color: var(--brand); }
.filter-chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.cat-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ─── SEARCH RESULTS ─────────────────────────────────────── */
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); max-height: 340px; overflow-y: auto; z-index: 400; display: none; }
.search-results.open { display: block; }
.search-result-item { display: flex; align-items: flex-start; gap: var(--gap-sm); padding: 10px var(--gap-md); cursor: pointer; transition: background var(--t-fast); border-bottom: 1px solid var(--border); }
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-hover); }

/* ─── MEMBERS ────────────────────────────────────────────── */
.member-list { display: flex; flex-direction: column; gap: 2px; }
.member-item { display: flex; align-items: center; gap: var(--gap-sm); padding: 7px var(--gap-sm); border-radius: var(--r-sm); transition: background var(--t-fast); }
.member-item:hover { background: var(--bg-hover); }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-green); border: 1.5px solid var(--bg-card); position: absolute; bottom: 0; right: 0; }

/* ─── CODE BLOCK ─────────────────────────────────────────── */
pre { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--gap-md); overflow-x: auto; font-family: var(--font-mono); font-size: 13px; line-height: 1.6; margin: var(--gap-sm) 0; }

/* ─── THEME TOGGLE ───────────────────────────────────────── */
.theme-toggle { width: 36px; height: 20px; border-radius: 10px; background: var(--bg-input); border: 1.5px solid var(--border); cursor: pointer; position: relative; transition: background var(--t-mid); display: flex; align-items: center; }
.theme-toggle.dark { background: var(--brand); border-color: var(--brand); }
.theme-toggle::after { content: ''; width: 14px; height: 14px; border-radius: 50%; background: #fff; position: absolute; left: 2px; transition: transform var(--t-mid); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.theme-toggle.dark::after { transform: translateX(16px); }

/* ─── ANIMATIONS ─────────────────────────────────────────── */
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fade-in var(--t-slow) ease both; }
.fade-in-1 { animation-delay: 40ms; }
.fade-in-2 { animation-delay: 80ms; }
.fade-in-3 { animation-delay: 120ms; }
.fade-in-4 { animation-delay: 160ms; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — TABLET (≤1024px)
═══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .content-grid { grid-template-columns: 1fr; }
  .right-panel { position: static; }
  .main-content { padding: var(--gap-md) var(--gap-lg); }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤768px)
═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Show mobile menu btn, hide desktop elements */
  .mobile-menu-btn { display: flex; }

  /* Sidebar becomes drawer */
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
    box-shadow: var(--shadow-lg);
    z-index: 300;
  }
  .sidebar.open { transform: translateX(0); }

  /* Main shifts to full width, adds bottom padding for bottom nav */
  .main-content {
    margin-left: 0;
    padding: var(--gap-sm) var(--gap-sm);
    padding-bottom: calc(var(--bottom-nav-h) + var(--gap-sm) + env(safe-area-inset-bottom));
  }

  /* Show bottom nav */
  .bottom-nav { display: flex; }

  /* Hide desktop nav items on mobile to save space */
  .nav-search { display: none; }
  .nav-actions .btn-primary { display: none; } /* Hide desktop "Post" btn - use bottom nav */

  /* Chat — full screen on mobile */
  .chat-layout {
    margin-left: 0;
    height: calc(100vh - var(--nav-h) - var(--bottom-nav-h));
    position: relative;
  }
  .chat-sidebar {
    position: absolute; left: 0; top: 0; bottom: 0; z-index: 10;
    width: 100%;
    transform: translateX(0);
    transition: transform var(--t-slow);
  }
  .chat-sidebar.hidden-mobile { transform: translateX(-100%); }
  .chat-main { width: 100%; }

  /* Post cards — horizontal vote row on mobile */
  .post-card { flex-direction: column; gap: var(--gap-xs); padding: var(--gap-sm); }
  .post-vote { flex-direction: row; border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: var(--gap-xs); min-width: unset; }

  /* Profile */
  .profile-hero { flex-direction: column; gap: var(--gap-md); padding: var(--gap-md); }
  .profile-name { font-size: 18px; }
  .profile-stats { gap: var(--gap-md); }
  .profile-stat-val { font-size: 16px; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; }
  .card-body { padding: var(--gap-md); }
  .card-header { padding: var(--gap-sm) var(--gap-md); }

  /* Groups grid */
  .group-grid { grid-template-columns: 1fr; }

  /* Dropdown — full width on small screens */
  .notif-menu { min-width: 290px; }

  /* Toasts — bottom, above bottom nav */
  .toast-container {
    left: var(--gap-sm); right: var(--gap-sm); bottom: calc(var(--bottom-nav-h) + var(--gap-sm));
  }
  .toast { min-width: unset; max-width: unset; width: 100%; }

  /* Comment indents tighter */
  .comment-content { padding-left: 36px; }
  .comment-actions { padding-left: 36px; }
  .comment-replies { padding-left: 28px; }

  /* Tabs scrollable */
  .tabs { margin-bottom: var(--gap-md); }

  /* Feed toolbar vertical on very small */
  .feed-toolbar { flex-direction: column; align-items: stretch; }
  .feed-toolbar .tabs { margin: 0; border: none; }

  /* Message bubbles — wider on mobile */
  .message-bubble { max-width: 85%; }

  /* Empty state tighter */
  .empty-state { padding: var(--gap-2xl) var(--gap-md); }

  /* Modal — slide up from bottom */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: var(--r-xl) var(--r-xl) 0 0; max-width: 100%; transform: translateY(100%); }
  .modal-overlay.open .modal { transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — SMALL (≤480px)
═══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .topnav { padding: 0 var(--gap-sm); gap: 4px; }
  .nav-logo span { display: none; } /* Hide "Nexus" text, keep icon */

  body { font-size: 14px; }

  .post-title { font-size: 14px; }
  .btn-lg { padding: 11px 20px; font-size: 14px; }

  /* Avatar sizes down */
  .avatar-xl { width: 72px; height: 72px; }

  /* Smaller cards */
  .card-body { padding: var(--gap-sm); }
}

/* ─── MOBILE SEARCH BAR ──────────────────────────────────── */
#mobileSearchBar {
  display: none;
  position: fixed; top: var(--nav-h); left: 0; right: 0; z-index: 199;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: var(--gap-sm) var(--gap-md);
  transform: translateY(-100%);
  transition: transform var(--t-mid);
  box-shadow: var(--shadow-md);
}
#mobileSearchBar.open { transform: translateY(0); }
#mobileSearchBar input {
  width: 100%; height: 40px; font-size: 16px;
  background: var(--bg-input); border: 1.5px solid var(--border);
  border-radius: var(--r-full); padding: 0 var(--gap-md) 0 42px;
  color: var(--text); outline: none;
}
#mobileSearchBar input:focus { border-color: var(--brand); }
#mobileSearchBar .search-icon { position: absolute; left: calc(var(--gap-md) + 12px); top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
#mobileSearchBar .mobile-search-results { position: static; margin-top: var(--gap-xs); box-shadow: none; border: 1px solid var(--border); }

@media (max-width: 768px) {
  #mobileSearchBtn { display: flex !important; }
  #mobileSearchBar { display: block; }

  /* When mobile search is open, push main content down */
  body.search-open .app-wrap { padding-top: calc(var(--nav-h) + 60px); }
}
