/* flux.css */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --black:   #070809;
  --deep:    #0d1117;
  --surface: #161b22;
  --raised:  #1c2230;
  --rim:     #30363d;
  --line:    rgba(255,255,255,0.08);

  --white:   #f0f6fc;
  --muted:   #8b949e;
  --faint:   #484f58;

  --blue:    #388bfd;
  --blue-lo: rgba(56,139,253,0.15);
  --blue-glow: rgba(56,139,253,0.3);
  --green:   #238636;
  --amber:   #d29922;
  --red:     #da3633;
  --purple:  #bc8cff;

  --r2: 6px;
  --r3: 10px;
  --r4: 16px;
  --rmax: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.8);

  --t: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'DM Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--black);
  color: var(--white);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea, select { font-family: inherit; }
a { color: var(--blue); text-decoration: none; transition: color var(--t); }
a:hover { color: #58a6ff; }
img { display: block; max-width: 100%; }
ul { list-style: none; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--faint); border-radius: var(--rmax); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Utilities */
.hidden { display: none !important; }
.flex { display: flex; }
.grid { display: grid; }
.col { flex-direction: column; }
.row { flex-direction: row; }
.wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }
.shrink-0 { flex-shrink: 0; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.items-start { align-items: flex-start; } .items-center { align-items: center; } .items-end { align-items: flex-end; }
.justify-start { justify-content: flex-start; } .justify-center { justify-content: center; } .justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; }
.p-2 { padding: 8px; } .p-3 { padding: 12px; } .p-4 { padding: 16px; } .p-5 { padding: 20px; } .p-6 { padding: 24px; } .p-8 { padding: 32px; } .p-10 { padding: 40px; }
.px-3 { padding-left: 12px; padding-right: 12px; } .py-2 { padding-top: 8px; padding-bottom: 8px; } .py-3 { padding-top: 12px; padding-bottom: 12px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-auto { margin-top: auto; } .mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; } .my-5 { margin-top: 20px; margin-bottom: 20px; } .ml-auto { margin-left: auto; }
.w-full { width: 100%; } .h-full { height: 100%; } .min-h-0 { min-height: 0; } .min-w-0 { min-width: 0; }
.overflow-y-auto { overflow-y: auto; overflow-x: hidden; } .relative { position: relative; } .absolute { position: absolute; }
.cursor-pointer { cursor: pointer; } .select-none { user-select: none; } .truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-2 { border-radius: var(--r2); } .r-3 { border-radius: var(--r3); } .r-4 { border-radius: var(--r4); }
.transition { transition: all var(--t); }

/* Typography */
.text-xs { font-size: 12px; } .text-sm { font-size: 13px; } .text-base { font-size: 15px; } .text-lg { font-size: 18px; } .text-xl { font-size: 22px; } .text-2xl { font-size: 28px; } .text-4xl { font-size: 36px; }
.fw-4 { font-weight: 400; } .fw-5 { font-weight: 500; } .fw-6 { font-weight: 600; } .fw-7 { font-weight: 700; }
.text-center { text-align: center; } .mono { font-family: var(--mono); }
.text-white { color: var(--white); } .text-muted { color: var(--muted); } .text-faint { color: var(--faint); }
.text-blue { color: var(--blue); } .text-green { color: var(--green); } .text-red { color: var(--red); } .text-amber { color: var(--amber); }
.bg-surface { background: var(--surface); } .bg-deep { background: var(--deep); } .bg-black { background: var(--black); }

/* Components */
.avatar { border-radius: var(--rmax); background: var(--raised); object-fit: cover; flex-shrink: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); background-position: center; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 42px; height: 42px; font-size: 14px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }
.avatar-xl { width: 96px; height: 96px; font-size: 28px; }

