/* ── Design tokens ────────────────────────────────────────────── */
:root {
  --bg:        #0d0d0f;
  --bg2:       #16161a;
  --bg3:       #1e1e24;
  --bg4:       #26262e;
  --border:    #2a2a35;
  --border2:   #38384a;
  --text:      #e8e8f0;
  --text-muted:#8888a0;
  --text-dim:  #55556a;
  --accent:    #7c6cf8;
  --accent2:   #9f8ffc;
  --accent-bg: rgba(124,108,248,0.12);
  --accent-bg2:rgba(124,108,248,0.2);
  --red:       #f05060;
  --red-bg:    rgba(240,80,96,0.12);
  --green:     #4ade80;
  --green-bg:  rgba(74,222,128,0.1);
  --amber:     #f59e0b;
  --amber-bg:  rgba(245,158,11,0.1);
  --font-head: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --r:         12px;
  --r-sm:      8px;
  --sidebar-w: 260px;
  --right-w:   300px;
  --transition: 0.15s ease;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }
img { display: block; max-width: 100%; }
ul { list-style: none; }

/* ── Layout ─────────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--right-w);
  min-height: 100vh;
  max-width: 1280px;
  margin: 0 auto;
}
.main-content {
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-height: 100vh;
}
.right-sidebar {
  padding: 20px 16px;
}

/* ── Sidebar nav ────────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent2);
  margin-bottom: 8px;
}
.brand svg { width: 32px; height: 32px; color: var(--accent); }
.nav-links { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--r);
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.nav-item:hover { background: var(--bg3); color: var(--accent2); }
.nav-item.active { color: var(--accent2); font-weight: 500; }
.nav-item.active svg { color: var(--accent); }
.nav-item svg { width: 22px; height: 22px; flex-shrink: 0; }
.badge {
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  margin-left: auto;
}

.compose-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--accent);
  color: white;
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 600;
  padding: 14px 20px;
  border-radius: 50px;
  margin: 16px 0;
  transition: background var(--transition), transform var(--transition);
  letter-spacing: 0.02em;
}
.compose-btn:hover { background: var(--accent2); transform: translateY(-1px); }

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--r);
  cursor: pointer;
  margin-top: auto;
  transition: background var(--transition);
}
.user-card:hover { background: var(--bg3); }
.user-card-info { display: flex; flex-direction: column; min-width: 0; }
.user-card-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card-handle { font-size: 12px; color: var(--text-muted); }
.user-menu {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  overflow: hidden;
  position: absolute;
  bottom: 80px;
  left: 12px;
  right: 12px;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.user-menu a, .user-menu button {
  display: block;
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  color: var(--text);
  font-size: 14px;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
.user-menu a:hover, .user-menu button:hover { background: var(--bg4); }
.user-menu button { border-top: 1px solid var(--border); color: var(--red); font-family: var(--font-body); }

/* ── Page header ────────────────────────────────────────────────── */
.page-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(13,13,15,0.85);
  backdrop-filter: blur(12px);
  z-index: 10;
}
.page-header h1 {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 600;
}
.page-header-sub { color: var(--text-muted); font-size: 13px; }

/* ── Tabs ───────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  flex: 1;
  padding: 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--text); background: var(--bg2); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }

/* ── Post card ──────────────────────────────────────────────────── */
.post-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.post-card:hover { background: rgba(255,255,255,0.018); }
.post-card.reply-card { padding-left: 32px; }

.post-repost-bar {
  grid-column: 1/-1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: -4px;
}

.post-left { display: flex; flex-direction: column; align-items: center; }
.post-thread-line {
  width: 2px;
  flex: 1;
  background: var(--border2);
  margin: 4px auto 0;
  border-radius: 1px;
}

.post-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.post-name {
  font-weight: 500;
  font-size: 14px;
}
.post-handle, .post-time {
  color: var(--text-muted);
  font-size: 13px;
}
.post-content {
  margin-top: 4px;
  font-size: 15px;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
}
.post-content .hashtag { color: var(--accent2); }
.post-content .mention { color: var(--accent2); }

.post-media {
  margin-top: 10px;
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--border);
  max-height: 400px;
}
.post-media img { width: 100%; object-fit: cover; max-height: 400px; }

