:root {
  --accent: #ff9100;
  --accent2: #ffb300;
  --bg1: #1a1a1a;
  --bg2: #0b0b0f;
  --panel: #141414;
  --panel2: #1b1b1b;
  --line: #2b2b2b;
  --text: #ffffff;
  --muted: #cfcfcf;
  --bubble-me-text: #111111;
  --mention: #1a6fd4;
}

body.theme-blue {
  --accent: #4da3ff;
  --accent2: #7fc0ff;
  --bg1: #101827;
  --bg2: #060b14;
  --panel: #0f1724;
  --panel2: #182235;
  --line: #2a3954;
  --text: #f5f9ff;
  --muted: #ced8e8;
  --bubble-me-text: #07111f;
  --mention: #e07b20;
}

body.theme-green {
  --accent: #29c46d;
  --accent2: #62e49a;
  --bg1: #0e1711;
  --bg2: #060b07;
  --panel: #101710;
  --panel2: #172419;
  --line: #28412d;
  --text: #f3fff6;
  --muted: #cde9d3;
  --bubble-me-text: #07110b;
  --mention: #cc3b6e;
}

body.theme-purple {
  --accent: #a76bff;
  --accent2: #c69cff;
  --bg1: #17111f;
  --bg2: #09060f;
  --panel: #14101a;
  --panel2: #21192d;
  --line: #3b2c56;
  --text: #fbf7ff;
  --muted: #ddd0ee;
  --bubble-me-text: #12091d;
  --mention: #7ab832;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Arial, sans-serif;
}

body {
  background: radial-gradient(circle at top, var(--bg1) 0%, var(--bg2) 45%, #000 100%);
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

body:not(.logged-in)::before {
  content: "";
  position: fixed;
  top: 50%;
  left: 50%;
  width: 180vmax;
  height: 180vmax;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    rgba(255, 149, 0, 0.07) 60deg,
    rgba(255, 179, 0, 0.10) 120deg,
    transparent 180deg,
    rgba(255, 149, 0, 0.05) 240deg,
    transparent 360deg
  );
  animation: rotateBgReverse 12s linear infinite;
  z-index: 0;
  pointer-events: none;
}


.topbar {
  height: 61px;
  background: #000;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.logo {
  font-size: 20px;
  font-weight: 700;
}

.logo span {
  background: linear-gradient(to bottom, var(--accent2), var(--accent));
  color: #111;
  padding: 3px 8px;
  border-radius: 8px;
}

.logo-img {
  height: 50px;
  width: auto;
  object-fit: contain;
}

.profile-container {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.profileIcon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--accent);
  object-fit: cover;
  background: #111;
}

.user-id {
  font-size: 13px;
  color: var(--muted);
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gear-btn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  padding: 0;
  border-radius: 50%;
  font-size: 31px;
  line-height: 48px;
  background: none;
  color: var(--accent);
}
#userSearchBtn svg {
  width: 26px;
  height: 26px;
  color: var(--accent);
}
#groupManageBtn {
  width: auto;
  height: auto;
  min-width: unset;
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
}

.profileMenu {
  position: absolute;
  top: 58px;
  right: 0;
  width: 270px;
  background: linear-gradient(to bottom, #1a1a1a, #101010);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  display: none;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
}

.menu-title {
  color: var(--accent2);
  font-weight: 700;
  margin-bottom: 4px;
}

.menu-label {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.search-wrapper {
  position: relative;
}

.search-menu {
  left: auto;
  right: auto;
  transform: translateX(-70%);
  width: 280px;
}

@media (max-width: 600px) {
  .search-menu {
    position: fixed;
    left: 50%;
    right: auto;
    top: 58px;
    transform: translateX(-50%);
    width: calc(100vw - 32px);
    max-width: 340px;
    z-index: 9999;
  }
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  margin-top: 4px;
}

.search-result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 10px;
  transition: 0.15s ease;
}

.search-result-row:hover {
  border-color: var(--accent);
}

.search-result-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  flex-shrink: 0;
}

.search-result-name {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-id {
  font-size: 11px;
  color: var(--muted);
}

.search-add-btn {
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  font-size: 16px;
  line-height: 28px;
  text-align: center;
  flex-shrink: 0;
}

.search-result-row.already-friend .search-add-btn {
  background: #2a2a2a;
  color: var(--muted);
  cursor: default;
}

.menu-select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: linear-gradient(135deg, #0d0d0d 0%, #1a1a2e 100%);
  color: var(--accent2);
  outline: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffb300' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  box-shadow: 0 0 10px rgba(255,149,0,0.12), inset 0 1px 0 rgba(255,255,255,0.04);
  transition: border-color 0.2s, box-shadow 0.2s;
}

@keyframes rotateBg {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes rotateBgReverse {
  0%   { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(-360deg); }
}

.center {
  width: 100%;
  max-width: 420px;
  margin: 90px auto 0;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 28px 22px;
  background: linear-gradient(to bottom, rgba(26,26,26,0.95), rgba(10,10,10,0.96));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.45);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.center::before {
  content: "";
  position: absolute;
  inset: -60%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    rgba(255, 149, 0, 0.18) 60deg,
    rgba(255, 179, 0, 0.22) 120deg,
    transparent 180deg,
    rgba(255, 149, 0, 0.10) 240deg,
    transparent 360deg
  );
  animation: rotateBg 6s linear infinite;
  z-index: -1;
  border-radius: 50%;
}

.center h2 {
  text-align: center;
  color: var(--accent2);
  font-size: 22px;
  margin: 4px 0 2px;
}

/* ── Auth Page ── */
.auth-page {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 9999;
  background: var(--bg2);
}

.auth-github-btn {
  position: absolute;
  top: 16px;
  right: 18px;
  z-index: 10001;
  color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  text-decoration: none;
}
.auth-github-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.12);
}

.auth-left {
  position: absolute;
  left: 0; top: 0;
  width: 50%; height: 100%;
  background: linear-gradient(148deg, #b35500 0%, #e07800 55%, #c96a00 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 36px 40px;
  overflow: hidden;
  box-sizing: border-box;
  transition: transform 0.65s cubic-bezier(0.77, 0, 0.175, 1);
  will-change: transform;
  z-index: 1;
}
.auth-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
}
.auth-left::after {
  content: '';
  position: absolute;
  width: 320px;
  height: 320px;
  background: rgba(255,255,255,0.07);
  border-radius: 50%;
  top: 8%;
  right: -80px;
  filter: blur(60px);
  pointer-events: none;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  position: relative;
  z-index: 2;
}
.auth-brand-logo {
  max-height: 64px;
  max-width: 180px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
}
.auth-brand-icon-dark {
  background: rgba(255,145,0,0.18);
}

