/* ============================================================
   Ulgamda CMS — Theme Stylesheet  v9-improved
   Design: Editorial magazine with Turkmen cultural warmth
   FIXES: missing variables, duplicate definitions, layout bugs
   ============================================================ */

/* ── Google Fonts — loaded via <link> in header.php ──────── */
/* @import removed: fonts are loaded via <link rel="preload"> */

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  /* Brand colours */
  --green:       #1a9c5b;
  --green-light: #2ecc71;
  --green-dark:  #0f5c35;
  --teal:        #0d8a7a;
  --red:         #dc2626;
  --amber:       #d97706;
  --blue:        #2563eb;
  --purple:      #7c3aed;

  /* Semantic alias — always resolves */
  --primary:     #1a9c5b;   /* = --green */

  /* Backgrounds */
  --bg:          #f7f6f2;
  --bg-white:    #ffffff;
  --bg-card:     #ffffff;
  --surface:     #f0ede6;
  --bg-hover:    #eceae4;   /* was missing → caused .share-btn:hover bug */

  /* Text */
  --text:        #1a1612;
  --text-1:      #1a1612;   /* alias for --text (fixes index.php online count) */
  --text-2:      #4a4540;
  --text-3:      #7a7570;

  /* Borders */
  --border:      #e2ddd6;
  --border-2:    #cec9c0;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.05);
  --shadow-lg:   0 12px 40px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);
  --shadow:      var(--shadow-sm);   /* alias — fixes pm-layout bug */

  /* Shape */
  --radius:      8px;
  --radius-lg:   14px;
  --radius-xl:   20px;

  /* Typography */
  --font-serif:   'Source Serif 4', Georgia, serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-mono:    'JetBrains Mono', monospace;
  --font-ui:      'Inter', -apple-system, 'Segoe UI', sans-serif;

  /* Layout */
  --header-h:    64px;
  --sidebar-w:   300px;
  --max-w:       1180px;

  /* Transitions */
  --ease:        cubic-bezier(.4,0,.2,1);
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); }
ul, ol { list-style: none; }

/* ── Layout ───────────────────────────────────────────────── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
}
.page-wrap {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  gap: 32px;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ── Header ───────────────────────────────────────────────── */
.site-header {
  background: var(--bg-white);
  border-bottom: 2px solid var(--green);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .25s var(--ease);
}
.site-header.scrolled { box-shadow: var(--shadow-md); }

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
}

.site-logo {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 900;
  color: var(--green-dark);
  letter-spacing: -.5px;
  white-space: nowrap;
  margin-left: 4px;
  flex-shrink: 0;
}
.site-logo span { color: var(--green-light); }
.site-logo small {
  display: block;
  font-family: var(--font-ui);
  font-size: .6rem;
  font-weight: 400;
  color: var(--text-3);
  letter-spacing: .07em;
  text-transform: uppercase;
  margin-top: -4px;
}

.header-search { flex: 1; max-width: 380px; }
.search-form { position: relative; }
.search-form input {
  width: 100%;
  padding: 9px 42px 9px 16px;
  border: 2px solid var(--border);
  border-radius: 99px;
  font-family: var(--font-ui);
  font-size: .88rem;
  background: var(--surface);
  transition: border-color .2s, background .2s, box-shadow .2s;
  color: var(--text);
}
.search-form input:focus {
  outline: none;
  border-color: var(--green);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(26,156,91,.12);
}
.search-form button {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 99px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .18s;
}
.search-form button:hover { background: var(--green-dark); }

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 99px;
  font-size: .85rem;
  font-family: var(--font-ui);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .18s var(--ease);
  text-decoration: none;
  white-space: nowrap;
}
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 2px solid var(--border);
}
.btn-ghost:hover {
  border-color: var(--green);
  color: var(--green);
  background: transparent;
}
.btn-primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 2px 8px rgba(26,156,91,.25);
}
.btn-primary:hover {
  background: var(--green-dark);
  color: #fff;
  box-shadow: 0 4px 14px rgba(26,156,91,.38);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); box-shadow: none; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-danger:hover  { background: #b91c1c; color: #fff; transform: translateY(-1px); }
.btn-sm  { padding: 5px 12px; font-size: .8rem; }

/* ── Hamburger ────────────────────────────────────────────── */
.hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-2);
  transition: all .18s;
  flex-shrink: 0;
}
.hamburger:hover {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.hamburger:active { background: var(--green-dark); }

/* ── Navigation bar — replaced by sidebar ─────────────────── */
.nav-bar  { display: none !important; }
.nav-inner { display: none !important; }

/* ── Mobile / Sidebar Menu ────────────────────────────────── */
.mobile-menu {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.mobile-menu.open { display: block; }

.mobile-menu-panel {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 300px;
  max-width: 88vw;
  background: var(--bg-white);
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: var(--shadow-lg);
  animation: slideIn .28s var(--ease) both;
  display: flex;
  flex-direction: column;
}
@keyframes slideIn {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

.mobile-menu-close {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 34px; height: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: all .15s;
  z-index: 1;
}
.mobile-menu-close:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.mobile-menu-logo-wrap {
  padding: 18px 20px 10px;
}
.mobile-menu-site-logo { font-size: 1.4rem; }

.mobile-menu .search-form { padding: 8px 16px 14px; }
.mobile-menu .search-form input { width: 100%; border-radius: var(--radius-lg); }

.mobile-menu-cats { flex: 1; }
.mobile-menu-cats a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: .9rem;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.mobile-menu-cats a:hover,
.mobile-menu-cats a.active {
  background: var(--surface);
  border-left-color: var(--green);
  color: var(--green-dark);
}

.mobile-menu-footer {
  padding: 16px 20px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}
.mobile-menu-footer .btn { justify-content: center; }

/* Write link inside menu */
.menu-write-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  margin: 0 12px 8px;
  background: var(--green);
  color: #fff !important;
  border-radius: var(--radius);
  font-weight: 700;
  font-family: var(--font-ui);
  font-size: .92rem;
  border-left: none !important;
  transition: background .15s;
  box-shadow: 0 2px 8px rgba(26,156,91,.25);
}
.menu-write-link:hover {
  background: var(--green-dark) !important;
  color: #fff !important;
}

/* Mowzuklar section accordion */
.menu-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: var(--text-2);
  font-family: var(--font-ui);
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  cursor: pointer;
  user-select: none;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  transition: color .15s;
}
.menu-section-header:hover { color: var(--green-dark); }
.menu-chevron {
  margin-left: auto;
  transition: transform .25s var(--ease);
  display: flex;
  color: var(--text-3);
}

.menu-topics-list {
  overflow: hidden;
  max-height: 0;
  transition: max-height .3s var(--ease);
}
.menu-topics-list.open { max-height: 900px; }

.menu-topic-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px 10px 36px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: .88rem;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.menu-topic-item:hover,
.menu-topic-item.active {
  background: var(--surface);
  border-left-color: var(--green);
  color: var(--green-dark);
}

/* ── View mode toggle ─────────────────────────────────────── */
.view-toggle-wrap {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.view-toggle-label {
  display: block;
  font-size: .7rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 7px;
  font-family: var(--font-ui);
}
.view-toggle-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 20px;
  border: 1.5px solid var(--border-2);
  background: var(--bg-white);
  color: var(--text-2);
  font-size: .77rem;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all .18s;
}
.view-toggle-btn:hover,
.view-toggle-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(26,156,91,.3);
}

/* Force view overrides */
html.force-mobile .page-wrap   { grid-template-columns: 1fr !important; }
html.force-mobile .sidebar     { display: none !important; }
html.force-mobile .header-search { display: none !important; }
html.force-desktop .page-wrap  { grid-template-columns: 1fr var(--sidebar-w) !important; }
html.force-desktop .sidebar    { display: flex !important; }
html.force-desktop .header-search { display: flex !important; }

/* ── Theme toggle ─────────────────────────────────────────── */
.theme-toggle-wrap {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
}
.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 0;
  font-family: var(--font-ui);
  color: var(--text-2);
}
.theme-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .9rem;
  font-weight: 500;
}
.theme-toggle-track {
  width: 42px; height: 24px;
  background: var(--border-2);
  border-radius: 99px;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.theme-toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  transition: transform .2s var(--ease);
}
body.dark-mode .theme-toggle-track { background: var(--green); }
body.dark-mode .theme-toggle-thumb { transform: translateX(18px); }

/* ── Profile Trigger ──────────────────────────────────────── */
.profile-trigger {
  display: flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  padding: 4px 10px 4px 4px;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: .84rem;
  font-weight: 600;
  transition: all .18s;
  max-width: 180px;
}
.profile-trigger:hover {
  border-color: var(--green);
  background: var(--surface);
}
.profile-trigger span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 110px;
}

