/* ============================================================================
   Beezifi Connect — Design System
   ============================================================================ */

/* ─── Fonts ─────────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── CSS Custom Properties ─────────────────────────────────────────────────── */
:root {
  /* Brand */
  --color-brand:        #6366f1;
  --color-brand-light:  #818cf8;
  --color-brand-dark:   #4f46e5;
  --color-brand-50:     rgba(99, 102, 241, 0.08);
  --color-brand-100:    rgba(99, 102, 241, 0.15);

  /* Surface (dark mode — default) */
  --bg-base:            #0a0a0f;
  --bg-surface:         #111117;
  --bg-elevated:        #18181f;
  --bg-hover:           #1e1e27;
  --bg-active:          #24242e;
  --bg-overlay:         rgba(0, 0, 0, 0.72);

  /* Borders */
  --border:             #1f1f2a;
  --border-subtle:      #161620;
  --border-strong:      #2d2d3d;

  /* Text */
  --text-primary:       #f0f0f5;
  --text-secondary:     #9898b0;
  --text-muted:         #5c5c78;
  --text-inverse:       #0a0a0f;

  /* Status */
  --color-success:      #22c55e;
  --color-warning:      #f59e0b;
  --color-error:        #ef4444;
  --color-info:         #3b82f6;

  /* Upvote / Downvote */
  --color-upvote:       #f97316;
  --color-downvote:     #6366f1;

  /* Spacing */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radius */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-size-xs:  11px;
  --font-size-sm:  13px;
  --font-size-base: 15px;
  --font-size-md:  17px;
  --font-size-lg:  20px;
  --font-size-xl:  24px;
  --font-size-2xl: 30px;
  --font-size-3xl: 36px;
  --font-size-4xl: 48px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow:    0 4px 12px rgba(0,0,0,0.4), 0 2px 4px rgba(0,0,0,0.3);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.5), 0 4px 8px rgba(0,0,0,0.4);
  --shadow-xl: 0 32px 64px rgba(0,0,0,0.6);
  --shadow-brand: 0 8px 32px rgba(99, 102, 241, 0.3);

  /* Transitions */
  --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition:      200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --nav-height:    60px;
  --sidebar-width: 260px;
  --content-max:   740px;
  --page-max:      1280px;
}

/* Light mode */
[data-theme="light"] {
  --bg-base:      #f6f6f9;
  --bg-surface:   #ffffff;
  --bg-elevated:  #f0f0f5;
  --bg-hover:     #eaeaf0;
  --bg-active:    #e2e2ec;
  --bg-overlay:   rgba(0, 0, 0, 0.5);
  --border:       #e2e2ec;
  --border-subtle: #ededf5;
  --border-strong: #c8c8d8;
  --text-primary:  #111118;
  --text-secondary:#50507a;
  --text-muted:    #8888a8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow:    0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.12);
}

/* ─── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, select { font-family: inherit; }
ul, ol { list-style: none; }

/* ─── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Typography ─────────────────────────────────────────────────────────────── */
h1,h2,h3,h4,h5,h6 { font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-md); }
h6 { font-size: var(--font-size-base); }
p { color: var(--text-secondary); }
code { font-family: var(--font-mono); font-size: 0.875em; background: var(--bg-active); padding: 2px 6px; border-radius: 4px; }
pre { font-family: var(--font-mono); background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4); overflow-x: auto; }
blockquote { border-left: 3px solid var(--color-brand); padding-left: var(--space-4); color: var(--text-secondary); margin: var(--space-4) 0; }

/* ─── Layout ─────────────────────────────────────────────────────────────────── */
.container { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--space-4); }

.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--nav-height) 1fr;
  min-height: 100vh;
}

.main-content {
  grid-column: 2;
  grid-row: 2;
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
  padding: var(--space-6) var(--space-4);
}

.feed-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-6);
  align-items: start;
}

