:root {
  --bg: #0b0d14;
  --bg-2: #11141d;
  --panel: rgba(22, 26, 36, 0.85);
  --panel-solid: #161a24;
  --panel-2: #1d2230;
  --border: rgba(120, 130, 160, 0.15);
  --border-strong: rgba(120, 130, 160, 0.28);
  --text: #eef0f4;
  --muted: #8a93a6;
  --muted-2: #5b6478;
  --accent: #7c5cff;
  --accent-2: #ff5c8a;
  --accent-grad: linear-gradient(135deg, #7c5cff 0%, #ff5c8a 100%);
  --good: #3ddc97;
  --warn: #ffb547;
  --danger: #ff5d6c;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 60px rgba(124, 92, 255, 0.18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
body { background:
  radial-gradient(1200px 800px at 10% -10%, rgba(124, 92, 255, 0.18), transparent 60%),
  radial-gradient(900px 700px at 110% 10%, rgba(255, 92, 138, 0.15), transparent 55%),
  radial-gradient(900px 700px at 50% 120%, rgba(61, 220, 151, 0.10), transparent 60%),
  var(--bg);
}

/* Background layers (static, no animation for performance) */
.aurora, .stars { display: none; }

a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-2); }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

h1, h2, h3, h4 { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 12px; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

/* ---------- Top nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 28px 14px;
  background: rgba(11, 13, 20, 0.7);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em;
  background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent-grad); position: relative; box-shadow: var(--shadow-lg); flex-shrink: 0; }
.brand-logo::after {
  content: ""; position: absolute; inset: 6px; border-radius: 5px;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.7), transparent 55%);
}
.nav-links { display: flex; gap: 6px; align-items: center; }
.nav-item {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 10px;
  color: var(--text); font-weight: 500; font-size: 0.92rem;
  background: transparent; border: 0; cursor: pointer; font-family: inherit;
  transition: background .15s, color .15s, transform .1s;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.06); text-decoration: none; color: var(--text); }
.nav-item:active { transform: scale(0.97); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item.logout { color: var(--muted); }
.nav-item.logout:hover { color: var(--danger); background: rgba(255, 93, 108, 0.08); }
.nav-item.profile-link { background: rgba(255,255,255,.04); }
.nav-item.profile-link:hover { background: rgba(255,255,255,.08); }
.badge-icon { display: inline-flex; align-items: center; justify-content: center; width: 1em; height: 1em; margin-left: 4px; vertical-align: -0.15em; }
.badge-icon svg { width: 100%; height: 100%; }
.badge-icon.verified { filter: drop-shadow(0 0 4px rgba(29, 155, 240, .5)); }
.badge-icon.admin { filter: drop-shadow(0 0 4px rgba(124, 92, 255, .5)); }
h1 .badge-icon { width: .85em; height: .85em; }

.badge {
  background: var(--accent-grad); color: white;
  font-size: 0.7rem; font-weight: 700;
  padding: 2px 7px; border-radius: 999px;
  position: absolute; top: 2px; right: 2px;
  box-shadow: 0 4px 12px rgba(255, 92, 138, .4);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

.hamburger {
  display: none; background: transparent; color: var(--text); padding: 8px;
  border-radius: 10px; border: 1px solid var(--border); flex-shrink: 0;
}
.hamburger svg { width: 22px; height: 22px; }

/* ---------- Container & cards ---------- */
.container { max-width: 820px; margin: 0 auto; padding: 28px 18px calc(60px + var(--safe-bottom)); animation: fade-up .4s ease both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.card {
  background: var(--panel);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  transition: border-color .2s, transform .2s;
}
.card:hover { border-color: var(--border-strong); }

/* ---------- Buttons & forms ---------- */
button, .btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  background: var(--accent-grad); color: white; border: 0; border-radius: 10px;
  padding: 10px 18px; font-weight: 600; font-size: 0.93rem;
  cursor: pointer; font-family: inherit;
  transition: transform .08s ease, opacity .15s, box-shadow .2s, filter .15s;
  box-shadow: 0 6px 18px rgba(124, 92, 255, .25);
}
button:hover, .btn:hover { filter: brightness(1.08); box-shadow: 0 10px 24px rgba(124, 92, 255, .35); text-decoration: none; }
button:active, .btn:active { transform: scale(0.97); }
button:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(.4); }
button svg, .btn svg { width: 16px; height: 16px; }

