:root,
:root[data-theme="light"] {
  /* Brand */
  --accent: #2dd4bf;
  --accent-hover: #14b8a6;

  --secondary: #fb923c;
  --secondary-hover: #f97316;

  /* Status */
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --error: #ef4444;

  /* Layout */
  --nav-height: 70px;
  --bubble-radius: 18px;

  /* Light Theme */
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(0, 0, 0, 0.08);
  --nav-bg: #ffffff;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.08);

  /* Extras */
  --online: #22c55e;
  --link: var(--accent);
}

:root[data-theme="dark"] {
  /* Brand stays consistent */
  --accent: #2dd4bf;
  --accent-hover: #14b8a6;

  --secondary: #fb923c;
  --secondary-hover: #f97316;

  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --error: #ef4444;

  /* Dark Theme */
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.08);
  --nav-bg: #111827;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.45);

  --online: #22c55e;
  --link: #5eead4;
}

:root[data-theme="oled"] {
  /* Brand stays consistent */
  --accent: #2dd4bf;
  --accent-hover: #14b8a6;

  --secondary: #fb923c;
  --secondary-hover: #f97316;

  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --error: #ef4444;

  /* OLED Theme */
  --bg: #000000;
  --card: #0a0a0a;
  --text: #f8fafc;
  --muted: #6b7280;
  --border: rgba(255, 255, 255, 0.06);
  --nav-bg: #000000;
  --shadow: none;

  --online: #22c55e;
  --link: #5eead4;
}

:root[data-bubble="modern"] {
  --bubble-radius: 6px;
}

:root {
  --font-scale: 1;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

:root[data-font-size="small"] {
  --font-scale: 0.875; /* 14px (based on 16px default) */
}

:root[data-font-size="large"] {
  --font-scale: 1.125; /* 18px */
}

:root[data-font-size="xlarge"] {
  --font-scale: 1.25; /* 20px */
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
}

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    sans-serif;
  overflow: hidden;
  transition:
    background 0.3s,
    color 0.3s;
  margin: auto;
  height: 100dvh;
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  font-size: calc(100% * var(--font-scale));
}
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.hidden {
  display: none !important;
}

/* Offline Banner */
#offline-banner {
  width: 100%;
  background: var(--error);
  color: white;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  padding: 6px;
  z-index: 20000;
  transition: transform 0.3s;
  transform: translateY(-100%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
#offline-banner.visible {
  transform: translateY(0);
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  align-items: center;
  width: 90%;
  max-width: 400px;
  pointer-events: none;
}
.app-toast {
  background: var(--card);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 30px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  pointer-events: auto;
  border: 1px solid var(--border);
  font-weight: 500;
}
.app-toast i {
  font-size: 18px;
}
.app-toast.error i {
  color: var(--error);
}
.app-toast.success i {
  color: var(--success);
}
.app-toast.info i {
  color: var(--accent);
}
@keyframes toastIn {
  from {
    transform: translateY(70px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
@keyframes toastOut {
  to {
    transform: translateY(70px);
    opacity: 0;
  }
}

/* Layout Containers */
section {
  height: 100%;
  width: 100%;
  flex-grow: 8;
  gap: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--nav-height);
}

.topbar {
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 64px;
  overflow: hidden;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  margin: 0;
  overflow-y: hidden;
}

.topbar h2 {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 64px;
  gap: 1.5rem;
}

.topbar h2 .brand_logo {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 24px;
  flex-shrink: 0;
}

.topbar h2 .brand_logo i {
  position: relative;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.topbar > div:last-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  height: 64px;
}

.scrollable-list {
  padding: 16px;
  overflow-y: auto;
  flex: 8;
  height: 100%;
}

/* Tabs UI */
.tabs-container {
  display: flex;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: 50px;
  overflow-y: hidden;
  overflow-x: auto;
  margin: 0;
  flex-shrink: 0;
}
.tabs-container#mod-tabs-container {
  scrollbar-width: none;
}
.tab-btn {
  flex: 1;
  text-align: center;
  padding: 14px 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  height: 50px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
  position: relative;
}
.tab-btn.active {
  color: var(--accent);
  font-weight: bold;
  border-bottom: 2px solid var(--accent);
}
.tab-btn.has-unread::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--error);
  border-radius: 50%;
  position: absolute;
  top: 10px;
  right: 20%;
}