/* ─── Navigation ─────────────────────────────────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-4);
}

[data-theme="light"] .navbar {
  background: rgba(255, 255, 255, 0.92);
}

.navbar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  text-decoration: none;
}

.navbar-logo .logo-mark {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--color-brand), #8b5cf6);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 900;
  color: #fff;
  flex-shrink: 0;
}

.navbar-search {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.navbar-search input {
  width: 100%;
  height: 38px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0 var(--space-4) 0 40px;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  transition: var(--transition);
  outline: none;
}

.navbar-search input::placeholder { color: var(--text-muted); }
.navbar-search input:focus { border-color: var(--color-brand); background: var(--bg-surface); box-shadow: 0 0 0 3px var(--color-brand-50); }
.navbar-search .search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }

.navbar-actions { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }

/* ─── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--nav-height));
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: var(--space-4) var(--space-3);
  z-index: 50;
}

.sidebar-section { margin-bottom: var(--space-6); }
.sidebar-label { font-size: var(--font-size-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); padding: 0 var(--space-3); margin-bottom: var(--space-2); }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
}

.sidebar-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-item.active { background: var(--color-brand-50); color: var(--color-brand-light); }
.sidebar-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-community-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
}

.sidebar-community-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-community-avatar { width: 20px; height: 20px; border-radius: 4px; flex-shrink: 0; object-fit: cover; }

/* ─── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  border-radius: var(--radius);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
  border: none;
  outline: none;
  text-decoration: none;
  font-family: var(--font-sans);
}

.btn:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--color-brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-brand-dark); transform: translateY(-1px); box-shadow: var(--shadow-brand); }

.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-strong); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger { background: var(--color-error); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-sm { height: 30px; padding: 0 var(--space-3); font-size: var(--font-size-xs); }
.btn-lg { height: 44px; padding: 0 var(--space-6); font-size: var(--font-size-base); border-radius: var(--radius-lg); }
.btn-xl { height: 52px; padding: 0 var(--space-8); font-size: var(--font-size-md); border-radius: var(--radius-lg); }

.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius); }
.btn-icon-sm { width: 28px; height: 28px; padding: 0; border-radius: var(--radius-sm); }

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
}

.card:hover { border-color: var(--border-strong); }
.card-body { padding: var(--space-5); }
.card-header { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
.card-footer { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border); }

/* ─── Post Card ─────────────────────────────────────────────────────────────── */
.post-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition-fast);
  cursor: pointer;
  display: block;
  text-decoration: none;
  margin-bottom: 12px;
}

.post-card:hover { border-color: var(--border-strong); background: var(--bg-elevated); transform: translateY(-1px); box-shadow: var(--shadow); }

.post-card-vote {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-4) var(--space-3);
  background: var(--bg-elevated);
  min-width: 52px;
}

.post-card-body {
  flex: 1;
  padding: var(--space-4);
  min-width: 0;
}

.post-card-inner { display: flex; min-height: 80px; }

.post-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.post-card-community {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-primary);
}

.post-card-community:hover { color: var(--color-brand-light); }
.post-card-community img { width: 16px; height: 16px; border-radius: 3px; }

.post-card-author { font-size: var(--font-size-xs); color: var(--text-muted); }
.post-card-time { font-size: var(--font-size-xs); color: var(--text-muted); }

.post-card-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: var(--space-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-title-link {
  color: inherit;
  text-decoration: none;
}

.post-title-link:hover {
  color: var(--color-brand-light);
  text-decoration: underline;
}

.post-card-flair {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  margin-right: var(--space-2);
}

.post-card-thumbnail {
  width: 90px;
  height: 68px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-left: var(--space-4);
  flex-shrink: 0;
}

.post-card-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-3);
}

.post-action-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 28px;
  padding: 0 var(--space-2);
  border-radius: var(--radius);
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  border: none;
  background: none;
}

.post-action-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }
.post-action-btn svg { width: 14px; height: 14px; }

/* Vote buttons */
.vote-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
}

.vote-btn:hover { background: var(--bg-hover); }
.vote-btn.upvoted { color: var(--color-upvote); }
.vote-btn.downvoted { color: var(--color-downvote); }
.vote-btn svg { width: 16px; height: 16px; }

.vote-score {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 24px;
  text-align: center;
}

.vote-score.positive { color: var(--color-upvote); }
.vote-score.negative { color: var(--color-downvote); }