.btn-ghost {
  background: rgba(255,255,255,.06); color: var(--text); box-shadow: none;
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: rgba(255,255,255,.1); filter: none; box-shadow: none; }
.btn-danger { background: linear-gradient(135deg, #ff5d6c, #ff3d6e); box-shadow: 0 6px 18px rgba(255, 93, 108, .3); }
.btn-success { background: linear-gradient(135deg, #3ddc97, #2bb47e); box-shadow: 0 6px 18px rgba(61, 220, 151, .3); }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

.link-btn {
  background: transparent; color: var(--muted); padding: 6px 10px; box-shadow: none;
  font-weight: 500;
}
.link-btn:hover { color: var(--text); background: rgba(255,255,255,.05); filter: none; box-shadow: none; }

input, textarea, select {
  width: 100%; background: rgba(255,255,255,.04); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 14px;
  font-size: 0.95rem; font-family: inherit;
  transition: border-color .15s, background .15s;
}
input:focus, textarea:focus, select:focus {
  outline: 0; border-color: var(--accent);
  background: rgba(124, 92, 255, .07);
}
textarea { min-height: 96px; resize: vertical; }
label { display: block; margin-bottom: 14px; font-size: 0.88rem; color: var(--muted); font-weight: 500; }
label > input, label > select, label > textarea { margin-top: 6px; }

/* ---------- Auth ---------- */
.auth-card {
  max-width: 420px; margin: 6vh auto; background: var(--panel);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  padding: 32px; border-radius: 20px; border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: fade-up .5s ease both;
}
.auth-card h1 { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: 8px; }
.error { color: var(--danger); min-height: 1.2em; margin: 4px 0 0; font-size: 0.88rem; font-weight: 500; }

/* ---------- Avatar ---------- */
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #2c3142, #1a1e2c);
  background-size: cover; background-position: center;
  display: inline-flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.75); flex-shrink: 0;
  aspect-ratio: 1 / 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
  overflow: hidden;
  border: 1px solid var(--border);
}
.avatar.has-img { background-color: #161a24; border-color: var(--border-strong); }
.avatar.guest { background: linear-gradient(135deg, #2c3142, #1a1e2c); }
.avatar.guest svg { width: 70%; height: 70%; opacity: .7; }
.avatar.xs { width: 26px; height: 26px; min-width: 26px; }
.avatar.sm { width: 36px; height: 36px; min-width: 36px; }
.avatar.lg {
  width: 112px; height: 112px; min-width: 112px;
  border: 3px solid transparent;
  background-clip: padding-box;
  box-shadow:
    0 0 0 2px rgba(124, 92, 255, .35),
    0 0 24px rgba(124, 92, 255, .25),
    0 12px 32px rgba(0, 0, 0, .45);
  position: relative;
  transition: box-shadow .25s ease, transform .25s ease;
}
.avatar.lg::before {
  content: '';
  position: absolute; inset: -5px;
  border-radius: 50%;
  background: var(--accent-grad);
  z-index: -1;
  opacity: .85;
  filter: blur(.5px);
}
.avatar.lg:hover {
  box-shadow:
    0 0 0 2px rgba(255, 92, 138, .45),
    0 0 32px rgba(255, 92, 138, .35),
    0 14px 38px rgba(0, 0, 0, .55);
  transform: translateY(-1px);
}
.avatar-edit { isolation: isolate; }

/* ---------- Composer & feed ---------- */
.composer .row { justify-content: space-between; }
.feed { display: flex; flex-direction: column; gap: 14px; }
.post { animation: fade-up .35s ease both; }
.post header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.author { display: flex; gap: 10px; align-items: center; color: var(--text); font-weight: 600; min-width: 0; }
.author strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post-content { white-space: pre-wrap; word-wrap: break-word; line-height: 1.55; margin: 8px 0 14px; font-size: 1.02rem; }
.post-actions { display: flex; gap: 4px; align-items: center; border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; flex-wrap: wrap; }
.post-actions button { background: transparent; color: var(--muted); padding: 7px 12px; box-shadow: none; font-size: 0.88rem; font-weight: 500; }
.post-actions button:hover { background: rgba(255,255,255,.05); filter: none; box-shadow: none; color: var(--text); }
.post-actions .heart-btn.active { color: var(--accent-2); }
.post-actions .heart-btn.active svg { fill: var(--accent-2); }
.post-actions .heart-btn.popped { animation: pop .35s ease; }
@keyframes pop { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.4); } }

.comments { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; animation: fade-up .25s ease both; }
.comment { display: flex; gap: 10px; align-items: center; padding: 8px 0; font-size: 0.93rem; min-width: 0; }
.comment > .avatar { flex-shrink: 0; }
.comment strong { color: var(--text); font-weight: 600; flex-shrink: 0; }
.comment span.body { color: var(--muted); flex: 1; min-width: 0; word-wrap: break-word; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- Profile ---------- */
.profile-header { display: flex; gap: 22px; align-items: center; }
.profile-info { flex: 1; min-width: 0; }
.profile-info h1 { margin: 0 0 4px; font-size: 1.5rem; }
.profile-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.profile-meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 6px; }
.meta-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  background: rgba(255,255,255,.05); border: 1px solid var(--border);
  font-size: 0.82rem; font-weight: 500; color: var(--text);
}
.meta-pill svg { width: 14px; height: 14px; }
.meta-pill a { color: var(--accent); margin-left: 2px; }
.meta-pill.status-in_relationship, .meta-pill.status-married { color: var(--accent-2); border-color: rgba(255, 92, 138, .3); background: rgba(255, 92, 138, .08); }
.meta-pill.status-complicated { color: var(--warn); }
.comment-author { color: inherit; text-decoration: none; display: inline-flex; align-items: center; }
.comment-author:hover strong { text-decoration: underline; }
.btn-success { background: linear-gradient(135deg, #16a34a, #22c55e); color: #fff; border: 0; }
.post.highlight { animation: postFlash 1.6s ease-out; box-shadow: 0 0 0 2px var(--accent), 0 12px 40px rgba(124,92,255,.35); }
@keyframes postFlash { 0% { box-shadow: 0 0 0 4px var(--accent), 0 12px 50px rgba(124,92,255,.55); } 100% { box-shadow: 0 0 0 2px var(--accent), 0 12px 40px rgba(124,92,255,.35); } }

.avatar-edit { position: relative; display: inline-block; }
.avatar-edit .avatar { cursor: pointer; }
.avatar-edit .pen {
  position: absolute; bottom: 4px; right: 4px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-grad); color: white;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,.35); cursor: pointer;
  border: 2px solid var(--bg);
}
.avatar-edit .pen svg { width: 14px; height: 14px; }
.avatar-edit input[type="file"] { display: none; }

/* ---------- Chat ---------- */
.chat-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; height: calc(100vh - 110px); min-height: 520px; }
.chat-sidebar { overflow-y: auto; padding: 14px; }
.chat-sidebar h3 { padding: 4px 6px 10px; }
.friend-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.friend-list li button.friend-pick {
  display: flex; gap: 10px; align-items: center; width: 100%;
  background: transparent; color: var(--text); padding: 10px; border-radius: 10px;
  text-align: left; box-shadow: none; font-weight: 500;
}
.friend-list li button.friend-pick:hover { background: rgba(255,255,255,.05); filter: none; box-shadow: none; }
.friend-list li button.friend-pick.active { background: rgba(124, 92, 255, .15); color: var(--text); }
.friend-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.presence { color: var(--muted-2); margin-left: auto; font-size: 0.6rem; }
.presence.online { color: var(--good); animation: pulse 2.5s ease-in-out infinite; }

.chat-main { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 600; }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.chat-composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: rgba(255,255,255,.02); }
.chat-composer input { flex: 1; }

