*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #000;
  --surface: #000;
  --border: #2f3336;
  --text: #e7e9ea;
  --text-muted: #71767b;
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --danger: #f4212e;
  --like: #f91880;
  --radius: 16px;
}

body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; min-height: 100vh; }

/* AUTH */
#auth-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.auth-box { width: 100%; max-width: 380px; padding: 40px 32px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.auth-box .logo { font-size: 48px; color: var(--text); }
.auth-box h1 { font-size: 28px; font-weight: 800; }
.auth-box .tagline { color: var(--text-muted); font-size: 14px; margin-bottom: 8px; }
.auth-box input { width: 100%; padding: 14px 16px; background: transparent; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 16px; outline: none; transition: border-color .2s; }
.auth-box input:focus { border-color: var(--accent); }
.auth-box button { width: 100%; padding: 14px; background: var(--text); color: #000; border: none; border-radius: var(--radius); font-size: 16px; font-weight: 700; cursor: pointer; transition: opacity .2s; margin-top: 4px; }
.auth-box button:hover { opacity: .85; }
.discord-btn { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; padding: 14px; background: #5865f2; color: #fff; border: none; border-radius: var(--radius); font-size: 16px; font-weight: 700; cursor: pointer; transition: opacity .2s; margin-top: 8px; }
.discord-btn:hover { opacity: .85; }
.switch-link { font-size: 14px; color: var(--text-muted); }
.switch-link a { color: var(--accent); text-decoration: none; }
.error-msg { color: var(--danger); font-size: 13px; min-height: 18px; }

/* LAYOUT */
#app { display: flex; max-width: 1280px; margin: 0 auto; min-height: 100vh; }

/* SIDEBAR */
.sidebar { position: sticky; top: 0; height: 100vh; padding: 8px 12px; display: flex; flex-direction: column; }
.left-sidebar { width: 275px; border-right: 1px solid var(--border); }
.right-sidebar { width: 350px; border-left: 1px solid var(--border); padding: 16px; overflow-y: auto; }
.sidebar-logo { font-size: 32px; padding: 12px 16px; cursor: pointer; }

nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 20px; padding: 12px 16px; border-radius: 9999px; text-decoration: none; color: var(--text); font-size: 20px; font-weight: 400; transition: background .15s; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.08); font-weight: 700; }
.nav-icon { font-size: 24px; }
.nav-label { font-size: 20px; }