/* ─── Tags / Badges ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  gap: 4px;
}

.badge-brand   { background: var(--color-brand-100); color: var(--color-brand-light); }
.badge-success { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-warning { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-error   { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-gray    { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-nsfw    { background: rgba(239,68,68,0.2); color: #f87171; }
.badge-oc      { background: rgba(34,197,94,0.15); color: #4ade80; }

/* ─── Avatar ─────────────────────────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.avatar-xs  { width: 20px; height: 20px; font-size: 9px; }
.avatar-sm  { width: 28px; height: 28px; font-size: 11px; }
.avatar-md  { width: 36px; height: 36px; font-size: 14px; }
.avatar-lg  { width: 48px; height: 48px; font-size: 18px; }
.avatar-xl  { width: 64px; height: 64px; font-size: 24px; }
.avatar-2xl { width: 96px; height: 96px; font-size: 36px; }

.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-brand), #8b5cf6);
  color: #fff;
  font-weight: 700;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--bg-surface);
}

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--space-5); }
.form-label { display: block; font-size: var(--font-size-sm); font-weight: 600; color: var(--text-secondary); margin-bottom: var(--space-2); }

.form-input {
  width: 100%;
  height: 42px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  transition: var(--transition);
  outline: none;
}

.form-input:focus { border-color: var(--color-brand); box-shadow: 0 0 0 3px var(--color-brand-50); }
.form-input::placeholder { color: var(--text-muted); }
.form-input.error { border-color: var(--color-error); }

.form-textarea {
  width: 100%;
  min-height: 120px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  transition: var(--transition);
  outline: none;
  resize: vertical;
  line-height: 1.6;
}

.form-textarea:focus { border-color: var(--color-brand); box-shadow: 0 0 0 3px var(--color-brand-50); }
.form-textarea::placeholder { color: var(--text-muted); }
.form-error { font-size: var(--font-size-xs); color: var(--color-error); margin-top: var(--space-1); }
.form-hint { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: var(--space-1); }

.form-select {
  width: 100%;
  height: 42px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235c5c78' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ─── Modal ─────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  transition: opacity var(--transition);
}

.modal-backdrop.open { opacity: 1; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px) scale(0.98);
  transition: transform var(--transition), opacity var(--transition);
}

.modal-backdrop.open .modal { transform: none; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border); }
.modal-title { font-size: var(--font-size-lg); font-weight: 700; }
.modal-body { flex: 1; overflow-y: auto; padding: var(--space-6); }
.modal-footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border); display: flex; gap: var(--space-3); justify-content: flex-end; }

/* ─── Dropdown ─────────────────────────────────────────────────────────────── */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  z-index: 150;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  transform-origin: top right;
  transition: all var(--transition-fast);
  pointer-events: none;
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  border: none;
  background: none;
  text-align: left;
}

.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-item.danger { color: var(--color-error); }
.dropdown-item svg { width: 16px; height: 16px; }
.dropdown-divider { height: 1px; background: var(--border); margin: var(--space-1) 0; }

/* ─── Skeleton loaders ──────────────────────────────────────────────────────── */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

.skeleton-text { height: 14px; border-radius: 4px; }
.skeleton-avatar { border-radius: 50%; }

/* ─── Toast / Alerts ────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-sm);
  font-weight: 500;
  max-width: 360px;
  pointer-events: auto;
  transform: translateX(120%);
  transition: transform var(--transition-slow);
}

.toast.show { transform: none; }
.toast.success { border-left: 3px solid var(--color-success); }
.toast.error   { border-left: 3px solid var(--color-error); }
.toast.warning { border-left: 3px solid var(--color-warning); }
.toast.info    { border-left: 3px solid var(--color-info); }

/* ─── Sort tabs ─────────────────────────────────────────────────────────────── */
.sort-tabs {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-1);
}

.sort-tab {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  border: none;
  background: none;
}

.sort-tab:hover { color: var(--text-primary); }
.sort-tab.active { background: var(--bg-elevated); color: var(--text-primary); }
.sort-tab svg { width: 14px; height: 14px; }

/* ─── Comment thread ────────────────────────────────────────────────────────── */
.comment-thread { padding: var(--space-4) 0; }
.comment-thread + .comment-thread { border-top: 1px solid var(--border); }