.msg {
  max-width: 70%; padding: 10px 14px; border-radius: 18px; line-height: 1.4;
  word-wrap: break-word; position: relative;
  animation: msg-in .25s ease both;
}
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.msg.me { align-self: flex-end; background: var(--accent-grad); color: white; border-bottom-right-radius: 6px; box-shadow: 0 4px 12px rgba(124, 92, 255, .25); }
.msg.them { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 6px; }
.msg .time { display: block; font-size: 0.68rem; opacity: 0.7; margin-top: 4px; }
.msg .heart-msg { position: absolute; bottom: -6px; right: 8px; cursor: pointer; opacity: 0; transition: opacity .2s, transform .2s; font-size: 0.95rem; background: var(--panel-solid); border-radius: 999px; padding: 2px 6px; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.msg:hover .heart-msg { opacity: 1; }
.msg .heart-msg.active { opacity: 1; color: var(--accent-2); }
.msg .heart-msg:hover { transform: scale(1.2); }
.msg.system { align-self: center; background: rgba(255,255,255,.05); color: var(--muted); font-size: 0.85rem; padding: 6px 12px; border-radius: 999px; }
.msg.them strong { display: block; font-size: 0.75rem; color: var(--accent); margin-bottom: 2px; }

.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }

/* ---------- Match ---------- */
.match-card h1 { margin-top: 0; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.match-chat {
  margin-top: 22px; border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; height: 460px;
  background: rgba(0,0,0,.2); overflow: hidden;
  animation: fade-up .35s ease both;
}
.match-chat .chat-messages { flex: 1; }
.match-status { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: rgba(255,255,255,.04); font-weight: 500; font-size: 0.9rem; }
.match-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); flex-shrink: 0; }
.match-status.searching .dot { background: var(--warn); animation: pulse 1.2s infinite; }
.match-status.matched .dot { background: var(--good); animation: pulse 1.5s infinite; }