/* ── Profile Drawer ───────────────────────────────────────── */
.profile-drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 215;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}
.profile-drawer-overlay.open { opacity: 1; pointer-events: all; }

.profile-drawer {
  position: fixed; top: 0; right: 0; height: 100%;
  width: 300px; max-width: 92vw;
  background: var(--bg-white);
  z-index: 220;
  box-shadow: var(--shadow-lg);
  transform: translateX(110%);
  transition: transform .32s var(--ease);
  display: flex;
  flex-direction: column;
}
.profile-drawer.open { transform: translateX(0); }

.profile-drawer-header {
  display: flex;
  justify-content: flex-end;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.profile-drawer-close {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 34px; height: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: all .15s;
}
.profile-drawer-close:hover { background: var(--red); border-color: var(--red); color: #fff; }

.profile-drawer-user {
  padding: 22px 22px 18px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, var(--surface), transparent);
}
.profile-drawer-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--green);
  margin: 0 auto 12px;
  display: block;
  box-shadow: 0 0 0 3px rgba(26,156,91,.15);
}
.profile-drawer-name {
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.profile-drawer-role { font-size: .8rem; color: var(--text-3); font-family: var(--font-ui); }

.profile-drawer-nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.profile-drawer-link {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  color: var(--text);
  font-family: var(--font-ui); font-size: .88rem;
  transition: all .15s;
  border-left: 3px solid transparent;
}
.profile-drawer-link:hover {
  background: var(--surface);
  color: var(--green);
  border-left-color: var(--green);
}
.profile-drawer-link svg { color: var(--text-3); flex-shrink: 0; }
.profile-drawer-link:hover svg { color: var(--green); }
.profile-drawer-admin { color: var(--amber) !important; }
.profile-drawer-admin svg { color: var(--amber) !important; }
.profile-drawer-admin:hover { background: #fef3c7; border-left-color: var(--amber); }

.profile-drawer-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
}
.profile-drawer-logout {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--red);
  font-family: var(--font-ui); font-size: .9rem; font-weight: 600;
  width: 100%;
  transition: all .15s;
}
.profile-drawer-logout:hover { background: #fef2f2; }

/* ── Notification Bell ────────────────────────────────────── */
.notif-bell {
  position: relative;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: all .15s;
  text-decoration: none;
}
.notif-bell:hover { background: var(--surface); color: var(--text); }

.notif-badge {
  position: absolute;
  top: 1px; right: 1px;
  background: var(--red);
  color: #fff;
  font-family: var(--font-ui); font-size: .62rem; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  border: 2px solid var(--bg-white);
}

/* ── Notifications Dropdown ───────────────────────────────── */
.notif-dropdown {
  position: fixed;
  top: calc(var(--header-h) + 10px);
  right: 18px;
  width: 380px;
  max-width: calc(100vw - 36px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,.07), 0 10px 32px -4px rgba(0,0,0,.14), 0 0 0 1px rgba(0,0,0,.06);
  overflow: hidden;
  z-index: 210;
  opacity: 0;
  transform: translateY(-8px) scale(.97);
  pointer-events: none;
  transition: opacity .2s, transform .2s var(--ease);
}
.notif-dropdown.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}
.notif-dropdown::before {
  content: '';
  position: absolute;
  top: -7px; right: 26px;
  width: 14px; height: 14px;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,.08);
  border-left: 1px solid rgba(0,0,0,.08);
  transform: rotate(45deg);
  border-radius: 2px 0 0 0;
}
.notif-dropdown-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px 14px;
  position: relative; z-index: 1;
  border-bottom: 1px solid var(--border);
}
.notif-dropdown-header > span {
  font-family: var(--font-ui); font-size: .95rem; font-weight: 700; color: var(--text);
}
.notif-mark-all {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-ui); font-size: .8rem; font-weight: 600;
  color: var(--green); padding: 4px 8px; border-radius: 6px;
  transition: background .15s;
}
.notif-mark-all:hover { background: #f0fdf4; color: var(--green-dark); }

.notif-list {
  max-height: 420px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.notif-list::-webkit-scrollbar { width: 4px; }
.notif-list::-webkit-scrollbar-track { background: transparent; }
.notif-list::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }

.notif-empty {
  padding: 40px 20px; text-align: center;
  color: var(--text-3); font-family: var(--font-ui); font-size: .875rem;
}

.notif-item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(0,0,0,.05);
  transition: background .15s;
  position: relative; color: var(--text);
  text-decoration: none; cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface); }
.notif-item.notif-unread { background: #f0fdf4; }
.notif-item.notif-unread:hover { background: #dcfce7; }

.notif-avatar {
  width: 42px; height: 42px;
  border-radius: 50%; object-fit: cover; flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(46,204,113,.2);
}
.notif-content {
  flex: 1; min-width: 0;
  font-family: var(--font-ui); font-size: .875rem; line-height: 1.5;
  color: var(--text);
}
.notif-actor { font-weight: 700; color: var(--text); }
.notif-time { font-size: .75rem; color: var(--text-3); margin-top: 4px; display: block; }
.notif-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green); flex-shrink: 0; margin-top: 6px;
  box-shadow: 0 0 0 2px rgba(26,156,91,.2);
}

/* ── Post List ────────────────────────────────────────────── */
.posts-list { display: flex; flex-direction: column; gap: 20px; }

.post-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .22s var(--ease), transform .22s var(--ease), border-color .22s;
  display: grid;
  grid-template-columns: 1fr;
}
.post-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border-2);
}
.post-card.has-image { grid-template-columns: 1fr 200px; }

.post-card-body {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.post-card-image { order: 1; overflow: hidden; }
.post-card-image img {
  width: 100%; height: 100%;
  object-fit: cover;
  min-height: 160px;
  transition: transform .3s var(--ease);
}
.post-card:hover .post-card-image img { transform: scale(1.04); }

.post-card-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.cat-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 99px;
  font-size: .73rem; font-family: var(--font-ui); font-weight: 700;
  background: var(--green); color: #fff;
  letter-spacing: .01em;
}
.featured-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 99px;
  font-size: .73rem; font-family: var(--font-ui); font-weight: 700;
  background: var(--amber); color: #fff;
}
.post-date {
  font-size: .78rem; color: var(--text-3);
  font-family: var(--font-ui);
}

.post-card-title {
  font-family: var(--font-display);
  font-size: 1.22rem; font-weight: 700; line-height: 1.3;
  color: var(--text);
}
.post-card-title a { color: inherit; }
.post-card-title a:hover { color: var(--green-dark); }

.post-card-excerpt {
  color: var(--text-2); font-size: .91rem; line-height: 1.65;
  display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}