.post-btn { background: var(--accent); color: #fff; border: none; border-radius: 9999px; padding: 16px 32px; font-size: 17px; font-weight: 700; cursor: pointer; margin-top: 16px; transition: background .2s; width: 90%; }
.post-btn:hover { background: var(--accent-hover); }
.post-btn.small { padding: 8px 20px; font-size: 15px; width: auto; margin-top: 0; }

.user-pill { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 9999px; cursor: pointer; margin-top: auto; margin-bottom: 8px; transition: background .15s; }
.user-pill:hover { background: rgba(255,255,255,.08); }
.user-info { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.display-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.username { color: var(--text-muted); font-size: 14px; }
.pill-dots { color: var(--text-muted); font-size: 18px; letter-spacing: 1px; }

/* AVATAR */
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; color: #fff; flex-shrink: 0; text-transform: uppercase; }
.avatar.large { width: 72px; height: 72px; font-size: 28px; }

/* MAIN */
.main-content { flex: 1; border-right: 1px solid var(--border); min-height: 100vh; }
.feed-header { padding: 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: rgba(0,0,0,.85); backdrop-filter: blur(12px); z-index: 10; }
.feed-header h2 { font-size: 20px; font-weight: 800; }

/* COMPOSE */
.compose-box { display: flex; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border); }
.compose-right { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.compose-right textarea { background: transparent; border: none; outline: none; color: var(--text); font-size: 20px; resize: none; min-height: 80px; width: 100%; font-family: inherit; }
.compose-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.char-count { color: var(--text-muted); font-size: 14px; }

/* POSTS */
.post { display: flex; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border); transition: background .15s; cursor: pointer; }
.post:hover { background: rgba(255,255,255,.03); }
.post-body { flex: 1; }
.post-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; flex-wrap: wrap; }
.delete-btn { margin-left: auto; background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: color .15s, background .15s; }
.delete-btn:hover { color: var(--danger); background: rgba(244,33,46,.1); }
.post-display { font-weight: 700; font-size: 15px; }
.post-username { color: var(--text-muted); font-size: 14px; }
.post-time { color: var(--text-muted); font-size: 14px; }
.post-text { font-size: 15px; line-height: 1.5; margin-bottom: 12px; white-space: pre-wrap; word-break: break-word; }
.post-actions { display: flex; gap: 28px; }
.action-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 13px; display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 9999px; transition: color .15s, background .15s; }
.action-btn:hover.reply { color: var(--accent); background: rgba(29,155,240,.1); }
.action-btn:hover.repost { color: #00ba7c; background: rgba(0,186,124,.1); }
.action-btn:hover.like { color: var(--like); background: rgba(249,24,128,.1); }
.action-btn.liked { color: var(--like); }
.action-btn.reposted { color: #00ba7c; }

/* SEARCH */
.search-bar { width: calc(100% - 32px); margin: 16px; padding: 12px 16px; background: #202327; border: 1px solid transparent; border-radius: 9999px; color: var(--text); font-size: 15px; outline: none; display: block; }
.search-bar:focus { border-color: var(--accent); background: var(--bg); }

/* NOTIFICATIONS */
.notif-item { padding: 16px; border-bottom: 1px solid var(--border); font-size: 15px; display: flex; gap: 12px; align-items: flex-start; }
.notif-icon { font-size: 20px; width: 24px; flex-shrink: 0; }

/* PROFILE */
.profile-banner { height: 150px; background: linear-gradient(135deg, #1d9bf0 0%, #0d47a1 100%); }
.profile-header { padding: 16px; border-bottom: 1px solid var(--border); display: flex; gap: 16px; align-items: flex-start; }
.profile-avatar { margin-top: -36px; border: 4px solid var(--bg); }
.profile-info { flex: 1; }
.profile-info h2 { font-size: 20px; font-weight: 800; }
.bio { color: var(--text-muted); font-size: 15px; margin: 4px 0 8px; }
.profile-stats { display: flex; gap: 16px; font-size: 14px; color: var(--text-muted); }
.profile-stats strong { color: var(--text); }

/* TRENDING */
.trending-box, .who-to-follow { background: #16181c; border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.trending-box h3, .who-to-follow h3 { font-size: 20px; font-weight: 800; margin-bottom: 12px; }
.trend-item { padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.trend-item:last-child { border-bottom: none; }
.trend-tag { font-weight: 700; font-size: 15px; }
.trend-count { color: var(--text-muted); font-size: 13px; }
.follow-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.follow-info { flex: 1; }
.follow-info .display-name { font-size: 15px; }
.follow-btn { background: var(--text); color: #000; border: none; border-radius: 9999px; padding: 6px 16px; font-weight: 700; font-size: 14px; cursor: pointer; }
.follow-btn:hover { opacity: .85; }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-start; justify-content: center; padding-top: 60px; z-index: 100; }
.modal-box { background: var(--bg); border-radius: var(--radius); width: 100%; max-width: 600px; padding: 16px; position: relative; border: 1px solid var(--border); }
.modal-close { position: absolute; top: 12px; right: 12px; background: none; border: none; color: var(--text); font-size: 18px; cursor: pointer; border-radius: 50%; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: rgba(255,255,255,.1); }

/* EMPTY STATE */
.empty-state { padding: 40px; text-align: center; color: var(--text-muted); font-size: 15px; }

/* EDIT PROFILE MODAL */
.edit-modal-box { max-width: 600px; padding: 0; overflow: hidden; }
.edit-modal-header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.edit-modal-header h2 { flex: 1; font-size: 18px; font-weight: 800; }
.save-btn { background: var(--text); color: #000; border: none; border-radius: 9999px; padding: 6px 18px; font-weight: 700; font-size: 14px; cursor: pointer; }
.save-btn:hover { opacity: .85; }
.edit-pfp-section { padding: 20px 16px 12px; display: flex; flex-direction: column; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.edit-pfp-preview { width: 80px; height: 80px; font-size: 32px; border: 3px solid var(--border); overflow: hidden; }
.edit-pfp-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.pfp-color-label { font-size: 13px; color: var(--text-muted); }
.color-swatches { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.swatch { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: border-color .15s, transform .15s; }
.swatch:hover { transform: scale(1.15); }
.swatch.selected { border-color: #fff; }
.pfp-upload-row { display: flex; gap: 10px; }
.upload-label { background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 9999px; padding: 6px 16px; font-size: 14px; cursor: pointer; font-weight: 600; }
.upload-label:hover { background: rgba(255,255,255,.08); }
.remove-img-btn { background: transparent; border: 1px solid var(--border); color: var(--text-muted); border-radius: 9999px; padding: 6px 16px; font-size: 14px; cursor: pointer; }
.remove-img-btn:hover { background: rgba(255,255,255,.08); }
.edit-fields { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.edit-field { display: flex; flex-direction: column; gap: 4px; }
.edit-field label { font-size: 13px; color: var(--text-muted); }
.edit-field input, .edit-field textarea { background: transparent; border: 1px solid var(--border); border-radius: 4px; color: var(--text); font-size: 15px; padding: 10px 12px; outline: none; font-family: inherit; resize: none; }
.edit-field input:focus, .edit-field textarea:focus { border-color: var(--accent); }
.edit-logout-row { padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.logout-btn { background: transparent; border: 1px solid var(--danger); color: var(--danger); border-radius: 9999px; padding: 8px 20px; font-size: 14px; font-weight: 700; cursor: pointer; }
.logout-btn:hover { background: rgba(244,33,46,.1); }

/* AVATAR IMAGE */
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

@media (max-width: 1100px) { .right-sidebar { display: none; } }
@media (max-width: 700px) {
  .left-sidebar { width: 68px; }
  .nav-label, .user-info, .logout-icon { display: none; }
  .post-btn:not(.small) { width: 44px; height: 44px; padding: 0; font-size: 22px; border-radius: 50%; }
  .post-btn:not(.small)::before { content: "+"; }
  .post-btn:not(.small) { font-size: 0; }
  .post-btn:not(.small)::before { font-size: 22px; }
}

/* ── Post image ── */
.post-image { margin: 8px 0 12px; border-radius: 12px; overflow: hidden; max-width: 100%; }
.post-image img { width: 100%; max-height: 400px; object-fit: cover; display: block; border-radius: 12px; }

/* ── Image preview in compose ── */
.img-preview { margin-top: 4px; }
.img-preview-wrap { position: relative; display: inline-block; }
.img-preview-wrap img { max-height: 200px; max-width: 100%; border-radius: 12px; display: block; }
.remove-img-x { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.7); color: #fff; border: none; border-radius: 50%; width: 26px; height: 26px; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.remove-img-x:hover { background: rgba(0,0,0,.9); }

/* ── Image upload icon in compose ── */
.img-upload-label { cursor: pointer; color: var(--accent); display: flex; align-items: center; padding: 4px; border-radius: 50%; transition: background .15s; }
.img-upload-label:hover { background: rgba(29,155,240,.1); }

/* ── Cooldown timer ── */
.cooldown-timer { color: var(--text-muted); font-size: 13px; }

/* ── Follow/Unfollow button states ── */
.follow-btn.following { background: transparent; color: var(--text); border: 1px solid var(--border); }
.follow-btn.following:hover { background: rgba(244,33,46,.1); color: var(--danger); border-color: var(--danger); }

/* ── Profile stat links ── */
.stat-link { cursor: pointer; }
.stat-link:hover strong { text-decoration: underline; }

/* ── Admin panel ── */
.admin-rename-btn { margin-left: auto; background: rgba(255,119,0,.15); color: #ff7700; border: 1px solid #ff7700; border-radius: 9999px; padding: 2px 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.admin-rename-btn:hover { background: rgba(255,119,0,.3); }