/* ---------- Lists ---------- */
.user-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.user-row { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 10px; color: var(--text); transition: background .15s; }
.user-row:hover { background: rgba(255,255,255,.04); text-decoration: none; }
.user-row strong { font-weight: 600; }

/* ---------- Notifications list ---------- */
.notif-row {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px;
  border-radius: 12px; color: var(--text); transition: background .15s;
  border: 1px solid transparent;
}
.notif-row:hover { background: rgba(255,255,255,.04); text-decoration: none; }
.notif-row .notif-icon {
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(124, 92, 255, .15); color: var(--accent); flex-shrink: 0;
}
.notif-row .notif-icon svg { width: 18px; height: 18px; }
.notif-row.heart .notif-icon { background: rgba(255, 92, 138, .15); color: var(--accent-2); }
.notif-row.friend .notif-icon { background: rgba(61, 220, 151, .15); color: var(--good); }
.notif-row.message .notif-icon { background: rgba(124, 92, 255, .15); color: var(--accent); }
.notif-text { flex: 1; min-width: 0; }
.notif-text .when { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 2px; }

/* ---------- Admin ---------- */
.admin-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.92rem; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.admin-table th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.admin-table td .row { gap: 6px; }
.status-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.status-pill.active { background: rgba(61, 220, 151, .15); color: var(--good); }
.status-pill.banned { background: rgba(255, 93, 108, .15); color: var(--danger); }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .topbar { padding: calc(10px + var(--safe-top)) 14px 12px; }
  .hamburger { display: inline-flex; }
  .nav-links {
    position: fixed; top: calc(58px + var(--safe-top)); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 4px;
    background: rgba(11, 13, 20, 0.96); backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px 18px;
    transform: translateY(-110%); transition: transform .25s ease;
  }
  .nav-links.open { transform: translateY(0); }
  .nav-item { padding: 12px 14px; font-size: 0.95rem; }
  .badge { position: static; margin-left: auto; }
  .container { padding: 16px 12px calc(80px + var(--safe-bottom)); }
  .card { padding: 16px; border-radius: 12px; }
  h1 { font-size: 1.4rem; }
  .chat-layout { grid-template-columns: 1fr; height: auto; gap: 10px; }
  .chat-sidebar { max-height: 240px; }
  .chat-main { min-height: 520px; }
  .profile-header { flex-direction: column; text-align: center; }
  .profile-info { text-align: center; }
  .profile-actions { justify-content: center; }
  .auth-card { margin: 4vh 12px; padding: 24px; }
  .admin-table { font-size: 0.84rem; }
  .admin-table th, .admin-table td { padding: 8px 4px; }
  .msg { max-width: 85%; }
  button, .btn { padding: 9px 14px; font-size: 0.88rem; }
  .topbar .brand { font-size: 1.05rem; }
  .post header time { font-size: 0.75rem; }
}

@media (max-width: 420px) {
  .nav-item span:not(.brand) { font-size: 0.92rem; }
  .post-actions button { padding: 6px 8px; font-size: 0.82rem; }
}

