: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-base: 14px;
}
:root[data-font-size="small"] {
  --font-base: 12px;
}
:root[data-font-size="large"] {
  --font-base: 16px;
}
body {
  font-size: var(--font-base);
}

* {
  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;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    sans-serif;
  line-height: 1.5;
  font-size: var(--font-base);
  overflow: hidden;
  transition:
    background 0.3s,
    color 0.3s;
  margin: auto;
}

.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: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--nav-height);
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.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;
}

.scrollable-list {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

/* Tabs UI */
.tabs-container {
  display: flex;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 64px;
  z-index: 90;
  overflow-x: auto;
}
.tab-btn {
  flex: 1;
  text-align: center;
  padding: 14px 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
  position: relative;
}
.tab-btn.active {
  color: var(--accent);
  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%;
}

/* 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;
}

/* =========================================
   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: 100%;
  height: 52px;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 0.1s,
    opacity 0.2s;
}
form button {
  margin-top: 1rem;
}
.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;
}
.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: 1;
  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);
}

/* 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;
  -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-title-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-left: 12px;
  overflow: hidden;
}
#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);
}

/* 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;
}

#message-form {
  padding: 12px 16px;
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border);
}
#message-input {
  flex: 1;
  margin-bottom: 0;
  height: 44px;
  border-radius: 22px;
  background: var(--card);
  border: 1px solid var(--border);
}
#send-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  background: transparent;
  color: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: auto!important;
}
#send-btn:active {
  background: rgba(56, 189, 248, 0.1);
}

/* 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);
  z-index: 1000;
}
.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);
}
.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: .3s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .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(--success);
}

.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);
}

@keyframes loaderSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


/* 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; }