.post-actions {
  display: flex;
  gap: 0;
  margin-top: 10px;
  margin-left: -8px;
}
.post-action {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  border-radius: 50px;
  font-size: 13px;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
  cursor: pointer;
  min-width: 52px;
}
.post-action:hover { background: var(--accent-bg); color: var(--accent2); }
.post-action.liked { color: var(--red); }
.post-action.liked:hover { background: var(--red-bg); }
.post-action.bookmarked { color: var(--accent); }
.post-action svg { width: 18px; height: 18px; flex-shrink: 0; }
.post-action-more { margin-left: auto; }

/* ── Avatars ────────────────────────────────────────────────────── */
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg3);
}
.avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg3);
}
.avatar-lg {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--bg);
  background: var(--bg3);
}

.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
  font-size: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Compose area ───────────────────────────────────────────────── */
.compose-area {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.compose-input {
  background: none;
  border: none;
  color: var(--text);
  font-size: 18px;
  resize: none;
  outline: none;
  width: 100%;
  min-height: 52px;
  line-height: 1.5;
}
.compose-input::placeholder { color: var(--text-dim); }
.compose-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 60px;
  backdrop-filter: blur(4px);
}
.compose-modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  width: 100%;
  max-width: 580px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  animation: modal-in 0.2s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(-20px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.compose-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.compose-body {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  padding: 16px;
}
.compose-right { display: flex; flex-direction: column; gap: 0; }
.compose-right textarea {
  background: none;
  border: none;
  color: var(--text);
  font-size: 17px;
  resize: none;
  outline: none;
  width: 100%;
  min-height: 100px;
  line-height: 1.6;
}
.compose-char-count { font-size: 12px; color: var(--text-dim); text-align: right; }
.compose-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.media-preview { position: relative; margin-top: 10px; }
.media-preview img { border-radius: var(--r-sm); max-height: 240px; object-fit: cover; }
.remove-media {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.6);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: white;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 18px;
  border-radius: 50px;
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
}
.btn-primary:hover:not(:disabled) { background: var(--accent2); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost {
  border: 1px solid var(--border2);
  color: var(--text);
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 50px;
  transition: background var(--transition);
}
.btn-ghost:hover { background: var(--bg3); }
.btn-follow {
  border: 1px solid var(--text);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  padding: 7px 16px;
  border-radius: 50px;
  transition: all var(--transition);
}
.btn-follow:hover { background: var(--text); color: var(--bg); }
.btn-follow.following {
  border-color: var(--border2);
  color: var(--text-muted);
}
.btn-follow.following:hover { border-color: var(--red); color: var(--red); background: var(--red-bg); }
.btn-danger { background: var(--red); color: white; font-size: 14px; padding: 8px 18px; border-radius: 50px; }
.btn-danger:hover { opacity: 0.9; }
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--accent);
  transition: background var(--transition);
}
.icon-btn:hover { background: var(--accent-bg); }

/* ── Profile ────────────────────────────────────────────────────── */
.profile-cover {
  height: 160px;
  background: linear-gradient(135deg, var(--accent-bg2) 0%, var(--bg3) 100%);
  position: relative;
}
.profile-cover img { width: 100%; height: 100%; object-fit: cover; }
.profile-info { padding: 16px 20px 0; }
.profile-avatar-wrap {
  margin-top: -52px;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}