.presence { position: relative; }
.presence::after { content: ''; position: absolute; bottom: 0; right: 0; width: 12px; height: 12px; border-radius: var(--rmax); border: 2px solid var(--black); background: var(--faint); }
.presence.online::after { background: var(--green); } .presence.idle::after { background: var(--amber); } .presence.dnd::after { background: var(--red); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none; border-radius: var(--rmax); font-family: var(--font); font-size: 14px; font-weight: 600; cursor: pointer; transition: all var(--t); padding: 10px 20px; outline: none; }
.btn:active { transform: scale(0.96); }
.btn-blue { background: var(--blue); color: #fff; } .btn-blue:hover { background: #58a6ff; box-shadow: 0 4px 14px var(--blue-glow); }
.btn-ghost { background: transparent; color: var(--white); border: 1px solid var(--rim); } .btn-ghost:hover { background: var(--surface); border-color: var(--faint); }
.btn-danger { background: rgba(218, 54, 51, 0.1); color: var(--red); } .btn-danger:hover { background: rgba(218, 54, 51, 0.2); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-icon { width: 36px; height: 36px; border-radius: var(--rmax); background: transparent; color: var(--muted); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; transition: all var(--t); }
.btn-icon:hover { background: var(--surface); color: var(--white); }
.btn-icon.active { color: var(--blue); background: var(--blue-lo); }

.input { width: 100%; background: var(--deep); border: 1px solid var(--rim); border-radius: var(--r3); color: var(--white); padding: 12px 16px; outline: none; transition: border-color var(--t), box-shadow var(--t); font-size: 14px; }
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-lo); }
.input::placeholder { color: var(--faint); }
.input-ghost { background: transparent; border: none; color: var(--white); outline: none; resize: none; width: 100%; font-size: 16px; line-height: 1.5; }
.input-ghost::placeholder { color: var(--muted); }

.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: var(--rmax); font-size: 12px; font-weight: 600; }
.badge-blue { background: var(--blue-lo); color: var(--blue); } .badge-red { background: rgba(218, 54, 51, 0.15); color: var(--red); } .badge-green { background: rgba(35, 134, 54, 0.15); color: var(--green); }
.badge-dot { width: 18px; height: 18px; background: var(--blue); border-radius: var(--rmax); font-size: 10px; font-weight: 700; color: #fff; display: flex; align-items: center; justify-content: center; }

.card { background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r4); }
.border { border: 1px solid var(--rim); } .border-b { border-bottom: 1px solid var(--line); } .border-t { border-top: 1px solid var(--line); }

.post-card { padding: 16px 20px; border-bottom: 1px solid var(--line); transition: background var(--t); cursor: pointer; }
.post-card:hover { background: rgba(255,255,255,0.02); }
.post-body { color: var(--white); font-size: 15px; line-height: 1.6; margin: 8px 0; word-break: break-word; }
.post-actions { display: flex; gap: 16px; margin-top: 12px; }
.post-action { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; transition: all var(--t); border: none; background: transparent; padding: 6px 8px; border-radius: var(--r3); }
.post-action:hover { color: var(--blue); background: var(--blue-lo); }
.post-action.liked { color: var(--red); } .post-action.liked:hover { background: rgba(218, 54, 51, 0.1); }
.post-action.hover-blue:hover { color: var(--blue); }
.post-action i { font-size: 15px; }

.reaction-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.reaction-chip { display: flex; align-items: center; gap: 4px; padding: 4px 10px; background: var(--raised); border: 1px solid var(--rim); border-radius: var(--rmax); font-size: 13px; cursor: pointer; transition: all var(--t); color: var(--muted); }
.reaction-chip:hover { border-color: var(--muted); color: var(--white); }
.reaction-chip.active { border-color: var(--blue); background: var(--blue-lo); color: var(--blue); }