/* =========================================
   Mobile-First Auth Redesign
   ========================================= */

.auth-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: 0;
  background: linear-gradient(
    135deg,
    var(--accent),
    var(--accent-hover)
  ); /* Brand gradient */
  position: relative;
  overflow: hidden;
}

/* Adjust gradient for dark themes */
:root[data-theme="dark"] .auth-layout,
:root[data-theme="oled"] .auth-layout {
  background: linear-gradient(135deg, var(--accent), #082f49);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  height: 100%;
  height: 35dvh;
  z-index: 2;
  padding: 20px;
  animation: fadeInDown 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.auth-brand i {
  font-size: 72px;
  text-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  margin-bottom: 8px;
}

.auth-brand h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
}

.auth-brand p {
  font-size: 15px;
  opacity: 0.9;
  font-weight: 500;
}

.auth-sheet {
  flex: 8;
  background: var(--bg);
  border-radius: 40px 40px 0 0;
  padding: 40px 24px 20px;
  height: 65dvh;
  width: 100%;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
  overflow-y: auto;
  transition: background 0.3s;
}

.auth-form-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-form-header h2 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}

.auth-form-header p {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

.auth-input-group {
  margin-bottom: 16px;
}

.auth-input-group input,
.auth-input-group select {
  margin-bottom: 0;
  background: var(--card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.auth-btn-container {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-btn-container button {
  margin-top: 0;
}

/* Subtle background decorations */
.auth-decor {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  z-index: 1;
}

.decor-1 {
  width: 350px;
  height: 350px;
  top: -120px;
  left: -120px;
}

.decor-2 {
  width: 200px;
  height: 200px;
  top: 15%;
  right: -60px;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

input,
select.app-select {
  width: 100%;
  height: 52px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 16px;
  color: var(--text);
  margin-bottom: 16px;
  font-size: 16px;
  transition: border-color 0.2s;
}
input:focus,
select.app-select:focus {
  border-color: var(--accent);
  outline: none;
}
select.app-select {
  appearance: none;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.toggle-row label {
  font-size: 14px;
  color: var(--text);
}
.toggle-row input[type="checkbox"] {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

button {
  width: max-content;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 52px;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 0.1s,
    opacity 0.2s;
}
form button {
  margin-top: 1rem;
  width: 100%;
}
.btn-primary {
  background: var(--accent);
  color: #0f172a;
}
.btn-primary:active {
  transform: scale(0.98);
}
.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-ghost:active {
  background: rgba(56, 189, 248, 0.1);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
  border: 1px solid var(--error);
}
.btn-danger:active {
  background: rgba(239, 68, 68, 0.2);
}
.btn-small {
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
  width: auto;
  margin: 0;
}

/* Profile Stats & Mutual Friends */
.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
  text-align: center;
}
#view-profile-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
#view-profile-actions > * {
  width: 100%;
}
#view-profile-actions > * button {
  padding: 5px 10px;
  width: 100%;
}

.stat-box {
  background: var(--card);
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
}
.stat-value {
  font-size: 16px;
  font-weight: bold;
  color: var(--text);
  margin-bottom: 4px;
}
.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mutual-friends-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--muted);
  text-align: left;
}
.avatar-stack {
  display: flex;
}
.avatar-stack .msg-avatar {
  border: 2px solid var(--bg);
  margin-right: -8px;
  width: 28px;
  height: 28px;
  font-size: 12px;
}
.avatar-stack .msg-avatar:last-child {
  margin-right: 0;
}

/* Chat UI */
#messages {
  flex: 8;
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  position: relative;
}
.message {
  max-width: 85%;
  transition: box-shadow 0.3s;
}
.message.own {
  align-self: flex-end;
}
.message.others {
  align-self: flex-start;
}

.author-row {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
  padding: 0 4px;
}
.own .author-row {
  justify-content: flex-end;
}

.msg-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 10px;
  flex-shrink: 0;
  margin-right: 8px;
  overflow: hidden;
  cursor: pointer;
}
.author-name {
  font-size: 12px;
  color: var(--muted);
}
.own .author-name {
  color: var(--accent);
}

.bubble {
  padding: 12px 16px;
  border-radius: var(--bubble-radius);
  font-size: 15px;
  line-height: 1.4;
  word-break: break-word;
  transition: box-shadow 0.3s;
}
.others .bubble {
  background: var(--card);
  border-bottom-left-radius: 4px;
}
.own .bubble {
  background: var(--accent);
  color: #0f172a;
  border-bottom-right-radius: 4px;
}
:root[data-theme="light"] .own .bubble {
  color: #ffffff;
}