/* ── Character stage ── */
.auth-stage {
  position: relative;
  width: 420px;
  height: 360px;
  margin: 0 auto;
  z-index: 2;
}
.auth-char {
  position: absolute;
  bottom: 0;
  transition: transform 0.5s ease, height 0.55s ease;
  transform-origin: bottom center;
}
.char-purple {
  left: 50px;
  width: 155px;
  height: 360px;
  background: var(--accent);
  border-radius: 10px 10px 0 0;
  z-index: 1;
  box-shadow: 0 -6px 30px rgba(224,120,0,0.35);
}
.char-black {
  left: 195px;
  width: 110px;
  height: 275px;
  background: #2D2D2D;
  border-radius: 8px 8px 0 0;
  z-index: 2;
  box-shadow: 0 -4px 18px rgba(0,0,0,0.4);
}
.char-orange {
  left: 0;
  width: 195px;
  height: 170px;
  background: #FF9B6B;
  border-radius: 110px 110px 0 0;
  z-index: 3;
  box-shadow: 0 -4px 18px rgba(255,155,107,0.3);
}
.char-yellow {
  left: 262px;
  width: 130px;
  height: 205px;
  background: #E8D754;
  border-radius: 65px 65px 0 0;
  z-index: 4;
  box-shadow: 0 -4px 18px rgba(232,215,84,0.25);
}
.char-eyes-wrap {
  position: absolute;
  display: flex;
  gap: 20px;
  transition: left 0.12s ease, top 0.12s ease;
}
.char-eyes-wrap.bare-pupils { gap: 18px; }
.eyeball {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: height 0.1s ease;
  flex-shrink: 0;
}
.eyeball-sm { width: 15px; height: 15px; }
.pupil {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1a1a1a;
  transition: transform 0.08s ease-out;
  flex-shrink: 0;
}
.pupil-bare {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #1a1a1a;
  transition: transform 0.08s ease-out;
  flex-shrink: 0;
}
.char-mouth {
  position: absolute;
  width: 58px;
  height: 4px;
  background: #1a1a1a;
  border-radius: 2px;
  transition: left 0.12s ease, top 0.12s ease;
}

.auth-left-footer {
  display: flex;
  gap: 20px;
  position: relative;
  z-index: 2;
}
.auth-left-footer a {
  color: rgba(255,255,255,0.45);
  font-size: 12px;
  text-decoration: none;
  transition: color 0.2s;
}
.auth-left-footer a:hover { color: rgba(255,255,255,0.9); }

/* ── Right panel ── */
.auth-right {
  position: absolute;
  left: 50%; top: 0;
  width: 50%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: var(--bg2);
  overflow-y: auto;
  box-sizing: border-box;
  transition: transform 0.65s cubic-bezier(0.77, 0, 0.175, 1);
  will-change: transform;
  z-index: 2;
}
.auth-page.auth-signup .auth-left { transform: translateX(100%); }
.auth-page.auth-signup .auth-right { transform: translateX(-100%); }
.auth-form-wrap {
  width: 100%;
  max-width: 400px;
}
.auth-brand-mobile {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 32px;
}
.auth-tabs {
  display: flex;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 13px;
  padding: 4px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  font-family: inherit;
}
.auth-tab-active {
  background: var(--accent) !important;
  color: #fff !important;
}
.auth-heading {
  text-align: center;
  margin-bottom: 24px;
}
.auth-heading h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
}
.auth-heading p {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}
.auth-field { margin-bottom: 16px; }
.auth-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.auth-field input {
  width: 100%;
  height: 48px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.11);
  border-radius: 12px;
  color: var(--text);
  padding: 0 14px;
  font-size: 15px;
  box-sizing: border-box;
  transition: border-color 0.2s;
  outline: none;
  font-family: inherit;
}
.auth-field input:focus { border-color: var(--accent); }
.auth-pw-wrap { position: relative; }
.auth-pw-wrap input { padding-right: 46px; }
.auth-eye-btn {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  display: flex;
  align-items: center;
  line-height: 1;
}
.auth-eye-btn:hover { color: var(--text); }
.auth-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 16px;
  user-select: none;
}
.auth-remember input[type=checkbox] {
  width: auto !important;
  height: auto !important;
  padding: 0 !important;
  background: none !important;
  border: none !important;
  accent-color: var(--accent);
  cursor: pointer;
}
.auth-msg {
  font-size: 13px;
  color: #ff6b6b;
  text-align: center;
  margin-bottom: 0;
  border-radius: 10px;
  min-height: 0;
  transition: padding 0.2s;
}
.auth-msg:not(:empty) {
  padding: 10px 14px;
  background: rgba(255,80,80,0.07);
  border: 1px solid rgba(255,80,80,0.18);
  margin-bottom: 12px;
}
.auth-msg.success { color: #4ade80; }
.auth-msg.success:not(:empty) {
  background: rgba(74,222,128,0.07);
  border: 1px solid rgba(74,222,128,0.2);
}
.auth-btn {
  width: 100%;
  height: 48px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, transform 0.1s;
  font-family: inherit;
  margin-top: 4px;
}
.auth-btn:hover { background: #e07800; }
.auth-btn:active { transform: scale(0.98); }

.auth-forgot-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  width: 100%;
  margin-top: 6px;
  padding: 4px 0;
  transition: color 0.15s;
}
.auth-forgot-btn:hover { color: var(--accent); }
.auth-note {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 10px 0 0;
}
@media (max-width: 880px) {
  .auth-left { display: none; }
  .auth-right { left: 0; width: 100%; transform: none !important; }
  .auth-brand-mobile { display: flex; }
}

#output {
  text-align: center;
  color: #fff3b8;
  min-height: 20px;
  margin-top: 4px;
  font-size: 14px;
}

input,
button {
  font-size: 14px;
}

input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #303030;
  border-radius: 999px;
  background: #f4f4f4;
  color: #111;
  outline: none;
  transition: 0.2s ease;
}

input:focus,
.menu-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,191,31,0.16);
}

button {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(to bottom, var(--accent2), var(--accent));
  color: #111;
  font-weight: 800;
  cursor: pointer;
}

.main-app {
  display: flex;
  height: calc(100vh - 64px);
}

.sidebar {
  width: 260px;
  min-width: 260px;
  background: #000;
  border-right: 1px solid var(--line);
  padding: 14px 0;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 10px;
  padding: 0 14px;
}

.sidebar-header h3 {
  color: var(--accent2);
  font-size: 20px;
  margin: 0;
}

.sidebar-dots-btn {
  position: absolute;
  right: 0;
  width: 30px;
  min-width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  font-size: 18px;
  line-height: 28px;
  background: transparent;
  color: var(--muted);
  border: none;
}

.sidebar-dots-btn:hover {
  background: var(--panel2);
  color: var(--text);
}

.sidebar-tools-wrap {
  position: absolute;
  left: 0;
}

.sidebar-tools-btn {
  width: 30px;
  min-width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
  line-height: 28px;
  background: transparent;
  color: var(--accent2);
  border: none;
  cursor: pointer;
}

.sidebar-tools-btn:hover {
  background: var(--panel2);
  color: var(--accent);
}

.sidebar-tools-menu {
  position: absolute;
  top: 36px;
  left: 0;
  z-index: 200;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  min-width: 200px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.45);
  flex-direction: column;
  gap: 6px;
}

.friends-dropdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.sidebar h3 {
  color: var(--accent2);
  margin-bottom: 10px;
  text-align: center;
  font-size: 20px;
}

.sidebar-btn {
  margin: 0 14px 10px;
  border-radius: 10px;
}