.msg-row { display: flex; align-items: flex-end; gap: 10px; padding: 4px 20px; }
.msg-row.own { flex-direction: row-reverse; }
.bubble { max-width: 75%; padding: 10px 14px; border-radius: 18px; font-size: 14px; line-height: 1.5; word-break: break-word; }
.bubble.other { background: var(--raised); color: var(--white); border-bottom-left-radius: 4px; border: 1px solid var(--rim); }
.bubble.own { background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.msg-meta { font-size: 11px; color: var(--faint); margin-top: 4px; text-align: right; }
.msg-row.other .msg-meta { text-align: left; }

.tab-bar { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; text-align: center; padding: 14px 0; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; transition: all var(--t); background: transparent; border-top: none; border-left: none; border-right: none; }
.tab:hover { color: var(--white); background: rgba(255,255,255,0.02); }
.tab.active { color: var(--white); border-bottom-color: var(--blue); }

.search-wrap { position: relative; width: 100%; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input { width: 100%; background: var(--surface); border: 1px solid var(--rim); border-radius: var(--rmax); color: var(--white); padding: 10px 16px 10px 38px; outline: none; transition: all var(--t); }
.search-input:focus { border-color: var(--blue); background: var(--black); }

.dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 180px; background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r3); box-shadow: var(--shadow-lg); z-index: 100; overflow: hidden; animation: popIn 0.15s ease; }
.dropdown-item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-size: 14px; cursor: pointer; color: var(--white); transition: background var(--t); border: none; background: transparent; width: 100%; text-align: left; font-weight: 500; }
.dropdown-item:hover { background: var(--raised); }
.dropdown-item.danger { color: var(--red); } .dropdown-item.danger:hover { background: rgba(218, 54, 51, 0.1); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px); z-index: 200; display: flex; align-items: center; justify-content: center; animation: fadeIn 0.2s ease; padding: 20px; }
.modal { background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r4); padding: 24px; width: 100%; max-width: 520px; box-shadow: var(--shadow-lg); animation: slideUp 0.3s cubic-bezier(0.34,1.56,0.64,1); }

#toast-container { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 9999; pointer-events: none; }
.toast { background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r3); padding: 12px 20px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); color: var(--white); display: flex; align-items: center; gap: 8px; animation: slideUpToast 0.3s cubic-bezier(0.34,1.56,0.64,1) forwards; pointer-events: auto; }
.toast.fade-out { animation: fadeOutToast 0.3s ease forwards; }