/* Metadata (Time & Read Receipts) */
.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  opacity: 0.7;
  margin-top: 6px;
  user-select: none;
  justify-content: flex-end;
}
.others .msg-meta {
  justify-content: flex-start;
}
.read-receipt i {
  font-size: 14px;
}
.read-receipt.read {
  color: #0f172a;
}
:root[data-theme="light"] .own .read-receipt.read {
  color: #ffffff;
}

/* System Messages & Dividers */
.system-message {
  text-align: center;
  margin: 12px 0;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}
.divider,
.date-divider {
  text-align: center;
  margin: 16px 0;
}
.divider span,
.date-divider span {
  background: rgba(0, 0, 0, 0.15);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.divider span {
  background: transparent;
}
:root[data-theme="light"] .date-divider span {
  background: rgba(0, 0, 0, 0.05);
}

/* Pinned Banner */
.pinned-banner {
  background: var(--card);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s;
  z-index: 99;
}
.pinned-banner:active {
  background: var(--bg);
}
.pinned-banner i {
  color: var(--accent);
  font-size: 18px;
}
.pinned-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pinned-content strong {
  color: var(--accent);
  font-size: 11px;
  margin-bottom: 2px;
}
.pinned-content span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
/* Sticker Message Type Modifiers */
.message.sticker-msg .bubble {
  background: transparent !important;
  padding: 0 !important;
  border: none !important;
  box-shadow: none !important;
  color: inherit;
}

.message.sticker-msg .msg-meta {
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 10px;
  width: fit-content;
  margin-top: 4px;
  color: white;
}

.message.sticker-msg.own .msg-meta {
  margin-left: auto;
}

/* Base Sticker Render */
.msg-sticker {
  width: 120px;
  height: 120px;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.msg-sticker:active {
  transform: scale(0.95);
}

/* Load Older Button */
.load-older-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--accent);
  border-radius: 16px;
  padding: 8px 16px;
  font-size: 12px;
  cursor: pointer;
  display: block;
  margin: 0 auto 16px auto;
  width: fit-content;
  transition: 0.2s;
  font-weight: 500;
}
.load-older-btn:active {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(0.95);
}
:root[data-theme="light"] .load-older-btn {
  background: rgba(0, 0, 0, 0.05);
}

/* Replied Context */
.reply-context {
  font-size: 13px;
  background: rgba(0, 0, 0, 0.15);
  padding: 8px 12px;
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  margin-bottom: 8px;
  color: inherit;
  opacity: 0.85;
  display: -webkit-box;
  line-clamp: 3;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}
:root[data-theme="light"] .reply-context {
  background: rgba(0, 0, 0, 0.05);
}

/* Unread Divider */
.unread-divider {
  text-align: center;
  color: var(--error);
  font-size: 12px;
  margin: 16px 0;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
}
.unread-divider hr {
  flex: 1;
  border: none;
  border-top: 1px solid var(--error);
  opacity: 0.3;
}

/* Chat Title & Subtitle */
.chat-details-container {
  flex: 1;
  display: flex;
  margin-left: 12px;
  gap: 12px;
  overflow: hidden;
}
.chat-title-container {
  flex: 8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-image-container {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#chat-title-text {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.chat-subtitle {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
}

/* Reactions */
.reaction-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.reaction-badge {
  background: rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;
}
.own .reaction-badge {
  background: rgba(15, 23, 42, 0.3);
  border: 1px solid rgba(15, 23, 42, 0.1);
  color: inherit;
}
.reaction-badge.user-reacted {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}
.own .reaction-badge.user-reacted {
  background: #0f172a;
  border-color: #0f172a;
  color: var(--accent);
}
.badge {
  background: var(--accent);
  color: var(--text);
  padding: 0px 3px;
  border-radius: 5px;
  font-size: small;
  display: inline-flex;
  align-items: center;
  user-select: none;
}

/* Media Attachments */
.msg-media {
  max-width: 100%;
  border-radius: 8px;
  margin-bottom: 8px;
  display: block;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.1);
}
.msg-file {
  display: inline-block;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  color: inherit;
  text-decoration: underline;
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 13px;
}