#friendsList {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.friend-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 0;
  transition: background 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.friend-row:hover,
.friend-row.active {
  background: rgba(255,255,255,0.05);
}

.friend-name-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: 2px;
}

.friend-name {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-last-msg {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.65;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-mood {
  font-size: 11px;
  color: var(--muted, rgba(255,255,255,0.4));
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-mood-bubble {
  position: absolute;
  top: -6px;
  left: 26px;
  background: rgba(14,14,18,0.88);
  border: 1px solid rgba(255,255,255,0.11);
  border-radius: 8px 8px 8px 2px;
  padding: 2px 7px;
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  font-style: italic;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  z-index: 4;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.online-count {
  font-size: 12px;
  font-weight: 400;
  color: #22c55e;
  margin-left: 4px;
}

.group-leave-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 11px 14px;
  border: 1px solid rgba(255, 77, 77, 0.4);
  border-radius: 10px;
  background: linear-gradient(to bottom, rgba(255,77,77,0.18), rgba(201,31,31,0.22));
  color: #ff8585;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.group-leave-btn:hover {
  background: linear-gradient(to bottom, #ff4d4d, #c91f1f);
  color: #fff;
  border-color: #ff4d4d;
}

.unread-dot {
  width: 10px;
  height: 10px;
  background: red;
  border-radius: 50%;
  display: none;
}

.chatContainer {
  flex: 1;
  padding: 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background-color: #111;
  background-image: url("../images/newbackimage.jpg");
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}

.chatContainer::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.7);
  pointer-events: none;
  z-index: 0;
}

.chatContainer > * {
  position: relative;
  z-index: 1;
}

.chat-top,
.friend-tools {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.chat-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 16px 14px;
  display: none;
  flex-direction: column;
  gap: 6px;
}

.chat-footer.visible {
  display: flex;
}

.message-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  background: rgba(14, 14, 18, 0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 28px;
  padding: 5px 8px 5px 6px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

.message-row #messageInput {
  background: transparent;
  border: none;
  color: #fff;
  box-shadow: none;
  max-width: none;
  padding: 8px 6px;
  border-radius: 0;
  resize: none;
  overflow-y: hidden;
  height: 36px;
  min-height: 36px;
  max-height: 120px;
  line-height: 1.45;
  display: block;
  align-self: center;
  scrollbar-width: none;
}

.message-row #messageInput::-webkit-scrollbar {
  display: none;
}

.message-row #messageInput::placeholder {
  color: rgba(255,255,255,0.32);
}

.message-row #messageInput:focus {
  border: none;
  box-shadow: none;
  outline: none;
}

.chat-top input,
.friend-tools input,
.message-row input,
.message-row textarea {
  flex: 1;
}

.chat-top button,
.friend-tools button {
  width: 170px;
}

.send-btn,
.message-row .send-btn {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-header {
  color: var(--accent2);
  font-weight: 700;
  margin-bottom: 4px;
  margin-top: 0;
  height: auto;
  overflow: visible;
  display: flex;
  align-items: center;
}
#chatHeaderText { margin-top: 0; }

.load-older-anchor {
  display: block;
  width: 100%;
  padding: 6px 14px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  min-height: 4px;
}

.chatBox {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
  padding: 14px 14px 140px 14px;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 149, 0, 0.5) transparent;
}

.chatBox::-webkit-scrollbar {
  width: 4px;
}

.chatBox::-webkit-scrollbar-track {
  background: transparent;
}

.chatBox::-webkit-scrollbar-thumb {
  background: rgba(255, 149, 0, 0.5);
  border-radius: 999px;
}

.chatBox::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 149, 0, 0.85);
}

.chatBox > * {
  position: relative;
  z-index: 1;
}

.chat-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255,255,255,0.15);
  font-size: 18px;
  text-align: center;
  pointer-events: none;
  user-select: none;
}

.message {
  padding: 10px 14px;
  margin: 6px 0;
  border-radius: 16px;
  max-width: 72%;
  word-wrap: break-word;
  position: relative;
}

.message.me {
  background: var(--accent);
  color: var(--bubble-me-text);
  margin-left: auto;
}

.message.other {
  background: #2a2a2a;
  color: white;
}

.reply-chip {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  border-left: 3px solid rgba(255,255,255,0.35);
  background: rgba(0,0,0,0.18);
  border-radius: 4px;
  padding: 3px 7px;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.message.me .reply-chip {
  border-left-color: rgba(0,0,0,0.25);
  background: rgba(0,0,0,0.10);
  color: rgba(0,0,0,0.45);
}

.typingIndicator {
  color: var(--accent2);
  font-size: 13px;
  min-height: 0;
  padding-left: 6px;
}

.replyPreview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 6px 10px;
  margin: 0 4px 4px 4px;
}

.replyPreviewText {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.replyCloseBtn {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
}

/* ── Hamburger button ── */
.hamburger-btn {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
}

/* ── Drawer overlay ── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 900;
}

/* ── Drawer sidebar ── */
.drawer {
  transition: transform 0.28s ease;
}

@media (max-width: 900px) {
  .user-id {
    display: none;
  }

  .main-app {
    flex-direction: column;
  }

  .hamburger-btn {
    display: flex;
  }

  .sidebar.drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    min-width: 100%;
    height: 100%;
    z-index: 1000;
    border-right: none;
    border-bottom: none;
    transform: translateX(-100%);
    overflow-y: auto;
    padding-top: 70px;
  }

  .sidebar.drawer.open {
    transform: translateX(0);
  }

  .chatContainer {
    width: 100%;
  }

  .center {
    margin: 30px 14px 0;
    width: auto;
  }

  .profileMenu {
    right: -6px;
    width: 230px;
  }

  .chatContainer {
    padding: 12px 12px 0 12px;
  }

  .chat-footer {
    padding: 6px 12px 12px;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding: 0 12px;
  }

  .logo {
    font-size: 18px;
  }

  .logo-img {
    height: 30px;
  }

  .profileIcon {
    width: 36px;
    height: 36px;
  }

  .chat-top,
  .friend-tools {
    flex-direction: column;
  }

  .chat-top button,
  .friend-tools button {
    width: 100%;
  }

  /* message-row always stays horizontal */
  .message-row {
    flex-direction: row;
    align-items: center;
  }

  .message {
    max-width: 88%;
  }
}

.message-row-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 8px;
}

.message-row-wrapper.with-label {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

.message-row-wrapper.with-label .message-row-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent, #f0a500);
}

.friend-av-wrap {
  position: relative;
  width: 48px;
  height: 48px;
  min-width: 48px;
  flex-shrink: 0;
  border-radius: 50%;
  cursor: pointer;
}

.friend-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent, #f0a500);
  display: block;
}
.msg-time {
  font-size: 11px;
  opacity: 0.65;
  margin-top: 6px;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
}

.msg-status {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  letter-spacing: -2px;
  flex-shrink: 0;
}

.msg-status.msg-status-read {
  color: #22c55e;
}

#usersList .friend-row {
  justify-content: space-between;
  align-items: center;
}

/* ── Groups sidebar ── */
.sidebar-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 14px 14px;
}