.comment-item {
  display: flex;
  gap: var(--space-3);
}

.comment-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 36px;
  flex-shrink: 0;
}

.comment-connector-line {
  width: 2px;
  flex: 1;
  background: var(--border);
  margin-top: var(--space-2);
  cursor: pointer;
  transition: var(--transition-fast);
  border-radius: 1px;
  min-height: 20px;
}

.comment-connector-line:hover { background: var(--color-brand); }

.comment-body { flex: 1; min-width: 0; }
.comment-header { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); flex-wrap: wrap; }
.comment-author { font-size: var(--font-size-sm); font-weight: 600; color: var(--text-primary); }
.comment-karma { font-size: var(--font-size-xs); color: var(--text-muted); }
.comment-time { font-size: var(--font-size-xs); color: var(--text-muted); }
.comment-text { font-size: var(--font-size-sm); color: var(--text-secondary); line-height: 1.7; }
.comment-actions { display: flex; align-items: center; gap: var(--space-1); margin-top: var(--space-2); }

/* ─── Markdown content ──────────────────────────────────────────────────────── */
.prose h1,
.prose h2,
.prose h3,
.prose h4 { color: var(--text-primary); margin: var(--space-6) 0 var(--space-3); }
.prose p { color: var(--text-secondary); margin-bottom: var(--space-4); }
.prose ul { list-style: disc; padding-left: var(--space-6); margin-bottom: var(--space-4); }
.prose ol { list-style: decimal; padding-left: var(--space-6); margin-bottom: var(--space-4); }
.prose li { color: var(--text-secondary); margin-bottom: var(--space-2); }
.prose a { color: var(--color-brand-light); text-decoration: underline; }
.prose strong { color: var(--text-primary); font-weight: 600; }
.prose code { font-family: var(--font-mono); }
.prose img { border-radius: var(--radius); margin: var(--space-4) 0; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: var(--space-6) 0; }

/* ─── Glassmorphism panels ──────────────────────────────────────────────────── */
.glass {
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.08);
}

/* ─── Community banner ──────────────────────────────────────────────────────── */
.community-banner {
  height: 160px;
  background: linear-gradient(135deg, var(--color-brand), #8b5cf6);
  position: relative;
  overflow: hidden;
}

.community-banner img { width: 100%; height: 100%; object-fit: cover; }

.community-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-4);
}

.community-info {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-4) 0;
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
  margin-top: -36px;
}

.community-avatar-wrap {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-lg);
  border: 4px solid var(--bg-surface);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--color-brand);
}

/* ─── Notifications panel ───────────────────────────────────────────────────── */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition-fast);
}

.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread { background: var(--color-brand-50); }
.notif-item.unread:hover { background: var(--color-brand-100); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-brand); flex-shrink: 0; margin-top: 6px; }

/* ─── User card ─────────────────────────────────────────────────────────────── */
.user-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.user-card-banner { height: 80px; background: linear-gradient(135deg, var(--color-brand), #8b5cf6); }
.user-card-body { padding: var(--space-5); margin-top: -32px; }
.user-card-avatar { width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--bg-surface); margin-bottom: var(--space-3); }

/* ─── Feed layout sorts ─────────────────────────────────────────────────────── */
.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-4);
}

/* ─── Infinite scroll trigger ──────────────────────────────────────────────── */
.scroll-sentinel {
  height: 1px;
  margin-top: var(--space-8);
}

/* ─── Post composer ─────────────────────────────────────────────────────────── */
.composer {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  transition: var(--transition-fast);
}

.composer:hover { border-color: var(--border-strong); background: var(--bg-elevated); }
.composer-input { flex: 1; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); height: 38px; padding: 0 var(--space-4); font-size: var(--font-size-sm); color: var(--text-muted); display: flex; align-items: center; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .feed-layout { grid-template-columns: 1fr; }
  .feed-sidebar { display: none; }
}