.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--raised) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite linear; border-radius: var(--r2); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes popIn { 0% { opacity: 0; transform: scale(0.95) translateY(-5px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: none; } }
@keyframes slideUpToast { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes fadeOutToast { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(10px); } }
.fade-in { animation: fadeIn 0.3s ease forwards; }

/* Layout & Navigation */
#app { display: grid; grid-template-columns: 260px 1fr; grid-template-rows: 100vh; height: 100vh; }
.sidebar { background: var(--deep); border-right: 1px solid var(--line); display: flex; flex-direction: column; height: 100vh; }
.sidebar-logo { font-size: 26px; font-weight: 800; color: var(--white); padding: 24px 20px 16px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.sidebar-logo i { color: var(--blue); }
.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.sidebar-bottom { padding: 16px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 12px; cursor: pointer; transition: background var(--t); }
.sidebar-bottom:hover { background: var(--surface); }

.nav-item { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-radius: var(--r3); cursor: pointer; transition: all var(--t); color: var(--muted); font-weight: 600; font-size: 16px; border: none; background: transparent; width: 100%; text-align: left; }
.nav-item:hover { background: var(--surface); color: var(--white); }
.nav-item.active { color: var(--white); background: var(--raised); }
.nav-item.active .nav-icon { color: var(--blue); }
.nav-icon { font-size: 20px; width: 24px; text-align: center; flex-shrink: 0; transition: color var(--t); }

.main-panel { display: flex; flex-direction: column; height: 100vh; overflow: hidden; border-right: 1px solid var(--line); position: relative; }
.main-header { padding: 16px 20px; border-bottom: 1px solid var(--line); background: rgba(7,8,9,0.7); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.main-scroll { flex: 1; overflow-y: auto; min-height: 0; scroll-behavior: smooth; }

#right-panel { display: none; flex-direction: column; height: 100vh; overflow-y: auto; padding: 24px; gap: 20px; background: var(--black); }

/* Chat Layout */
.chat-layout { display: grid; grid-template-columns: 320px 1fr; height: 100%; }
.chat-sidebar { border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; background: var(--deep); }
.chat-main { display: flex; flex-direction: column; height: 100%; background: var(--black); }
.dm-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; transition: background var(--t); border-bottom: 1px solid rgba(255,255,255,0.02); }
.dm-item:hover { background: var(--surface); } .dm-item.active { background: var(--raised); border-left: 3px solid var(--blue); padding-left: 13px; }
.dm-item .dm-name { font-size: 15px; font-weight: 600; color: var(--white); } .dm-item .dm-preview { font-size: 13px; color: var(--muted); }

.msg-stream { flex: 1; overflow-y: auto; padding: 20px 0; display: flex; flex-direction: column; gap: 4px; }
.msg-input-area { padding: 16px 20px; border-top: 1px solid var(--line); background: var(--deep); }
.msg-input-box { display: flex; align-items: flex-end; gap: 12px; background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r4); padding: 8px 16px; transition: border-color var(--t); }
.msg-input-box:focus-within { border-color: var(--blue); }
.msg-input-box textarea { flex: 1; background: transparent; border: none; color: var(--white); font-size: 15px; resize: none; outline: none; line-height: 1.5; max-height: 150px; padding: 6px 0; }
.msg-input-box textarea::placeholder { color: var(--muted); }

/* Profile Banner */
.profile-banner { height: 200px; background: linear-gradient(135deg, var(--surface) 0%, var(--raised) 100%); position: relative; }
.profile-header-info { padding: 0 24px 24px; position: relative; }
.profile-avatar-wrap { margin-top: -48px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: flex-end; }
.stat-box { display: flex; align-items: baseline; gap: 6px; }
.stat-num { font-size: 16px; font-weight: 700; color: var(--white); } .stat-label { font-size: 14px; color: var(--muted); }

/* Notifications */
.notif-item { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background var(--t); }
.notif-item:hover { background: rgba(255,255,255,0.02); }
.notif-item.unseen { background: rgba(56,139,253,0.05); }
.notif-item.unseen::before { content: ''; width: 6px; height: 6px; border-radius: var(--rmax); background: var(--blue); flex-shrink: 0; }
.notif-icon { font-size: 16px; flex-shrink: 0; }

/* Communities */
.community-card { transition: all var(--t); }
.community-card:hover { border-color: var(--faint); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* Emoji Picker */
.emoji-picker-popup { position: absolute; bottom: calc(100% + 8px); left: 0; display: flex; gap: 4px; padding: 8px; background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r3); box-shadow: var(--shadow-lg); z-index: 100; animation: popIn 0.15s ease; }
.emoji-pick-btn { width: 36px; height: 36px; border: none; background: transparent; border-radius: var(--r2); cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center; transition: all var(--t); }
.emoji-pick-btn:hover { background: var(--raised); transform: scale(1.2); }

/* Chat file preview */
#chat-file-preview { background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r3); }

/* Auth */
#auth-screen { display: flex; align-items: center; justify-content: center; height: 100vh; background: radial-gradient(circle at top, var(--surface), var(--black)); }
.auth-box { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r4); padding: 40px; box-shadow: var(--shadow-lg); }

/* Responsive */
@media (max-width: 1200px) {
  #app { grid-template-columns: 80px 1fr; }
  .nav-label, #sidebar-username, #sidebar-handle, .sidebar-logo span { display: none; }
  .sidebar-logo { justify-content: center; padding: 24px 0; }
  .nav-item { justify-content: center; padding: 16px; } .nav-icon { width: auto; margin: 0; }
  .sidebar-bottom { justify-content: center; padding: 16px 0; }
}
@media (min-width: 1300px) {
  #app { grid-template-columns: 260px minmax(600px, 700px) 1fr; }
  #right-panel { display: flex; }
}
@media (max-width: 768px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 1fr 65px; }
  .sidebar { flex-direction: row; position: fixed; bottom: 0; width: 100%; height: 65px; border-right: none; border-top: 1px solid var(--line); z-index: 100; padding: 0; background: rgba(13,17,23,0.9); backdrop-filter: blur(10px); }
  .sidebar-logo, .sidebar-bottom, .nav-label { display: none; }
  .sidebar-nav { flex-direction: row; width: 100%; justify-content: space-around; align-items: center; padding: 0; }
  .nav-item { flex: 1; justify-content: center; border-radius: 0; height: 100%; }
  #nav-new-post { position: fixed; bottom: 85px; right: 20px; width: 56px; height: 56px; border-radius: 50%; padding: 0; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-lg); z-index: 90; }
  .main-panel { height: calc(100vh - 65px); }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-sidebar { display: none; } /* Simplified for mobile, would need toggle logic in full app */
}