.group-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 0;
  transition: background 0.15s;
  width: 100%;
  box-sizing: border-box;
  cursor: pointer;
}

.group-row:hover {
  background: rgba(255,255,255,0.05);
}

.group-icon {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--accent);
  display: block;
}

/* ── Chat header with rename ── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rename-group-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.rename-group-row input {
  flex: 1;
}

.rename-group-row button {
  width: auto;
  padding: 10px 16px;
  flex-shrink: 0;
}

/* ── Icon buttons ── */
.icon-btn {
  width: 30px;
  min-width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  font-size: 14px;
  line-height: 30px;
  text-align: center;
  background: none;
  color: var(--accent);
}

.cancel-btn {
  background: #333;
  color: var(--text);
}

/* ── Create Group inline panel ── */
#createGroupPanel {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.member-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  padding: 4px 0;
}

.member-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.member-check-row input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
  padding: 0;
  border-radius: 4px;
}

/* ── Image sending ── */
.emoji-panel {
  display: block;
  background: rgba(22, 22, 22, 0.9);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 10px 10px;
  max-height: 210px;
  overflow-y: auto;
}

.emoji-panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.emoji-panel-gif-btn {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  cursor: pointer;
  transition: 0.15s;
  letter-spacing: 0.5px;
}
.emoji-panel-gif-btn:hover,
.emoji-panel-gif-btn.active { background: rgba(255,255,255,0.14); color: var(--accent); }

.emoji-panel-emojis {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}

.emoji-item {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 19px;
  line-height: 34px;
  text-align: center;
  cursor: pointer;
  transition: background 0.12s;
}

.emoji-item:hover {
  background: var(--panel2);
}

.img-pick-btn,
.message-row .img-pick-btn {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 400;
  line-height: 36px;
  flex-shrink: 0;
}

.message-row .img-pick-btn {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.75);
}

.message-row .img-pick-btn:hover {
  background: rgba(255,255,255,0.13);
}

.preview-thumb {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.chat-image {
  max-width: 220px;
  max-height: 220px;
  width: 100%;
  border-radius: 10px;
  display: block;
  margin-top: 4px;
  cursor: zoom-in;
  object-fit: contain;
  transition: opacity 0.15s;
}

.chat-image:hover {
  opacity: 0.85;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.lightbox-img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 14px;
  box-shadow: 0 0 60px rgba(255, 149, 0, 0.25);
  object-fit: contain;
}

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 22px;
  width: 42px;
  min-width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(30,30,30,0.85);
  border: 1px solid rgba(255,149,0,0.3);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  z-index: 10000;
}

.lightbox-download {
  position: fixed;
  top: 18px;
  right: 72px;
  width: 42px;
  min-width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(30,30,30,0.85);
  border: 1px solid rgba(255,149,0,0.3);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Online / offline status dot ── */
.avatar-wrapper {
  position: relative;
  flex-shrink: 0;
}

.status-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2.5px solid var(--bg2);
  background: #22c55e;
  z-index: 2;
  display: none;
}

.status-dot.online {
  display: block;
}

.friend-username {
  font-size: 11px;
  color: var(--accent);
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Group chat sender label ── */
.sender-label {
  font-size: 11px;
  color: var(--accent2);
  padding-left: 38px;
  margin-bottom: 2px;
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0,0,0,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-box {
  position: relative;
  background: var(--panel);
  border: 1px solid rgba(255,149,0,0.22);
  border-radius: 18px;
  padding: 24px 20px 20px;
  width: min(92vw, 380px);
  max-height: 82vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.7);
}

.modal-box .lightbox-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 34px;
  min-width: 34px;
  height: 34px;
  font-size: 15px;
}
.profile-modal-settings-btn {
  position: absolute;
  top: 12px;
  left: 14px;
  width: 51px;
  min-width: 51px;
  height: 51px;
  font-size: 30px;
  line-height: 51px;
}

/* ── Profile modal ── */
.profile-modal-avatar {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  margin-bottom: 4px;
}

.profile-modal-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

.profile-modal-id {
  font-size: 12px;
  color: var(--muted);
}

.profile-modal-bio {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-top: 2px;
}

.profile-modal-mood {
  font-size: 13px;
  color: var(--accent2);
  font-style: italic;
  text-align: center;
  margin-top: 2px;
}

.profile-modal-friend-count {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 2px;
}

.profile-modal-status {
  font-size: 13px;
  margin-top: 4px;
}

/* ── Profile modal actions ── */
.profile-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.pma-btn {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  width: auto;
  min-width: unset;
  cursor: pointer;
}

.pma-remove-friend { background: #3a1a00; color: #ffaa55; }
.pma-block { background: #7b0000; color: #fff; }
.pma-report { background: #333; color: #ccc; }
.pma-mute  { background: #1e1e3a; color: #aaa; }

.mute-submenu {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 4px;
  padding-top: 10px;
  margin-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.mute-submenu button {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: 9px;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}

.mute-submenu button:hover {
  background: rgba(255,255,255,0.1);
}

.profile-nickname-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.profile-nickname-section input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 10px;
  color: #fff;
  padding: 8px 12px;
  font-size: 14px;
}
.profile-nickname-section button {
  width: 100%;
  background: #1a3a5c;
  color: #7ec8f7;
  border: none;
  border-radius: 10px;
  padding: 9px 0;
  font-size: 14px;
  cursor: pointer;
}
.profile-nickname-section button:hover {
  background: #1e4a74;
}

/* ── Self profile edit ── */
.profile-avatar-edit-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s;
  z-index: 3;
}
.profile-avatar-edit-overlay:hover { opacity: 1; }

.profile-self-edit {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.self-edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.self-edit-field label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
}

.self-edit-field input {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  border-radius: 0;
  padding: 7px 2px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
  box-sizing: border-box;
}
.self-edit-field input:focus { border-bottom-color: var(--accent); }
.self-edit-field input::placeholder { color: rgba(255,255,255,0.22); }

.self-edit-save-btn {
  align-self: flex-end;
  background: var(--accent);
  color: #000;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 20px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.15s;
}
.self-edit-save-btn:hover { opacity: 0.85; }

/* ── Group manage modal ── */
.group-modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin-bottom: 4px;
}

.group-modal-icon-wrap {
  position: relative;
  flex-shrink: 0;
  width: 58px;
  height: 58px;
}

.group-modal-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
}

.group-modal-icon-edit {
  position: absolute;
  bottom: 0;
  right: 0;
  background: var(--accent);
  color: #111;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.group-members-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-height: 220px;
  overflow-y: auto;
}

.group-member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  background: var(--panel2);
}

/* ── Message reactions ── */
.reaction-picker {
  display: none;
  position: absolute;
  top: -42px;
  left: 0;
  flex-direction: row;
  gap: 2px;
  background: var(--panel);
  border: 1px solid rgba(255,149,0,0.3);
  border-radius: 22px;
  padding: 4px 8px;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0,0,0,0.55);
  white-space: nowrap;
}

.reaction-picker.visible {
  display: flex;
}

.message.me .reaction-picker {
  left: auto;
  right: 0;
}