.post-card-footer {
  display: flex; align-items: center; gap: 14px;
  margin-top: auto; padding-top: 12px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.post-author { display: flex; align-items: center; gap: 8px; }
.post-author img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.post-author-name {
  font-family: var(--font-ui); font-size: .8rem; font-weight: 600;
  color: var(--text-2);
}
.post-stats { margin-left: auto; display: flex; gap: 12px; flex-shrink: 0; }
.post-stat {
  display: flex; align-items: center; gap: 4px;
  font-size: .78rem; color: var(--text-3); font-family: var(--font-ui);
}
.post-stat svg { width: 13px; height: 13px; }
.read-more {
  font-family: var(--font-ui); font-size: .82rem; font-weight: 700;
  color: var(--green); flex-shrink: 0;
}
.read-more:hover { color: var(--green-dark); }

/* ── Featured Hero ────────────────────────────────────────── */
.featured-hero {
  background: var(--green-dark);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: 24px;
  position: relative;
  min-height: 320px;
  display: flex; align-items: flex-end;
}
.featured-hero-img {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: .35;
  transition: opacity .3s;
}
.featured-hero:hover .featured-hero-img { opacity: .28; }
.featured-hero-body {
  position: relative; padding: 32px;
  background: linear-gradient(to top, rgba(15,92,53,.96) 40%, transparent);
  width: 100%;
}
.featured-hero-body h2 {
  font-family: var(--font-display);
  font-size: 1.7rem; font-weight: 900; color: #fff; line-height: 1.25;
  margin-bottom: 10px;
}
.featured-hero-body p  { color: rgba(255,255,255,.72); font-size: .93rem; margin-bottom: 16px; }
.featured-hero-body .post-author-name { color: rgba(255,255,255,.75); }
.featured-hero-body .post-date        { color: rgba(255,255,255,.5); }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 20px; }
.widget {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.widget:hover { box-shadow: var(--shadow-md); }
.widget-title {
  font-family: var(--font-ui); font-size: .74rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .1em; color: var(--text-3);
  padding: 13px 18px 11px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.widget-body { padding: 14px 18px; }

/* Category list */
.cat-list { display: flex; flex-direction: column; gap: 2px; }
.cat-list-item a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: var(--radius);
  font-family: var(--font-ui); font-size: .86rem; color: var(--text);
  transition: background .15s;
}
.cat-list-item a:hover { background: var(--surface); color: var(--green-dark); }
.cat-list-item.active a { background: var(--green); color: #fff; font-weight: 600; }
.cat-list-item.active a:hover { background: var(--green-dark); color: #fff; }
.cat-list-item.active .cat-count { background: rgba(255,255,255,.25); color: #fff; }
.cat-list-item .cat-info { display: flex; align-items: center; gap: 8px; }
.cat-count {
  font-size: .72rem; background: var(--surface);
  padding: 2px 7px; border-radius: 99px; color: var(--text-3); font-weight: 600;
}

/* Popular widget */
.popular-list { display: flex; flex-direction: column; gap: 14px; }
.popular-item { display: flex; gap: 10px; align-items: flex-start; }
.popular-num {
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 900;
  color: var(--border-2); line-height: 1; flex-shrink: 0; width: 26px;
}
.popular-title a {
  font-family: var(--font-ui); font-size: .86rem; color: var(--text);
  line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.popular-title a:hover { color: var(--green-dark); }
.popular-meta { font-size: .73rem; color: var(--text-3); font-family: var(--font-ui); margin-top: 2px; }

/* Tags widget */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-cloud a {
  padding: 4px 11px; border-radius: 99px;
  border: 1px solid var(--border);
  font-size: .78rem; font-family: var(--font-ui); color: var(--text-2);
  transition: all .15s;
}
.tag-cloud a:hover { background: var(--green); border-color: var(--green); color: #fff; }

/* User widget */
.user-widget { text-align: center; padding: 22px 18px; }
.user-widget img {
  width: 70px; height: 70px; border-radius: 50%;
  margin: 0 auto 12px;
  border: 3px solid var(--green);
  object-fit: cover;
  box-shadow: 0 0 0 4px rgba(26,156,91,.12);
}
.user-widget-name  { font-family: var(--font-ui); font-weight: 700; font-size: .95rem; color: var(--text); }
.user-widget-role  { font-size: .78rem; color: var(--text-3); margin-bottom: 14px; font-family: var(--font-ui); }
.user-widget-stats { display: flex; justify-content: center; gap: 24px; margin-bottom: 14px; }
.user-widget-stat label { display: block; font-size: .7rem; color: var(--text-3); font-family: var(--font-ui); text-transform: uppercase; letter-spacing: .06em; }
.user-widget-stat strong { font-size: 1.2rem; color: var(--text); font-family: var(--font-display); }

/* ── Single Post ──────────────────────────────────────────── */
.post-full {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.post-full-header { padding: 36px 40px 24px; }
.post-full-title {
  font-family: var(--font-display);
  font-size: 2rem; font-weight: 900; line-height: 1.2; color: var(--text);
  margin: 14px 0 18px;
}
.post-full-cover { width: 100%; max-height: 460px; object-fit: cover; }
.post-full-body {
  padding: 32px 40px 40px;
  font-family: var(--font-serif); font-size: 1.05rem; line-height: 1.85; color: var(--text);
}
.post-full-body p { margin-bottom: 1.4em; }
.post-full-body h2, .post-full-body h3 {
  font-family: var(--font-display); margin: 1.8em 0 .7em;
}
.post-full-body blockquote {
  border-left: 4px solid var(--green); padding: 12px 20px;
  background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-2); font-style: italic; margin: 1.4em 0;
}
.post-full-body ol, .post-full-body ul {
  padding-left: 1.6em; margin-bottom: 1.4em; list-style: revert;
}
.post-full-body li { margin-bottom: .4em; }
.post-full-body pre {
  background: #1e1e2e; color: #cdd6f4;
  padding: 16px 20px; border-radius: var(--radius);
  overflow-x: auto; margin: 1.4em 0;
  font-family: var(--font-mono); font-size: .88em;
}
.post-full-body code {
  font-family: var(--font-mono); font-size: .88em;
  background: var(--surface); padding: 1px 6px; border-radius: 4px;
}
.post-full-body pre code { background: none; padding: 0; }
.post-full-body table {
  display: block; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-collapse: collapse; width: 100%;
}
.post-full-body th, .post-full-body td {
  border: 1px solid var(--border); padding: 8px 12px;
  font-size: .9rem; white-space: nowrap;
}

/* Tags */
.post-full-tags { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 40px 28px; }
.post-full-tags a {
  display: inline-block; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Post actions */
.post-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 18px 40px; border-top: 1px solid var(--border);
}
.like-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 99px;
  border: 2px solid var(--border); background: var(--bg-white);
  cursor: pointer; font-family: var(--font-ui); font-size: .86rem; font-weight: 600;
  color: var(--text-2); transition: all .18s;
}
.like-btn:hover   { background: #fef2f2; border-color: var(--red); color: var(--red); }
.like-btn.liked   { background: #fef2f2; border-color: var(--red); color: var(--red); }
.like-btn.liked svg { fill: var(--red); stroke: var(--red); }
.like-btn:not(:disabled):hover { transform: scale(1.04); }
.like-btn svg { width: 17px; height: 17px; }

.dislike-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 99px;
  border: 2px solid var(--border); background: var(--bg-white);
  cursor: pointer; font-family: var(--font-ui); font-size: .86rem; font-weight: 600;
  color: var(--text-2); transition: all .18s;
}
.dislike-btn:hover,
.dislike-btn.disliked { background: #fff7ed; border-color: var(--amber); color: var(--amber); }
.dislike-btn svg { width: 17px; height: 17px; }

.share-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 99px;
  border: 2px solid var(--border); background: var(--bg-white);
  cursor: pointer; font-family: var(--font-ui); font-size: .86rem; font-weight: 600;
  color: var(--text-2); transition: all .18s;
}
.share-btn:hover { background: var(--bg-hover); border-color: var(--green); color: var(--green); }

/* ── Author block ─────────────────────────────────────────── */
.post-author-block {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 0 0; margin-top: 12px;
  border-top: 1px solid var(--border);
}
.post-author-avatar { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.post-author-nick-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.post-author-date { font-size: .8rem; color: var(--text-3); margin-top: 3px; font-family: var(--font-ui); }

/* ── Online indicators ────────────────────────────────────── */
.online-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
}
.online-dot.online  { background: var(--green); box-shadow: 0 0 0 2px rgba(46,204,113,.25); }
.online-dot.offline { background: var(--text-3); }
.online-dot-sm {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--green);
  margin-right: 4px; vertical-align: middle;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot { 0%,100%{ opacity:1; } 50%{ opacity:.5; } }
.online  { color: var(--green); }
.recent  { color: var(--amber); }
.offline { color: var(--text-3); }

/* ── Online indicator on avatar ───────────────────────────── */
.online-indicator {
  position: absolute; bottom: 2px; right: 2px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--border-2); border: 2px solid #fff;
  transition: background .3s;
}
.online-indicator.is-online { background: var(--green); }

/* ── Comments ─────────────────────────────────────────────── */
.comments-section {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--border);
  margin-top: 24px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.comments-header {
  padding: 18px 30px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-ui); font-weight: 700; font-size: .93rem;
}
.comment-form-wrap {
  padding: 22px 30px;
  border-bottom: 1px solid var(--border);
}
.comment-form-wrap textarea {
  width: 100%; min-height: 100px; padding: 12px 16px;
  border: 2px solid var(--border); border-radius: var(--radius-lg);
  font-family: var(--font-serif); font-size: .95rem; resize: vertical;
  background: var(--bg-white); color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.comment-form-wrap textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(26,156,91,.1);
}
.comment-form-actions {
  display: flex; justify-content: space-between; align-items: center; margin-top: 10px;
}
.comment-list { padding: 20px 30px; display: flex; flex-direction: column; gap: 18px; }
.comment { display: flex; gap: 14px; }
.comment-avatar img {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--border); flex-shrink: 0;
}
.comment-body { flex: 1; }
.comment-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px; flex-wrap: wrap;
}
.comment-author { font-family: var(--font-ui); font-weight: 700; font-size: .86rem; }
.comment-time   { font-size: .76rem; color: var(--text-3); font-family: var(--font-ui); }
.comment-text   { font-size: .9rem; color: var(--text-2); line-height: 1.6; overflow-wrap: break-word; word-break: break-word; }
.comment-reply-btn {
  background: none; border: none; cursor: pointer;
  font-size: .76rem; color: var(--text-3); font-family: var(--font-ui);
  padding: 3px 0; margin-top: 6px;
}
.comment-reply-btn:hover { color: var(--green); }
.comment-replies {
  margin-top: 14px; padding-left: 18px;
  border-left: 2px solid var(--border-2);
  display: flex; flex-direction: column; gap: 14px;
}

/* ── Auth Forms ───────────────────────────────────────────── */
.auth-page {
  min-height: calc(100vh - var(--header-h));
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
}
.auth-card {
  background: var(--bg-white); border: 1.5px solid var(--border);
  border-radius: var(--radius-xl); padding: 40px;
  width: 100%; max-width: 440px; box-shadow: var(--shadow-md);
}
.auth-title {
  font-family: var(--font-display); font-size: 1.7rem; font-weight: 900;
  margin-bottom: 24px; color: var(--text);
}
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; font-family: var(--font-ui); font-size: .84rem;
  font-weight: 600; color: var(--text-2); margin-bottom: 6px;
}
.form-control, .form-input {
  width: 100%; padding: 10px 14px;
  border: 2px solid var(--border); border-radius: var(--radius);
  font-size: .95rem; font-family: var(--font-ui);
  background: var(--bg-white); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box; max-width: 100%;
}
.form-control:focus, .form-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(26,156,91,.12);
}
.form-control.error { border-color: var(--red); }
.form-hint  { font-size: .8rem; color: var(--text-3); margin-top: 4px; font-family: var(--font-ui); }
.form-error { font-size: .8rem; color: var(--red); margin-top: 4px; font-family: var(--font-ui); }

