/* ============================================================
  EduSmartUp Developer Community
   Professional Design System v2.0
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
  /* Brand */
  --primary:      #1e40af;
  --primary-dk:   #1e3a8a;
  --primary-lt:   #dbeafe;
  --primary-xs:   #eff6ff;
  --secondary:    #7c3aed;
  --accent:       #0ea5e9;

  /* Semantic */
  --success:      #059669;
  --success-lt:   #d1fae5;
  --danger:       #dc2626;
  --danger-lt:    #fee2e2;
  --warning:      #d97706;
  --warning-lt:   #fef3c7;
  --info:         #0284c7;
  --info-lt:      #e0f2fe;

  /* Neutral */
  --bg:           #f1f5f9;
  --bg-2:         #e2e8f0;
  --surface:      #ffffff;
  --border:       #e2e8f0;
  --border-dk:    #cbd5e1;
  --text:         #0f172a;
  --text-2:       #334155;
  --text-muted:   #64748b;
  --text-light:   #94a3b8;

  /* Radii */
  --radius:       14px;
  --radius-sm:    9px;
  --radius-xs:    6px;
  --radius-full:  999px;

  /* Shadows */
  --shadow-xs:    0 1px 2px rgba(0,0,0,.05);
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:    0 4px 12px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:    0 12px 28px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);

  /* Layout */
  --nav-h:        62px;
  --header-h:     56px;
  --header-top-gap: 6px;
  --chat-vv-height: 100dvh;
  --chat-vv-top: 0px;
  --chat-lock-top: 0px;

  /* Transitions */
  --t-fast:       .12s ease;
  --t-base:       .2s ease;
  --t-slow:       .3s ease;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  font-size: 16px;
  scroll-behavior: smooth;
}
html.chat-room-active {
  height: 100%;
  overflow: hidden;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto,
               Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.chat-room-active {
  position: fixed;
  top: var(--chat-lock-top);
  left: 0;
  right: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
input, textarea, select, button { font-family: inherit; }
button { cursor: pointer; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dk); border-radius: 2px; }

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted   { color: var(--text-muted); }
.text-light   { color: var(--text-light); }
.text-sm      { font-size: .8125rem; }
.text-xs      { font-size: .75rem; }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-center  { text-align: center; }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.mt-4         { margin-top: 4px; }
.mt-8         { margin-top: 8px; }
.mt-12        { margin-top: 12px; }
.mt-16        { margin-top: 16px; }
.mt-24        { margin-top: 24px; }
.mb-16        { margin-bottom: 16px; }
.hidden       { display: none !important; }
.flex         { display: flex; }
.flex-1       { flex: 1; }
.items-center { align-items: center; }
.gap-8        { gap: 8px; }

/* ============================================================
   OFFLINE BANNER
   ============================================================ */
#offline-banner {
  display: none;
  background: var(--warning);
  color: white;
  text-align: center;
  font-size: .8125rem;
  font-weight: 600;
  padding: 8px 16px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10000;
  letter-spacing: .01em;
}
#offline-banner.show { display: block; }

/* ============================================================
   AUTH SCREEN
   ============================================================ */
#auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background:
    linear-gradient(rgba(15, 23, 42, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, .035) 1px, transparent 1px),
    #f8fafc;
  background-size: 28px 28px;
  padding: 28px 16px 40px;
  position: relative;
  overflow: hidden;
}
#auth-screen::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 210px;
  background: linear-gradient(135deg, #0f172a 0%, #0f766e 58%, #2563eb 100%);
  pointer-events: none;
}
#auth-screen::after {
  display: none;
}

.auth-logo {
  text-align: center;
  color: white;
  margin-bottom: 28px;
  padding-top: 20px;
  position: relative;
  z-index: 1;
}
.auth-logo .logo-icon {
  width: 58px;
  height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 16px;
  background: rgba(255,255,255,.12);
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0;
}
.auth-logo-img {
  width: 74px;
  height: 74px;
  display: block;
  object-fit: cover;
  margin: 0 auto 12px;
  border: 2px solid rgba(255,255,255,.42);
  border-radius: 18px;
  background: white;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
}
.auth-logo h1 { font-size: 1.625rem; font-weight: 800; letter-spacing: 0; }
.auth-logo p  { font-size: .9rem; opacity: .7; margin-top: 3px; }

.auth-tabs {
  display: flex;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 20px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow);
}
.auth-tab {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 600;
  transition: all var(--t-base);
}
.auth-tab.active {
  background: #0f172a;
  color: white;
  box-shadow: var(--shadow);
}

.auth-card {
  background: white;
  border-radius: var(--radius);
  padding: 26px 24px;
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 48px rgba(15,23,42,.14);
  position: relative;
  z-index: 1;
}
.auth-card h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.auth-card > div > p { color: var(--text-muted); font-size: .875rem; margin-bottom: 20px; }
.auth-panel { display: none; }
.auth-panel.active { display: block; }

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text-2);
  letter-spacing: .01em;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.input, select.input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9375rem;
  background: white;
  color: var(--text);
  transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
  -webkit-appearance: none;
  appearance: none;
}
.input:focus, select.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,64,175,.12);
  background: #fafcff;
}
.input:disabled { background: var(--bg); color: var(--text-muted); cursor: not-allowed; }
textarea.input { resize: vertical; min-height: 90px; }
select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* Input with icon */
.input-wrap { position: relative; }
.input-wrap .input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: .9rem; pointer-events: none; }
.input-wrap.has-icon .input { padding-left: 36px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font-size: .9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-base);
  -webkit-user-select: none;
  user-select: none;
  white-space: nowrap;
  letter-spacing: .01em;
}
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn:active { transform: scale(.97); }