/* Inline Media Preview */
.inline-media-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--card);
  border-top: 1px solid var(--border);
}
.inline-media-preview img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.inline-media-preview .file-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--accent);
}
.inline-media-preview .media-info {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inline-media-preview .clear-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Base chat forms logic */
#comment-form {
  padding: 12px 16px;
  max-width: 600px;
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border);
  box-shadow:
    0px 0px 2px rgba(0, 0, 0, 0.08),
    0px 4px 16px rgba(0, 0, 0, 0.08);
}

.chat-footer-wrapper {
  background: var(--bg);
  border-top: 1px solid var(--border);
  box-shadow:
    0px 0px 2px rgba(0, 0, 0, 0.08),
    0px -4px 16px rgba(0, 0, 0, 0.04);
  z-index: 1000;
  max-width: 600px;
  position: relative;
}

#message-form {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Emoji / Sticker Tray */
.emoji-item {
  cursor: pointer;
  padding: 8px;
  transition: transform 0.1s;
  border-radius: 8px;
}
.emoji-item:active {
  transform: scale(1.3);
  background: rgba(0, 0, 0, 0.05);
}
.sticker-pack-icon {
  cursor: pointer;
  font-size: 24px;
  width: fit-content;
  text-align: center;
  padding: 8px 0;
  border-radius: 8px;
  opacity: 0.5;
  transition:
    opacity 0.2s,
    background 0.2s;
}
.sticker-pack-icon.active {
  opacity: 1;
  background: rgba(0, 0, 0, 0.05);
}
.sticker-item {
  width: 100%;
  cursor: pointer;
  transition: transform 0.1s;
}
.sticker-item:active {
  transform: scale(0.9);
}
.emoji-tray-tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition:
    color 0.2s,
    border-bottom 0.2s;
}
.emoji-tray-tab.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}
:root[data-theme="dark"] .emoji-item:active,
:root[data-theme="oled"] .emoji-item:active,
:root[data-theme="dark"] .sticker-pack-icon.active,
:root[data-theme="oled"] .sticker-pack-icon.active {
  background: rgba(255, 255, 255, 0.05);
}

/* Bottom Nav & Badges */
.bottom-nav {
  position: fixed;
  bottom: 0;
  width: 100%;
  height: var(--nav-height);
  background: var(--nav-bg);
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid var(--border);
  box-shadow:
    0px 0px 2px rgba(0, 0, 0, 0.08),
    0px 4px 16px rgba(0, 0, 0, 0.08);
  z-index: 1000;
  max-width: 600px;
}
.nav-item {
  position: relative;
  color: var(--muted);
  font-size: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  width: 50px;
}
.nav-item.active {
  color: var(--accent);
  font-weight: bold;
}
.nav-item span {
  font-size: 10px;
  margin-top: 4px;
  font-weight: 500;
}

.nav-badge {
  position: absolute;
  top: -2px;
  right: 2px;
  background: var(--error);
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 5px;
  border-radius: 10px;
  line-height: 1;
  min-width: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--nav-bg);
}

/* FABs */
.fab {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.4);
  cursor: pointer;
  z-index: 90;
  transition:
    transform 0.2s,
    opacity 0.2s;
}
.fab:active {
  transform: scale(0.95);
}

.chat-fab {
  position: fixed;
  bottom: 85px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: var(--shadow);
  cursor: pointer;
  z-index: 90;
  transition: opacity 0.3s;
}
.chat-fab .nav-badge {
  top: -4px;
  right: -4px;
  box-shadow: 0 0 0 2px var(--card);
}

/* Generic List Items & Unread Badge */
.list-item {
  display: flex;
  align-items: center;
  padding: 16px;
  background: var(--card);
  gap: 16px;
  cursor: pointer;
  transition: background 0.2s;
}
.list-item:active {
  background: var(--border);
}
.list-item.dimmed {
  opacity: 0.6;
}

.list-item:last-child {
  border-bottom-right-radius: 1rem;
  border-bottom-left-radius: 1rem;
}
.list-item:first-child {
  border-top-left-radius: 1rem;
  border-top-right-radius: 1rem;
}
.list-item:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.unread-badge {
  background: var(--error);
  color: #fff;
  border-radius: 12px;
  min-width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  padding: 0 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.avatar-circle {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 20px;
  flex-shrink: 0;
}
.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}
.online-dot {
  width: 14px;
  height: 14px;
  background: var(--success);
  border-radius: 50%;
  border: 3px solid var(--card);
  position: absolute;
  bottom: -2px;
  right: -2px;
}