/* ── Write Post ───────────────────────────────────────────── */
.write-page { max-width: 860px; margin: 0 auto; padding: 28px 20px 60px; }
.write-card {
  background: var(--bg-white); border: 1.5px solid var(--border);
  border-radius: var(--radius-xl); padding: 36px; box-shadow: var(--shadow-sm);
}
.write-title-input {
  width: 100%; border: none; outline: none;
  font-family: var(--font-display); font-size: 1.8rem; font-weight: 900;
  color: var(--text); background: transparent; line-height: 1.3;
  border-bottom: 2px solid var(--border); padding-bottom: 14px; margin-bottom: 16px;
  resize: none; overflow: hidden; box-sizing: border-box;
}
.write-title-input::placeholder { color: var(--border-2); }
.write-body-input {
  width: 100%; min-height: 340px; border: none; outline: none;
  font-family: var(--font-serif); font-size: 1.05rem; line-height: 1.8;
  color: var(--text); background: transparent; resize: vertical;
  box-sizing: border-box;
}
.write-body-input::placeholder { color: var(--border-2); }
.write-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.write-toolbar-btn {
  padding: 6px 10px; border-radius: var(--radius);
  font-family: var(--font-mono); font-size: .8rem;
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; color: var(--text-2); transition: all .15s;
}
.write-toolbar-btn:hover { background: var(--green); color: #fff; border-color: var(--green); }
.write-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }

/* ── Flash Messages ───────────────────────────────────────── */
/* Inline flash (inside page) */
.flash { padding: 12px 18px; border-radius: var(--radius); margin-bottom: 14px; font-family: var(--font-ui); font-size: .88rem; }
.flash--success, .flash-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.flash--error,   .flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash--info,    .flash-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.flash--warning  { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* Toast flash (fixed position) */
.flash-messages {
  position: fixed;
  top: calc(var(--header-h) + 12px);
  right: 16px;
  z-index: 9000;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.flash-messages .flash {
  pointer-events: auto;
  animation: slideInRight .3s var(--ease);
  box-shadow: var(--shadow-md);
}
@keyframes slideInRight {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  margin-top: 28px; padding: 0 12px;
}
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 10px;
  border-radius: 99px; font-family: var(--font-ui);
  font-size: .84rem; font-weight: 600;
  border: 2px solid var(--border); color: var(--text-2);
  text-decoration: none; transition: all .15s; box-sizing: border-box;
}
.pagination a:hover       { border-color: var(--green); color: var(--green); background: rgba(26,156,91,.06); }
.pagination .active,
.pagination span.active   { background: var(--green); border-color: var(--green); color: #fff; }
.pagination .dots         { border-color: transparent; }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: clamp(32px, 8vw, 60px) 20px; text-align: center;
  color: var(--text-3); font-family: var(--font-ui);
}
.empty-state-icon { font-size: clamp(2.5rem, 8vw, 3.5rem); margin-bottom: 14px; }
.empty-state h3   { font-family: var(--font-display); font-size: 1.1rem; color: var(--text-2); margin-bottom: 6px; }
.empty-state p    { font-size: .9rem; max-width: 280px; line-height: 1.5; }

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 24px;
}
.page-header h1 {
  font-family: var(--font-display); font-size: clamp(1.3rem, 4vw, 1.7rem);
  font-weight: 900; color: var(--text);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-ui); font-size: .8rem; color: var(--text-3);
  margin-bottom: 10px;
}
.breadcrumb a { color: var(--green); }
.breadcrumb span { color: var(--border-2); }

/* ── Divider ──────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 22px 0; }
hr.divider { margin: 26px 0; }

/* ── Admin Layout ─────────────────────────────────────────── */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.admin-sidebar {
  background: var(--green-dark); padding: 24px 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-sidebar-logo {
  padding: 0 20px 24px;
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 900; color: #fff;
}
.admin-sidebar-logo small {
  display: block; font-size: .65rem; color: rgba(255,255,255,.45);
  text-transform: uppercase; letter-spacing: .06em; margin-top: 2px;
}
.admin-nav-label {
  padding: 6px 20px; font-size: .68rem; font-family: var(--font-ui);
  font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: rgba(255,255,255,.32);
}
.admin-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: rgba(255,255,255,.68);
  font-family: var(--font-ui); font-size: .86rem; transition: all .15s;
  border-left: 3px solid transparent;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.admin-nav a svg { flex-shrink: 0; }
.admin-nav a:hover,
.admin-nav a.active,
.admin-nav a[aria-current="page"] {
  background: rgba(255,255,255,.09); color: #fff;
  border-left-color: var(--green-light);
}

.admin-main { padding: 32px; background: var(--bg); overflow-y: auto; }

.admin-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 26px; flex-wrap: wrap; gap: 12px;
}
.admin-title {
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 900;
  color: var(--text); display: flex; align-items: center; gap: 8px;
}

/* Stats grid — single clean definition */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-white); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow-sm); overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card-icon { font-size: 1.8rem; margin-bottom: 8px; }
.stat-card-value {
  font-family: var(--font-display); font-size: 2rem; font-weight: 900;
  color: var(--green-dark); line-height: 1.1; word-break: break-all;
}
.stat-card-label {
  font-family: var(--font-ui); font-size: .76rem; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .07em; margin-top: 4px;
}

/* Admin table */
.admin-table-wrap {
  border-radius: var(--radius-lg); border: 1px solid var(--border);
  overflow: hidden; overflow-x: auto; -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-sm);
}
.admin-table { width: 100%; border-collapse: collapse; font-family: var(--font-ui); font-size: .86rem; }
.admin-table thead { background: var(--surface); }
.admin-table th {
  padding: 11px 14px; text-align: left; font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-3);
  white-space: nowrap; border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--surface); }