/* ---------- Threaded comments ---------- */
.comment { align-items: flex-start; }
.comment-body-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.comment-line { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; min-width: 0; }
.comment.is-reply { margin-left: 36px; padding-left: 12px; border-left: 2px solid var(--border); }
.comment .comment-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.comment:hover .comment-actions, .comment:focus-within .comment-actions { opacity: 1; }
.comment-actions .link-btn { padding: 2px 8px; font-size: 0.78rem; }
.comment-form { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.comment-input-row { display: flex; gap: 8px; }
.comment-input-row input { flex: 1; }
.reply-context {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 8px;
  background: rgba(124, 92, 255, .08); border: 1px solid rgba(124, 92, 255, .2);
  font-size: 0.82rem;
}
.reply-context .reply-context-text { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-context .reply-context-text strong { color: var(--accent); }
.reply-context .reply-cancel { padding: 0 6px; font-size: 1.1rem; line-height: 1; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; padding-bottom: 0; flex-wrap: wrap; }
.tabs .tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 10px 10px 0 0;
  color: var(--muted); font-weight: 600; font-size: 0.92rem;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s, background .15s;
}
.tabs .tab:hover { color: var(--text); background: rgba(255,255,255,.04); text-decoration: none; }
.tabs .tab.active { color: var(--accent); border-bottom-color: var(--accent); background: rgba(124, 92, 255, .06); }
.tabs .tab svg { width: 16px; height: 16px; }
.tab-badge { background: var(--accent-grad); color: white; font-size: 0.7rem; font-weight: 700; padding: 2px 7px; border-radius: 999px; }

/* ---------- Chat sidebar search & unread ---------- */
.chat-sidebar-head { display: flex; flex-direction: column; gap: 8px; padding: 4px 6px 12px; }
.chat-sidebar-head h3 { padding: 0; margin: 0; }
.friend-search { padding: 8px 12px; font-size: 0.88rem; }
.unread-pill {
  margin-left: auto; background: var(--accent-grad); color: white;
  font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  min-width: 22px; text-align: center;
  box-shadow: 0 2px 6px rgba(255, 92, 138, .3);
}
.friend-list .name { flex: initial; }
.friend-list li button.friend-pick { flex-wrap: nowrap; }
.friend-list li button.friend-pick .name { flex: 1; }

/* ---------- Chat reply UI ---------- */
.chat-layout { height: calc(100vh - 110px); max-height: calc(100vh - 110px); }
.chat-main { min-height: 0; }
.chat-messages { flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

/* ---------- Chat empty state ---------- */
.chat-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 32px; text-align: center; color: var(--muted);
}
.chat-empty svg { color: var(--accent); opacity: 0.7; }
.chat-empty h3 { margin: 6px 0 0; color: var(--text); }
.chat-empty p { margin: 0; max-width: 280px; }

/* ---------- Admin pager & search ---------- */
.admin-users-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-top: 18px; margin-bottom: 10px; }
.admin-users-head h3 { margin: 0; }
.admin-search-form { display: flex; gap: 8px; align-items: center; flex: 1; max-width: 420px; min-width: 220px; }
.admin-search-form input { flex: 1; padding: 8px 12px; font-size: 0.9rem; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 14px 0 4px; flex-wrap: wrap; }
.pager .btn-sm.disabled { opacity: 0.4; pointer-events: none; }
.chat-back { display: none; padding: 4px 10px; font-size: 0.9rem; }
@media (max-width: 760px) { body.chat-active .chat-back { display: inline-flex; } }
.chat-reply-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-top: 1px solid var(--border);
  background: rgba(124, 92, 255, .08); font-size: 0.85rem;
}
.chat-reply-bar .chat-reply-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.chat-reply-bar strong { color: var(--accent); }
.chat-reply-bar .link-btn { padding: 0 8px; font-size: 1.2rem; line-height: 1; }