.item-content {
  flex: 1;
  overflow: hidden;
}
.item-content h4 {
  font-size: 16px;
  margin-bottom: 4px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.item-content p {
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-btn {
  background: var(--accent);
  color: #0f172a;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  height: auto;
  width: auto;
}

input.search-bar {
  width: 100%;
  margin: 0;
  height: 44px;
  border-radius: 12px;
  padding: 0 16px;
  border: 1px solid #334155;
  background: var(--card);
  color: white;
}

/* Custom Modals Overlay */
.app-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.app-modal {
  background: var(--card);
  padding: 24px;
  border-radius: 16px;
  width: 100%;
  max-width: 350px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.app-modal.large-modal {
  max-width: 450px;
}

/* Android-style Bottom Sheet Drawer */
.bottom-sheet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10005;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.bottom-sheet-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.bottom-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1);
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border);
}
.bottom-sheet-overlay.visible .bottom-sheet {
  transform: translateY(0);
}
.bs-handle {
  width: 40px;
  height: 5px;
  background: var(--muted);
  border-radius: 5px;
  margin: 12px auto;
  opacity: 0.5;
}
.bs-content {
  padding: 0 20px 20px;
  max-height: 70vh;
  overflow-y: auto;
}
.bs-item {
  padding: 16px 0;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 16px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
}
.bs-item:last-child {
  border-bottom: none;
}
.bs-item:active {
  background: rgba(255, 255, 255, 0.05);
}
.bs-item i {
  font-size: 22px;
  color: var(--accent);
}
.bs-item.danger {
  color: var(--error);
}
.bs-item.danger i {
  color: var(--error);
}
:root[data-theme="light"] .bs-item:active {
  background: rgba(0, 0, 0, 0.05);
}

/* Select Mode Chat UI */
.chat-select-checkbox {
  display: none;
  width: 22px;
  height: 22px;
  aspect-ratio: 1/1;
  border-radius: 50%;
  border: 2px solid var(--muted);
  margin: auto;
  padding: 0px;
  appearance: none;
  outline: none;
  flex-shrink: 0;
  background: transparent;
  transition: all 0.2s;
}
.chat-select-checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
  position: relative;
}
.chat-select-checkbox:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #0f172a;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.select-mode .chat-select-checkbox {
  display: block;
}
.select-mode .list-item {
  padding-left: 12px;
}
#chats-select-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--nav-bg);
  padding: 12px 20px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1001;
  box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.3);
  transform: translateY(100%);
  transition: transform 0.3s;
  border-top: 1px solid var(--border);
}
#chats-select-bar.visible {
  transform: translateY(0);
}

/* Map View Styles */
.district-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s;
  z-index: 1;
}
.district-node:hover {
  transform: translate(-50%, -50%) scale(1.15);
  z-index: 10;
}
.district-node:active {
  transform: translate(-50%, -50%) scale(0.95);
}
.district-pin {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  border: 2px solid var(--bg);
  transition:
    background 0.3s,
    color 0.3s;
}
.district-name {
  margin-top: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text);
  text-shadow:
    0 1px 3px var(--bg),
    0 -1px 3px var(--bg),
    1px 0 3px var(--bg),
    -1px 0 3px var(--bg);
  white-space: nowrap;
}

/* Sleek Modern Settings UI */
.settings-section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 0 0 10px 16px;
  font-weight: 700;
}

.settings-group {
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
  margin-bottom: 24px;
  overflow: hidden;
}

.settings-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
  transition: background 0.2s;
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-item:active {
  background: rgba(0, 0, 0, 0.03);
}

:root[data-theme="dark"] .settings-item:active,
:root[data-theme="oled"] .settings-item:active {
  background: rgba(255, 255, 255, 0.05);
}

.settings-item .item-icon {
  font-size: 22px;
  color: var(--accent);
  width: 36px;
  display: flex;
  justify-content: flex-start;
}

.settings-item .item-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.settings-item .item-content label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 2px;
  letter-spacing: 0.5px;
}

.settings-input,
.settings-select {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  font-weight: 500;
  padding: 0;
  height: auto;
  width: 100%;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  margin-bottom: 0; /* Override generic input style */
}