.admin-table .admin-sidebar-nav a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Admin tabs */
.admin-tabs-row {
  display: flex; gap: 0; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none; flex-wrap: nowrap;
}
.admin-tabs-row::-webkit-scrollbar { display: none; }
.admin-tabs-row a { flex-shrink: 0; white-space: nowrap; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 99px;
  font-family: var(--font-ui); font-size: .72rem; font-weight: 700;
}
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red   { background: #fee2e2; color: #991b1b; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-blue  { background: #dbeafe; color: #1e40af; }
.badge-gray  { background: var(--surface); color: var(--text-3); }

/* ── Profile Page ─────────────────────────────────────────── */
/* User public profile page wrapper */
.user-profile-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}
.profile-hero {
  background: var(--green-dark); border-radius: var(--radius-xl);
  padding: 36px; display: flex; align-items: center; gap: 24px;
  margin-bottom: 28px; flex-wrap: wrap; flex-direction: column;
  text-align: center;
}
.profile-hero img {
  width: 96px; height: 96px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.3); object-fit: cover;
}
.profile-hero { position: relative; }
.profile-hero-info h1 { font-family: var(--font-display); font-size: 1.6rem; font-weight: 900; color: #fff; justify-content: center; }
.profile-hero-info p  { color: rgba(255,255,255,.6); font-size: .9rem; margin-top: 4px; }
.profile-hero-stats { margin-top: 12px; display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
.profile-hero-stat { text-align: center; }
.profile-hero-stat label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: rgba(255,255,255,.4); display: block; font-family: var(--font-ui); }
.profile-hero-stat strong { font-size: 1.3rem; color: #fff; font-family: var(--font-display); }
.profile-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

/* ── Members Page ─────────────────────────────────────────── */
.members-page { max-width: var(--max-w); margin: 0 auto; padding: 24px 20px 60px; box-sizing: border-box; }
.members-hero { padding: 28px 0 20px; border-bottom: 1px solid var(--border); margin-bottom: 28px; }
.members-hero-inner { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.members-title { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; margin: 0; }
.members-count { margin-left: auto; font-family: var(--font-ui); font-size: .875rem; color: var(--text-3); background: var(--surface); padding: 4px 10px; border-radius: 20px; border: 1px solid var(--border); }

/* Members search */
.members-search-form { margin: 16px 0 14px; }
.members-search-wrap {
  position: relative; display: flex; align-items: center;
  background: var(--bg-white); border: 1.5px solid var(--border);
  border-radius: 12px; overflow: hidden;
  transition: border-color .18s, box-shadow .18s;
}
.members-search-wrap:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 14%, transparent);
}
.members-search-icon {
  position: absolute; left: 14px; color: var(--text-3); pointer-events: none; flex-shrink: 0;
}
.members-search-input {
  flex: 1; border: none; background: transparent; outline: none;
  padding: 12px 48px 12px 42px;
  font-family: var(--font-ui); font-size: .9rem; color: var(--text);
  width: 100%; box-sizing: border-box;
}
.members-search-input::placeholder { color: var(--text-3); }
.members-search-clear {
  position: absolute; right: 46px; display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  color: var(--text-3); background: var(--surface); border: 1px solid var(--border);
  transition: all .15s; text-decoration: none;
}
.members-search-clear:hover { background: var(--border); color: var(--text); }
.members-search-btn {
  position: absolute; right: 8px; display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--green); color: #fff; border: none; cursor: pointer;
  transition: background .15s;
}
.members-search-btn:hover { background: var(--green-dark); }

.members-tabs { display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
.members-tab { display: flex; align-items: center; gap: 7px; padding: 8px 16px; border-radius: 8px; font-family: var(--font-ui); font-size: .875rem; font-weight: 500; color: var(--text-2); transition: all .15s; border: 1.5px solid transparent; flex-shrink: 0; white-space: nowrap; }
.members-tab:hover { background: var(--surface); color: var(--text); }
.members-tab.active { background: var(--green); color: #fff; border-color: var(--green-dark); }

.members-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.member-card {
  background: var(--bg-white); border-radius: 14px;
  border: 1.5px solid var(--border); padding: 20px 16px;
  text-align: center; transition: all .2s; text-decoration: none;
  color: var(--text); display: flex; flex-direction: column; align-items: center;
}
.member-card:hover { border-color: var(--green); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.member-avatar-wrap { position: relative; margin-bottom: 10px; }
.member-avatar { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.member-name { font-family: var(--font-ui); font-weight: 600; font-size: .86rem; color: var(--text); margin-bottom: 4px; }
.member-username { font-size: .78rem; color: var(--text-3); margin-bottom: 6px; }
.member-role-badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 20px; margin-bottom: 4px; letter-spacing: .02em; }
.member-online-status { font-size: .75rem; color: var(--text-3); margin-top: 2px; }
.member-online-status.online { color: var(--green); font-weight: 500; }
.member-posts { display: flex; align-items: center; gap: 4px; font-size: .75rem; color: var(--text-3); margin-top: 6px; }

/* Staff cards */
.staff-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.staff-group { margin-bottom: 32px; }
.staff-group-title {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-ui); font-size: .8rem; font-weight: 700;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .07em;
  margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.staff-count {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  font-size: .72rem; color: var(--text-2); font-weight: 600;
}
.staff-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-white); border-radius: 14px;
  border: 1.5px solid var(--border); padding: 16px;
  text-decoration: none; color: var(--text); transition: all .2s;
}
.staff-card:hover { border-color: var(--green); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.staff-avatar-wrap { position: relative; flex-shrink: 0; }
.staff-avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); display: block; }
.staff-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.staff-name { font-family: var(--font-ui); font-weight: 700; font-size: .9rem; color: var(--text); }
.staff-username { font-size: .78rem; color: var(--text-3); }
.staff-status { font-size: .75rem; color: var(--text-3); margin-top: 2px; }
.staff-status.online { color: var(--green); font-weight: 500; }

