:root {
  --primary: #1D9BF0;
  --bg: #000000;
  --border: #2f3336;
  --accent: #16181c;
  --text: #e7e9ea;
  --muted: #71767b;
  --danger: #f4212e;
  --green: #00ba7c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Tahoma, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.3;
}

a { color: inherit; text-decoration: none; }

button, input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.app {
  display: flex;
  justify-content: center;
  min-height: 100dvh;
  width: 100%;
}

.app-inner {
  display: flex;
  width: 100%;
  max-width: 1265px;
}

/* Left nav */
.sidebar {
  width: 88px;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  padding: 8px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

@media (min-width: 1280px) {
  .sidebar { width: 275px; padding: 8px 16px; }
}

@media (max-width: 639px) {
  .sidebar { display: none; }
}

.nav-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 16px;
  padding: 12px; border-radius: 999px;
  width: fit-content;
  font-size: 20px;
}
.nav-item:hover { background: rgba(255,255,255,0.1); }
.nav-item.active { font-weight: 700; }
.nav-item .label { display: none; }
@media (min-width: 1280px) { .nav-item .label { display: inline; } .nav-item { padding: 12px 24px 12px 12px; } }
.nav-item svg { width: 26px; height: 26px; }

.post-btn {
  margin-top: 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  height: 52px;
  font-weight: 700;
  font-size: 17px;
  cursor: pointer;
  display: none;
  width: 100%;
}
@media (min-width: 1280px) { .post-btn.full { display: block; } }
.post-btn.icon-only {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; padding: 0; border-radius: 999px; margin-top: 16px;
}
@media (min-width: 1280px) { .post-btn.icon-only { display: none; } }
.post-btn:hover { background: #1a8cd8; }

.user-menu-wrap { position: relative; width: 100%; }

.user-menu {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 999px;
  background: none; border: none; cursor: pointer;
  text-align: left; width: 100%;
}
.user-menu:hover { background: rgba(255,255,255,0.1); }
.user-menu .info { display: none; flex: 1; overflow: hidden; }
@media (min-width: 1280px) { .user-menu .info { display: flex; flex-direction: column; } }
.user-menu .name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu .handle { color: var(--muted); font-size: 15px; }

.user-menu-dropdown {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: var(--bg, #000);
  border: 1px solid var(--border, #2f3336);
  border-radius: 16px;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
  padding: 6px;
  z-index: 50;
}
.user-menu-dropdown.open { display: block; }
.user-menu-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px; border-radius: 10px;
  background: none; border: none; cursor: pointer;
  font-size: 15px; text-align: left; text-decoration: none;
  color: inherit; box-sizing: border-box;
}
.user-menu-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.user-menu-item:hover { background: rgba(255,255,255,0.1); }
.user-menu-item.danger { color: #f4212e; }

/* Avatar */
.avatar {
  border-radius: 999px;
  object-fit: cover;
  background: rgba(29,155,240,0.2);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--primary);
  font-weight: 700;
  flex-shrink: 0;
}

/* آنلاین/آفلاین: نقطه‌ی سبز کم‌رنگ گوشه‌ی پایین-راست آواتار */
.avatar-wrap { position: relative; display: inline-block; line-height: 0; flex-shrink: 0; }
.presence-dot {
  position: absolute; right: 0; bottom: 0;
  width: 26%; height: 26%;
  min-width: 8px; min-height: 8px;
  border-radius: 50%;
  background: rgba(0,186,124,0.65);
  border: 2px solid var(--bg, #000);
  box-sizing: content-box;
}
.profile-avatar-wrap .presence-dot { border-width: 3px; }

/* Main column */
.main {
  flex: 1; min-width: 0;
  max-width: 600px;
  border-right: 1px solid var(--border);
  padding-bottom: 60px;
}
@media (min-width: 640px) { .main { padding-bottom: 0; } }

.main-header {
  position: sticky; top: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  z-index: 10;
}
.main-header h1 { margin: 0; font-size: 20px; font-weight: 800; }
.main-header-row { display: flex; align-items: center; justify-content: space-between; position: relative; }

/* آواتار کاربر گوشه بالا-راست هدر، فقط توی صفحه‌ی Home و فقط توی موبایل نشون داده میشه */
.home-header-avatar { display: none; margin-inline-start: auto; }
@media (max-width: 639px) {
  .main-header:has(.home-header-avatar) { display: flex; align-items: center; justify-content: space-between; }
  .home-header-avatar { display: inline-flex; }
}
.news-header-link {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; justify-content: center;
  padding: 6px 16px;
  border-radius: 999px;
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
}
.news-header-link:hover { background: rgba(255,255,255,0.1); }
.news-unread-badge {
  position: absolute; top: -2px; right: -2px;
  background: #f4212e; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
  min-width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  border: 2px solid var(--bg, #000);
}

/* Right sidebar */
.rightbar {
  width: 350px;
  flex-shrink: 0;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex; flex-direction: column; gap: 16px;
}
@media (max-width: 1023px) { .rightbar { display: none; } }

.search-box {
  position: relative;
}
.search-box input {
  width: 100%; height: 44px;
  background: rgba(255,255,255,0.05);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 16px 0 44px;
  outline: none;
}
.search-box input:focus { background: #000; border-color: var(--primary); }
.search-box svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }

.card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  padding-top: 12px;
}
.card h2 { font-size: 20px; margin: 0 0 12px; padding: 0 16px; }
.card .row { padding: 12px 16px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.card .row:hover { background: rgba(255,255,255,0.05); }
.card .small { font-size: 13px; color: var(--muted); }
.card .bold { font-weight: 700; font-size: 15px; }

/* Mobile bottom nav */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 60px;
  background: rgba(0,0,0,0.9);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  align-items: center; justify-content: space-around;
  z-index: 50;
}
@media (max-width: 639px) { .bottom-nav { display: flex; } }
.bottom-nav a { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.bottom-nav svg { width: 24px; height: 24px; }
.bottom-nav a.active svg { color: var(--primary); }

/* بج قرمز روی آیکون زنگوله (تعداد نوتیفیکیشن نخونده) */
.nav-icon-wrap { position: relative; display: inline-flex; }
.notif-badge {
  position: absolute; top: -6px; right: -8px;
  background: #f4212e; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
  min-width: 16px; height: 16px;
  border-radius: 999px;
  align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg, #000);
}
.bottom-nav .notif-badge { top: -4px; right: -6px; }

/* Compose */
.compose {
  display: flex; gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.compose textarea {
  flex: 1; background: none; border: none; outline: none;
  resize: none; font-size: 20px; color: var(--text);
  min-height: 60px;
}
.compose textarea::placeholder { color: var(--muted); }
.compose-footer { display: flex; justify-content: flex-end; align-items: center; margin-top: 8px; gap: 12px; }
.compose-footer .compose-image-btn { margin-right: auto; cursor: pointer; }
[dir="rtl"] .compose-footer .compose-image-btn { margin-right: 0; margin-left: auto; }
.char-count { font-size: 13px; color: var(--muted); }
.compose-image-preview { position: relative; display: inline-block; margin-top: 10px; max-width: 100%; }
.compose-image-preview img { display: block; max-width: 100%; max-height: 300px; border-radius: 16px; border: 1px solid var(--border); object-fit: cover; }
.compose-image-remove { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.65); color: #fff; border-radius: 999px; cursor: pointer; }
.compose-image-remove svg { width: 16px; height: 16px; }
[dir="rtl"] .compose-image-remove { right: auto; left: 8px; }

.btn {
  background: var(--primary); color: #fff; border: none;
  border-radius: 999px; padding: 8px 20px; font-weight: 700; cursor: pointer;
}
.btn:hover { background: #1a8cd8; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.outline {
  background: none; border: 1px solid var(--border); color: var(--text);
}
.btn.outline:hover { background: rgba(255,255,255,0.1); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 14px; font-size: 14px; }

/* Tweet card */
.tweet {
  display: flex; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.tweet:hover { background: rgba(255,255,255,0.02); }
.tweet-body { flex: 1; min-width: 0; }
.tweet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; font-size: 15px; }
.tweet-head-meta { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-width: 0; }
.tweet-head .name { font-weight: 700; }
.tweet-head .handle, .tweet-head .dot, .tweet-head .time { color: var(--muted); }
.tweet-delete, .tweet-icon-action { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 999px; color: var(--muted); flex-shrink: 0; }
.tweet-delete:hover, .tweet-icon-action:hover { color: var(--danger); background: rgba(244,33,46,0.1); }
.tweet-delete svg, .tweet-icon-action svg { width: 16px; height: 16px; }
.tweet-text { white-space: pre-wrap; word-break: break-word; margin: 2px 0 8px; }
.tweet-text .tag, .tweet-text .mention { color: var(--primary); }
.tweet-image-wrap { margin: 2px 0 10px; }
.tweet-image { display: block; max-width: 100%; max-height: 500px; width: 100%; object-fit: cover; border-radius: 16px; border: 1px solid var(--border); cursor: default; }
.tweet-actions { display: flex; justify-content: space-between; max-width: 425px; color: var(--muted); }
.tweet-action { display: flex; align-items: center; gap: 4px; cursor: pointer; border-radius: 999px; padding: 6px; }
.tweet-action:hover { color: var(--primary); background: rgba(29,155,240,0.1); }
.tweet-action.like:hover { color: #f91880; background: rgba(249,24,128,0.1); }
.tweet-action.retweet:hover { color: var(--green); background: rgba(0,186,124,0.1); }
.tweet-action.liked { color: #f91880; }
.tweet-action.retweeted { color: var(--green); }
.tweet-action svg { width: 18px; height: 18px; }
.tweet-action .count { font-size: 13px; }

.badge {
  display: inline-flex; width: 16px; height: 16px; flex-shrink: 0;
  color: var(--primary);
}
.badge svg { width: 100%; height: 100%; fill: currentColor; }

.verified-badge-owner { color: #ffd700; }

/* Profile */
.profile-cover { height: 133px; position: relative; }
.profile-header { padding: 12px 16px; border-bottom: 1px solid var(--border); position: relative; }
.profile-avatar-wrap { margin-top: -60px; margin-bottom: 8px; }
.profile-avatar { width: 133px; height: 133px; font-size: 48px; border: 4px solid var(--bg); }
.profile-name { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 4px; }
.profile-handle { color: var(--muted); }
.profile-bio { margin: 12px 0; white-space: pre-wrap; }
.profile-stats { display: flex; align-items: center; gap: 20px; font-size: 14px; color: var(--muted); }
.profile-stats b { color: var(--text); }
.profile-stats svg { width: 16px; height: 16px; flex-shrink: 0; }
.profile-actions { position: absolute; top: 8px; right: 16px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 32px); }
.profile-actions .btn { box-shadow: 0 1px 6px rgba(0,0,0,0.45); }
.profile-actions .btn.outline { background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); }
.icon-btn { width: 36px; height: 36px; padding: 0 !important; display: flex; align-items: center; justify-content: center; border-radius: 999px; }
.icon-btn svg { width: 18px; height: 18px; }

.tabs { display: flex; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; text-align: center; padding: 16px; font-weight: 700; color: var(--muted);
  cursor: pointer; position: relative; white-space: nowrap;
}
.tab.active { color: var(--text); }
.tab.active::after {
  content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 56px; height: 4px; background: var(--primary); border-radius: 999px;
}

/* Forms (auth) */
.auth-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h1 { font-size: 28px; margin-bottom: 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.field input, .field textarea {
  width: 100%; background: transparent; border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--primary); }
.error-msg { color: var(--danger); font-size: 14px; margin-bottom: 12px; }
.success-msg { color: var(--green); font-size: 14px; margin-bottom: 12px; }
.auth-switch { margin-top: 16px; font-size: 14px; color: var(--muted); }
.auth-switch a { color: var(--primary); }
.lang-switch { margin-top: 20px; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.lang-switch select { background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; color: var(--text); font-size: 13px; }

.empty-state { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--text); font-size: 20px; margin-bottom: 8px; }

.loading { padding: 24px; text-align: center; color: var(--muted); }

.back-header { display: flex; align-items: center; gap: 20px; }
.back-btn { width: 36px; height: 36px; border-radius: 999px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.back-btn:hover { background: rgba(255,255,255,0.1); }
.back-btn svg { width: 20px; height: 20px; }

.notification-row { display: flex; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border); }
.notification-row.unread { background: rgba(29,155,240,0.05); }
.notification-icon svg { width: 24px; height: 24px; }
.notification-icon.like { color: #f91880; }
.notification-icon.retweet { color: var(--green); }
.notification-icon.follow { color: var(--primary); }
.notification-icon.reply, .notification-icon.mention { color: var(--primary); }

.user-card-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.user-card-row .info { flex: 1; min-width: 0; }
.user-card-row .name-row { display: flex; align-items: center; gap: 4px; font-weight: 700; }
.user-card-row .handle { color: var(--muted); font-size: 14px; }
.user-card-row .bio { font-size: 14px; margin-top: 2px; color: var(--text); }

.settings-form { padding: 16px; }
.color-swatches { display: flex; gap: 8px; margin-top: 8px; }
.swatch { width: 32px; height: 32px; border-radius: 999px; cursor: pointer; border: 2px solid transparent; }
.swatch.selected { border-color: #fff; }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.admin-table th { color: var(--muted); font-weight: 600; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; margin-right: 4px; }

/* ===== RTL overrides ===== */
[dir="rtl"] .sidebar { border-right: none; border-left: 1px solid var(--border); }
[dir="rtl"] .main { border-left: 1px solid var(--border); border-right: none; }
[dir="rtl"] .user-menu, [dir="rtl"] .user-menu-item { text-align: right; }
[dir="rtl"] .user-menu-dropdown { left: auto; right: 0; }
[dir="rtl"] .search-box svg { left: auto; right: 14px; }
[dir="rtl"] .search-box input { padding-left: 12px; padding-right: 44px; }
[dir="rtl"] .admin-table th, [dir="rtl"] .admin-table td { text-align: right; }
[dir="rtl"] .pill { margin-right: 0; margin-left: 4px; }
[dir="rtl"] .profile-actions { right: auto; left: 16px; justify-content: flex-start; }
[dir="rtl"] .back-btn { transform: scaleX(-1); }
.pill.blue { background: rgba(29,155,240,0.15); color: var(--primary); }
.pill.gold { background: rgba(255,215,0,0.15); color: #ffd700; }
.pill.red { background: rgba(244,33,46,0.15); color: var(--danger); }

.news-item { padding: 16px; border-bottom: 1px solid var(--border); }
.news-item h3 { margin: 4px 0; }
.news-item .meta { color: var(--muted); font-size: 13px; }
.news-item .news-media { margin-top: 10px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.news-item .news-media img, .news-item .news-media video { display: block; width: 100%; max-height: 420px; object-fit: cover; }
.news-media-picker { margin-bottom: 12px; }
.news-media-picker .preview-wrap { position: relative; display: inline-block; margin-top: 8px; }
.news-media-picker .preview-wrap img, .news-media-picker .preview-wrap video { max-width: 100%; max-height: 260px; border-radius: 12px; display: block; }
.news-media-picker .remove-media-btn {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,0.7); color: #fff;
  border: none; border-radius: 50%;
  width: 26px; height: 26px; cursor: pointer;
  font-size: 14px; line-height: 1;
}

.toast-container { position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; }
@media (min-width: 640px) { .toast-container { bottom: 24px; } }
.toast { background: #fff; color: #000; padding: 12px 20px; border-radius: 8px; font-size: 14px; font-weight: 600; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.toast.error { background: var(--danger); color: #fff; }

.admin-only-badge { color: #ffd700; }

/* Modal (used for verify-request dialog) */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  z-index: 200; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  background: var(--bg); border: 1px solid var(--border); border-radius: 16px;
  width: 100%; max-width: 420px; padding: 20px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-close { background: none; border: none; color: var(--text); font-size: 16px; cursor: pointer; padding: 6px; border-radius: 999px; }
.modal-close:hover { background: rgba(255,255,255,0.1); }
.modal-desc { color: var(--muted); font-size: 13px; margin: 0 0 12px; line-height: 1.6; }
.modal-box textarea {
  width: 100%; background: transparent; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; color: var(--text); resize: vertical; font-family: inherit;
}
.modal-box textarea:focus { border-color: var(--primary); outline: none; }
.modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.modal-footer .small { color: var(--muted); font-size: 12px; }