.settings-select {
  cursor: pointer;
}

.settings-input::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

.settings-btn {
  width: 100%;
  margin-top: 8px;
}

/* Sleek iOS/Android Toggle Switch */
.toggle-switch {
  position: relative;
  width: 50px;
  height: 30px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(100, 116, 139, 0.3);
  transition: 0.3s;
  border-radius: 34px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* Global Full Screen Loader */
#global-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
  z-index: 9999999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  animation: loaderSpin 0.8s linear infinite;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Typing Indicator Animation */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  animation: fadeIn 0.3s forwards;
}
.typing-dots span {
  display: inline-block;
  width: 4px;
  height: 4px;
  background-color: var(--muted);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite both;
}
.typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}
.typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
}
@keyframes typingBounce {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Map Interactivity: Active Pulse */
@keyframes pulseRing {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}
.pulse-active {
  animation: pulseRing 2s infinite;
}

/* Map Event Pins */
.district-event-pin {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  background: var(--danger);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transform: rotate(-45deg);
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.4);
}
.district-event-pin i {
  transform: rotate(45deg);
}
.event-title {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--danger);
  white-space: nowrap;
  background: var(--card);
  padding: 2px 6px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Intelligent Search Headers */
.search-section-header {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 700;
  padding: 16px 16px 8px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Gallery View & Navigation */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 16px 0;
}
.gallery-item {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.1);
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}
.gallery-item:active img {
  transform: scale(0.95);
}
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-size: 48px;
  cursor: pointer;
  z-index: 100000;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.nav-arrow:active {
  background: rgba(255, 255, 255, 0.2);
}
.nav-arrow.left {
  left: 20px;
}
.nav-arrow.right {
  right: 20px;
}

/* ═══════════════════════════════════════════════════════════════ */
/* Notification Items                               */
/* ═══════════════════════════════════════════════════════════════ */

.notification-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--card);
  transition: background 0.2s ease;
  cursor: pointer;
  text-decoration: none;
}

.notification-item:last-child {
  border-bottom-right-radius: 1rem;
  border-bottom-left-radius: 1rem;
}
.notification-item:first-child {
  border-top-left-radius: 1rem;
  border-top-right-radius: 1rem;
}
.notification-item:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.notification-item:hover {
  background: var(--border);
}

.notification-item.unread {
  background: rgba(45, 212, 191, 0.08); /* Light tint of your --accent color */
}

.notification-avatar-wrapper {
  position: relative;
  flex-shrink: 0;
  margin-right: 16px;
}

.notification-avatar {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 20px;
  flex-shrink: 0;
}

.notification-action-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 14px;
  border: 3px solid var(--card); /* Creates the cutout effect over the avatar */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.notification-content {
  flex: 1;
  min-width: 0; /* Prevents text from breaking flexbox bounds */
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.notification-text {
  font-size: 15px;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  line-clamp: 3;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-text strong {
  font-weight: 700;
  color: var(--text);
}

.notification-time {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
}

.notification-unread-dot {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--accent);
  margin-left: 12px;
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.2); /* Soft glow around the dot */
}

/* Universal Loading & Empty States for Lists */

/* Empty States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 250px;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}
.empty-state i {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.empty-state p {
  font-size: 15px;
  max-width: 250px;
}

.app-loading-state,
.app-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: var(--muted);
  text-align: center;
  padding: 20px;
  width: 100%;
}

.app-empty-state i {
  font-size: 48px;
  color: var(--border);
  margin-bottom: 12px;
}

.app-empty-state h3 {
  font-size: 16px;
  color: var(--text);
  margin-bottom: 6px;
  font-weight: 600;
}

.app-loading-state .spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: loaderSpin 1s linear infinite;
  margin-bottom: 12px;
}

@keyframes loaderSpin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   MCHEZO ENHANCED POST UI & STREAM SYSTEM
   ========================================================================== */

.post-card-item {
  background: var(--card);
  padding: 16px;
  position: relative;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease;
  cursor: pointer;
}

.post-card-item:last-child {
  border-bottom-right-radius: 1rem;
  border-bottom-left-radius: 1rem;
}
.post-card-item:first-child {
  border-top-left-radius: 1rem;
  border-top-right-radius: 1rem;
}
.post-card-item:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.post-card-item:hover {
  background: rgba(0, 0, 0, 0.02);
}
:root[data-theme="dark"] .post-card-item:hover,
:root[data-theme="oled"] .post-card-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.post-card-item.main-thread-post {
  cursor: default;
  background: var(--bg);
}
.post-card-item.main-thread-post:hover {
  background: var(--bg);
}