/* ── Chat Page ────────────────────────────────────────────── */
.chat-page-wrap {
  padding: 16px 20px 40px; box-sizing: border-box;
  max-width: var(--max-w); margin: 0 auto;
}
/* Rooms tab bar */
.chat-rooms-bar {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; margin-bottom: 12px;
  background: var(--bg-white); border: 1.5px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.chat-rooms-bar::-webkit-scrollbar { display: none; }
.chat-rooms-inner {
  display: flex; flex-wrap: nowrap; gap: 4px;
  padding: 8px 12px; min-width: max-content;
}
.chat-room-tab {
  white-space: nowrap; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 20px;
  font-size: .86rem; font-weight: 500;
  color: var(--text-2); background: transparent;
  border: 1px solid transparent;
  cursor: pointer; transition: all .15s; text-decoration: none;
}
.chat-room-tab:hover { background: var(--surface); color: var(--text); }
.chat-room-tab.active {
  background: var(--green); color: #fff;
  border-color: var(--green-dark);
}
.chat-room-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.chat-room-dot.open  { background: var(--green); }
.chat-room-dot.closed { background: var(--red); }
.chat-room-count {
  background: rgba(0,0,0,.12); color: inherit;
  border-radius: 10px; padding: 1px 6px; font-size: .72rem;
}
.chat-room-tab.active .chat-room-count { background: rgba(255,255,255,.25); }
/* Legacy alias */
.chat-rooms { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chat-rooms::-webkit-scrollbar { display: none; }
.chat-rooms-inner { flex-wrap: nowrap !important; }
.chat-online-count { font-variant-numeric: tabular-nums; position: relative; }
.chat-text-input { font-size: 16px; }
.chat-container {
  height: calc(100vh - var(--header-h) - 50px - 80px);
  min-height: 400px; max-height: 780px;
  background: var(--bg-white); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
}

/* ── Chat Header ─────────────────────────────────────────── */
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg-white); flex-shrink: 0; gap: 12px;
}
.chat-header-info { display: flex; align-items: center; gap: 12px; }
.chat-header-icon { font-size: 1.5rem; line-height: 1; }
.chat-header-title { font-family: var(--font-display); font-size: 1rem; font-weight: 700; margin: 0; }
.chat-header-desc  { font-size: .78rem; color: var(--text-3); margin: 0; }
.chat-header-meta  { display: flex; align-items: center; gap: 10px; flex-shrink: 0; flex-wrap: wrap; position: relative; }
.chat-online-dot   { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; animation: pulse-dot 2s infinite; }
.chat-total-msgs   { font-size: .78rem; color: var(--text-3); }
.chat-closed-badge { font-size: .76rem; color: var(--red); background: rgba(231,76,60,.08); padding: 2px 8px; border-radius: 12px; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* ── Chat Messages Area ──────────────────────────────────── */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
  background: #f8fffe; scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.chat-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 32px; color: var(--text-3); font-size: .9rem;
}
.chat-spinner {
  width: 20px; height: 20px; border: 2px solid var(--border);
  border-top-color: var(--green); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Chat Message Bubbles ────────────────────────────────── */
.chat-msg-wrap {
  display: flex; align-items: flex-end; gap: 8px;
  max-width: 84%; animation: msg-in .18s ease-out;
}
.chat-msg-wrap.mine { flex-direction: row-reverse; align-self: flex-end; }
.chat-msg-wrap:not(.mine) { align-self: flex-start; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.chat-msg-avatar {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
  flex-shrink: 0; border: 2px solid var(--border);
}
.chat-msg-bubble {
  background: var(--bg-white); border: 1px solid var(--border);
  border-radius: 14px; border-bottom-left-radius: 4px;
  padding: 9px 13px; box-shadow: 0 1px 3px rgba(0,0,0,.05);
  flex: 1; min-width: 0;
}
.chat-msg-wrap.mine .chat-msg-bubble {
  background: var(--surface); color: var(--text);
  border-color: var(--border);
  border-bottom-left-radius: 14px; border-bottom-right-radius: 4px;
}
.chat-msg-wrap.mine .chat-msg-body-inner {
  background: var(--green); color: #fff;
  border-radius: 10px; padding: 7px 11px; margin-top: 6px;
  word-break: break-word; overflow-wrap: break-word;
  font-size: .9rem; line-height: 1.45;
}
.chat-msg-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.chat-msg-user { font-weight: 700; font-size: .82rem; color: var(--green); text-decoration: none; line-height: 1; }
.chat-msg-wrap.mine .chat-msg-user { color: var(--green); }
.chat-msg-time { font-size: .68rem; color: var(--text-3); white-space: nowrap; }
.chat-msg-wrap.mine .chat-msg-time { color: var(--text-3); }
.chat-msg-body { font-size: .9rem; line-height: 1.45; word-break: break-word; overflow-wrap: break-word; }
.chat-mention { color: var(--green); font-weight: 600; }
.chat-msg-wrap.mine .chat-mention { color: var(--green); }
.chat-link { color: var(--blue); text-decoration: underline; }
.chat-msg-wrap.mine .chat-link { color: var(--blue); }
.chat-msg-reply {
  background: rgba(0,0,0,.05); border-left: 3px solid var(--green);
  border-radius: 6px; padding: 5px 9px; margin-bottom: 7px; cursor: pointer; transition: background .15s;
}
.chat-msg-wrap.mine .chat-msg-reply { background: rgba(46,204,113,.08); border-left-color: var(--green); }
.chat-msg-reply-user { font-size: .72rem; font-weight: 700; display: block; margin-bottom: 2px; }
.chat-msg-reply-text { font-size: .75rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 280px; }
.chat-msg-wrap.mine .chat-msg-reply-text { color: var(--text-2); }
.chat-msg-actions { margin-top: 5px; display: flex; gap: 6px; opacity: 0; transition: opacity .15s; }
.chat-msg-wrap:hover .chat-msg-actions { opacity: 1; }
.chat-action-reply {
  background: none; border: none; cursor: pointer; padding: 2px 7px;
  border-radius: 8px; font-size: .71rem; color: var(--text-3);
  transition: background .15s, color .15s;
}
.chat-action-reply:hover { background: var(--surface); color: var(--text); }
.chat-msg-wrap.mine .chat-action-reply { color: var(--text-3); }
.chat-msg-wrap.mine .chat-action-reply:hover { background: var(--surface); color: var(--text); }
.chat-action-delete {
  background: none; border: none; cursor: pointer; padding: 2px 6px;
  border-radius: 8px; font-size: .71rem; color: var(--red, #e74c3c);
  transition: background .15s;
}
.chat-action-delete:hover { background: rgba(231,76,60,.1); }
.chat-action-edit {
  background: none; border: none; cursor: pointer; padding: 2px 6px;
  border-radius: 8px; font-size: .71rem; color: var(--text-3);
  transition: background .15s, color .15s;
}
.chat-action-edit:hover { background: var(--surface); color: var(--text); }
.chat-edited-label { font-size: .7rem; color: var(--text-3); font-style: italic; }
.chat-msg-wrap.highlight { animation: highlight-flash .6s ease-out; }
@keyframes highlight-flash { 0%,100% { background: transparent; } 30% { background: rgba(46,204,113,.15); } }

/* ── Reply bar ───────────────────────────────────────────── */
.chat-reply-bar {
  display: flex; align-items: center;
  border-top: 1px solid var(--border);
  background: var(--surface); padding: 8px 12px; gap: 8px; flex-shrink: 0;
}
.chat-reply-inner { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.chat-reply-icon { color: var(--green); font-size: 1rem; flex-shrink: 0; }
.chat-reply-preview { flex: 1; min-width: 0; }
.chat-reply-preview strong { font-size: .78rem; color: var(--green); display: block; }
.chat-reply-preview span { font-size: .75rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.chat-reply-cancel {
  background: none; border: none; cursor: pointer; color: var(--text-3);
  width: 24px; height: 24px; border-radius: 50%; font-size: .85rem;
  display: flex; align-items: center; justify-content: center; transition: background .15s;
}
.chat-reply-cancel:hover { background: rgba(231,76,60,.1); color: var(--red); }

/* ── Chat Input area ─────────────────────────────────────── */
.chat-input-area {
  border-top: 1px solid var(--border);
  background: var(--bg-white); padding: 10px 12px; flex-shrink: 0; position: relative;
}
.chat-input-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-emoji-btn {
  background: none; border: none; font-size: 1.3rem; cursor: pointer;
  padding: 6px; border-radius: 8px; flex-shrink: 0; transition: background .15s;
  align-self: flex-end; margin-bottom: 1px;
}
.chat-emoji-btn:hover { background: var(--surface); }
.chat-input-wrapper { flex: 1; position: relative; }
.chat-textarea {
  width: 100%; box-sizing: border-box;
  border: 1.5px solid var(--border); border-radius: 20px;
  padding: 9px 56px 9px 14px;
  font-size: 15px; font-family: var(--font-ui);
  resize: none; outline: none; line-height: 1.45;
  min-height: 40px; max-height: 120px; overflow-y: auto;
  background: var(--surface); color: var(--text); transition: border-color .15s;
}
.chat-textarea:focus { border-color: var(--green); }
.chat-char-count {
  position: absolute; right: 12px; bottom: 9px;
  font-size: .65rem; color: var(--text-3);
  pointer-events: none; font-family: var(--font-ui);
}
.chat-char-count.warn   { color: #f39c12; }
.chat-char-count.danger { color: var(--red); }
.chat-send-btn {
  background: var(--green); border: none; color: #fff;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: background .2s, transform .1s;
  align-self: flex-end;
}
.chat-send-btn svg { width: 18px; height: 18px; }
.chat-send-btn:hover  { background: var(--green-dark); }
.chat-send-btn:active { transform: scale(.92); }
.chat-send-btn:disabled { opacity: .6; cursor: default; }
.chat-closed-notice {
  padding: 16px; text-align: center; color: var(--text-3);
  font-size: .88rem; border-top: 1px solid var(--border); background: var(--surface);
}

/* ── Emoji picker ────────────────────────────────────────── */
.chat-emoji-picker {
  position: absolute; bottom: calc(100% + 6px); left: 0;
  width: 320px; background: var(--bg-white);
  border: 1.5px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  z-index: 200; overflow: hidden; display: none;
}
.chat-emoji-picker.open { display: block; }
.emoji-picker-tabs {
  display: flex; gap: 2px; padding: 8px 10px;
  border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap;
}
.emoji-tab {
  background: none; border: none; cursor: pointer; padding: 5px 8px;
  border-radius: 8px; font-size: 1.1rem; transition: background .12s;
}
.emoji-tab:hover { background: var(--border); }
.emoji-tab.active { background: var(--green); }
.emoji-grid {
  display: grid; grid-template-columns: repeat(8, 1fr);
  gap: 2px; padding: 8px; max-height: 200px; overflow-y: auto;
}
.emoji-item {
  background: none; border: none; cursor: pointer;
  padding: 5px; border-radius: 6px; font-size: 1.15rem;
  transition: background .1s; text-align: center; line-height: 1;
}
.emoji-item:hover { background: var(--surface); }

/* ── Mention dropdown ────────────────────────────────────── */
.chat-mention-dropdown {
  position: absolute; bottom: calc(100% + 4px); left: 48px;
  width: 240px; background: var(--bg-white);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,.12); z-index: 201; overflow: hidden;
}
.mention-list { max-height: 180px; overflow-y: auto; }
.mention-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; cursor: pointer; transition: background .12s;
}
.mention-item:hover, .mention-item.active { background: var(--surface); }
.mention-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.mention-name { font-size: .85rem; font-weight: 600; color: var(--text); }
.mention-user { font-size: .75rem; color: var(--text-3); margin-left: auto; }

/* ── Private Messages ─────────────────────────────────────── */
.pm-layout {
  display: flex;
  height: calc(100vh - 112px);
  max-width: var(--max-w);
  margin: 0 auto;
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);  /* was var(--shadow) — undefined, now fixed */
}
.pm-sidebar {
  width: 310px; min-width: 280px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  background: var(--bg-white);
}
.pm-sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.pm-sidebar-header h2 { font-family: var(--font-display); font-size: 1.05rem; margin: 0; }
.pm-new-btn {
  background: var(--green); border: none; color: #fff;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .2s;
}
.pm-new-btn:hover { background: var(--green-dark); }
.pm-search-wrap { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.pm-search {
  width: 100%; padding: 7px 12px;
  border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface); font-size: .86rem; color: var(--text); outline: none;
}
.pm-search:focus { border-color: var(--green); }
.pm-convo-list { flex: 1; overflow-y: auto; }
.pm-loading, .pm-empty-convos { padding: 24px 20px; color: var(--text-3); font-size: .9rem; text-align: center; }
.pm-convo-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .15s; min-height: 64px;
}
.pm-convo-item:hover { background: var(--surface); }
.pm-convo-item.active { background: #f0fdf4; border-left: 3px solid var(--green); }
.pm-convo-item.has-unread .pm-convo-name { font-weight: 700; }
.pm-convo-avatar-wrap { position: relative; flex-shrink: 0; }
.pm-convo-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.pm-convo-badge {
  position: absolute; top: -2px; right: -4px;
  background: var(--red); color: #fff;
  border-radius: 10px; padding: 0 5px;
  font-size: .7rem; font-weight: 700; min-width: 18px; text-align: center;
}
.pm-convo-info { flex: 1; min-width: 0; }
.pm-convo-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-convo-preview { font-size: .78rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.pm-convo-time { font-size: .73rem; color: var(--text-3); flex-shrink: 0; white-space: nowrap; }

.pm-chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pm-chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; }
.pm-chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg-white); flex-shrink: 0;
}
.pm-back-btn { display: none; background: none; border: none; cursor: pointer; color: var(--text-2); padding: 4px; border-radius: 6px; }
.pm-chat-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.pm-chat-info { flex: 1; }
.pm-chat-name { font-weight: 700; font-size: .93rem; }
.pm-chat-status { font-size: .78rem; color: var(--text-3); }
.pm-chat-profile-link { color: var(--text-3); padding: 6px; border-radius: 6px; transition: color .15s; }
.pm-chat-profile-link:hover { color: var(--green); }

.pm-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
  background: #f8fffe;
}
.pm-msg-wrap { display: flex; margin-bottom: 2px; }
.pm-msg-wrap.pm-msg-mine   { justify-content: flex-end; }
.pm-msg-wrap.pm-msg-theirs { justify-content: flex-start; }
.pm-msg-bubble {
  max-width: 70%; padding: 10px 14px; border-radius: 18px;
  font-size: .9rem; line-height: 1.45; word-break: break-word; overflow-wrap: break-word;
}
.pm-msg-mine   .pm-msg-bubble { background: var(--green); color: #fff; border-bottom-right-radius: 4px; }
.pm-msg-theirs .pm-msg-bubble { background: var(--bg-white); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.pm-msg-time { font-size: .68rem; opacity: .65; text-align: right; margin-top: 4px; white-space: nowrap; }
.pm-msg-image { max-width: 260px; max-height: 260px; border-radius: 10px; display: block; cursor: pointer; }
.pm-input-area {
  border-top: 1px solid var(--border);
  background: var(--bg-white); padding: 10px 12px; flex-shrink: 0;
}
.pm-input-row { display: flex; align-items: flex-end; gap: 8px; }
.pm-attach-btn { cursor: pointer; color: var(--text-3); padding: 8px; border-radius: 8px; transition: color .15s; flex-shrink: 0; display: flex; align-items: center; }
.pm-attach-btn:hover { color: var(--green); }
.pm-text-input {
  flex: 1; border: 1px solid var(--border); border-radius: 20px;
  padding: 9px 16px; resize: none; font-size: 16px; font-family: var(--font-ui);
  outline: none; line-height: 1.4; max-height: 120px; overflow-y: auto;
  background: var(--surface); color: var(--text);
}
.pm-text-input:focus { border-color: var(--green); }
.pm-send-btn {
  background: var(--green); border: none; color: #fff;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: background .2s, transform .1s;
}
.pm-send-btn:hover  { background: var(--green-dark); }
.pm-send-btn:active { transform: scale(.93); }

/* PM Modal */
.pm-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.pm-modal {
  background: var(--bg-white); border-radius: var(--radius-lg);
  width: 100%; max-width: 440px; max-height: 80vh;
  display: flex; flex-direction: column; box-shadow: 0 8px 40px rgba(0,0,0,.2); overflow: hidden;
}
.pm-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.pm-modal-header h3 { margin: 0; font-family: var(--font-display); }
.pm-modal-body { padding: 16px; overflow-y: auto; }
.pm-user-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; transition: background .15s;
}
.pm-user-item:hover { background: var(--surface); }
.pm-user-item img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.pm-user-name   { font-weight: 600; font-size: .9rem; }
.pm-user-handle { font-size: .76rem; color: var(--text-3); }

/* ── Notification Page ────────────────────────────────────── */
.notif-page-list { display: flex; flex-direction: column; gap: 0; }
.notif-page-item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: var(--bg-white); transition: background .15s;
  text-decoration: none; color: var(--text);
}
.notif-page-item:hover  { background: var(--surface); }
.notif-page-item.unread { background: #f0fdf4; }
.notif-page-item.unread:hover { background: #dcfce7; }
.notif-page-item img    { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; }
.notif-page-content     { flex: 1; overflow-wrap: break-word; word-break: break-word; }
.notif-page-actor       { font-weight: 700; }
.notif-page-time        { font-size: .75rem; color: var(--text-3); margin-top: 4px; }

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  background: var(--green-dark); color: rgba(255,255,255,.7);
  padding: 14px 20px; margin-top: 40px;
  border-top: 2px solid rgba(0,0,0,.15);
}
.footer-inner { max-width: var(--max-w); margin: 0 auto; }
.footer-bottom {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 6px;
}
.footer-bottom p   { font-size: .8rem; color: rgba(255,255,255,.45); font-family: var(--font-ui); margin: 0; }
.footer-bottom a   { color: var(--green-light); text-decoration: none; }
.footer-bottom a:hover { text-decoration: underline; }
.footer-copy { font-size: .8rem; color: rgba(255,255,255,.4); font-family: var(--font-ui); text-align: center; word-break: break-word; }
.footer-logo { color: #fff !important; font-size: 1.5rem; margin-bottom: 10px; }
.footer-logo span { color: var(--green-light) !important; }
body.page-chat .site-footer,
body.page-messages .site-footer { display: none; }

/* ── SVG icons ────────────────────────────────────────────── */
.cat-icon svg { display: inline-block; vertical-align: middle; }
.nav-bar a .cat-icon { display: inline-flex; align-items: center; }

/* ── Scroll to top ────────────────────────────────────────── */
#scroll-top {
  position: fixed; bottom: 24px; right: 20px;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--green); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md); opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 500;
}
#scroll-top.visible { opacity: 1; pointer-events: auto; }
#scroll-top:hover   { background: var(--green-dark); transform: translateY(-2px); }

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.fade-in { animation: fadeIn .4s var(--ease) both; }
.fade-in-delay-1 { animation-delay: .08s; }
.fade-in-delay-2 { animation-delay: .16s; }
.fade-in-delay-3 { animation-delay: .24s; }