.msg .msg-tools { display: inline-flex; gap: 4px; align-items: center; position: absolute; bottom: -10px; right: 8px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools { opacity: 1; }
.msg .msg-tools .heart-msg, .msg .msg-tools .msg-action {
  position: static; opacity: 1; background: var(--panel-solid); border-radius: 999px;
  padding: 2px 7px; box-shadow: 0 2px 6px rgba(0,0,0,.3);
  cursor: pointer; font-size: 0.85rem; color: var(--text); border: 0;
}
.msg .msg-tools .msg-action { padding: 2px 8px; }
.msg .msg-tools .heart-msg.active { color: var(--accent-2); }
.msg-quote {
  display: block; margin-bottom: 6px; padding: 6px 10px;
  border-left: 3px solid rgba(255,255,255,.4);
  background: rgba(0, 0, 0, .15); border-radius: 6px;
  font-size: 0.82rem; color: inherit; text-decoration: none;
  max-width: 100%; overflow: hidden;
}
.msg.them .msg-quote { border-left-color: var(--accent); background: rgba(124, 92, 255, .1); }
.msg-quote .quote-author { display: block; font-weight: 600; opacity: 0.85; margin-bottom: 2px; }
.msg-quote .quote-text { display: block; opacity: 0.8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.msg-flash { animation: msgFlash 1.4s ease; }
@keyframes msgFlash { 0%, 100% { box-shadow: 0 4px 12px rgba(124, 92, 255, .25); } 30% { box-shadow: 0 0 0 3px var(--accent-2), 0 8px 24px rgba(255, 92, 138, .5); } }

@media (max-width: 760px) {
  .chat-layout { grid-template-columns: 1fr; height: calc(100vh - 110px); max-height: calc(100vh - 110px); gap: 10px; }
  .chat-sidebar { max-height: 240px; min-height: 0; }
  .chat-main { min-height: 0; }
  .comment.is-reply { margin-left: 16px; }
  body.chat-active .chat-sidebar { display: none; }
  body.chat-active .chat-main { min-height: calc(100vh - 110px); }
}

/* Rich text: mentions + hashtags */
.post-content, .comment .body, .text { white-space: pre-wrap; word-wrap: break-word; }
.mention { color: #c9b6ff; font-weight: 600; text-decoration: none; }
.mention:hover { text-decoration: underline; }
.hashtag { color: #4aa3ff; font-weight: 600; text-decoration: none; }
.hashtag:hover { text-decoration: underline; }

/* Repost card */
.repost-banner {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: #9aa0b4; margin-bottom: 6px;
}
.repost-banner a { color: #c9b6ff; text-decoration: none; font-weight: 600; }
.repost-quote {
  display: block;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  text-decoration: none; color: inherit;
  transition: background .15s ease;
}
.repost-quote:hover { background: rgba(255,255,255,0.06); }
.repost-quote-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.repost-quote-body { white-space: pre-wrap; word-wrap: break-word; color: #d5d8e6; }
.repost-btn { display: inline-flex; align-items: center; gap: 4px; }
.repost-btn svg { width: 18px; height: 18px; }

/* Mobile-friendly admin: stack rows as cards */
@media (max-width: 720px) {
  .admin-table { border: 0; }
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
  .admin-table tr {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    margin-bottom: 10px;
    padding: 10px 12px;
  }
  .admin-table td {
    border: 0;
    padding: 6px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    text-align: right;
  }
  .admin-table td::before {
    content: attr(data-label);
    font-size: 12px;
    color: #9aa0b4;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
  }
  .admin-table td .row { justify-content: flex-end; flex-wrap: wrap; }
  .admin-table td.muted.small { word-break: break-all; }
  .admin-actions { flex-wrap: wrap; gap: 6px; }
  div[style*="overflow-x:auto"] { overflow-x: visible !important; }
}

/* ===== Groups ===== */
.group-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.group-row { background: var(--panel, rgba(255,255,255,.04)); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; transition: transform .15s, border-color .15s; }
.group-row:hover { transform: translateY(-1px); border-color: rgba(124,92,255,.4); }
.group-link { display: flex; flex-direction: column; gap: .15rem; padding: .75rem 1rem; text-decoration: none; color: inherit; }
.group-name { font-weight: 700; }
.group-card .messages { min-height: 320px; max-height: 60vh; overflow-y: auto; padding: .75rem; background: rgba(0,0,0,.2); border-radius: 12px; display: flex; flex-direction: column; gap: .5rem; }

/* ===== Group message bubble (distinct from 1:1 chat) ===== */
.group-card .msg { position: relative; max-width: 78%; padding: .25rem .25rem .35rem; }
.group-card .msg.mine { align-self: flex-end; text-align: right; }
.group-card .msg.theirs { align-self: flex-start; text-align: left; }
.group-card .msg.system { align-self: center; max-width: 90%; text-align: center; }
.msg-meta { font-size: .72rem; opacity: .7; margin-bottom: .15rem; }
.msg-reply { padding: .2rem .5rem; border-left: 2px solid rgba(124,92,255,.6); margin-bottom: .15rem; opacity: .8; }
.msg-bubble { display: inline-block; padding: .45rem .75rem; border-radius: 14px; background: rgba(255,255,255,.08); word-wrap: break-word; white-space: pre-wrap; }
.msg.mine .msg-bubble { background: linear-gradient(135deg, #7c5cff, #ff5c8a); color: #fff; }
.msg.system .system-bubble { background: transparent; border: 1px dashed rgba(255,255,255,.15); color: var(--muted, #aaa); font-size: .8rem; }
.msg-reactions { margin-top: .15rem; display: inline-flex; gap: .25rem; flex-wrap: wrap; }
.rxn { background: rgba(255,255,255,.08); border-radius: 999px; padding: 1px 8px; font-size: .75rem; }
.msg-actions { opacity: 0; display: inline-flex; gap: .25rem; margin-top: .2rem; transition: opacity .15s; }
.group-card .msg:hover .msg-actions { opacity: 1; }
.rxn-btn { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 999px; padding: 1px 8px; font-size: .8rem; cursor: pointer; color: inherit; }
.rxn-btn:hover { background: rgba(255,255,255,.14); }
.typing-indicator { font-style: italic; }

/* ===== Dialog ===== */
.dialog { border: none; border-radius: 16px; padding: 0; max-width: 520px; width: 92vw; background: var(--panel-solid, #161824); color: inherit; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.dialog::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(4px); }
.dialog-body { padding: 1.25rem; }
.form-row { margin-bottom: 1rem; }
.form-row label { display: block; font-weight: 600; margin-bottom: .35rem; }
.form-stack { display: grid; gap: .75rem; max-width: 420px; }
.form-stack label { display: grid; gap: .25rem; font-weight: 600; }

/* ===== Members list ===== */
.member-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; max-height: 240px; overflow-y: auto; }
.member-row { display: flex; align-items: center; gap: .35rem; padding: .35rem .5rem; background: rgba(255,255,255,.04); border-radius: 10px; }
.badge.tag { background: rgba(124,92,255,.2); color: #c5b8ff; border-radius: 999px; padding: 1px 7px; font-size: .68rem; margin-left: .25rem; vertical-align: middle; }
.badge.tag.warn { background: rgba(255,140,80,.2); color: #ffc69b; }
.warn { color: #ffb070; }
.btn-ghost.mini, .btn-danger.mini { padding: 2px 8px; font-size: .75rem; border-radius: 8px; }
.btn-danger { background: linear-gradient(135deg, #ff5c5c, #ff5c8a); color: #fff; border: none; padding: .45rem .9rem; border-radius: 10px; cursor: pointer; font-weight: 600; }
.btn-danger:hover { filter: brightness(1.1); }

/* ===== Group chat alignment overrides (defeat older .msg rules) ===== */
.group-card .messages { align-items: flex-start; }
.group-card .msg { background: transparent !important; padding: 0 !important; border-radius: 0 !important; box-shadow: none !important; max-width: 78%; animation: msg-in .2s ease both; }
.group-card .msg.mine   { align-self: flex-end !important; text-align: right; }
.group-card .msg.theirs { align-self: flex-start !important; text-align: left; }
.group-card .msg.system { align-self: center !important; text-align: center; max-width: 92%; }
.group-card .msg .msg-bubble { max-width: 100%; }

/* ===== Mention autocomplete ===== */
.mention-pop {
  position: absolute; z-index: 1000; min-width: 220px; max-width: 300px;
  background: var(--panel-solid, #161824); border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.4); overflow: hidden;
  max-height: 260px; overflow-y: auto;
}
.mention-pop .mention-item {
  display: flex; gap: .5rem; align-items: center; padding: .45rem .6rem; cursor: pointer;
  font-size: .9rem;
}
.mention-pop .mention-item:hover,
.mention-pop .mention-item.active { background: rgba(124,92,255,.18); }
.mention-pop .mention-item .avatar { width: 24px; height: 24px; flex-shrink: 0; }
.mention-pop .mention-item strong { font-weight: 600; }
.mention-pop .mention-empty { padding: .6rem; color: var(--muted, #999); font-size: .85rem; text-align: center; }

/* ===== Emoji button + picker ===== */
.emoji-btn { background: transparent; border: none; font-size: 1.25rem; cursor: pointer; padding: 4px 8px; line-height: 1; opacity: .85; }
.emoji-btn:hover { opacity: 1; transform: scale(1.1); }
.chat-composer .emoji-btn { font-size: 1.4rem; padding: 0 6px; }

.emoji-pop {
  position: absolute; z-index: 1100; width: 320px; max-height: 320px; overflow-y: auto;
  padding: .5rem; background: var(--panel-solid, #161824); border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.emoji-pop .emoji-cat { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted, #999); margin: .35rem .25rem .15rem; }
.emoji-pop .emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-pop .emoji-cell { background: transparent; border: none; cursor: pointer; padding: 4px; font-size: 1.25rem; border-radius: 6px; line-height: 1; color: inherit; }
.emoji-pop .emoji-cell:hover { background: rgba(124,92,255,.18); }

/* ===== Mentions inside group bubbles ===== */
.msg-bubble .mention { color: #c5b8ff; font-weight: 600; text-decoration: none; }
.msg-bubble .mention.everyone { color: #ffd87a; }
.msg.mine .msg-bubble .mention { color: #fff; text-decoration: underline; text-underline-offset: 2px; }

/* ===== @everyone avatar in mention popup ===== */
.mention-pop .avatar.everyone-av {
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #ffd87a, #ff5c8a); color: #1a1a1a; font-weight: 800; font-size: .75rem;
}

/* ===== iOS-style switch ===== */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; cursor: pointer; user-select: none; padding: .25rem 0; }
.switch-label { flex: 1; font-weight: 500; }
.switch { position: relative; display: inline-block; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-track {
  position: absolute; inset: 0; border-radius: 999px;
  background: rgba(255,255,255,.18);
  transition: background .25s ease, box-shadow .25s ease;
  display: block;
}
.switch-thumb {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), background .25s ease;
}
.switch input:checked + .switch-track {
  background: linear-gradient(135deg, #7c5cff, #ff5c8a);
  box-shadow: 0 0 12px rgba(124,92,255,.5);
}
.switch input:checked + .switch-track .switch-thumb { transform: translateX(22px); }
.switch input:focus-visible + .switch-track { outline: 2px solid #7c5cff; outline-offset: 2px; }

/* ===== Reply preview above composer ===== */
.reply-preview {
  display: flex; align-items: stretch; gap: .5rem;
  margin: 0 .75rem; padding: .5rem .6rem;
  background: rgba(124,92,255,.08); border-radius: 10px 10px 0 0;
  border-left: 3px solid #7c5cff;
  animation: replySlide .18s ease-out;
}
@keyframes replySlide { from { transform: translateY(6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.reply-preview-bar { display: none; }
.reply-preview-body { flex: 1; min-width: 0; }
.reply-preview-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .9rem; opacity: .85; }
.reply-preview .btn-ghost.mini { align-self: center; padding: 2px 8px; }

/* Reply quote shown inside an outgoing/incoming bubble */
.msg-reply {
  border-left: 3px solid rgba(124,92,255,.55);
  padding: 2px 8px; margin-bottom: 4px;
  background: rgba(124,92,255,.08); border-radius: 4px;
  cursor: pointer;
}
.msg-reply:hover { background: rgba(124,92,255,.15); }

/* ===== In-group search results ===== */
.search-results {
  max-height: 50vh; overflow-y: auto;
  padding: .25rem .5rem .5rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.search-results .sr-empty { padding: 1rem; text-align: center; color: var(--muted, #999); }
.search-result {
  padding: .5rem .65rem; margin: .25rem 0; border-radius: 8px;
  background: rgba(255,255,255,.04); cursor: pointer;
  transition: background .15s ease;
}
.search-result:hover { background: rgba(124,92,255,.15); }
.search-result .sr-meta { font-size: .75rem; color: var(--muted, #999); margin-bottom: .15rem; }
.search-result mark { background: rgba(255,193,7,.45); color: inherit; padding: 0 2px; border-radius: 3px; }

/* highlight a message after jumping to it */
.msg.highlight { animation: msgFlash 1.5s ease; }
@keyframes msgFlash {
  0%, 100% { background-color: transparent; }
  20%      { background-color: rgba(255,193,7,.18); }
}