.profile-name {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.profile-handle { color: var(--text-muted); font-size: 14px; margin-top: 2px; }
.profile-bio { margin-top: 10px; font-size: 15px; line-height: 1.6; }
.profile-meta {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--text-muted);
}
.profile-meta a:hover { color: var(--text); text-decoration: underline; }
.profile-stats {
  display: flex;
  gap: 20px;
  margin-top: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.stat-item { font-size: 14px; }
.stat-num { font-weight: 600; color: var(--text); }
.stat-label { color: var(--text-muted); margin-left: 4px; }

/* ── Right sidebar widgets ──────────────────────────────────────── */
.widget {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 16px;
}
.widget-title {
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 600;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.widget-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  cursor: pointer;
}
.widget-row:last-child { border-bottom: none; }
.widget-row:hover { background: var(--bg3); }
.widget-row-info { flex: 1; min-width: 0; }
.widget-row-name { font-size: 14px; font-weight: 500; }
.widget-row-sub { font-size: 12px; color: var(--text-muted); }

.trending-tag { font-weight: 500; font-size: 14px; color: var(--accent2); }
.trending-count { font-size: 12px; color: var(--text-muted); }

/* ── Search bar ─────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 10px 16px;
  margin-bottom: 16px;
  transition: border-color var(--transition);
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar svg { color: var(--text-muted); flex-shrink: 0; }
.search-bar input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  width: 100%;
}

/* ── Notifications ──────────────────────────────────────────────── */
.notif-item {
  display: flex;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.notif-item:hover { background: var(--bg2); }
.notif-item.unread { background: var(--accent-bg); }
.notif-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.notif-like   { background: var(--red-bg);    color: var(--red);    }
.notif-follow { background: var(--accent-bg); color: var(--accent); }
.notif-reply  { background: var(--green-bg);  color: var(--green);  }
.notif-repost { background: var(--green-bg);  color: var(--green);  }
.notif-mention{ background: var(--amber-bg);  color: var(--amber);  }
.notif-text { font-size: 14px; line-height: 1.5; }
.notif-time { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Messages ───────────────────────────────────────────────────── */
.messages-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
  overflow: hidden;
}
.conversation-list { border-right: 1px solid var(--border); overflow-y: auto; }
.convo-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.convo-item:hover { background: var(--bg3); }
.convo-item.active { background: var(--accent-bg); }
.chat-area { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-bubble {
  max-width: 68%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
}
.bubble-in  { background: var(--bg3); border-bottom-left-radius: 4px; align-self: flex-start; }
.bubble-out { background: var(--accent); color: white; border-bottom-right-radius: 4px; align-self: flex-end; }
.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 20px;
  padding: 10px 16px;
  resize: none;
  outline: none;
  font-size: 14px;
  max-height: 120px;
}

/* ── Auth pages ─────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 20% 80%, rgba(124,108,248,0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(159,143,252,0.05) 0%, transparent 60%),
              var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 40px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4);
}
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 700;
  color: var(--accent2);
  margin-bottom: 32px;
}
.auth-brand svg { width: 36px; height: 36px; color: var(--accent); }
.auth-title { font-family: var(--font-head); font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.auth-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text-muted); }
.form-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: 15px;
  transition: border-color var(--transition);
  outline: none;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-dim); }
.auth-submit {
  width: 100%;
  background: var(--accent);
  color: white;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 16px;
  padding: 14px;
  border-radius: 50px;
  margin-top: 8px;
  transition: background var(--transition), transform var(--transition);
}
.auth-submit:hover { background: var(--accent2); transform: translateY(-1px); }
.auth-link { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-muted); }
.auth-link a { color: var(--accent2); }
.flash { padding: 12px 16px; border-radius: var(--r-sm); margin-bottom: 16px; font-size: 14px; }
.flash-error { background: var(--red-bg); color: var(--red); border: 1px solid rgba(240,80,96,0.3); }
.flash-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(74,222,128,0.3); }

/* ── Admin ──────────────────────────────────────────────────────── */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 20px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
}
.stat-card-num { font-family: var(--font-head); font-size: 32px; font-weight: 700; }
.stat-card-label { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ── Loading spinner ────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-posts {
  display: flex;
  justify-content: center;
  padding: 32px;
}

/* ── Skeletons ──────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Utilities ──────────────────────────────────────────────────── */
.ml-auto { margin-left: auto; }
.op-50 { opacity: 0.5; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent2); }
.text-sm { font-size: 13px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.p-4 { padding: 16px; }
.p-5 { padding: 20px; }
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state h2 { font-family: var(--font-head); font-size: 20px; color: var(--text); margin-bottom: 8px; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .layout { grid-template-columns: var(--sidebar-w) 1fr; }
  .right-sidebar { display: none; }
}
@media (max-width: 700px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    flex-direction: row;
    padding: 8px 16px;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    z-index: 100;
  }
  .brand, .user-card, .compose-btn span, .nav-item span { display: none; }
  .nav-links { flex-direction: row; justify-content: space-around; flex: 1; }
  .compose-btn { padding: 10px; min-width: 44px; border-radius: 50%; }
  .main-content { padding-bottom: 72px; }
  .messages-layout { grid-template-columns: 1fr; }
  .admin-stats { grid-template-columns: 1fr 1fr; }
}