/* ─── Mobile Bottom Navigation ──────────────────────────────────────────────── */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(60px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(10,10,15,0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 110;
}

.mbn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  height: 60px;
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
  font-family: inherit;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.mbn-item svg { width: 22px; height: 22px; flex-shrink: 0; }
.mbn-item span { font-size: 10px; font-weight: 500; letter-spacing: 0.01em; }
.mbn-item.active { color: var(--color-brand-light); }
.mbn-item.active svg { stroke: var(--color-brand-light); }

.mbn-create {
  background: linear-gradient(135deg, var(--color-brand), #8b5cf6);
  color: #fff !important;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  flex: none;
  box-shadow: 0 4px 16px rgba(99,102,241,0.4);
}
.mbn-create svg { width: 26px; height: 26px; stroke: #fff !important; }

.mbn-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 20px);
  min-width: 16px;
  height: 16px;
  background: var(--color-error, #ef4444);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  pointer-events: none;
}

.mbn-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
}
.mbn-avatar img { width: 100%; height: 100%; object-fit: cover; }
.mbn-avatar svg { width: 18px; height: 18px; }
.mbn-avatar.has-avatar { background: linear-gradient(135deg, var(--color-brand), #8b5cf6); color: #fff; font-size: 12px; font-weight: 700; }

@media (max-width: 768px) {
  :root { --sidebar-width: 0px; --nav-height: 52px; --mobile-bottom-nav-height: calc(60px + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .app-layout { grid-template-columns: 1fr; }
  .main-content { grid-column: 1; padding: var(--space-4) var(--space-3); }
  .post-card-vote { display: none; }
  h1 { font-size: var(--font-size-2xl); }
  h2 { font-size: var(--font-size-xl); }

  /* Compact top navbar */
  #pageContent {
    padding-top: calc(var(--nav-height) + 2px) !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    padding-bottom: var(--mobile-bottom-nav-height) !important;
  }

  /* Hide desktop navbar items on mobile — moved to bottom nav */
  #notifBtn, #dmBtn, #userDropdown, #authActions .btn-primary { display: none !important; }
  #guestActions { display: none !important; }

  /* Tighter navbar */
  .navbar { padding: 0 14px; gap: 10px; }
  .navbar-search { display: none !important; }

  /* Post cards: full bleed, rounder feel */
  .post-card {
    border-radius: var(--radius-xl);
    margin-bottom: 10px;
  }

  /* Feed */
  .feed-header { margin-bottom: var(--space-3); }
  .sort-tabs { width: 100%; justify-content: space-between; }
  .sort-tab { flex: 1; justify-content: center; }

  /* Composer full width */
  .composer { border-radius: var(--radius-xl); }

  /* Comments indent less on mobile */
  .comment-thread { padding-left: 10px; }
}

@media (max-width: 480px) {
  .modal { border-radius: var(--radius-lg) var(--radius-lg) 0 0; margin-top: auto; max-height: 92vh; }
  .post-card-meta { flex-wrap: wrap; gap: 4px; }
}

/* ─── Page transitions ──────────────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: none; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-fade-in-up { animation: fadeInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.animate-fade-in    { animation: fadeIn 0.2s ease forwards; }
.animate-scale-in   { animation: scaleIn 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.animate-pulse      { animation: pulse 2s ease-in-out infinite; }

/* ─── Loading spinner ───────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 24px; height: 24px; border: 2px solid var(--border); border-top-color: var(--color-brand); border-radius: 50%; animation: spin 0.6s linear infinite; }
.spinner-sm { width: 16px; height: 16px; }
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }

/* ─── Utility classes ───────────────────────────────────────────────────────── */
.text-primary   { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted     { color: var(--text-muted) !important; }
.text-brand     { color: var(--color-brand-light) !important; }
.text-success   { color: var(--color-success) !important; }
.text-error     { color: var(--color-error) !important; }
.text-warning   { color: var(--color-warning) !important; }

.font-bold   { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium  { font-weight: 500; }
.font-mono    { font-family: var(--font-mono); }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

.d-flex { display: flex; }
.d-grid { display: grid; }
.d-block { display: block; }
.d-none { display: none !important; }

.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.w-full { width: 100%; }
.h-full { height: 100%; }

.rounded { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.p-4 { padding: var(--space-4); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }

.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }

.border-bottom { border-bottom: 1px solid var(--border); }
.border-top { border-top: 1px solid var(--border); }