/* ── VIP ──────────────────────────────────────────────────── */
.vip-avatar  { outline: 2px solid #f1c40f; outline-offset: 2px; }
.vip-badge   { font-size: .75em; vertical-align: middle; }
/* VIP special badge - premium styled */
.vip-badge-special {
  display: inline-block;
  background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
  color: #7c3a00;
  font-size: .68em;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  letter-spacing: .04em;
  vertical-align: middle;
  box-shadow: 0 1px 4px rgba(253,160,133,.4);
  text-transform: uppercase;
}
/* Post card VIP highlight */
.post-card .vip-badge-special { font-size: .6em; }

/* ── Utilities ────────────────────────────────────────────── */
.text-center  { text-align: center; }
.mt-8  { margin-top: 8px; }  .mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.d-flex { display: flex; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.align-center { align-items: center; }

/* ── Global overflow guard ────────────────────────────────── */
body { position: relative; }
.site-header, .mobile-menu { width: 100%; }

/* ── Word-wrap on long content ───────────────────────────── */
.post-card-title, .post-full-title, .comment-text, .widget-body,
.notif-page-content, .pm-msg-bubble, .chat-msg-body, h1, h2, h3, h4 {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ── Flex rows that must wrap ─────────────────────────────── */
.post-card-footer, .post-actions, .post-stats, .header-actions,
.admin-header, .comment-header { flex-wrap: wrap; }

/* ── Widget button full-width ─────────────────────────────── */
.widget-body .btn, .user-widget .btn, .sidebar .btn {
  width: 100%; justify-content: center; box-sizing: border-box;
}

/* ── Admin filter row ─────────────────────────────────────── */
.admin-filter-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Mobile menu logo ─────────────────────────────────────── */
.mobile-menu-logo { font-family: var(--font-display); font-size: 1.4rem; font-weight: 900; color: var(--green-dark); padding: 0 24px 12px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }

/* ── Drawer message badge ─────────────────────────────────── */
#drawer-msg-badge {
  display: none; background: var(--red); color: #fff;
  border-radius: 10px; padding: 0 6px; font-size: .7rem;
  margin-left: 4px; vertical-align: middle;
}

/* ── Search result header ─────────────────────────────────── */
.search-header { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.search-header form { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.search-header input { flex: 1; min-width: 180px; }

/* ── Profile hero actions ─────────────────────────────────── */
.profile-hero-actions .btn { min-width: 100px; justify-content: center; }

/* ── Friend action button ─────────────────────────────────── */
.friend-action-btn { transition: all .2s; }

/* ── Files view layout ────────────────────────────────────── */
.files-view-layout { display: flex; gap: 24px; align-items: flex-start; }
.files-view-cover  { width: 200px; flex-shrink: 0; }

/* ── Write submit row ─────────────────────────────────────── */
.write-submit-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ── Admin settings ───────────────────────────────────────── */
.admin-settings-wrap { max-width: 680px; }
.admin-dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.admin-files-cats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Mobile menu message badge ────────────────────────────── */
.mobile-menu-footer .btn { display: flex; align-items: center; gap: 8px; }

/* ── PM time ──────────────────────────────────────────────── */
.pm-msg-time { white-space: nowrap; }

/* ── Dark mode ────────────────────────────────────────────── */
body.dark-mode {
  --bg:        #0f1117;
  --bg-white:  #1a1d27;
  --bg-card:   #1a1d27;
  --surface:   #232634;
  --bg-hover:  #2a2e42;

  --text:      #e8e6e0;
  --text-1:    #e8e6e0;
  --text-2:    #b0aaa0;
  --text-3:    #706a60;

  --border:    #2e3144;
  --border-2:  #3a3f58;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.25);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.5), 0 4px 12px rgba(0,0,0,.3);

  --green:      #22c55e;
  --green-light:#4ade80;
  --green-dark: #16a34a;
  --primary:    #22c55e;
}

/* Dark mode card improvements */
body.dark-mode .post-card,
body.dark-mode .widget { box-shadow: 0 1px 4px rgba(0,0,0,.4); }
body.dark-mode .post-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.5); }
body.dark-mode img { opacity: .92; }
body.dark-mode .featured-hero-img { opacity: .24; }
body.dark-mode .pm-messages { background: #12151f; }
body.dark-mode .notif-dropdown { background: #1a1d27; box-shadow: 0 4px 6px -1px rgba(0,0,0,.3), 0 10px 32px -4px rgba(0,0,0,.5); }
body.dark-mode .notif-dropdown::before { background: #1a1d27; }
body.dark-mode .notif-item.notif-unread { background: rgba(34,197,94,.08); }
body.dark-mode .notif-item.notif-unread:hover { background: rgba(34,197,94,.14); }
body.dark-mode .auth-card { border-color: var(--border); }
body.dark-mode .view-toggle-btn { background: var(--bg-card); border-color: var(--border-2); color: var(--text-2); }
body.dark-mode .view-toggle-btn.active { background: var(--primary); color: #fff; }
body.dark-mode .site-header { border-bottom-color: var(--green-dark); }
body.dark-mode .hamburger { background: var(--surface); border-color: var(--border); color: var(--text-2); }
body.dark-mode .mobile-menu-panel { background: var(--bg-white); }
body.dark-mode .profile-drawer { background: var(--bg-white); }
body.dark-mode .stat-card { background: var(--bg-card); }
body.dark-mode .flash--success { background: rgba(16,185,129,.15); color: #6ee7b7; border-color: rgba(16,185,129,.25); }
body.dark-mode .flash--error   { background: rgba(220,38,38,.15);  color: #fca5a5; border-color: rgba(220,38,38,.25); }
body.dark-mode .flash--info    { background: rgba(37,99,235,.15);  color: #93c5fd; border-color: rgba(37,99,235,.25); }

/* Anti-flash before JS runs */
html.pre-dark body { background: #0f1117; }
html.pre-dark body .site-header { background: #1a1d27; border-bottom-color: #16a34a; }

/* Mobile hover adjustment (no jarring transform) */
@media (hover: none) {
  .post-card:hover { transform: none; box-shadow: var(--shadow-sm); }
  .btn-primary:hover { transform: none; }
}

/* Post card image radius */
.post-card.has-image .post-card-image img { border-radius: 0 var(--radius-lg) var(--radius-lg) 0; }

/* Better footer border */
.site-footer { border-top: 2px solid var(--green-dark); }

/* ── Profile Edit Page ─────────────────────────────────────── */
.profile-edit-wrap { max-width: 680px; margin: 0 auto; padding: 0 0 40px; }
.avatar-upload-row { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 24px; padding: 20px; background: var(--surface); border-radius: var(--radius); }

/* ── Member location badge (Ulgamda näme edýär) ─────────────── */
.member-location-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .7rem;
  color: var(--green-dark, #166534);
  background: var(--green-light, #dcfce7);
  border-radius: 20px;
  padding: 2px 8px;
  margin-top: 4px;
  font-weight: 500;
}
/* ═══════════════════════════════════════════════
   Post mazmun görnüşi — post.php içine goşuň
   ═══════════════════════════════════════════════ */

/* 1. Esasy setir aralyk goragy */
.post-content {
  line-height: 1.85;
  font-size: 1rem;
  color: var(--text, #1a1a1a);
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Boş däl setirler arasy */
.post-content br { display: block; content: ""; margin-top: .35em; }

/* 2. Başlyklar */
.post-content .post-h2 {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 1.6em 0 .6em;
  padding-bottom: .3em;
  border-bottom: 2px solid var(--primary, #3b82f6);
  color: var(--heading, #111);
}
.post-content .post-h3 {
  font-size: 1.18rem;
  font-weight: 600;
  margin: 1.3em 0 .5em;
  color: var(--heading, #111);
}

/* 3. Sitat */
.post-content .post-quote {
  border-left: 4px solid var(--primary, #3b82f6);
  background: var(--quote-bg, #f0f7ff);
  margin: 1.2em 0;
  padding: 14px 18px;
  border-radius: 0 10px 10px 0;
  color: var(--text-muted, #444);
  font-style: italic;
}
.post-content .post-quote cite {
  display: block;
  font-size: .8rem;
  font-style: normal;
  font-weight: 600;
  color: var(--primary, #3b82f6);
  margin-bottom: 6px;
}

/* 4. Kod bölümi */
.post-content .post-code {
  background: #1e1e2e;
  border-radius: 10px;
  padding: 16px 18px;
  margin: 1.2em 0;
  overflow-x: auto;
}
.post-content .post-code code {
  color: #cdd6f4;
  font-family: 'Courier New', Consolas, monospace;
  font-size: .9rem;
  line-height: 1.65;
  white-space: pre;
}

/* 5. Inline strong/em/u */
.post-content strong { font-weight: 700; }
.post-content em     { font-style: italic; }
.post-content u      { text-decoration: underline; text-underline-offset: 3px; }
.post-content s      { text-decoration: line-through; color: var(--text-muted, #888); }

/* 6. Sanaw */
.post-content .post-list {
  padding-left: 1.5em;
  margin: .8em 0;
}
.post-content .post-list li {
  margin-bottom: .4em;
  line-height: 1.7;
}
.post-content .post-list li::marker { color: var(--primary, #3b82f6); }

/* 7. Baglanyşyk */
.post-content .post-link {
  color: var(--primary, #3b82f6);
  text-decoration: underline;
  text-underline-offset: 3px;
  word-break: break-all;
}
.post-content .post-link:hover { opacity: .75; }

/* 8. Surat */
.post-content .post-img {
  max-width: 100%;
  border-radius: 10px;
  display: block;
  margin: 1em auto;
  box-shadow: 0 2px 12px rgba(0,0,0,.1);
}

/* 9. Bölüji */
.post-content .post-hr {
  border: none;
  border-top: 2px dashed var(--border, #e5e7eb);
  margin: 1.8em 0;
}

/* 10. Spoiler */
.post-content .post-spoiler {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  margin: 1em 0;
  overflow: hidden;
}
.post-content .post-spoiler summary {
  padding: 10px 16px;
  background: var(--toolbar-bg, #f8f9fa);
  cursor: pointer;
  font-weight: 600;
  font-size: .88rem;
  color: var(--text-muted, #666);
  user-select: none;
}
.post-content .post-spoiler summary:hover { background: var(--border, #eee); }
.post-content .post-spoiler > div {
  padding: 14px 18px;
  border-top: 1px solid var(--border, #e5e7eb);
}

   <?php
   require_once __DIR__ . '/includes/bbcode.php';
   ?>
   <div class="post-content">
     <?= renderPost($post['body']) ?>
   </div>