.reaction-picker-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 0 3px;
  border-radius: 50%;
  transition: transform 0.1s;
  line-height: 1;
}

.reaction-picker-btn:hover {
  transform: scale(1.25);
}

.reaction-bar {
  position: absolute;
  bottom: -13px;
  right: 10px;
  display: flex;
  flex-direction: row;
  gap: 2px;
  z-index: 5;
  pointer-events: auto;
}
.message:not(.me) .reaction-bar { right: auto; left: 10px; }
.message.has-reactions { margin-bottom: 18px; }

.reaction-pill {
  background: var(--panel);
  border: 1px solid rgba(255,149,0,0.25);
  border-radius: 20px;
  padding: 1px 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  transition: transform 0.1s;
  white-space: nowrap;
  line-height: 1.6;
}
.reaction-pill:hover { transform: scale(1.1); }

.reaction-pill.reacted {
  background: rgba(255,149,0,0.22);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Clickable links in chat ── */
.chat-link {
  color: #e74c3c;
  text-decoration: underline;
  cursor: pointer;
  word-break: break-all;
}

.link-popup {
  position: fixed;
  z-index: 9999;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.5);
  min-width: 140px;
}

.link-popup button {
  background: var(--panel2);
  border: none;
  border-radius: 7px;
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
}

.link-popup button:hover {
  background: var(--accent);
  color: #000;
}

/* ── Mention dropdown ── */
.mention-dropdown {
  display: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 -4px 18px rgba(0,0,0,0.45);
  max-height: 200px;
  overflow-y: auto;
  margin: 0 8px 6px 8px;
}

.mention-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background 0.1s;
}

.mention-item:hover {
  background: var(--panel2);
  color: var(--accent);
}

.mention-everyone {
  color: var(--accent2);
  font-weight: 700;
}

.mention-everyone:hover {
  color: var(--accent);
}

#avatarFileInput {
  background: linear-gradient(135deg, #0d0d0d 0%, #1a1a2e 100%);
  color: var(--accent2);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.4px;
  box-shadow: 0 0 10px rgba(255,149,0,0.12), inset 0 1px 0 rgba(255,255,255,0.04);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.theme-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 0 14px;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s;
  user-select: none;
}

.theme-option:hover { border-color: rgba(255,255,255,0.18); }

.theme-option.active {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(255,145,0,0.2);
}

.theme-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
}

.theme-label {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.4px;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 999;
}

#settingsMenu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 0;
  border: none;
  overflow: hidden;
  z-index: 1000;
  padding: 0;
  box-sizing: border-box;
  background: #0b0b0e;
  flex-direction: column;
}

.settings-inner {
  flex: 1;
  overflow-y: auto;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 16px 40px;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,149,0,0.3) transparent;
}
.settings-inner::-webkit-scrollbar { width: 3px; }
.settings-inner::-webkit-scrollbar-track { background: transparent; }
.settings-inner::-webkit-scrollbar-thumb { background: rgba(255,149,0,0.3); border-radius: 99px; }

.settings-menu-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 16px 16px 14px;
  background: #0b0b0e;
  margin-bottom: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.settings-menu-header .menu-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.1px;
}

.settings-profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 16px 18px;
  max-width: 520px;
  margin: 0 auto;
  cursor: pointer;
  flex-shrink: 0;
}
.settings-profile-header:active { opacity: 0.7; }

.settings-profile-img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  flex-shrink: 0;
}

.settings-profile-text { flex: 1; min-width: 0; }

.settings-profile-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-profile-sub {
  font-size: 13px;
  color: var(--muted);
  opacity: 0.7;
  margin-top: 2px;
}

.settings-profile-edit-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-close-btn {
  position: absolute;
  right: 14px;
  width: 32px;
  min-width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--muted);
  font-size: 13px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.settings-close-btn:hover { background: rgba(255,255,255,0.13); }

.settings-section {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 0 14px;
  margin-bottom: 8px;
  margin-top: 30px;
  position: relative;
  z-index: 1;
}

.settings-section-danger { border-color: rgba(255,60,60,0.12); }

.settings-section-label {
  position: absolute;
  top: -22px;
  left: 2px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1px;
  text-transform: none;
  color: var(--muted);
  padding: 0;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  cursor: pointer;
  transition: opacity 0.15s;
}
.settings-row:hover { opacity: 0.75; }

.settings-row-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.settings-row-text { flex: 1; font-size: 14px; color: var(--text); font-weight: 500; }
.settings-row-arrow { color: var(--muted); font-size: 20px; line-height: 1; }
.settings-row-sub { color: var(--muted); font-size: 13px; margin-left: auto; }
.settings-row-logout .settings-row-text { color: #ff8a65; }
.settings-row-delete .settings-row-text { color: #ff5252; }

.settings-toggle {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 14px;
  background: rgba(255,255,255,0.14);
  flex-shrink: 0;
  font-size: 0;
  transition: background 0.22s;
  cursor: pointer;
  display: inline-block;
  vertical-align: middle;
}
.settings-toggle::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
}
.settings-toggle.toggle-on {
  background: #4cd964;
}
.settings-toggle.toggle-on::after {
  transform: translateX(20px);
}

.blocked-users-list { padding: 4px 0; }

.blocked-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.blocked-user-row:last-child { border-bottom: none; }

.settings-empty-label {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 0;
  text-align: center;
}

.settings-field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.settings-field-row input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.settings-field-row input:focus { border-color: var(--accent); background: rgba(255,255,255,0.07); }
.settings-field-row input::placeholder { color: rgba(255,255,255,0.28); }

.settings-save-btn {
  background: var(--accent) !important;
  color: #000 !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  padding: 6px 14px !important;
  border-radius: 20px !important;
  border: none !important;
  cursor: pointer;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  min-width: unset !important;
  width: auto !important;
  transition: opacity 0.15s;
}
.settings-save-btn:hover { opacity: 0.85; }

.settings-email-note {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 2px 6px;
  min-height: 16px;
}

/* ── @mention highlight in messages ── */
.chat-mention {
  color: var(--mention);
  font-weight: 600;
  cursor: default;
}

/* ── Avatar decorations ── */
.avatar-deco-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.avatar-deco-wrap img {
  position: relative;
  z-index: 1;
}

/* Rotating ring for rainbow & galaxy */
.avatar-deco-wrap[data-deco="rainbow"]::before,
.avatar-deco-wrap[data-deco="galaxy"]::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  z-index: 0;
  animation: deco-spin 2.5s linear infinite;
}