.post-header-track {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.repost-indicator {
  margin-bottom: 12px;
}

.post-footer-actions .post-action-btn,
.post-header-track > :last-child {
  max-width: fit-content;
}

.post-author-info {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.post-author-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 4px;
}

.post-author-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.post-options-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  border-radius: 5px;
  display: flex;
  transition:
    background 0.2s,
    color 0.2s;
}
.post-options-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}
:root[data-theme="dark"] .post-options-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.post-body-content {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  margin-bottom: 12px;
  word-break: break-word;
  white-space: pre-wrap;
}

.bubble a,
.post-body-content a {
  text-decoration: none;
  color: var(--accent);
}
.message.own .bubble a,
.post-body-content a {
  text-decoration: none;
  color: #ffffff;
}

/* --- Native Interactive Elements (Polls, Events, Embeds) --- */

/* Events */
.post-event-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.post-event-cover {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.post-event-body {
  padding: 14px;
  display: flex;
  gap: 14px;
  align-items: center;
}
.event-icon-box {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  background: var(--secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}
.event-action-bar {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.event-action-bar button {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: 0.2s;
  border-radius: 0;
}
.event-action-bar button:last-child {
  border-right: none;
}
.event-action-bar button:hover {
  background: rgba(0, 0, 0, 0.03);
}
.event-action-bar button.active {
  color: var(--accent);
  background: rgba(45, 212, 191, 0.05);
  border-bottom: 2px solid var(--accent);
}

/* Polls */
.post-poll-card {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
:root[data-theme="dark"] .post-poll-card {
  background: rgba(255, 255, 255, 0.02);
}

.poll-choice-row {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 13px;
  transition: border-color 0.2s;
  background: var(--card);
}
.poll-choice-row:hover:not(.ended) {
  border-color: var(--accent);
}
.poll-choice-row.user-voted {
  border-color: var(--accent);
}
.poll-choice-row.user-voted .poll-choice-text {
  color: var(--accent);
}

.poll-fill-track {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: rgba(45, 212, 191, 0.15);
  z-index: 1;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.poll-choice-text,
.poll-choice-metrics {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
}
.poll-opt-img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
}
.poll-ended-badge {
  background: var(--error);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: bold;
  margin-left: 8px;
}

/* Quotes */
.embedded-quote-container {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  margin-top: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.quote-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.quote-author {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.quote-time {
  font-size: 12px;
  color: var(--muted);
}
.quote-body-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
}

/* Media */
.post-media-box {
  margin-top: 12px;
  margin-bottom: 12px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  display: flex;
  justify-content: center;
}
.native-media-player {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
}
.audio-container {
  background: transparent !important;
  padding: 4px 0;
}
.native-audio-player {
  width: 100%;
}

/* --- Action Bar & FB Reactions --- */
.post-footer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 8px;
}
.fb-reaction-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.fb-popover-tray {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 30px;
  padding: 6px 12px;
  display: flex;
  gap: 12px;
  z-index: 110;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    transform 0.2s,
    opacity 0.2s ease;
}
.fb-reaction-wrapper:hover .fb-popover-tray,
.fb-popover-tray:hover {
  transform: translateY(-8px);
  opacity: 1;
  pointer-events: auto;
}
.fb-reaction-icon {
  font-size: 24px;
  cursor: pointer;
  transition: transform 0.15s ease;
  user-select: none;
}
.fb-reaction-icon:hover {
  transform: scale(1.3) translateY(-4px);
}

.post-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 20px;
  transition:
    background 0.2s,
    color 0.2s;
  height: fit-content;
  width: fit-content;
}
.post-action-btn:hover {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text);
}
:root[data-theme="dark"] .post-action-btn:hover {
  background: rgba(255, 255, 255, 0.04);
}
.post-action-btn:active {
  transform: scale(0.96);
}
.post-action-btn.active-reaction {
  color: var(--accent);
  background: rgba(45, 212, 191, 0.05);
}

/* Multi-image grid for posts */
.post-media-box.multi-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(48%, 1fr));
  gap: 4px;
  background: transparent;
}
.post-media-box.multi-image-grid .native-media-player {
  width: 100%;
  max-height: 250px;
  object-fit: cover;
  border-radius: 8px;
}