.btn-primary  { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover  { background: var(--primary-dk); border-color: var(--primary-dk); box-shadow: 0 4px 12px rgba(30,64,175,.25); }
.btn-outline  { background: white; border-color: var(--border-dk); color: var(--text-2); }
.btn-outline:hover  { border-color: var(--primary); color: var(--primary); background: var(--primary-xs); }
.btn-ghost    { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover    { background: var(--bg); color: var(--text); }
.btn-success  { background: var(--success); color: white; border-color: var(--success); }
.btn-success:hover  { background: #047857; }
.btn-danger   { background: var(--danger);  color: white; border-color: var(--danger); }
.btn-danger:hover   { background: #b91c1c; }
.btn-warning  { background: var(--warning); color: white; border-color: var(--warning); }
.btn-full     { width: 100%; }
.btn-sm       { padding: 7px 13px; font-size: .8125rem; border-radius: var(--radius-xs); }
.btn-xs       { padding: 4px 10px; font-size: .75rem; border-radius: var(--radius-xs); }
.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .875rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  transition: background var(--t-fast), color var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-icon:hover { background: var(--bg); color: var(--text-2); }
.btn-icon.danger:hover { background: var(--danger-lt); color: var(--danger); }
.btn-icon.active { color: var(--primary); }

/* ============================================================
   MAIN APP LAYOUT
   ============================================================ */
#main-app { display: none; flex-direction: column; height: 100vh; height: 100dvh; }

/* Top header */
.app-header {
  height: calc(var(--header-h) + var(--header-top-gap) + env(safe-area-inset-top, 0px));
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  padding: calc(var(--header-top-gap) + env(safe-area-inset-top, 0px)) 12px 0 14px;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  flex-shrink: 0;
  overflow: hidden;
}
.header-logo {
  flex: 1;
  min-width: 0;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0;
  line-height: 1.05;
  display: flex;
  flex-direction: column;
}
.header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}
.header-brand-logo {
  width: 30px;
  height: 30px;
  object-fit: cover;
  border-radius: 8px;
  background: white;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.header-title-text {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-logo .header-subtitle {
  display: block;
  min-width: 0;
  font-size: .68rem;
  font-weight: 400;
  opacity: .7;
  margin-top: 2px;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.header-icon-btn {
  background: rgba(255,255,255,.14);
  border: none;
  color: white;
  width: 38px; height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background var(--t-base);
  font-size: 1.1rem;
}
.header-icon-btn:hover { background: rgba(255,255,255,.24); }

.notif-badge {
  position: absolute;
  top: -2px; right: -2px;
  background: var(--danger);
  color: white;
  font-size: .6rem;
  min-width: 16px; height: 16px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  padding: 0 3px;
  border: 1.5px solid var(--primary);
}

.header-avatar-btn {
  background: rgba(255,255,255,.18);
  border: none;
  border-radius: 50%;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 700;
  font-size: .875rem;
  cursor: pointer;
  transition: background var(--t-base);
  flex-shrink: 0;
  overflow: hidden;
}
.header-avatar-btn:hover { background: rgba(255,255,255,.3); }
.header-avatar-btn img { width: 34px; height: 34px; object-fit: cover; border-radius: 50%; }

@media (max-width: 420px) {
  :root { --header-h: 54px; }
  .app-header {
    padding-left: 12px;
    padding-right: 10px;
    gap: 6px;
  }
  .header-logo { font-size: .98rem; }
  .header-brand-logo {
    width: 27px;
    height: 27px;
    border-radius: 7px;
  }
  .header-logo .header-subtitle { font-size: .62rem; }
  .header-icon-btn {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  .header-avatar-btn {
    width: 32px;
    height: 32px;
    font-size: .78rem;
  }
  .header-avatar-btn img {
    width: 32px;
    height: 32px;
  }
}

@media (max-width: 340px) {
  .header-logo .header-subtitle { display: none; }
  .header-logo { font-size: .94rem; }
  .header-brand-logo {
    width: 25px;
    height: 25px;
  }
  .app-header { align-items: center; }
}

/* Pages container */
.pages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(var(--nav-h) + 16px);
}

/* Individual pages */
.page { display: none; padding: 14px 14px 4px; animation: pageFadeIn .2s ease; }
.page.active { display: block; }
@keyframes pageFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.page-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-top: 2px;
}
.page-title-bar h2 { font-size: 1.2rem; font-weight: 800; letter-spacing: -.02em; color: var(--text); }

/* Welcome bar */
.welcome-bar {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-md);
}
.welcome-avatar { width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; font-weight: 700; flex-shrink: 0; overflow: hidden; }
.welcome-avatar img { width: 100%; height: 100%; object-fit: cover; }
.welcome-text h3 { font-size: 1rem; font-weight: 700; }
.welcome-text p  { font-size: .8125rem; opacity: .8; margin-top: 2px; }

/* Bottom navigation */
.bottom-nav {
  height: var(--nav-h);
  background: white;
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  z-index: 200;
  box-shadow: 0 -2px 16px rgba(0,0,0,.06);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-item {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: .6rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 2px;
  transition: color var(--t-base);
  text-transform: uppercase;
  letter-spacing: .04em;
  position: relative;
  overflow: hidden;
}
.nav-item .nav-icon { font-size: 1.25rem; line-height: 1; transition: transform var(--t-base); }
.nav-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.1;
}
.nav-item.active { color: var(--primary); }
.nav-item.active .nav-icon { transform: scale(1.15); }
.nav-item::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 2px;
  background: var(--primary);
  border-radius: 0 0 2px 2px;
  transform: scaleX(0);
  transition: transform var(--t-base);
}
.nav-item.active::before { transform: scaleX(1); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 15px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  transition: box-shadow var(--t-base), transform var(--t-fast);
}
.card:last-child { margin-bottom: 0; }
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* ============================================================
   POST CARDS
   ============================================================ */
.post-card { position: relative; overflow: hidden; }  /* overflow:hidden for bleed-edge media grid */
.post-card.pinned { border-left: 3px solid var(--primary); }

/* ── Feed Photo Grid ─────────────────────────────────────────── */
.post-media-grid {
  display: grid;
  gap: 2px;
  margin: 10px -15px 0;   /* bleed to card edges */
}
/* single image – wide landscape */
.post-media-1 { grid-template-columns: 1fr; }
.post-media-1 .post-media-cell { aspect-ratio: 16/9; max-height: 420px; }
/* two images – side by side */
.post-media-2 { grid-template-columns: 1fr 1fr; }
.post-media-2 .post-media-cell { aspect-ratio: 1/1; }
/* three images – hero top + two below */
.post-media-3 { grid-template-columns: 1fr 1fr; }
.post-media-3 .post-media-cell:first-child { grid-column: 1/-1; aspect-ratio: 16/9; }
.post-media-3 .post-media-cell:not(:first-child) { aspect-ratio: 1/1; }
/* four images – 2×2 */
.post-media-4 { grid-template-columns: 1fr 1fr; }
.post-media-4 .post-media-cell { aspect-ratio: 1/1; }

.post-media-cell {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: #0d1117;
}
.post-media-img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .3s ease, opacity .2s;
  opacity: 1;
}
.post-media-cell:active .post-media-img { transform: scale(1.04); }
.post-media-more {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.58);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.1rem; font-weight: 700; color: #fff;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  pointer-events: none;
}

/* ── Feed Doc Chips ──────────────────────────────────────────── */
.post-doc-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0 2px;
}
.post-doc-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--primary-xs);
  border: 1px solid var(--primary-lt);
  border-radius: var(--radius-xs);
  text-decoration: none;
  transition: background var(--t-fast);
}
button.post-doc-chip {
  width: 100%;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.post-doc-chip:hover { background: var(--primary-lt); }
.post-doc-chip-icon { font-size: 1.75rem; flex-shrink: 0; line-height: 1; }
.post-doc-chip-info { flex: 1; min-width: 0; }
.post-doc-chip-name {
  font-size: .82rem; font-weight: 600; color: var(--primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.post-doc-chip-meta { font-size: .7rem; color: var(--text-muted); margin-top: 1px; }
.post-doc-chip-dl   { font-size: 1rem; color: var(--primary); flex-shrink: 0; opacity: .8; }

/* ── Feed Image Lightbox ─────────────────────────────────────── */
.feed-lightbox {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.93);
  display: flex; align-items: center; justify-content: center;
}
.feed-lightbox-inner {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  max-width: 96vw;
}
.feed-lightbox-img {
  max-width: 96vw; max-height: 82vh;
  object-fit: contain;
  border-radius: 6px;
  display: block;
  -webkit-user-select: none;
  user-select: none;
}
.feed-lightbox-close {
  position: absolute; top: -46px; right: 0;
  background: rgba(255,255,255,.14); border: none;
  color: #fff; font-size: 1.2rem;
  width: 36px; height: 36px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.feed-lightbox-close:hover { background: rgba(255,255,255,.3); }
.feed-lightbox-nav {
  display: flex; align-items: center; gap: 16px; margin-top: 10px;
}
.feed-lightbox-prev,
.feed-lightbox-next {
  background: rgba(255,255,255,.14); border: none;
  color: #fff; font-size: 1.6rem;
  width: 44px; height: 44px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s; line-height: 1;
}
.feed-lightbox-prev:hover,
.feed-lightbox-next:hover { background: rgba(255,255,255,.28); }
.feed-lightbox-counter {
  color: rgba(255,255,255,.8); font-size: .88rem;
  min-width: 52px; text-align: center;
}
.feed-lightbox-name {
  color: rgba(255,255,255,.42); font-size: .74rem; margin-top: 7px;
  max-width: 90vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Emoji Reaction Picker (shared: feed + chat) ─────────────── */
.react-picker {
  position: fixed;
  background: #fff;
  border-radius: 9999px;
  box-shadow: 0 6px 28px rgba(0,0,0,.22), 0 1px 4px rgba(0,0,0,.10);
  padding: 7px 12px;
  display: flex; gap: 6px;
  z-index: 10000;
  animation: react-picker-pop .14s cubic-bezier(.34,1.56,.64,1);
}
@keyframes react-picker-pop {
  from { transform: scale(.55); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.react-picker-emoji {
  font-size: 1.55rem; cursor: pointer;
  transition: transform .13s;
  line-height: 1; border-radius: 50%;
  -webkit-user-select: none; user-select: none; display: inline-flex; align-items: center;
}
.react-picker-emoji:hover { transform: scale(1.45); }
.react-picker-emoji.active {
  transform: scale(1.2);
  filter: drop-shadow(0 0 4px rgba(59,130,246,.7));
}

/* ── Feed post reaction pills ─────────────────────────────────── */
.post-reactions {
  display: flex; flex-wrap: wrap; gap: 5px;
  margin: 6px 0 2px;
  min-height: 0;
}
.post-react-btn.reacted { color: var(--primary); font-weight: 700; }

/* ── Shared reaction pill ─────────────────────────────────────── */
.reaction-pill {
  display: inline-flex; align-items: center; gap: 3px;
  background: #f1f5f9; border: 1.5px solid #e2e8f0;
  border-radius: 9999px; padding: 3px 9px;
  font-size: .82rem; font-weight: 600; cursor: pointer;
  transition: background .12s, border-color .12s; -webkit-user-select: none; user-select: none;
}
.reaction-pill.mine { background: #eff6ff; border-color: #3b82f6; color: #1d4ed8; }
.reaction-pill:hover { background: #e2e8f0; }
.reaction-pill.mine:hover { background: #dbeafe; }
.reaction-pill-emoji { font-size: .95rem; }
.reaction-pill-count { font-size: .76rem; }

/* ── Chat bubble column (bubble + reactions stacked) ──────────── */
.chat-bubble-col {
  display: flex; flex-direction: column; align-items: flex-start;
  max-width: min(78vw, 520px);
  min-width: 0;
}
.msg-mine .chat-bubble-col { align-items: flex-end; }

/* ── Chat message reaction pills ─────────────────────────────── */
.msg-reactions {
  display: flex; flex-wrap: wrap; gap: 3px;
  margin-top: 3px; max-width: 78vw;
}

/* ── Reaction button on each message (appears on hover) ──────── */
.chat-msg-react-btn {
  opacity: 0; visibility: hidden;
  background: none; border: none;
  font-size: .97rem; cursor: pointer;
  padding: 3px 5px; border-radius: 50%;
  flex-shrink: 0; align-self: flex-end; margin-bottom: 2px;
  transition: opacity .15s, background .12s;
  line-height: 1;
}
.chat-msg-row:hover .chat-msg-react-btn { opacity: 1; visibility: visible; }
.chat-msg-react-btn:hover { background: rgba(0,0,0,.07); }
@media (hover: none) {
  .chat-msg-react-btn {
    opacity: .72;
    visibility: visible;
  }
}
.pin-badge { font-size: .7rem; color: var(--primary); font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 4px; }

.post-header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.post-meta { flex: 1; min-width: 0; }
.post-author {
  font-weight: 700;
  font-size: .875rem;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  color: var(--text);
}
.post-time { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }
.post-title  { font-size: .9375rem; font-weight: 700; margin-bottom: 6px; color: var(--text); line-height: 1.4; }
.post-content { font-size: .875rem; color: var(--text-2); line-height: 1.65; word-break: break-word; }
.post-footer {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.post-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--primary-xs);
  border: 1px solid var(--primary-lt);
  border-radius: var(--radius-xs);
  padding: 5px 10px;
  font-size: .78rem;
  color: var(--primary);
  font-weight: 600;
  transition: background var(--t-fast);
}
.file-chip:hover { background: var(--primary-lt); text-decoration: none; }
.file-size { color: var(--text-muted); font-size: .7rem; font-weight: 400; }

.category-tag {
  font-size: .66rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
  flex-shrink: 0;
}
.cat-general     { background: #f1f5f9; color: #475569; }
.cat-research    { background: #dbeafe; color: #1d4ed8; }
.cat-coursework  { background: #dcfce7; color: #15803d; }
.cat-resource    { background: #fef9c3; color: #854d0e; }
.cat-discussion  { background: #fce7f3; color: #9d174d; }

/* Comments */
.comments-section { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.comment-item { display: flex; gap: 9px; margin-bottom: 10px; }
.comment-body {
  flex: 1;
  background: var(--bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) var(--radius-sm);
  padding: 8px 11px;
}
.comment-author { font-weight: 700; font-size: .8125rem; margin-right: 6px; color: var(--text); }
.comment-time   { font-size: .7rem; color: var(--text-muted); }
.comment-text   { font-size: .875rem; margin-top: 3px; color: var(--text-2); word-break: break-word; }
.comment-form   { margin-top: 10px; display: flex; gap: 8px; align-items: flex-end; }
.comment-form .input { flex: 1; }

/* ============================================================
   ANNOUNCEMENT CARDS
   ============================================================ */
.ann-card { border-left: 3px solid var(--border-dk); }
.ann-header { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
.ann-title  { font-size: .9375rem; font-weight: 700; margin-bottom: 7px; color: var(--text); }
.ann-body   { font-size: .875rem; line-height: 1.65; color: var(--text-2); word-break: break-word; }
.ann-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 6px;
}

.ann-type-badge {
  display: inline-block;
  font-size: .66rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.type-exam      { background: #fee2e2; color: #991b1b; }
.type-seminar   { background: #ede9fe; color: #5b21b6; }
.type-deadline  { background: #fef3c7; color: #92400e; }
.type-event     { background: #d1fae5; color: #065f46; }
.type-general   { background: #f1f5f9; color: #334155; }

.priority-border-urgent { border-left-color: var(--danger) !important; }
.priority-border-high   { border-left-color: var(--warning) !important; }
.priority-border-medium { border-left-color: var(--primary) !important; }
.priority-border-low    { border-left-color: var(--success) !important; }

.priority-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-urgent { background: var(--danger); }
.dot-high   { background: var(--warning); }
.dot-medium { background: var(--primary); }
.dot-low    { background: var(--success); }

.expires-badge { font-size: .72rem; background: var(--warning-lt); color: #92400e; padding: 3px 9px; border-radius: var(--radius-full); font-weight: 600; }

/* ============================================================
   RESOURCES
   ============================================================ */
.resource-card { display: flex; gap: 14px; align-items: flex-start; }
.resource-icon { font-size: 2.2rem; flex-shrink: 0; width: 44px; text-align: center; line-height: 1; }
.resource-info { flex: 1; min-width: 0; }
.resource-info h4 { font-size: .9375rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.resource-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; align-items: center; }
.resource-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.res-type-badge {
  font-size: .66rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  letter-spacing: .04em;
  background: var(--primary-lt);
  color: var(--primary);
}

/* ============================================================
   MEMBERS
   ============================================================ */
.member-card { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.member-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.member-avatar { flex-shrink: 0; }
.member-info { flex: 1; min-width: 0; }
.member-name { font-weight: 700; font-size: .9rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.member-dept { font-size: .8rem; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   PROFILE
   ============================================================ */
.profile-header-view {
  text-align: center;
  padding: 24px 16px 20px;
  background: linear-gradient(135deg, var(--primary-xs), white);
  border-radius: var(--radius);
  border: 1px solid var(--primary-lt);
  margin-bottom: 14px;
}
.profile-header-view h2 { font-size: 1.2rem; font-weight: 800; margin: 11px 0 5px; letter-spacing: -.02em; }
.profile-name-row { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.profile-details { background: white; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.detail-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 11px 15px;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
  transition: background var(--t-fast);
}
.detail-row:last-child { border-bottom: none; }
.detail-row:hover { background: var(--bg); }
.detail-row > span:first-child { min-width: 105px; color: var(--text-muted); font-size: .8125rem; font-weight: 500; flex-shrink: 0; }
.detail-row > span:last-child  { font-weight: 500; flex: 1; word-break: break-word; color: var(--text); }
.profile-bio { background: white; border-radius: var(--radius); padding: 14px 15px; border: 1px solid var(--border); }
.profile-bio strong { font-size: .8125rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: 5px; }
.profile-bio p { font-size: .9rem; color: var(--text-2); line-height: 1.6; }

/* ============================================================
   AVATARS
   ============================================================ */
.avatar-wrap { position: relative; flex-shrink: 0; }
.avatar-initials {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .875rem; color: white;
  flex-shrink: 0;
}
.avatar-wrap.sm .avatar-initials { width: 30px; height: 30px; font-size: .7rem; }
.avatar-img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.profile-avatar-lg { position: relative; display: inline-block; cursor: pointer; }
.profile-avatar-lg .avatar-initials { width: 88px; height: 88px; font-size: 1.75rem; margin: 0 auto; }
.profile-avatar-lg .avatar-img      { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; border: 3px solid white; box-shadow: var(--shadow-md); }
.avatar-edit-hint {
  position: absolute;
  bottom: 0; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.65);
  color: white;
  font-size: .6rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  letter-spacing: .04em;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  font-size: .62rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-admin   { background: #fee2e2; color: #991b1b; }
.badge-lead    { background: #ede9fe; color: #5b21b6; }
.badge-student { background: #dbeafe; color: #1e40af; }

/* ============================================================
   ADMIN PANEL
   ============================================================ */
.admin-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.admin-tab-btn {
  flex: 1;
  padding: 9px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--t-base);
}
.admin-tab-btn.active { border-color: var(--primary); color: var(--primary); background: var(--primary-xs); }
.pending-actions { display: flex; gap: 8px; margin-top: 10px; }
.admin-user-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.role-select {
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: .8rem;
  font-weight: 600;
  background: white;
  color: var(--text);
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px 14px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: all var(--t-base);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card.stat-alert { border-color: var(--warning); background: var(--warning-lt); cursor: pointer; }
.stat-card.stat-alert:hover { box-shadow: 0 4px 12px rgba(217,119,6,.2); }
.stat-number {
  font-size: 2rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
  letter-spacing: -.04em;
}
.stat-alert .stat-number { color: var(--warning); }
.stat-label  { font-size: .72rem; color: var(--text-muted); margin-top: 5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.section-title { font-size: .8rem; font-weight: 700; margin: 18px 0 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; display: flex; align-items: center; gap: 6px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.mini-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-bottom: 7px;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all var(--t-base);
}
.mini-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.mini-card:last-child { margin-bottom: 0; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 1000;
  align-items: flex-end;
  justify-content: center;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.modal-box {
  background: white;
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0 env(safe-area-inset-bottom, 16px);
  position: relative;
  animation: slideUp .22s cubic-bezier(.32,1.05,.65,1);
}
/* Profile view modal – full-width gradient header */
#profile-view-content > .profile-header-view:first-child {
  border-radius: 0;
  margin: 0;
}
@keyframes slideUp { from { transform: translateY(100%); opacity: .5; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: white;
  z-index: 10;
  border-radius: var(--radius) var(--radius) 0 0;
}
.modal-header h3 { font-size: 1rem; font-weight: 800; letter-spacing: -.01em; }
.modal-close {
  background: var(--bg);
  border: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t-fast), color var(--t-fast);
  line-height: 1;
}
.modal-close:hover { background: var(--border-dk); color: var(--text); }
.modal-body { padding: 18px 20px; }
/* Forms directly inside modal-box get padding */
.modal-box > form { padding: 16px 20px 20px; }

.group-admin-modal {
  max-width: 980px;
}
.group-admin-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 16px;
  padding: 16px 20px 20px;
}
.group-create-form,
.group-manage-panel {
  min-width: 0;
}
.group-create-form h4,
.group-manage-panel h4 {
  margin: 0 0 10px;
  font-size: .95rem;
}
.group-member-picker {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 8px;
  background: var(--bg);
}
.group-member-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  cursor: pointer;
}
.group-member-choice input {
  flex-shrink: 0;
}
.group-member-choice .avatar-img,
.group-member-choice .avatar-initials {
  width: 28px;
  height: 28px;
  font-size: .7rem;
}
.group-member-choice-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-admin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.group-admin-row {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-xs);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}
.group-admin-row:hover {
  border-color: var(--primary);
  background: var(--primary-xs);
}
.group-admin-row-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.group-admin-row-main strong,
.group-admin-row-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-admin-row-main small {
  color: var(--text-muted);
}
.group-manage-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 12px;
}
.group-manage-head,
.group-add-row,
.group-member-row,
.group-member-main {
  display: flex;
  align-items: center;
  gap: 10px;
}
.group-manage-head {
  justify-content: space-between;
  margin-bottom: 10px;
}
.group-add-row {
  align-items: stretch;
  margin-bottom: 10px;
}
.group-add-row .input {
  flex: 1;
}
.group-member-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.group-member-row {
  justify-content: space-between;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
}
.group-member-main {
  min-width: 0;
}
.group-member-main .avatar-img,
.group-member-main .avatar-initials {
  width: 32px;
  height: 32px;
  font-size: .75rem;
}
.group-member-tools {
  margin-top: 14px;
}

/* ============================================================
   FAB
   ============================================================ */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 14px);
  right: 16px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 1.5rem;
  border: none;
  box-shadow: 0 4px 16px rgba(30,64,175,.4);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 150;
  transition: transform var(--t-base), box-shadow var(--t-base), background var(--t-base);
  line-height: 1;
}
.fab:hover { transform: scale(1.1) rotate(45deg); box-shadow: 0 6px 20px rgba(30,64,175,.5); background: var(--primary-dk); }
.fab:active { transform: scale(.95); }

/* ============================================================
   FILTER CHIPS
   ============================================================ */
.filter-chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 10px; }
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  background: white;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--t-base);
  white-space: nowrap;
}
.chip:hover  { border-color: var(--primary); color: var(--primary); background: var(--primary-xs); }
.chip.active { border-color: var(--primary); color: var(--primary); background: var(--primary-lt); box-shadow: 0 0 0 1px var(--primary-lt); }

/* ============================================================
   TOAST
   ============================================================ */
#toast-container {
  position: fixed;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  width: calc(100% - 24px);
  max-width: 380px;
}
.toast {
  background: var(--text);
  color: white;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  font-size: .875rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(-14px) scale(.95);
  transition: all .25s cubic-bezier(.34,1.3,.64,1);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast-success { background: #064e3b; }
.toast-error   { background: #7f1d1d; }
.toast-info    { background: #0c4a6e; }
.toast-icon    { font-style: normal; flex-shrink: 0; font-size: 1rem; }

/* ============================================================
   LOADING & EMPTY STATES
   ============================================================ */
.loader-wrap { display: flex; flex-direction: column; align-items: center; padding: 48px 24px; gap: 12px; color: var(--text-muted); }
.loader-wrap p { font-size: .875rem; }

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner-sm {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 52px 24px;
  gap: 10px;
  color: var(--text-muted);
  text-align: center;
}
.empty-icon  { font-size: 3.5rem; margin-bottom: 4px; }
.empty-state p { font-size: .9rem; }
.empty-state .text-sm { font-size: .8rem; }

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg-2) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-xs);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skel-line { height: 14px; border-radius: var(--radius-full); }
.skel-text { height: 10px; border-radius: var(--radius-full); }
.skel-avatar { width: 40px; height: 40px; border-radius: 50%; }

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-bar .input { flex: 1; }

/* ============================================================
   NOTIFICATIONS
   ============================================================ */
.notif-item {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: background var(--t-fast);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }
.notif-item.notif-unread { background: var(--primary-xs); border-left: 3px solid var(--primary); }
.notif-item.notif-unread:hover { background: var(--primary-lt); }
.notif-msg  { font-size: .875rem; color: var(--text); font-weight: 500; line-height: 1.5; }
.notif-time { font-size: .72rem; color: var(--text-muted); }

/* ============================================================
   CHAT
   ============================================================ */
/* Conversations list */
.chat-conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 8px;
  transition: all .2s ease;
  border-bottom: 1px solid #f0f0f0;
  background: white;
  position: relative;
}
.chat-conv-item:hover { 
  background: #f9f9f9;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.chat-conv-item:active {
  background: #f5f5f5;
}

.chat-conv-body { flex: 1; min-width: 0; }
.chat-conv-top  { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.chat-conv-name { font-weight: 500; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #111; }
.chat-conv-time { font-size: .72rem; color: #999; flex-shrink: 0; }
.chat-conv-preview { font-size: .8125rem; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.chat-conv-preview.chat-conv-unread { color: #111; font-weight: 600; }
.chat-conv-role { margin-top: 3px; font-size: .7rem; }
.chat-title-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.chat-section-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 14px 4px 8px;
}
.group-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0f766e;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(15,118,110,.2);
}
.group-avatar.sm {
  width: 34px;
  height: 34px;
  font-size: .9rem;
}
.chat-group-sender {
  font-size: .72rem;
  font-weight: 700;
  color: #0f766e;
  margin-bottom: 4px;
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-room-title-main {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.chat-room-manage-btn {
  margin-left: auto;
  flex-shrink: 0;
}

.chat-unread-dot {
  position: absolute;
  top: 50%; right: 12px;
  transform: translateY(-50%);
  background: #25d366;
  color: white;
  font-size: .65rem;
  min-width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  padding: 0 3px;
  border: 1.5px solid white;
}

/* ─── Highlight pulse animation (notification deep-link) ─── */
@keyframes highlightPulse {
  0%   { box-shadow: 0 0 0 0 rgba(37,211,102,.7); background: #f0fdf4; }
  50%  { box-shadow: 0 0 0 10px rgba(37,211,102,.0); background: #dcfce7; }
  100% { box-shadow: 0 0 0 0 rgba(37,211,102,.0); background: ''; }
}
.highlight-pulse {
  animation: highlightPulse 1.1s ease 2;
  border-radius: var(--radius);
}

/* ─── Notification items ─────────────────────────────────── */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  position: relative;
  transition: background var(--t-fast);
}
.notif-item:last-child { border-bottom: none; }
.notif-unread { background: #eff6ff; }
.notif-clickable { cursor: pointer; }
.notif-clickable:hover { background: #f0fdf4; }
.notif-icon-wrap {
  font-size: 1.35rem;
  flex-shrink: 0;
  width: 38px; height: 38px;
  background: var(--bg-2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.notif-unread .notif-icon-wrap { background: #dbeafe; }
.notif-body   { flex: 1; min-width: 0; }
.notif-type-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--primary); margin-bottom: 2px; }
.notif-msg    { font-size: .875rem; line-height: 1.45; color: var(--text); word-break: break-word; }
.notif-time   { font-size: .7rem; color: var(--text-muted); margin-top: 4px; }
.notif-unread-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 5px;
}
.notif-arrow  { font-size: 1.3rem; color: var(--text-muted); align-self: center; flex-shrink: 0; }

/* Chat nav badge */
.chat-nav-badge {
  position: absolute;
  top: 3px; right: 4px;
  background: var(--danger);
  color: white;
  font-size: .52rem;
  min-width: 14px; height: 14px;
  border-radius: var(--radius-full);
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  padding: 0 2px;
  pointer-events: none;
  border: 1.5px solid white;
}

/* Chat room full-screen panel */
#chat-room-panel {
  position: fixed;
  top: var(--chat-vv-top, 0px);
  right: 0;
  bottom: auto;
  left: 0;
  height: var(--chat-vv-height, 100dvh);
  max-height: var(--chat-vv-height, 100dvh);
  min-height: 320px;
  background: #fff;
  z-index: 600;
  display: none;
  flex-direction: column;
  transform: translate3d(100%, 0, 0);
  transition: transform .26s cubic-bezier(.32,.72,0,1);
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y;
  will-change: transform;
}
#chat-room-panel.chat-panel-open { transform: translate3d(0, 0, 0); }

.chat-room-header {
  height: 62px;
  background: linear-gradient(135deg, #25d366 0%, #20ba5a 100%);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 62px;
}
.chat-back-btn {
  background: rgba(255,255,255,.2);
  border: none;
  color: white;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--t-base), transform .15s;
}
.chat-back-btn:hover { background: rgba(255,255,255,.3); transform: scale(1.05); }
.chat-back-btn:active { transform: scale(0.95); }
.chat-room-title { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; overflow: hidden; }
.chat-room-avatar { flex-shrink: 0; }
.chat-room-avatar .avatar-initials { width: 42px; height: 42px; font-size: .9rem; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.chat-room-name { font-weight: 700; font-size: .96rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-room-role { font-size: .72rem; opacity: .92; margin-top: 2px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-room-status { font-size: .72rem; opacity: .88; margin-top: 1px; display: flex; align-items: center; gap: 4px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Messages area */
.chat-messages-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fff;
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23f9f9f9'%3E%3Ccircle cx='50' cy='50' r='1'/%3E%3C/g%3E%3C/svg%3E");
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-padding-bottom: 14px;
}
.chat-start-hint {
  text-align: center;
  color: #999;
  font-size: .9rem;
  margin: auto;
  padding: 40px 24px;
  background: rgba(255,255,255,.8);
  border-radius: 12px;
  align-self: center;
  font-weight: 500;
}
.chat-date-divider { 
  text-align: center;
  margin: 14px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-date-divider::before,
.chat-date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #ddd;
}
.chat-date-divider span {
  background: transparent;
  color: #999;
  font-size: .72rem;
  padding: 0 8px;
  border-radius: 12px;
  font-weight: 500;
  letter-spacing: .02em;
}

/* ── Message rows ─── */
.chat-msg-row { 
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-bottom: 2px;
  max-width: 100%;
  animation: slideIn .2s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-mine   { flex-direction: row-reverse; padding-right: 8px; }
.msg-theirs { flex-direction: row;         padding-left: 8px; }

.chat-msg-avatar .avatar-initials { width: 32px; height: 32px; font-size: .7rem; }

/* ── Bubbles ─── */
.chat-bubble {
  max-width: 100%;
  border-radius: 18px;
  padding: 8px 12px;
  position: relative;
  word-break: break-word;
  line-height: 1.45;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
  font-size: .9rem;
}
/* WhatsApp-style tails */
.bubble-mine {
  background: #dcf8c6;
  color: #111;
  border-bottom-right-radius: 4px;
}
.bubble-mine::after {
  content: '';
  position: absolute;
  bottom: 0; right: -8px;
  width: 0; height: 0;
  border-style: solid;
  border-width: 0 8px 8px 0;
  border-color: transparent #dcf8c6 transparent transparent;
}
.bubble-theirs {
  background: #e5e5ea;
  color: #111;
  border-bottom-left-radius: 4px;
}
.bubble-theirs::after {
  content: '';
  position: absolute;
  bottom: 0; left: -8px;
  width: 0; height: 0;
  border-style: solid;
  border-width: 8px 8px 0 0;
  border-color: #e5e5ea transparent transparent transparent;
}
/* Image bubble has no padding */
.chat-bubble-img {
  padding: 0;
  overflow: hidden;
  background: transparent;
  border-radius: 12px;
  box-shadow: none;
}
.chat-bubble-img::after { display: none; }
.chat-bubble-img.has-group-sender {
  background: #e5e5ea;
  padding: 7px;
  overflow: visible;
}
.chat-bubble-img.has-group-sender .chat-group-sender {
  padding: 0 3px 6px;
  margin: 0;
}
.chat-bubble-gif {
  padding: 7px;
  background: transparent;
  box-shadow: none;
}
.chat-bubble-gif::after { display: none; }
.chat-bubble-gif.has-group-sender {
  background: #e5e5ea;
}
.chat-gif-card,
.chat-gif-option {
  background: var(--gif-bg, #f1f5f9);
  color: var(--gif-fg, #0f172a);
}
.chat-gif-card {
  width: min(220px, 62vw);
  min-height: 138px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
}
.chat-gif-emoji {
  font-size: 2.6rem;
  line-height: 1;
  animation: chat-gif-pop 1.1s ease-in-out infinite;
}
.chat-gif-text {
  font-size: .95rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}
.chat-gif-image-wrap {
  display: block;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  max-width: min(240px, 68vw);
}
.chat-gif-image {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  display: block;
}
.chat-gif-footer {
  padding-top: 5px;
}
@keyframes chat-gif-pop {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.08); }
}

.chat-msg-text { font-size: .9rem; font-weight: 400; }
.chat-msg-meta {
  font-size: .68rem;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  color: #666;
  line-height: 1;
}
.bubble-mine .chat-msg-meta { color: #999; }
.bubble-theirs .chat-msg-meta { color: #999; }
.chat-tick      { font-size: .7rem; color: #999; }
.chat-tick.sent { color: #999; }
.chat-tick.read { color: #34b7f1; font-weight: 600; }  /* WhatsApp blue ticks */

/* ── Input bar ─── */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px;
  background: #f7f8fa;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
  position: relative;
  z-index: 12;
}
.chat-textarea {
  flex: 1;
  min-width: 0;
  border: 1.5px solid #d7dde4;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: .9375rem;
  resize: none;
  min-height: 40px;
  max-height: 100px;
  line-height: 1.4;
  background: #fff;
  font-family: inherit;
  box-shadow: none;
  outline: none;
  overflow-y: auto;
  transition: all .2s ease;
}
.chat-textarea::placeholder { color: #bbb; font-weight: 500; }
.chat-textarea:focus { 
  border-color: #25d366;
  background: white;
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.12);
}
.chat-send-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #25d366;
  color: white;
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .2s ease;
  box-shadow: 0 2px 6px rgba(37,211,102,.3);
  font-size: 1.1rem;
}
.chat-send-btn:hover { 
  background: #20ba5a;
  transform: scale(1.08);
  box-shadow: 0 4px 10px rgba(37,211,102,.4);
}
.chat-send-btn:active { transform: scale(0.95); }
.chat-send-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ── Attach button ─── */
.chat-attach-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #fff;
  border: none;
  color: #25d366;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: none;
  transition: all .2s ease;
  font-size: .95rem;
  font-weight: 600;
}
.chat-attach-btn:hover { 
  background: #eff6ff;
  color: #20ba5a;
  transform: scale(1.05);
}
.chat-attach-btn:active { transform: scale(0.95); }
.chat-gif-btn {
  font-size: .82rem;
  font-weight: 850;
  letter-spacing: 0;
}

.chat-gif-picker {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: flex;
  align-items: flex-end;
}
.chat-gif-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .28);
}
.chat-gif-sheet {
  position: relative;
  width: 100%;
  max-height: min(62vh, 520px);
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 8px 12px calc(14px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -16px 34px rgba(15, 23, 42, .18);
  overflow: hidden;
  animation: chat-gif-sheet-in .18s ease;
}
.chat-gif-handle {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: #cbd5e1;
  margin: 2px auto 10px;
}
.chat-gif-head,
.chat-gif-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-gif-head {
  justify-content: space-between;
  padding: 0 2px 10px;
}
.chat-gif-head strong {
  font-size: 1rem;
}
.chat-gif-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #f1f5f9;
  color: #334155;
  font-size: 1.35rem;
  line-height: 1;
}
.chat-gif-search-row {
  padding-bottom: 10px;
}
.chat-gif-search {
  flex: 1;
  min-width: 0;
  height: 38px;
  border: 1.5px solid #e2e8f0;
  border-radius: 999px;
  padding: 0 14px;
  outline: none;
  font-size: .92rem;
}
.chat-gif-search:focus {
  border-color: #25d366;
  box-shadow: 0 0 0 3px rgba(37, 211, 102, .12);
}
.chat-gif-url-btn {
  height: 38px;
  border: 0;
  border-radius: 999px;
  padding: 0 14px;
  background: #0f172a;
  color: #fff;
  font-weight: 800;
}
.chat-gif-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  overflow-y: auto;
  max-height: calc(min(62vh, 520px) - 112px);
  padding: 1px 0 4px;
}
.chat-gif-option {
  min-height: 104px;
  border: 0;
  border-radius: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px;
  overflow: hidden;
}
.chat-gif-option:active {
  transform: scale(.98);
}
.chat-gif-empty {
  grid-column: 1 / -1;
  padding: 28px 10px;
  color: #64748b;
  text-align: center;
  font-size: .9rem;
}
.chat-gif-loading {
  grid-column: 1 / -1;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #475569;
  font-size: .82rem;
  text-align: center;
}
.chat-gif-real-option {
  min-height: 126px;
  padding: 0;
  overflow: hidden;
  background: #e2e8f0;
}
.chat-gif-thumb {
  width: 100%;
  height: 126px;
  display: block;
  object-fit: cover;
}
@keyframes chat-gif-sheet-in {
  from { transform: translateY(18px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.chat-room-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}
.chat-header-icon-btn,
.chat-msg-action-btn {
  border: 0;
  background: rgba(255,255,255,.16);
  color: inherit;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
}
.chat-header-icon-btn:active,
.chat-msg-action-btn:active { transform: scale(.96); }
.chat-pref-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 6px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: .62rem;
  font-weight: 800;
  vertical-align: middle;
}
.chat-conv-archived {
  opacity: .74;
}
.chat-typing-indicator {
  display: none;
  padding: 5px 14px 4px;
  color: #128c4a;
  background: #fff;
  font-size: .78rem;
  font-weight: 650;
  border-top: 1px solid rgba(226, 232, 240, .8);
  flex-shrink: 0;
}
.chat-reply-preview-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid #e5e7eb;
  background: #f8fafc;
  flex-shrink: 0;
}
.chat-reply-preview-main {
  min-width: 0;
  flex: 1;
  border-left: 3px solid #25d366;
  padding-left: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-reply-preview-main strong,
.chat-reply-preview-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-reply-preview-main strong {
  color: #075e54;
  font-size: .78rem;
}
.chat-reply-preview-main span {
  color: #475569;
  font-size: .78rem;
}
.chat-reply-preview-close {
  border: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #334155;
  font-size: 1.1rem;
  line-height: 1;
}
.chat-reply-quote {
  width: 100%;
  border: 0;
  border-left: 3px solid #16a34a;
  border-radius: 7px;
  background: rgba(255,255,255,.58);
  padding: 6px 8px;
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  color: inherit;
}
.bubble-theirs .chat-reply-quote { background: rgba(255,255,255,.9); }
.chat-reply-quote strong,
.chat-reply-quote span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-reply-quote strong {
  color: #047857;
  font-size: .75rem;
}
.chat-reply-quote span {
  color: #475569;
  font-size: .76rem;
}
.chat-msg-action-btn {
  align-self: center;
  width: 28px;
  height: 28px;
  background: transparent;
  color: #64748b;
  opacity: .72;
}
.chat-msg-row:hover .chat-msg-action-btn,
.chat-msg-action-btn:focus { opacity: 1; }
.chat-message-action-menu,
.chat-room-menu {
  position: fixed;
  z-index: 12000;
  min-width: 190px;
  border-radius: 8px;
  padding: 6px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, .22), 0 1px 3px rgba(15, 23, 42, .12);
  border: 1px solid rgba(226, 232, 240, .9);
}
.chat-message-action-menu button,
.chat-room-menu button {
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 10px 11px;
  background: transparent;
  color: #0f172a;
  text-align: left;
  font-size: .9rem;
  font-weight: 650;
}
.chat-message-action-menu button:hover,
.chat-room-menu button:hover { background: #f1f5f9; }
.chat-message-action-menu button.danger { color: #dc2626; }
.chat-message-action-menu button:disabled {
  color: #94a3b8;
  cursor: not-allowed;
}
.chat-read-count {
  border: 0;
  background: transparent;
  color: #15803d;
  font-size: .68rem;
  font-weight: 800;
  padding: 0 2px;
  margin-left: 4px;
}
.chat-msg-highlight .chat-bubble {
  animation: chat-msg-highlight 1.4s ease;
}
@keyframes chat-msg-highlight {
  0%, 100% { box-shadow: 0 1px 2px rgba(0,0,0,.1); }
  20%, 70% { box-shadow: 0 0 0 4px rgba(37, 211, 102, .28), 0 1px 2px rgba(0,0,0,.12); }
}
.chat-info-modal {
  max-width: 520px;
}
.chat-info-body {
  padding: 14px 18px 18px;
  max-height: min(68vh, 620px);
  overflow-y: auto;
}
.chat-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px 0;
}
.chat-search-box .input {
  min-width: 0;
  flex: 1;
}
.chat-search-result,
.chat-info-file-row {
  width: 100%;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
}
.chat-search-result span,
.chat-search-result small,
.chat-info-file-row strong,
.chat-info-file-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-search-result span { color: #334155; }
.chat-search-result small,
.chat-info-file-row small { color: #64748b; }
.chat-group-info-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e2e8f0;
}
.chat-group-info-head h4 {
  margin: 0 0 2px;
  font-size: 1rem;
}
.chat-group-info-head p,
.chat-group-info-head span {
  margin: 0;
  color: #64748b;
  font-size: .82rem;
}
.group-avatar.lg {
  width: 54px;
  height: 54px;
  font-size: 1.3rem;
}
.chat-info-section-title {
  margin: 16px 0 8px;
  font-size: .86rem;
  color: #0f172a;
}
.chat-info-member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
}
.chat-info-member-row > div:last-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.chat-info-member-row strong,
.chat-info-member-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-info-member-row span {
  color: #64748b;
  font-size: .78rem;
}
.chat-info-media-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.chat-info-media-grid button {
  min-height: 84px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
  padding: 0;
}
.chat-info-media-grid .chat-gif-card,
.chat-info-media-grid .chat-gif-image-wrap {
  width: 100%;
  min-height: 84px;
  max-width: 100%;
  border-radius: 0;
}
.chat-info-media-grid .chat-gif-emoji {
  font-size: 1.6rem;
}
.chat-info-media-grid .chat-gif-text {
  font-size: .72rem;
}
.chat-info-file-row {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.chat-info-file-row span {
  flex-shrink: 0;
  font-size: 1.2rem;
}
.chat-read-summary {
  padding: 9px 10px;
  border-radius: 8px;
  background: #ecfdf5;
  color: #047857;
  font-size: .86rem;
  font-weight: 800;
  margin-bottom: 10px;
}

/* ── File preview bar ─── */
.chat-file-preview-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #f9f9f9;
  border-top: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.chat-file-preview-thumb {
  width: 40px; height: 40px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid #e5e7eb;
  display: none;
}
.chat-file-preview-icon { font-size: 1.5rem; flex-shrink: 0; }
.chat-file-preview-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-file-preview-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  font-size: .85rem;
  color: #111;
}
.chat-file-preview-size { color: #999; font-size: .75rem; }
.chat-file-clear-btn {
  width: 24px; height: 24px; border-radius: 50%;
  background: #f0f0f0;
  border: none; cursor: pointer;
  color: #999;
  font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all .2s ease;
}
.chat-file-clear-btn:hover { background: #fde8e8; color: #ef4444; }

/* ── Image bubble ─── */
.chat-img-wrap {
  position: relative;
  line-height: 0;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  display: inline-block;
  max-width: 100%;
}
.chat-img-bubble {
  display: block;
  max-width: 240px;
  max-height: 300px;
  width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 10px;
  transition: filter .15s;
}
.chat-img-loading {
  min-width: 180px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  font-size: .8rem;
  background: rgba(255,255,255,.7);
}
.chat-img-wrap:hover .chat-img-bubble { filter: brightness(.88); }
.chat-img-overlay {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity .15s;
  background: rgba(0,0,0,.18);
  border-radius: 10px;
}
.chat-img-wrap:hover .chat-img-overlay { opacity: 1; }
.chat-img-overlay span { font-size: 1.6rem; }
.chat-img-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 4px 3px;
}
.chat-img-dl-btn {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: .7rem;
  color: #25d366;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: .03em;
}
.chat-img-dl-btn:hover { text-decoration: underline; }
.chat-msg-meta-inline {
  font-size: .65rem;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 2px;
}
.chat-img-caption, .chat-file-caption {
  font-size: .875rem;
  padding: 4px 4px 2px;
  line-height: 1.4;
  color: #111;
}
.chat-img-err { padding: 10px; color: #ef4444; font-size: .8rem; }

/* ── File chip (document) ─── */
.chat-file-chip {
  border: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  min-width: 180px;
  max-width: 280px;
  background: rgba(0,0,0,.06);
  transition: background .15s;
}
.chat-file-chip:hover { background: rgba(0,0,0,.11); }
.bubble-mine   .chat-file-chip { background: rgba(0,0,0,.1);  color: #111; }
.bubble-theirs .chat-file-chip { background: rgba(0,0,0,.05); color: #111; }
.chat-file-chip-icon { font-size: 2rem; flex-shrink: 0; line-height: 1; }
.chat-file-chip-info { flex: 1; min-width: 0; }
.chat-file-chip-name {
  font-size: .875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #111;
}
.chat-file-chip-meta { font-size: .72rem; color: #6b7280; margin-top: 2px; }
.chat-file-chip-dl {
  font-size: 1.1rem;
  flex-shrink: 0;
  color: #25d366;
  font-weight: 700;
}

/* ── Lightbox / image viewer modal ─── */
.chat-img-modal {
  position: fixed; inset: 0;
  z-index: 1200;
  display: none;
  align-items: center; justify-content: center;
}
.chat-img-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.82);
  cursor: zoom-out;
}
.chat-img-modal-box {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 92vw;
  max-height: 90vh;
}
.chat-img-modal-box img {
  max-width: 92vw;
  max-height: 78vh;
  border-radius: 10px;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
  display: block;
}
.chat-img-modal-close {
  position: absolute;
  top: -40px; right: 0;
  background: rgba(255,255,255,.18);
  border: none;
  color: white;
  font-size: 1.2rem;
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.chat-img-modal-close:hover { background: rgba(255,255,255,.32); }
.chat-img-modal-actions { display: flex; gap: 10px; }

/* ============================================================
   MOBILE RESPONSIVE PASS
   ============================================================ */
@media (max-width: 520px) {
  .page {
    padding: 12px 10px 4px;
  }

  .page-title-bar {
    align-items: flex-start;
    gap: 8px;
    flex-wrap: wrap;
  }
  .page-title-bar h2 {
    min-width: 0;
    font-size: 1.1rem;
    line-height: 1.25;
  }
  .page-title-bar .btn {
    flex-shrink: 0;
  }

  .auth-card {
    padding: 22px 18px;
  }
  .auth-logo h1 {
    font-size: 1.45rem;
    line-height: 1.2;
  }
  .auth-logo p {
    font-size: .84rem;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .search-bar {
    flex-direction: column;
    gap: 8px;
  }
  .search-bar .btn {
    width: 100%;
  }

  .card {
    padding: 12px;
    border-radius: 12px;
  }
  .post-media-grid {
    margin-left: -12px;
    margin-right: -12px;
  }

  .post-footer,
  .resource-actions,
  .pending-actions,
  .admin-user-actions,
  .admin-action-btns,
  .chat-img-modal-actions {
    gap: 7px;
  }
  .post-footer .btn-icon,
  .resource-actions .btn,
  .pending-actions .btn,
  .admin-action-btns .btn,
  .chat-img-modal-actions .btn {
    flex: 1 1 auto;
    min-width: 0;
  }

  .comment-form {
    flex-direction: column;
    align-items: stretch;
  }
  .comment-form .btn {
    width: 100%;
  }

  .resource-card {
    gap: 10px;
  }
  .resource-icon {
    width: 36px;
    font-size: 1.85rem;
  }

  .admin-tabs {
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .admin-tabs::-webkit-scrollbar {
    display: none;
  }
  .admin-tab-btn {
    flex: 0 0 auto;
    min-width: 112px;
  }

  .modal-box {
    max-height: calc(100dvh - env(safe-area-inset-top, 0px));
    border-radius: 16px 16px 0 0;
  }
  .modal-header {
    padding: 15px 16px 12px;
  }
  .modal-body,
  .modal-box > form {
    padding-left: 16px;
    padding-right: 16px;
  }

  #toast-container {
    top: calc(10px + env(safe-area-inset-top, 0px));
    width: calc(100% - 20px);
  }

  .filter-chips {
    margin-left: -10px;
    margin-right: -10px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .react-picker {
    max-width: calc(100vw - 16px);
    overflow-x: auto;
  }

  .fab {
    right: 12px;
    width: 48px;
    height: 48px;
    bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom, 0px));
  }

  .chat-room-header {
    height: calc(var(--header-h) + var(--header-top-gap) + env(safe-area-inset-top, 0px));
    padding: calc(var(--header-top-gap) + env(safe-area-inset-top, 0px)) 10px 0;
    gap: 8px;
  }
  .chat-back-btn {
    width: 34px;
    height: 34px;
  }
  .chat-room-name {
    font-size: .9rem;
  }
  .chat-messages-area {
    padding: 8px 8px 4px;
  }
  .chat-bubble-col {
    max-width: 84vw;
  }
  .chat-bubble {
    max-width: 100%;
  }
  .chat-input-bar {
    gap: 6px;
    padding-left: 8px;
    padding-right: 8px;
  }
  .chat-attach-btn,
  .chat-send-btn {
    width: 40px;
    height: 40px;
  }
  .chat-textarea {
    min-width: 0;
    min-height: 40px;
    padding: 9px 14px;
  }
  .chat-file-chip {
    min-width: 0;
    max-width: calc(100vw - 112px);
  }
  .chat-img-bubble {
    max-width: min(240px, 72vw);
  }
}

@media (max-width: 420px) {
  :root {
    --nav-h: 58px;
  }

  .bottom-nav {
    height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .nav-item {
    padding: 7px 2px;
    gap: 0;
  }
  .nav-label {
    display: none;
  }
  .nav-item .nav-icon {
    font-size: 1.32rem;
  }
  .nav-item.active .nav-icon {
    transform: scale(1.08);
  }
  .chat-nav-badge {
    top: 7px;
    right: 8px;
  }

  .pages-container {
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 14px);
  }

  .btn {
    padding-left: 14px;
    padding-right: 14px;
  }
  .btn-sm {
    padding-left: 10px;
    padding-right: 10px;
  }

  .stats-grid {
    gap: 8px;
  }
  .stat-card {
    padding: 13px 10px;
  }
  .stat-number {
    font-size: 1.65rem;
  }
  .stat-label {
    font-size: .66rem;
  }

  .welcome-bar {
    padding: 14px;
    gap: 10px;
  }
  .welcome-avatar {
    width: 42px;
    height: 42px;
    font-size: 1.05rem;
  }

  .member-card,
  .chat-conv-item {
    gap: 10px;
  }

  .modal-header h3 {
    font-size: .96rem;
    line-height: 1.25;
  }
  .notif-modal-hd {
    gap: 6px;
  }

  .empty-state {
    padding: 38px 18px;
  }
  .empty-icon {
    font-size: 2.8rem;
  }
}

@media (max-width: 360px) {
  .app-header {
    padding-left: 10px;
    padding-right: 8px;
  }
  .header-logo {
    font-size: .9rem;
  }

  .page {
    padding-left: 8px;
    padding-right: 8px;
  }
  .card {
    padding: 10px;
  }
  .post-media-grid {
    margin-left: -10px;
    margin-right: -10px;
  }

  .detail-row {
    flex-direction: column;
    gap: 4px;
  }
  .detail-row > span:first-child {
    min-width: 0;
  }

  .post-footer .btn-icon,
  .admin-action-btns .btn,
  .pending-actions .btn {
    flex-basis: calc(50% - 4px);
  }

  .chat-msg-avatar {
    display: none;
  }
  .chat-bubble {
    max-width: 90%;
  }
  .chat-file-chip {
    max-width: 70vw;
  }
  .chat-img-bubble {
    max-width: 76vw;
  }

  .chat-attach-btn,
  .chat-send-btn {
    width: 38px;
    height: 38px;
  }
  .chat-textarea {
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* ============================================================
   RESPONSIVE — Tablet+
   ============================================================ */
@media (min-width: 600px) {
  #auth-screen { justify-content: center; padding: 40px 20px; }
  .modal-overlay { align-items: center; }
  .modal-box { border-radius: var(--radius); max-height: 88vh; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .page { padding: 18px 18px 4px; }
  .chat-bubble { max-width: 62%; }
}
@media (min-width: 900px) {
  .pages-container { max-width: 720px; margin: 0 auto; }
  .bottom-nav { max-width: 720px; margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* ============================================================
   ADMIN PANEL — Enhanced User Management
   ============================================================ */
.admin-search-bar { padding: 0 0 14px; }

.admin-user-card {
  padding: 12px 14px !important;
  margin-bottom: 10px !important;
}
.admin-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.admin-user-avatar .avatar { width: 40px !important; height: 40px !important; font-size: 15px !important; flex-shrink: 0; }
.admin-user-actions { display: flex; flex-direction: column; gap: 8px; }
.admin-action-btns  { display: flex; gap: 6px; flex-wrap: wrap; }

/* User status badges */
.user-status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  vertical-align: middle;
  line-height: 1.5;
}
.user-status-badge.active    { background: #e8f5e9; color: #2e7d32; }
.user-status-badge.suspended { background: #fff3e0; color: #e65100; }
.user-status-badge.banned    { background: #ffebee; color: #b71c1c; }
.user-status-badge.pending   { background: #e3f2fd; color: #1565c0; }

/* ============================================================
   REPORT CARDS (Admin view)
   ============================================================ */
.report-card {
  padding: 14px !important;
  margin-bottom: 12px !important;
}
.report-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.report-status-badge {
  display: inline-block;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: .5px;
}
.report-parties {
  font-size: 13px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.report-action-taken {
  margin-top: 8px;
  font-size: 12px;
  background: #e8f5e9;
  color: #2e7d32;
  padding: 6px 10px;
  border-radius: 8px;
}

/* ============================================================
   REPORT BUTTON (user-facing)
   ============================================================ */
.report-btn {
  background: #fff0f0 !important;
  color: #c62828 !important;
  border: 1px solid #ffcdd2 !important;
}
.report-btn:hover { background: #ffebee !important; }

/* Admin access-account button */
.btn-admin-access {
  background: #e8eaf6 !important;
  color: #283593 !important;
  border: 1px solid #c5cae9 !important;
}
.btn-admin-access:hover { background: #c5cae9 !important; }

/* ============================================================
   IMPERSONATION BANNER
   ============================================================ */
#impersonation-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 2000;
  background: #c62828;
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
#impersonation-banner button {
  background: rgba(255,255,255,.25);
  border: 1px solid rgba(255,255,255,.5);
  color: #fff;
  padding: 3px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
#impersonation-banner button:hover { background: rgba(255,255,255,.4); }
body.impersonating { padding-top: 40px !important; }

/* ============================================================
   ONLINE STATUS INDICATORS
   ============================================================ */

/* Small dot overlaid on avatar in admin list */
.online-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid #fff;
  flex-shrink: 0;
  vertical-align: middle;
}
.online-dot.online  { background: #22c55e; }
.online-dot.recent  { background: #f59e0b; }
.online-dot.offline { background: #9ca3af; }
.online-dot.never   { background: #d1d5db; }

/* Dot positioned over avatar in admin user card */
.admin-user-avatar .online-dot {
  position: absolute;
  bottom: 0; right: 0;
  width: 12px; height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
}

/* Pulsing ring for online */
.online-dot.online {
  box-shadow: 0 0 0 0 rgba(34,197,94,.5);
  animation: online-pulse 2s infinite;
}
@keyframes online-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.5); }
  70%  { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* Text label beside dot in admin user card */
.online-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  margin-top: 3px;
  font-weight: 500;
}
.online-label .online-dot { width: 8px; height: 8px; border: none; }
.online-label.online  { color: #16a34a; }
.online-label.recent  { color: #d97706; }
.online-label.offline { color: #6b7280; }
.online-label.never   { color: #9ca3af; }

/* Large dot for profile view modal */
.online-dot-lg {
  position: absolute;
  bottom: 4px; right: 4px;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 3px solid #fff;
}
.online-dot-lg.online  { background: #22c55e; animation: online-pulse 2s infinite; }
.online-dot-lg.recent  { background: #f59e0b; }
.online-dot-lg.offline { background: #9ca3af; }
.online-dot-lg.never   { background: #d1d5db; }

/* Text label in profile modal */
.online-label-lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin: 4px 0 0;
  font-weight: 600;
}
.online-label-lg .online-dot { width: 8px; height: 8px; border: none; }
.online-label-lg.online  { color: #16a34a; }
.online-label-lg.recent  { color: #d97706; }
.online-label-lg.offline { color: #6b7280; }
.online-label-lg.never   { color: #9ca3af; }

/* ── Chat header online status line ─────────────────────────── */
.chat-room-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  opacity: .85;
  margin-top: 2px;
  color: rgba(255,255,255,.9);
}
.chat-room-status .online-dot { width: 7px; height: 7px; border: 1.5px solid rgba(255,255,255,.6); }

/* ── Small online dot on member-card / chat-user-list avatar ── */
.member-online-dot {
  position: absolute;
  bottom: 0; right: 0;
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 2px solid #fff;
}
.member-online-dot.online  { background: #22c55e; animation: online-pulse 2s infinite; }
.member-online-dot.recent  { background: #f59e0b; }
.member-online-dot.offline { background: #9ca3af; }
.member-online-dot.never   { background: #d1d5db; }

/* ── Tiny dot on conversation-list avatar (bottom-left corner) ─ */
.chat-conv-online-dot {
  position: absolute;
  bottom: 1px; left: 1px;
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 2px solid #fff;
}
.chat-conv-online-dot.online { background: #22c55e; animation: online-pulse 2s infinite; }
.chat-conv-online-dot.recent { background: #f59e0b; }

/* ── WhatsApp-style pinned post banner ─────────────────────── */
#pinned-banner {
    display: none;
    margin-bottom: 12px;
    border-radius: 14px;
    overflow: hidden;
    animation: pin-banner-in .25s cubic-bezier(.34,1.56,.64,1);
    background: linear-gradient(135deg, #e8f5e9 0%, #d4edda 100%);
    border-left: 4px solid #25d366;
}
@keyframes pin-banner-in {
    from { opacity: 0; transform: translateY(-10px) scale(.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1);    }
}
.pinned-banner-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: background .15s;
}
.pinned-banner-inner:hover { background: rgba(37,211,102,.12); }
.pinned-banner-icon { font-size: 1.1rem; flex-shrink: 0; }
.pinned-banner-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.pinned-banner-label {
    font-size: .68rem;
    font-weight: 700;
    color: #16a34a;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.pinned-banner-title {
    font-size: .88rem;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pinned-banner-unpin {
    background: none;
    border: none;
    color: #64748b;
    font-size: .95rem;
    cursor: pointer;
    padding: 4px 7px;
    border-radius: 50%;
    flex-shrink: 0;
    line-height: 1;
    transition: background .15s, color .15s;
}
.pinned-banner-unpin:hover { background: rgba(0,0,0,.08); color: #ef4444; }

/* Pin highlight flash when scrolling to pinned post */
@keyframes pin-flash {
    0%   { box-shadow: 0 0 0 0   rgba(37,211,102,.7); }
    50%  { box-shadow: 0 0 0 10px rgba(37,211,102,.15); }
    100% { box-shadow: 0 0 0 0   rgba(37,211,102,0);  }
}
.post-card.pin-highlight { animation: pin-flash .65s ease 2; }

/* ── Elements initially hidden, toggled by JS ────────────── */
#ann-create-btn             { display: none; }
#admin-nav                  { display: none; }
#chat-group-btn             { display: none; }
#all-users-tab              { display: none; }
#reports-tab                { display: none; }
#chat-file-preview-bar      { display: none; }
#chat-file-input            { display: none; }
#chat-file-preview-thumb    { display: none; }
.nav-item[data-page="chat"] { position: relative; }

/* ── Modal inner form utility classes ───────────────────── */
.modal-body { padding: 16px; }
.modal-form-label { display: block; font-size: .8125rem; font-weight: 600; color: #333; }
.modal-report-note { margin: 0 0 14px; color: #555; font-size: .875rem; }
.modal-form-select {
  width: 100%; padding: 10px; border-radius: 10px; border: 1px solid #ddd;
  margin: 6px 0 14px; font-size: .875rem; background: #fff;
}
.modal-form-textarea {
  width: 100%; padding: 10px; border-radius: 10px; border: 1px solid #ddd;
  margin: 6px 0 16px; font-size: .875rem; resize: vertical;
  box-sizing: border-box; font-family: inherit;
}
.resolve-summary { background: #f8f8f8; border-radius: 10px; padding: 12px; margin-bottom: 14px; font-size: .8125rem; color: #444; }
.notif-modal-hd { display: flex; gap: 8px; align-items: center; }
.notif-list-wrap { max-height: 72vh; overflow-y: auto; }
.modal-hr { margin: 14px 0; border-color: var(--border); }
.admin-search-input { width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid #ddd; font-size: .875rem; }
.admin-search-select { margin-top: 8px; width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid #ddd; font-size: .875rem; }

.stat-card-clickable {
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.stat-card-clickable:hover,
.stat-card-clickable:focus {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .12);
  outline: none;
}
.composer-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.emoji-picker {
  position: absolute;
  z-index: 9999;
  width: min(312px, calc(100vw - 16px));
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .2);
}
.emoji-picker-btn {
  border: 0;
  background: transparent;
  min-width: 34px;
  height: 34px;
  border-radius: 7px;
  font-size: 20px;
  cursor: pointer;
}
.emoji-picker-btn:hover { background: var(--bg); }
.media-delete-btn,
.post-file-delete-btn {
  border: 0;
  background: rgba(17, 24, 39, .78);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.media-delete-btn { position: absolute; top: 8px; right: 8px; }
.post-doc-chips { align-items: stretch; }
.post-doc-row { display: flex; gap: 8px; align-items: stretch; }
.post-doc-row .post-doc-chip { flex: 1; min-width: 0; }
.post-file-delete-btn { flex-shrink: 0; align-self: center; }
.comment-actions { display: flex; gap: 10px; margin-top: 4px; }
.btn-link {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: .78rem;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
}
.btn-link.danger { color: var(--danger); }
.profile-photo-actions { margin-top: 4px; }
.admin-inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* Final mobile overrides: keep these at the end so they win the cascade. */
@media (max-width: 520px) {
  .modal-body,
  .modal-box > form {
    padding-left: 16px;
    padding-right: 16px;
  }
  .admin-user-card,
  .report-card {
    padding: 12px !important;
  }
  .admin-user-info,
  .report-card-header {
    align-items: flex-start;
    gap: 10px;
  }
  .admin-user-actions,
  .admin-action-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
  }
  .admin-action-btns .btn,
  .admin-user-actions .btn,
  .admin-user-actions select {
    min-width: 0;
    flex: 1 1 auto;
  }
  .notif-list-wrap {
    max-height: calc(100dvh - 140px);
  }
  .pinned-banner-inner {
    padding: 9px 12px;
  }
}

@media (max-width: 420px) {
  .nav-label {
    display: none;
  }
  .modal-body,
  .modal-box > form {
    padding-left: 14px;
    padding-right: 14px;
  }
  .admin-search-input,
  .admin-search-select,
  .modal-form-select,
  .modal-form-textarea {
    font-size: .875rem;
  }
}

/* ============================================================
   Pro Mobile App Shell Polish
   ============================================================ */
.app-icon,
.nav-icon svg,
.stat-icon svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#main-app {
  background: #f6f8fc;
}

.app-header {
  height: auto;
  min-height: calc(92px + env(safe-area-inset-top, 0px));
  padding: calc(13px + env(safe-area-inset-top, 0px)) 20px 15px;
  gap: 14px;
  align-items: center;
  background: linear-gradient(180deg, #073ed6 0%, #082fb7 100%);
  box-shadow: 0 10px 26px rgba(8, 47, 183, .22);
}

.header-logo {
  gap: 4px;
}

.header-title {
  gap: 12px;
}

.header-brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  border: 1px solid rgba(255,255,255,.75);
  box-shadow: 0 8px 18px rgba(2, 6, 23, .18);
}

.header-title-text {
  font-size: 1.28rem;
  font-weight: 850;
  letter-spacing: 0;
}

.header-logo .header-subtitle {
  font-size: .86rem;
  font-weight: 500;
  opacity: .92;
  margin-left: 60px;
  margin-top: -12px;
}

.header-actions {
  gap: 12px;
}

.header-icon-btn {
  width: 54px;
  height: 54px;
  background: rgba(255,255,255,.10);
  border: 1.5px solid rgba(255,255,255,.72);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}

.header-icon-btn .app-icon {
  width: 29px;
  height: 29px;
  color: #ffd43b;
  stroke-width: 2.15;
}

.header-avatar-btn {
  width: 52px;
  height: 52px;
  border: 2px solid rgba(255,255,255,.9);
  background: #e2e8f0;
  color: #0f172a;
  font-size: .95rem;
  box-shadow: 0 8px 18px rgba(2, 6, 23, .18);
}

.header-avatar-btn img {
  width: 52px;
  height: 52px;
}

.notif-badge {
  top: 6px;
  right: 7px;
  min-width: 13px;
  height: 13px;
  padding: 0;
  font-size: 0;
  border: 2px solid #073ed6;
}

.pages-container {
  background: #f6f8fc;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 24px);
}

.page {
  padding: 20px 18px 8px;
}

.page-title-bar {
  margin: 2px 0 20px;
}

.page-title-bar h2 {
  font-size: 1.42rem;
  line-height: 1.1;
  font-weight: 850;
  color: #111827;
  letter-spacing: 0;
}

.welcome-bar {
  min-height: 136px;
  padding: 24px;
  margin-bottom: 22px;
  border-radius: 20px;
  gap: 20px;
  background: linear-gradient(135deg, #1640c8 0%, #8733ea 100%);
  box-shadow: 0 16px 34px rgba(37, 99, 235, .24);
}

.welcome-avatar {
  width: 74px;
  height: 74px;
  border: 3px solid rgba(255,255,255,.72);
  box-shadow: 0 10px 24px rgba(2, 6, 23, .18);
}

.welcome-text h3 {
  font-size: 1.28rem;
  line-height: 1.2;
  font-weight: 850;
}

.welcome-text p {
  font-size: 1rem;
  opacity: .93;
  margin-top: 8px;
}

.stats-grid {
  gap: 16px;
  margin-bottom: 26px;
}

.stat-card {
  min-height: 116px;
  padding: 18px 16px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  box-shadow: 0 10px 26px rgba(15, 23, 42, .06);
  border-width: 1.5px;
}

.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(15, 23, 42, .09);
}

.stat-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 29px;
}

.stat-main {
  min-width: 0;
}

.stat-number {
  font-size: 2.05rem;
  font-weight: 900;
  line-height: .95;
  letter-spacing: 0;
}

.stat-label {
  margin-top: 8px;
  color: #111827;
  font-size: .95rem;
  font-weight: 650;
  line-height: 1.15;
  text-transform: none;
  letter-spacing: 0;
}

.stat-arrow {
  margin-left: auto;
  font-size: 2rem;
  line-height: 1;
  font-weight: 400;
}

.stat-members {
  border-color: #bfdbfe;
  background: linear-gradient(135deg, #ffffff 0%, #f4f8ff 100%);
}
.stat-members .stat-icon {
  color: #0b73ff;
  background: #dbeafe;
}
.stat-members .stat-number,
.stat-members .stat-arrow { color: #0b53d6; }

.stat-posts {
  border-color: #bbf7d0;
  background: linear-gradient(135deg, #ffffff 0%, #f4fff8 100%);
}
.stat-posts .stat-icon {
  color: #16a34a;
  background: #dcfce7;
}
.stat-posts .stat-number,
.stat-posts .stat-arrow { color: #16a34a; }

.stat-announcements {
  border-color: #fed7aa;
  background: linear-gradient(135deg, #ffffff 0%, #fff8f1 100%);
}
.stat-announcements .stat-icon {
  color: #f97316;
  background: #ffedd5;
}
.stat-announcements .stat-number,
.stat-announcements .stat-arrow { color: #f97316; }

.stat-resources {
  border-color: #e9d5ff;
  background: linear-gradient(135deg, #ffffff 0%, #fbf7ff 100%);
}
.stat-resources .stat-icon {
  color: #7c3aed;
  background: #f3e8ff;
}
.stat-resources .stat-number,
.stat-resources .stat-arrow { color: #7c3aed; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 12px;
}

.section-heading h3 {
  font-size: .98rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: .02em;
  color: #1f2937;
  font-weight: 850;
}

.section-heading button {
  border: 0;
  background: transparent;
  color: #081f8f;
  font-weight: 850;
  font-size: .92rem;
  padding: 6px 0 6px 10px;
}

.mini-card {
  min-height: 96px;
  padding: 18px 20px;
  margin-bottom: 14px;
  border: 0;
  border-radius: 17px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .055);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
}

.mini-card-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mini-card strong {
  font-size: 1.04rem;
  line-height: 1.25;
  color: #111827;
}

.mini-card-arrow {
  margin-left: auto;
  color: #334155;
  font-size: 2rem;
  line-height: 1;
}

.bottom-nav {
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  min-height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding: 7px 7px env(safe-area-inset-bottom, 0px);
  background: rgba(255,255,255,.98);
  border-top: 1px solid rgba(226, 232, 240, .95);
  box-shadow: 0 -10px 28px rgba(15, 23, 42, .08);
}

.nav-item {
  gap: 4px;
  padding: 4px 2px 6px;
  color: #475569;
  font-size: .64rem;
  font-weight: 650;
  text-transform: none;
  letter-spacing: 0;
  border-radius: 14px;
  overflow: visible;
}

.nav-item::before {
  display: none;
}

.nav-item .nav-icon {
  width: 27px;
  height: 27px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 27px;
  transition: color var(--t-base), transform var(--t-base);
}

.nav-item .nav-icon svg {
  width: 25px;
  height: 25px;
}

.nav-label {
  display: block;
  max-width: 100%;
  line-height: 1.05;
  white-space: nowrap;
  text-transform: none;
}

.nav-item.active {
  color: #073ed6;
}

.nav-item.active .nav-icon {
  transform: translateY(-1px);
}

.nav-item.active .nav-label {
  font-weight: 850;
}

.chat-nav-badge {
  top: 4px;
  right: 10px;
}

.fab {
  width: 62px;
  height: 62px;
  right: 22px;
  bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, #073ed6 0%, #082fb7 100%);
  border: 4px solid #ffffff;
  box-shadow: 0 14px 28px rgba(8, 47, 183, .34);
}

.fab:hover {
  transform: translateY(-2px);
  background: linear-gradient(180deg, #073ed6 0%, #082fb7 100%);
}

@media (max-width: 520px) {
  :root {
    --header-h: 92px;
    --nav-h: 74px;
  }

  .page {
    padding-left: 18px;
    padding-right: 18px;
  }
}

@media (max-width: 420px) {
  .app-header {
    min-height: calc(88px + env(safe-area-inset-top, 0px));
    padding: calc(12px + env(safe-area-inset-top, 0px)) 15px 13px;
    gap: 10px;
  }

  .header-brand-logo {
    width: 43px;
    height: 43px;
    border-radius: 12px;
  }

  .header-title {
    gap: 10px;
  }

  .header-title-text {
    font-size: 1.05rem;
  }

  .header-logo .header-subtitle {
    display: block;
    margin-left: 53px;
    margin-top: -10px;
    font-size: .73rem;
  }

  .header-actions {
    gap: 8px;
  }

  .header-icon-btn,
  .header-avatar-btn {
    width: 46px;
    height: 46px;
  }

  .header-avatar-btn img {
    width: 46px;
    height: 46px;
  }

  .header-icon-btn .app-icon {
    width: 25px;
    height: 25px;
  }

  .page-title-bar h2 {
    font-size: 1.33rem;
  }

  .welcome-bar {
    min-height: 116px;
    padding: 20px;
    gap: 16px;
  }

  .welcome-avatar {
    width: 62px;
    height: 62px;
  }

  .welcome-text h3 {
    font-size: 1.12rem;
  }

  .welcome-text p {
    font-size: .92rem;
  }

  .stats-grid {
    gap: 14px;
  }

  .stat-card {
    min-height: 108px;
    padding: 16px 12px;
    gap: 10px;
    border-radius: 16px;
  }

  .stat-icon {
    width: 48px;
    height: 48px;
    font-size: 24px;
  }

  .stat-number {
    font-size: 1.85rem;
  }

  .stat-label {
    font-size: .82rem;
  }

  .stat-arrow {
    font-size: 1.7rem;
  }

  .nav-label {
    display: block !important;
    font-size: .55rem;
  }

  .nav-item .nav-icon {
    width: 25px;
    height: 25px;
  }

  .nav-item .nav-icon svg {
    width: 23px;
    height: 23px;
  }
}

@media (max-width: 360px) {
  .page {
    padding-left: 10px;
    padding-right: 10px;
  }

  .header-title-text {
    font-size: .92rem;
  }

  .header-logo .header-subtitle {
    font-size: .65rem;
  }

  .header-icon-btn,
  .header-avatar-btn {
    width: 42px;
    height: 42px;
  }

  .header-avatar-btn img {
    width: 42px;
    height: 42px;
  }

  .stats-grid {
    gap: 10px;
  }

  .stat-card {
    padding: 14px 9px;
    gap: 8px;
  }

  .stat-icon {
    width: 42px;
    height: 42px;
    font-size: 21px;
  }

  .stat-label {
    font-size: .74rem;
  }

  .nav-label {
    font-size: .5rem;
  }
}

@media (max-width: 760px) {
  .group-admin-modal {
    width: min(96vw, 520px);
  }

  .group-admin-layout {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .group-add-row {
    flex-direction: column;
  }

  .group-member-row {
    align-items: flex-start;
    gap: 8px;
  }

  .group-member-row .btn {
    align-self: flex-end;
  }
}

@media (max-width: 420px) {
  .chat-title-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .group-manage-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .group-manage-head .btn {
    width: 100%;
  }
}