.avatar-deco-wrap[data-deco="rainbow"]::before {
  background: conic-gradient(#ff0000, #ff8800, #ffff00, #00ff00, #0088ff, #8800ff, #ff0000);
}

.avatar-deco-wrap[data-deco="galaxy"]::before {
  background: conic-gradient(#6600ff, #0088ff, #00ffee, #ff00aa, #8800ff, #6600ff);
  animation-duration: 4s;
  filter: blur(1px);
}

/* Glow pulse decorations */
.avatar-deco-wrap[data-deco="gold"] img {
  border-color: #ffb300;
  animation: deco-gold 2s ease-in-out infinite;
}

.avatar-deco-wrap[data-deco="fire"] img {
  border-color: #ff6600;
  animation: deco-fire 1.4s ease-in-out infinite;
}

.avatar-deco-wrap[data-deco="frost"] img {
  border-color: #7fc0ff;
  animation: deco-frost 2.5s ease-in-out infinite;
}

.avatar-deco-wrap[data-deco="neon"] img {
  border-color: #00ff88;
  animation: deco-neon 1.6s ease-in-out infinite;
}

@keyframes deco-spin {
  to { transform: rotate(360deg); }
}

@keyframes deco-gold {
  0%, 100% { box-shadow: 0 0 0 2px #ff9100, 0 0 8px 2px rgba(255,145,0,0.4); }
  50%       { box-shadow: 0 0 0 2px #ffb300, 0 0 14px 4px rgba(255,179,0,0.62); }
}

@keyframes deco-fire {
  0%, 100% { box-shadow: 0 0 0 2px #ff4500, 0 0 8px 2px rgba(255,60,0,0.4); }
  50%       { box-shadow: 0 0 0 2px #ff8800, 0 0 14px 4px rgba(255,100,0,0.65); }
}

@keyframes deco-frost {
  0%, 100% { box-shadow: 0 0 0 2px #7fc0ff, 0 0 8px 2px rgba(100,180,255,0.4); }
  50%       { box-shadow: 0 0 0 2px #b8d8ff, 0 0 14px 4px rgba(150,210,255,0.62); }
}

@keyframes deco-neon {
  0%, 100% { box-shadow: 0 0 0 2px #00ff88, 0 0 8px 2px rgba(0,255,136,0.4); }
  50%       { box-shadow: 0 0 0 2px #00ffaa, 0 0 14px 4px rgba(0,255,160,0.65); }
}

/* Decoration picker */
.deco-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 0 14px;
}

.deco-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s;
  user-select: none;
}

.deco-option:hover { border-color: rgba(255,255,255,0.18); }

.deco-option.active {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(255,145,0,0.2);
}

.deco-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.3px;
}

.deco-preview-ring {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #2a2a3a;
  flex-shrink: 0;
}

.attach-btn-wrap {
  position: relative;
  width: 36px;
  min-width: 36px;
  height: 36px;
  flex-shrink: 0;
}

/* ── Attach popup ── */
.attach-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: linear-gradient(to bottom, #1e1e1e, #111);
  border: 1px solid rgba(255,149,0,0.3);
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 300;
  min-width: 130px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.6);
}

.attach-option {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  width: 100%;
}

.attach-option:hover {
  background: var(--panel2);
  color: var(--accent2);
}

/* ── File chip in chat ── */
.file-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 8px 10px;
  margin-top: 4px;
  min-width: 160px;
  max-width: 220px;
}

.file-chip-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.file-chip-name {
  flex: 1;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
}

.file-chip-dl {
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  font-size: 13px;
  line-height: 28px;
  text-align: center;
  flex-shrink: 0;
  background: rgba(255,255,255,0.1);
  border: none;
  cursor: pointer;
  color: inherit;
}

/* ── Edited badge ── */
.msg-edited {
  font-size: 10px;
  opacity: 0.55;
  margin-left: 4px;
}

/* ── Inline message edit ── */
.msg-edit-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.msg-edit-row input {
  flex: 1;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,149,0,0.4);
  color: #fff;
}

.msg-edit-row button {
  width: auto;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
}

.deco-ring-none  { outline: 2px solid #444; }
.deco-ring-gold  { box-shadow: 0 0 0 2px #ff9100, 0 0 8px 2px rgba(255,145,0,0.55); }
.deco-ring-fire  { box-shadow: 0 0 0 2px #ff4500, 0 0 8px 2px rgba(255,60,0,0.55); }
.deco-ring-frost { box-shadow: 0 0 0 2px #7fc0ff, 0 0 8px 2px rgba(100,180,255,0.55); }
.deco-ring-neon  { box-shadow: 0 0 0 2px #00ff88, 0 0 8px 2px rgba(0,255,136,0.55); }
.deco-ring-rainbow { background: conic-gradient(#ff0000, #ff8800, #ffff00, #00ff00, #0088ff, #8800ff, #ff0000); }
.deco-ring-galaxy  { background: conic-gradient(#6600ff, #0088ff, #00ffee, #ff00aa, #8800ff, #6600ff); }

/* ══════════════ GIF Picker ══════════════ */
.gif-btn {
  width: auto;
  min-width: unset;
  padding: 0 8px;
  height: 34px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  background: rgba(255,255,255,0.07);
  color: var(--accent2);
  border: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s;
}
.gif-btn:hover, .gif-btn.active { background: rgba(255,255,255,0.14); color: var(--accent); }

.gif-picker {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 70vh;
  z-index: 2000;
  flex-direction: column;
  background: rgba(8,8,12,0.98);
  border-top: 1px solid rgba(255,255,255,0.09);
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.7);
}

.gif-picker-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.gif-search-input {
  flex: 1;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 9px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  width: auto;
}
.gif-search-input:focus { border-color: var(--accent); }
.gif-search-input::placeholder { color: rgba(255,255,255,0.3); }

.gif-close-btn {
  width: 32px;
  min-width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.gif-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  padding: 6px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,149,0,0.4) transparent;
}
.gif-grid::-webkit-scrollbar { width: 3px; }
.gif-grid::-webkit-scrollbar-thumb { background: rgba(255,149,0,0.4); border-radius: 99px; }

.gif-item {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 100%;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background-color: rgba(255,255,255,0.05);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  -webkit-tap-highlight-color: rgba(255,149,0,0.3);
  transition: opacity 0.12s;
}
.gif-item:active { opacity: 0.7; }

.gif-loading {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 30px;
  grid-column: 1/-1;
}

/* ══════════════ Admin Panel ══════════════ */
body.admin-page {
  background: #060608;
}
body.admin-page::before { display: none; }

.adm-gate-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.adm-gate-card {
  width: 100%;
  max-width: 360px;
  background: linear-gradient(to bottom, rgba(22,22,22,0.98), rgba(8,8,10,0.99));
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 24px;
  padding: 36px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.75);
}

.adm-gate-icon { font-size: 36px; text-align: center; }
.adm-gate-title { font-size: 22px; font-weight: 700; color: var(--accent2); text-align: center; margin: 0; }
.adm-gate-sub { font-size: 13px; color: var(--muted); text-align: center; margin: -4px 0 4px; opacity: 0.6; }
.adm-gate-error { font-size: 13px; color: #ff6b6b; text-align: center; min-height: 18px; }

.adm-topbar {
  height: 56px;
  background: rgba(6,6,8,0.94);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.adm-logo { height: 34px; width: auto; object-fit: contain; border-radius: 8px; }

.adm-topbar-title {
  font-size: 14px;
  font-weight: 700;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.adm-body {
  max-width: 860px;
  margin: 28px auto 60px;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.adm-input {
  width: 100%;
  padding: 11px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
  font-family: inherit;
}
.adm-input:focus { border-color: var(--accent); }
.adm-input::placeholder { color: rgba(255,255,255,0.22); }

.adm-btn-primary {
  padding: 11px 20px;
  background: linear-gradient(to bottom, var(--accent2), var(--accent));
  color: #111;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.15s;
  width: auto;
  min-width: unset;
  font-family: inherit;
}
.adm-btn-primary:hover { opacity: 0.82; }

.adm-btn-sm {
  padding: 6px 13px;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
  background: rgba(255,255,255,0.09);
  color: var(--text);
  width: auto;
  min-width: unset;
  font-family: inherit;
}
.adm-btn-sm:hover { opacity: 0.72; }
.adm-btn-danger { background: rgba(180,30,30,0.45); color: #ff8888; }
.adm-btn-blue { background: rgba(37,99,235,0.45); color: #93c5fd; }
.adm-btn-muted { background: rgba(80,80,80,0.35); color: var(--muted); }

.adm-search-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.adm-search-input { flex: 1; width: auto; }

.adm-output {
  font-size: 13px;
  color: #4ade80;
  text-align: center;
  min-height: 0;
}
.adm-output:not(:empty) { padding: 6px 0; }

.adm-user-card {
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 0.18s;
}
.adm-user-card:hover { border-color: rgba(255,255,255,0.13); }
.adm-user-card-reported {
  border-color: rgba(255,80,80,0.35);
  background: rgba(160,0,0,0.06);
}

.adm-user-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.adm-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.adm-user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 2px solid rgba(255,149,0,0.35);
}

.adm-avatar-wrap .friend-mood-bubble {
  left: 30px;
}

.adm-user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.adm-user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.adm-user-meta {
  font-size: 12px;
  color: rgba(255,255,255,0.38);
}

.adm-user-report-line {
  font-size: 12px;
  color: #ff6b6b;
  font-weight: 600;
}

.adm-user-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.adm-msg-panel {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 14px;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.adm-msg-panel .adm-input { flex: 1; width: auto; }
.adm-msg-panel .adm-btn-primary { padding: 9px 16px; font-size: 13px; }

.adm-section {
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.adm-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
}

.adm-fields-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.adm-fields-row .adm-input { flex: 1; width: auto; }

.adm-status-msg {
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}

@media (max-width: 600px) {
  .adm-user-main { flex-wrap: wrap; }
  .adm-user-actions { width: 100%; padding: 0 16px 12px; }
  .adm-fields-row { flex-direction: column; }
  .adm-fields-row .adm-btn-primary { width: 100%; }
}

/* ── Settings Tabs ── */
.settings-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px;
  background: #0b0b0e;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.settings-tabs::-webkit-scrollbar { display: none; }

.settings-tab {
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  letter-spacing: 0.1px;
}
.settings-tab.active {
  color: #000;
  background: var(--accent);
  border-color: var(--accent);
}
.settings-tab:hover:not(.active) { color: rgba(255,255,255,0.8); background: rgba(255,255,255,0.1); }

.settings-tab-panel { display: none; }
.settings-tab-panel.active { display: block; }

.settings-subsection-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.55;
  padding: 10px 0 6px;
}

/* ── Color Picker ── */
.cp-container { padding: 4px 0 8px; }

.settings-colors-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.settings-color-col {
  flex: 1;
  min-width: 0;
}

.cp-sq-wrap {
  position: relative;
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
}
.cp-sq { display: block; width: 100%; height: 100%; }

.cp-cursor {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
  pointer-events: none;
  transform: translate(-50%, -50%);
  top: 0; left: 0;
}

.cp-hue-wrap {
  position: relative;
  width: 100%;
  max-width: 260px;
  height: 14px;
  border-radius: 7px;
  margin-top: 10px;
  cursor: pointer;
  touch-action: none;
  background: linear-gradient(to right,#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00);
  overflow: visible;
}
.cp-hue-thumb {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
  left: 0;
}

.cp-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  max-width: 260px;
}
.cp-preview {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  flex-shrink: 0;
}
.cp-hex {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 7px 10px;
  font-family: monospace;
  min-width: 0;
}
.cp-hex:focus { outline: none; border-color: var(--accent); }
.cp-apply {
  background: var(--accent);
  color: #111;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 14px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.cp-apply:hover { opacity: 0.85; }

/* ── Custom ring color ── */
.avatar-deco-wrap[data-deco="custom"] img,
.avatar-deco-wrap[data-deco="custom"] .chat-avatar {
  border-color: var(--custom-ring-color, #ff9100) !important;
  box-shadow: 0 0 0 2px var(--custom-ring-color, #ff9100), 0 0 8px 2px var(--custom-ring-glow, rgba(255,145,0,0.45));
  animation: none !important;
}

/* ═══════════════════════════════════════════
   FONT SIZE
   ═══════════════════════════════════════════ */
:root { --msg-font-size: 14px; }
body.font-small { --msg-font-size: 12px; }
body.font-large  { --msg-font-size: 17px; }
.msg-text-content { font-size: var(--msg-font-size); }
.font-size-row { display: flex; gap: 8px; padding: 10px 14px; }
.font-size-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: rgba(255,255,255,0.05); border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 10px 6px; color: var(--text); cursor: pointer;
  transition: all 0.15s;
}
.font-size-btn.active { border-color: var(--accent); background: rgba(255,145,0,0.12); }
.fs-label { font-size: 16px; font-weight: 700; line-height: 1; }
.fs-label-md { font-size: 20px; }
.fs-label-lg { font-size: 24px; }
.fs-name { font-size: 10px; opacity: 0.6; }

/* ═══════════════════════════════════════════
   LIGHT MODE
   ═══════════════════════════════════════════ */
body.light-mode {
  --bg: #f2f3f7;
  --bg2: #ffffff;
  --text: #1a1a2e;
  --muted: #6b7280;
  --border: rgba(0,0,0,0.08);
  --msg-out: #e8f4ff;
  --msg-in: #ffffff;
  --sidebar-bg: #ffffff;
  background: #f2f3f7;
  color: #1a1a2e;
}
body.light-mode .topbar { background: #ffffff; border-bottom: 1px solid rgba(0,0,0,0.08); }
body.light-mode .sidebar { background: #ffffff; border-right: 1px solid rgba(0,0,0,0.08); }
body.light-mode .chatContainer { background: #f2f3f7; }
body.light-mode .chat-header { background: #ffffff; border-bottom: 1px solid rgba(0,0,0,0.08); color: #1a1a2e; }
body.light-mode .chat-footer { background: #ffffff; border-top: 1px solid rgba(0,0,0,0.08); }
body.light-mode .message { background: #ffffff; color: #1a1a2e; }
body.light-mode .message.mine { background: #dff0fb; }
body.light-mode #messageInput { background: rgba(0,0,0,0.05); color: #1a1a2e; }
body.light-mode .profileMenu { background: #ffffff; }
body.light-mode .settings-section { background: rgba(0,0,0,0.03); }
body.light-mode .settings-row { border-color: rgba(0,0,0,0.06); color: #1a1a2e; }
body.light-mode .settings-section-label { color: #6b7280; }
body.light-mode .modal-box { background: #ffffff; color: #1a1a2e; }
body.light-mode h3, body.light-mode .sidebar-header h3 { color: #1a1a2e; }
body.light-mode .friend-row, body.light-mode .group-row { color: #1a1a2e; }
body.light-mode .friend-row:hover, body.light-mode .group-row:hover { background: rgba(0,0,0,0.04); }
body.light-mode .msg-time { color: #9ca3af; }
body.light-mode input, body.light-mode textarea { background: rgba(0,0,0,0.05); color: #1a1a2e; border-color: rgba(0,0,0,0.12); }
body.light-mode .icon-btn { color: #374151; }
body.light-mode .typingIndicator { color: #6b7280; }
body.light-mode .chat-placeholder { color: #9ca3af; }
body.light-mode .auth-page { background: #f2f3f7; }
body.light-mode .auth-right { background: #ffffff; }
body.light-mode .auth-field input { background: rgba(0,0,0,0.05); color: #1a1a2e; }
body.light-mode .settings-toggle { background: rgba(0,0,0,0.14); }
body.light-mode .settings-toggle::after { background: #fff; }
body.light-mode .settings-toggle.toggle-on { background: #4cd964; }
body.light-mode .settings-row-icon { background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.06); }
body.light-mode .settings-field-row input { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.12); color: #1a1a2e; }
body.light-mode .settings-field-row input:focus { border-color: var(--accent); background: rgba(0,0,0,0.06); }
body.light-mode .settings-field-row input::placeholder { color: rgba(0,0,0,0.3); }

/* ═══════════════════════════════════════════
   CHAT SEARCH BAR
   ═══════════════════════════════════════════ */
.chat-search-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.chat-search-bar input {
  flex: 1; background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px; padding: 6px 12px; font-size: 13px; color: var(--text);
}
.chat-search-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.chat-search-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 2px 6px; }
.message-row-wrapper.search-hidden { display: none !important; }
.msg-text-content mark { background: rgba(255,200,0,0.35); border-radius: 3px; padding: 0 1px; color: inherit; }
body.light-mode .msg-text-content mark { background: rgba(255,165,0,0.3); }
body.light-mode .chat-search-bar { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.08); }
body.light-mode .chat-search-bar input { background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.12); color: #1a1a2e; }

/* ═══════════════════════════════════════════
   PINNED MESSAGE BANNER
   ═══════════════════════════════════════════ */
.pinned-msg-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; background: rgba(255,145,0,0.12);
  border-bottom: 1px solid rgba(255,145,0,0.2);
  cursor: pointer; transition: background 0.15s;
}
.pinned-msg-banner:hover { background: rgba(255,145,0,0.18); }
.pinned-icon { font-size: 14px; flex-shrink: 0; }
.pinned-text { flex: 1; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pinned-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 2px 4px; flex-shrink: 0; }
body.light-mode .pinned-msg-banner { background: rgba(255,145,0,0.1); border-color: rgba(255,145,0,0.2); }

/* ═══════════════════════════════════════════
   CHAT WALLPAPER PICKER
   ═══════════════════════════════════════════ */
.wallpaper-picker {
  position: absolute; top: 52px; right: 12px; z-index: 200;
  background: #1a1a2e; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px; padding: 14px; width: 240px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.wallpaper-picker-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; opacity: 0.8; }
.wallpaper-swatches { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-bottom: 10px; }
.wallpaper-swatch {
  height: 44px; border-radius: 8px; cursor: pointer; border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.1s;
}
.wallpaper-swatch:hover { border-color: var(--accent); transform: scale(1.06); }
.wallpaper-swatch.active { border-color: var(--accent); }
.wallpaper-remove-btn { width: 100%; background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1); color: var(--text); border-radius: 8px; padding: 7px; font-size: 12px; cursor: pointer; }
.wallpaper-remove-btn:hover { background: rgba(255,255,255,0.12); }
body.light-mode .wallpaper-picker { background: #ffffff; border-color: rgba(0,0,0,0.12); }

/* ═══════════════════════════════════════════
   FORWARD MODAL
   ═══════════════════════════════════════════ */
.forward-box { max-width: 400px; width: 90vw; max-height: 70vh; display: flex; flex-direction: column; overflow: hidden; }
.forward-list { flex: 1; overflow-y: auto; }
.forward-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.05); cursor: pointer;
  border-radius: 8px; transition: background 0.12s;
}
.forward-row:hover { background: rgba(255,255,255,0.06); }
.forward-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--accent); flex-shrink: 0; }
.forward-name { font-size: 14px; font-weight: 500; }
body.light-mode .forward-row { border-color: rgba(0,0,0,0.06); }
body.light-mode .forward-row:hover { background: rgba(0,0,0,0.04); }

/* ═══════════════════════════════════════════
   POLL MODAL
   ═══════════════════════════════════════════ */
.poll-box { max-width: 400px; width: 90vw; }
.poll-option-input { width: 100%; box-sizing: border-box; margin-bottom: 6px; }

/* ═══════════════════════════════════════════
   POLL MESSAGE BUBBLE
   ═══════════════════════════════════════════ */
.poll-bubble {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px; padding: 12px 14px; min-width: 200px; max-width: 300px;
}
.poll-question { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.poll-option {
  display: flex; flex-direction: column; gap: 3px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px; padding: 8px 12px; margin-bottom: 6px; cursor: pointer;
  transition: background 0.15s; position: relative; overflow: hidden;
}
.poll-option:hover { background: rgba(255,255,255,0.1); }
.poll-option.voted { border-color: var(--accent); }
.poll-option-bar {
  position: absolute; left: 0; top: 0; height: 100%;
  background: rgba(255,145,0,0.15); border-radius: 10px; transition: width 0.4s;
}
.poll-option-text { font-size: 13px; position: relative; z-index: 1; }
.poll-option-pct { font-size: 11px; color: var(--muted); position: relative; z-index: 1; }
.poll-total { font-size: 11px; color: var(--muted); margin-top: 6px; text-align: center; }
body.light-mode .poll-bubble { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.1); }
body.light-mode .poll-option { background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.1); }
body.light-mode .poll-option:hover { background: rgba(0,0,0,0.08); }
body.light-mode .poll-option-bar { background: rgba(255,145,0,0.12); }

/* ═══════════════════════════════════════════
   MESSAGE FORWARD BUTTON (context menu)
   ═══════════════════════════════════════════ */
.msg-ctx-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; background: none; border: none; color: var(--text);
  font-size: 13px; padding: 9px 14px; cursor: pointer; transition: background 0.1s;
  text-align: left;
}
.msg-ctx-btn:hover { background: rgba(255,255,255,0.07); }
body.light-mode .msg-ctx-btn:hover { background: rgba(0,0,0,0.05); }

/* ═══════════════════════════════════════════
   MESSAGE CONTEXT MENU
   ═══════════════════════════════════════════ */
.msg-context-menu {
  position: fixed; z-index: 9000; background: #1c1c2e;
  border: 1px solid rgba(255,255,255,0.1); border-radius: 12px;
  overflow: hidden; box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  min-width: 160px;
}
body.light-mode .msg-context-menu { background: #ffffff; border-color: rgba(0,0,0,0.12); box-shadow: 0 8px 28px rgba(0,0,0,0.15); }