/* Enhancements for composer preview clear buttons */
.composer-preview-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.2s;
}
.composer-preview-close:active {
  transform: scale(0.9);
}

/* --- Composer UI --- */
.composer-tabs-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
  overflow-y: hidden;
  margin-bottom: 8px;
}
.composer-type-btn {
  max-width: fit-content;
  background: transparent;
  border: none;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-radius: 0px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin: auto;
  transition: background 0.2s;
}
.composer-type-btn.active {
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
}

.poll-image-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 0 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
  font-size: 18px;
  width: 50px;
  height: 50px;
  position: relative;
}
.poll-image-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poll-image-btn.has-img {
  background: var(--accent);
  color: #0f172a;
  border-color: var(--accent);
}

/* --- Layouts --- */
.thread-divider-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 18px 16px 8px 16px;
}

/* Composer App-like File Uploads */
.composer-file-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s;
  text-align: center;
}
.composer-file-upload:active {
  background: rgba(0, 0, 0, 0.02);
  border-color: var(--accent);
}
:root[data-theme="dark"] .composer-file-upload:active,
:root[data-theme="oled"] .composer-file-upload:active {
  background: rgba(255, 255, 255, 0.02);
}
.composer-upload-icon {
  font-size: 32px;
  color: var(--accent);
  margin-bottom: 8px;
}
.composer-upload-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

/* App-like Inputs for Composer */
.composer-input-app {
  border: none;
  border-bottom: 2px solid var(--border);
  border-radius: 0;
  background: transparent;
  padding: 12px 0;
  font-size: 16px;
  color: var(--text);
  transition: border-color 0.2s;
}
.composer-input-app:focus {
  border-color: var(--accent);
  outline: none;
}
.composer-input-app::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

/* Parent Post Bar in Thread */
.parent-post-bar {
  background: var(--bg);
  padding: 12px 16px;
  border-bottom: 4px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.parent-post-bar:active {
  background: var(--border);
}
.parent-post-bar-icon {
  color: var(--muted);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.parent-post-bar-content {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
  color: var(--muted);
}
.parent-post-bar-content strong {
  color: var(--text);
}

/* Feed Tabs -> Pills */
.feed-sub-tabs {
  border-bottom: none !important;
  padding: 16px;
  height: fit-content;
  gap: 8px;
  overflow-x: auto;
  align-items: center;
}
.feed-sub-tabs .tab-btn {
  border-bottom: none !important;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  height: 36px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.feed-sub-tabs .tab-btn.active {
  background: var(--accent);
  color: #0f172a;
  border-color: var(--accent);
}
:root[data-theme="light"] .feed-sub-tabs .tab-btn.active {
  color: #ffffff;
}

/* Mobile Long-Press Reaction Tray override */
.fb-popover-tray.force-show {
  transform: translateY(-8px);
  opacity: 1;
  pointer-events: auto;
}

/* Inline Upload Progress Bars */
.inline-upload-progress {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 16px;
  background: var(--bg);
  min-height: 68px; /* Matches standard form height */
  gap: 8px;
  width: 100%;
  max-width: 600px;
  border-top: 1px solid var(--border);
  box-shadow:
    0px 0px 2px rgba(0, 0, 0, 0.08),
    0px 4px 16px rgba(0, 0, 0, 0.08);
}
.inline-upload-progress.composer-mode {
  border-top: none;
  box-shadow: none;
  background: transparent;
  padding: 20px 16px;
  min-height: 100px;
}
.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  overflow: hidden;
}
:root[data-theme="dark"] .progress-track,
:root[data-theme="oled"] .progress-track {
  background: rgba(255, 255, 255, 0.08);
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  border-radius: 4px;
  transition: width 0.15s ease-out;
}
.progress-status {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

/* Store & Mchezo+ specific styles */
.sticker-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}
.sticker-card:active {
  transform: scale(0.96);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}
.sticker-card-icon {
  font-size: 54px;
  line-height: 1;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}
.sticker-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.sticker-card-price {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 16px;
}
.sticker-card-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background: linear-gradient(135deg, #f59e0b, #fb923c);
  color: white;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.4);
  border: 2px solid var(--card);
  z-index: 2;
}

@keyframes tourBounce {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-10px);
  }
}
