* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ========== THEME CSS VARIABLES ========== */
:root,
[data-theme="default"] {
  --bg-primary: #0f0c29;
  --bg-secondary: #302b63;
  --bg-tertiary: #24243e;
  --bg-sidebar: rgba(255, 255, 255, 0.05);
  --bg-chat: transparent;
  --bg-input: rgba(255, 255, 255, 0.06);
  --bg-hover: rgba(255, 255, 255, 0.08);
  --bg-active: rgba(255, 255, 255, 0.12);
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-message-sent: linear-gradient(135deg, #7c5cbf, #5a3e9e);
  --bg-message-recv: rgba(255, 255, 255, 0.08);
  --bg-overlay: rgba(0, 0, 0, 0.6);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.4);
  --text-faint: rgba(255, 255, 255, 0.25);
  --accent-primary: #7c5cbf;
  --accent-secondary: #5865f2;
  --accent-gradient: linear-gradient(135deg, #7c5cbf, #5a3e9e);
  --accent-gradient-2: linear-gradient(135deg, #5865f2, #7c5cbf);
  --success: #51cf66;
  --danger: #ff6b6b;
  --danger-bg: #ed4245;
  --scrollbar: rgba(255, 255, 255, 0.15);
  --shadow: rgba(0, 0, 0, 0.3);
}

[data-theme="midnight"] {
  --bg-primary: #0a0e27;
  --bg-secondary: #111638;
  --bg-tertiary: #0d1130;
  --bg-sidebar: rgba(17, 22, 56, 0.95);
  --bg-input: rgba(255, 255, 255, 0.05);
  --bg-hover: rgba(88, 101, 242, 0.1);
  --bg-active: rgba(88, 101, 242, 0.18);
  --bg-card: rgba(88, 101, 242, 0.06);
  --bg-message-sent: linear-gradient(135deg, #5865f2, #4752c4);
  --bg-message-recv: rgba(255, 255, 255, 0.06);
  --border-color: rgba(88, 101, 242, 0.15);
  --border-subtle: rgba(88, 101, 242, 0.08);
  --accent-primary: #5865f2;
  --accent-secondary: #7289da;
  --accent-gradient: linear-gradient(135deg, #5865f2, #4752c4);
  --accent-gradient-2: linear-gradient(135deg, #5865f2, #7289da);
}

[data-theme="forest"] {
  --bg-primary: #0a1a0f;
  --bg-secondary: #0f2818;
  --bg-tertiary: #0c2212;
  --bg-sidebar: rgba(15, 40, 24, 0.95);
  --bg-input: rgba(255, 255, 255, 0.05);
  --bg-hover: rgba(59, 165, 93, 0.1);
  --bg-active: rgba(59, 165, 93, 0.18);
  --bg-card: rgba(59, 165, 93, 0.06);
  --bg-message-sent: linear-gradient(135deg, #2d7a4f, #1a5c36);
  --bg-message-recv: rgba(255, 255, 255, 0.06);
  --border-color: rgba(59, 165, 93, 0.15);
  --border-subtle: rgba(59, 165, 93, 0.08);
  --accent-primary: #3ba55d;
  --accent-secondary: #2d7a4f;
  --accent-gradient: linear-gradient(135deg, #3ba55d, #2d7a4f);
  --accent-gradient-2: linear-gradient(135deg, #2d7a4f, #3ba55d);
}

[data-theme="sunset"] {
  --bg-primary: #1a0f0a;
  --bg-secondary: #2a1810;
  --bg-tertiary: #22140c;
  --bg-sidebar: rgba(42, 24, 16, 0.95);
  --bg-input: rgba(255, 255, 255, 0.05);
  --bg-hover: rgba(237, 135, 51, 0.1);
  --bg-active: rgba(237, 135, 51, 0.18);
  --bg-card: rgba(237, 135, 51, 0.06);
  --bg-message-sent: linear-gradient(135deg, #e07628, #c45e1a);
  --bg-message-recv: rgba(255, 255, 255, 0.06);
  --border-color: rgba(237, 135, 51, 0.15);
  --border-subtle: rgba(237, 135, 51, 0.08);
  --accent-primary: #ed8733;
  --accent-secondary: #e07628;
  --accent-gradient: linear-gradient(135deg, #ed8733, #c45e1a);
  --accent-gradient-2: linear-gradient(135deg, #e07628, #ed8733);
}

[data-theme="rose"] {
  --bg-primary: #1a0a14;
  --bg-secondary: #2a1020;
  --bg-tertiary: #220c1a;
  --bg-sidebar: rgba(42, 16, 32, 0.95);
  --bg-input: rgba(255, 255, 255, 0.05);
  --bg-hover: rgba(219, 76, 133, 0.1);
  --bg-active: rgba(219, 76, 133, 0.18);
  --bg-card: rgba(219, 76, 133, 0.06);
  --bg-message-sent: linear-gradient(135deg, #db4c85, #b83a6d);
  --bg-message-recv: rgba(255, 255, 255, 0.06);
  --border-color: rgba(219, 76, 133, 0.15);
  --border-subtle: rgba(219, 76, 133, 0.08);
  --accent-primary: #db4c85;
  --accent-secondary: #f06292;
  --accent-gradient: linear-gradient(135deg, #db4c85, #b83a6d);
  --accent-gradient-2: linear-gradient(135deg, #b83a6d, #db4c85);
}

[data-theme="ocean"] {
  --bg-primary: #0a1520;
  --bg-secondary: #0e1f30;
  --bg-tertiary: #0c1a28;
  --bg-sidebar: rgba(14, 31, 48, 0.95);
  --bg-input: rgba(255, 255, 255, 0.05);
  --bg-hover: rgba(41, 152, 217, 0.1);
  --bg-active: rgba(41, 152, 217, 0.18);
  --bg-card: rgba(41, 152, 217, 0.06);
  --bg-message-sent: linear-gradient(135deg, #2998d9, #1a7ab5);
  --bg-message-recv: rgba(255, 255, 255, 0.06);
  --border-color: rgba(41, 152, 217, 0.15);
  --border-subtle: rgba(41, 152, 217, 0.08);
  --accent-primary: #2998d9;
  --accent-secondary: #1a7ab5;
  --accent-gradient: linear-gradient(135deg, #2998d9, #1a7ab5);
  --accent-gradient-2: linear-gradient(135deg, #1a7ab5, #2998d9);
}

[data-theme="amoled"] {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #050505;
  --bg-sidebar: rgba(10, 10, 10, 0.98);
  --bg-input: rgba(255, 255, 255, 0.04);
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-active: rgba(255, 255, 255, 0.1);
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-message-sent: linear-gradient(135deg, #5865f2, #4752c4);
  --bg-message-recv: rgba(255, 255, 255, 0.04);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --accent-primary: #5865f2;
  --accent-secondary: #7289da;
  --accent-gradient: linear-gradient(135deg, #5865f2, #4752c4);
  --accent-gradient-2: linear-gradient(135deg, #5865f2, #7289da);
  --scrollbar: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f2f3f5;
  --bg-tertiary: #e3e5e8;
  --bg-sidebar: rgba(242, 243, 245, 0.98);
  --bg-input: rgba(0, 0, 0, 0.04);
  --bg-hover: rgba(0, 0, 0, 0.04);
  --bg-active: rgba(0, 0, 0, 0.08);
  --bg-card: rgba(0, 0, 0, 0.03);
  --bg-message-sent: linear-gradient(135deg, #5865f2, #4752c4);
  --bg-message-recv: #f2f3f5;
  --bg-overlay: rgba(0, 0, 0, 0.5);
  --border-color: rgba(0, 0, 0, 0.1);
  --border-subtle: rgba(0, 0, 0, 0.06);
  --text-primary: #2e3338;
  --text-secondary: #4f5660;
  --text-muted: #80848e;
  --text-faint: #b5bac1;
  --accent-primary: #5865f2;
  --accent-secondary: #4752c4;
  --accent-gradient: linear-gradient(135deg, #5865f2, #4752c4);
  --accent-gradient-2: linear-gradient(135deg, #5865f2, #7289da);
  --success: #3ba55d;
  --danger: #ed4245;
  --danger-bg: #ed4245;
  --scrollbar: rgba(0, 0, 0, 0.15);
  --shadow: rgba(0, 0, 0, 0.1);
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary), var(--bg-tertiary));
  color: var(--text-primary);
  overflow: hidden;
}

/* ========== LOGIN PAGE ========== */

.login-container {
  background: var(--bg-card);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  width: 360px;
  box-shadow: 0 8px 32px var(--shadow);
}

.login-container h1 {
  margin-bottom: 28px;
  font-size: 1.6rem;
  font-weight: 600;
}

form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

input[type="password"],
input[type="text"] {
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.3s;
}

input[type="password"]::placeholder,
input[type="text"]::placeholder {
  color: var(--text-muted);
}

input[type="password"]:focus,
input[type="text"]:focus {
  border-color: var(--accent-primary);
}

button {
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.3s;
}

button:hover {
  opacity: 0.85;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  min-height: 1.2em;
}

.switch-text {
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.switch-text a {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 600;
}

.switch-text a:hover {
  text-decoration: underline;
}

/* ========== GOOGLE SIGN-IN ========== */

.auth-divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  gap: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.auth-divider span {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
}

.google-signin-wrapper {
  display: flex;
  justify-content: center;
}

.google-signin-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.google-signin-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  box-shadow: 0 2px 8px var(--shadow);
}

.google-signin-btn:active {
  transform: scale(0.98);
}

.google-signin-btn .google-icon {
  flex-shrink: 0;
}

[data-theme="light"] .google-signin-btn {
  background: #fff;
  border-color: #dadce0;
  color: #3c4043;
}

[data-theme="light"] .google-signin-btn:hover {
  background: #f7f8f8;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.15);
}

.hidden {
  display: none !important;
}

/* ========== AUTH SCREEN ========== */

.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
}

/* ========== CHAT APP LAYOUT ========== */

.chat-app {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* ========== SIDEBAR ========== */

.sidebar {
  width: 300px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-hover);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s;
  flex-shrink: 0;
}

.sidebar-icon-btn:hover {
  background: var(--bg-active);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.sidebar-icon-btn svg {
  pointer-events: none;
}

.clubs-link {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  transition: all 0.2s;
  font-weight: 600;
}

.clubs-link:hover {
  background: var(--bg-active);
  color: var (--text-primary);
}

.sidebar-header h2 {
  font-size: 1.3rem;
}

.sidebar-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.logged-in-user {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.logout-btn {
  padding: 4px 10px;
  border: 1px solid rgba(255, 107, 107, 0.25);
  border-radius: 6px;
  background: rgba(255, 107, 107, 0.1);
  color: var(--danger);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: rgba(255, 107, 107, 0.25);
}

/* Tabs */

.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border-color);
}

.tab {
  flex: 1;
  padding: 12px 4px;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s, border-bottom 0.2s;
  border-bottom: 2px solid transparent;
  position: relative;
}

.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-primary);
  background: none;
}

.tab:hover {
  color: var(--text-primary);
  opacity: 1;
}

.badge {
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 4px;
}

/* Tab content */

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* Friends list */

.friends-list {
  list-style: none;
  padding: 0;
}

.friend-item {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  cursor: pointer;
  transition: background 0.2s;
  gap: 10px;
}

.friend-item:hover {
  background: var(--bg-hover);
}

.friend-item.active {
  background: var(--bg-active);
  border-left: 3px solid var(--accent-primary);
}

/* Avatar wrapper with overlaid status dot */
.friend-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.friend-status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2.5px solid var(--bg-secondary);
  z-index: 1;
}

.friend-status-dot.online {
  background: #3ba55c;
  box-shadow: 0 0 5px rgba(59, 165, 92, 0.5);
}

.friend-status-dot.idle {
  background: #faa61a;
  box-shadow: 0 0 5px rgba(250, 166, 26, 0.4);
}

.friend-status-dot.dnd {
  background: #ed4245;
  box-shadow: 0 0 5px rgba(237, 66, 69, 0.4);
}

.friend-status-dot.invisible {
  background: #747f8d;
}

.friend-status-dot.offline {
  background: #747f8d;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.status-dot.offline {
  background: var(--text-faint);
}

.friend-name {
  font-size: 0.95rem;
  flex: 1;
}

.group-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.member-count {
  font-size: 0.75rem;
  color: var(--text-faint);
  background: var(--bg-hover);
  padding: 2px 8px;
  border-radius: 10px;
}

/* Unread message badge */
.unread-badge {
  background: var(--danger);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  margin-left: auto;
  flex-shrink: 0;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(237, 66, 69, 0.4);
  animation: unreadPop 0.3s ease;
}
.unread-badge.hidden {
  display: none;
}

@keyframes unreadPop {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.empty-text {
  padding: 24px 20px;
  color: var(--text-faint);
  font-size: 0.9rem;
  text-align: center;
}

/* Request item */

.request-item {
  justify-content: space-between;
}

.request-actions {
  display: flex;
  gap: 6px;
}

.accept-btn, .decline-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.accept-btn {
  background: var(--success);
}

.decline-btn {
  background: var(--danger);
}

/* Add friend form */

.add-friend-form {
  padding: 20px;
  gap: 10px;
}

.add-friend-msg {
  padding: 0 20px;
  font-size: 0.85rem;
  min-height: 1.2em;
}

/* ========== CREATE GROUP ========== */

.create-group-btn {
  margin: 12px 16px;
  padding: 10px;
  font-size: 0.9rem;
  border-radius: 10px;
}

.create-group-modal {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

.create-group-modal h3 {
  font-size: 1rem;
  margin-bottom: 12px;
}

.modal-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.checkbox-label:hover {
  background: var(--bg-hover);
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--accent-primary);
  width: 16px;
  height: 16px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  flex-direction: row;
}

.modal-actions button {
  flex: 1;
  padding: 10px;
  font-size: 0.9rem;
}

.cancel-btn {
  background: var(--bg-hover) !important;
}

/* ========== CHAT AREA ========== */

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.no-chat {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  flex: 1;
  color: var(--text-faint);
  font-size: 1.1rem;
  min-height: 0;
  overflow: hidden;
}

.chat-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.chat-view-inner {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.chat-view-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

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

.chat-with {
  font-weight: 700;
  font-size: 1rem;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-status {
  font-size: 0.75rem;
  display: block;
}
.chat-status.online { color: var(--success); }
.chat-status.idle { color: #faa61a; }
.chat-status.dnd { color: #ed4245; }
.chat-status.offline { color: var(--text-muted); }

/* ========== SEARCH BAR (text-style) ========== */
.cha-search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  height: 34px;
  box-sizing: border-box;
}
.cha-search-bar:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
  border-color: var(--text-muted);
}
.cha-search-bar.cha-active {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}
.cha-search-bar svg {
  flex-shrink: 0;
  opacity: 0.6;
}

/* Add member button in chat header */
.add-member-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
  height: 34px;
  box-sizing: border-box;
}
.add-member-btn:hover {
  opacity: 0.85;
}

/* ========== SETTINGS BUTTON ========== */
.settings-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.3s;
  flex-shrink: 0;
}
.settings-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  transform: rotate(60deg);
}
.settings-btn svg {
  pointer-events: none;
}

/* ========== SETTINGS OVERLAY ========== */
.settings-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5000;
  background: var(--bg-primary);
  display: flex;
  align-items: stretch;
  justify-content: center;
  animation: settingsFadeIn 0.2s ease;
}
.settings-overlay.hidden {
  display: none;
}

@keyframes settingsFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.settings-layout {
  display: flex;
  width: 100%;
  max-width: 1200px;
  height: 100%;
}

/* Settings Sidebar */
.settings-sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-subtle);
}

.settings-sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 60px 10px 20px;
}

.settings-category-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 8px 12px 4px;
  margin-top: 4px;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.settings-nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.settings-nav-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
  font-weight: 600;
}
.settings-nav-item svg {
  flex-shrink: 0;
  opacity: 0.6;
}
.settings-nav-item.active svg,
.settings-nav-item:hover svg {
  opacity: 1;
}

.settings-nav-danger {
  color: var(--danger) !important;
}
.settings-nav-danger:hover {
  background: rgba(237, 66, 69, 0.1) !important;
}

.settings-nav-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 8px 12px;
}

.settings-version {
  font-size: 0.72rem;
  color: var(--text-faint);
  padding: 8px 12px;
}

/* Settings Content */
.settings-content {
  flex: 1;
  display: flex;
  min-width: 0;
  position: relative;
}

.settings-content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 60px 40px 40px;
  max-width: 740px;
}

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

.settings-heading {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.settings-subheading {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.settings-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.settings-section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

/* Settings Close Button */
.settings-close-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 60px 24px 0;
  flex-shrink: 0;
}

.settings-close-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s;
}
.settings-close-btn:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.settings-close-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* ===== My Account Card ===== */
.settings-account-card {
  background: var(--bg-tertiary);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.settings-account-banner {
  height: 100px;
  background: var(--accent-gradient-2);
}

.settings-account-body {
  padding: 0 20px 20px;
}

.settings-account-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: -32px;
  margin-bottom: 20px;
  position: relative;
}

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

.settings-account-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid var(--bg-tertiary);
}
.settings-account-dot.online { background: var(--success); }
.settings-account-dot.offline { background: #747f8d; }

.settings-account-name-wrap {
  flex: 1;
  min-width: 0;
  padding-top: 36px;
}

.settings-account-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.settings-edit-profile-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
  margin-top: 36px;
}
.settings-edit-profile-btn:hover { opacity: 0.85; }

.settings-account-fields {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 4px 16px;
}

.settings-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.settings-field-row:last-child {
  border-bottom: none;
}

.settings-field-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.settings-field-value {
  font-size: 0.92rem;
  color: var(--text-primary);
  word-break: break-word;
}

/* ===== Edit Profile (Settings) ===== */
.settings-profile-avatar-section {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

.settings-avatar-upload-btn {
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
  display: inline-block;
}
.settings-avatar-upload-btn:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}

.settings-form-group {
  margin-bottom: 18px;
}

.settings-form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.settings-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.settings-input:focus {
  border-color: var(--accent-primary);
}

.settings-textarea {
  resize: vertical;
  min-height: 70px;
  max-height: 160px;
}

.settings-char-count {
  text-align: right;
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-top: 4px;
}

.settings-save-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.settings-save-btn:hover { opacity: 0.85; }

.settings-save-msg {
  text-align: center;
  font-size: 0.85rem;
  margin-top: 10px;
  min-height: 1.2em;
}
.settings-save-msg.success { color: var(--success); }
.settings-save-msg.error { color: var(--danger); }

/* ===== Theme Grid ===== */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.theme-card {
  border-radius: 10px;
  border: 2px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
  background: var(--bg-card);
}
.theme-card:hover {
  border-color: var(--text-muted);
  transform: translateY(-2px);
}
.theme-card.selected {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.theme-preview {
  height: 80px;
  display: flex;
  padding: 6px;
  gap: 4px;
  border-radius: 8px 8px 0 0;
}

.tp-sidebar {
  width: 30%;
  border-radius: 4px;
}
.tp-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-radius: 4px;
  padding: 4px;
}
.tp-header {
  height: 10px;
  border-radius: 3px;
}
.tp-msg {
  height: 8px;
  border-radius: 3px;
  width: 70%;
}
.tp-msg2 { width: 50%; }
.tp-input {
  height: 10px;
  border-radius: 3px;
  margin-top: auto;
}

/* Theme Preview Colors */
.theme-preview-default {
  background: #24243e;
}
.theme-preview-default .tp-sidebar { background: rgba(255,255,255,0.08); }
.theme-preview-default .tp-main { background: rgba(255,255,255,0.03); }
.theme-preview-default .tp-header { background: rgba(255,255,255,0.08); }
.theme-preview-default .tp-msg1 { background: linear-gradient(135deg, #7c5cbf, #5a3e9e); }
.theme-preview-default .tp-msg2 { background: rgba(255,255,255,0.1); }
.theme-preview-default .tp-input { background: rgba(255,255,255,0.06); }

.theme-preview-midnight {
  background: #0d1130;
}
.theme-preview-midnight .tp-sidebar { background: rgba(88,101,242,0.12); }
.theme-preview-midnight .tp-main { background: rgba(255,255,255,0.02); }
.theme-preview-midnight .tp-header { background: rgba(88,101,242,0.1); }
.theme-preview-midnight .tp-msg1 { background: linear-gradient(135deg, #5865f2, #4752c4); }
.theme-preview-midnight .tp-msg2 { background: rgba(255,255,255,0.06); }
.theme-preview-midnight .tp-input { background: rgba(255,255,255,0.05); }

.theme-preview-forest {
  background: #0c2212;
}
.theme-preview-forest .tp-sidebar { background: rgba(59,165,93,0.12); }
.theme-preview-forest .tp-main { background: rgba(255,255,255,0.02); }
.theme-preview-forest .tp-header { background: rgba(59,165,93,0.1); }
.theme-preview-forest .tp-msg1 { background: linear-gradient(135deg, #2d7a4f, #1a5c36); }
.theme-preview-forest .tp-msg2 { background: rgba(255,255,255,0.06); }
.theme-preview-forest .tp-input { background: rgba(255,255,255,0.05); }

.theme-preview-sunset {
  background: #22140c;
}
.theme-preview-sunset .tp-sidebar { background: rgba(237,135,51,0.12); }
.theme-preview-sunset .tp-main { background: rgba(255,255,255,0.02); }
.theme-preview-sunset .tp-header { background: rgba(237,135,51,0.1); }
.theme-preview-sunset .tp-msg1 { background: linear-gradient(135deg, #e07628, #c45e1a); }
.theme-preview-sunset .tp-msg2 { background: rgba(255,255,255,0.06); }
.theme-preview-sunset .tp-input { background: rgba(255,255,255,0.05); }

.theme-preview-rose {
  background: #220c1a;
}
.theme-preview-rose .tp-sidebar { background: rgba(219,76,133,0.12); }
.theme-preview-rose .tp-main { background: rgba(255,255,255,0.02); }
.theme-preview-rose .tp-header { background: rgba(219,76,133,0.1); }
.theme-preview-rose .tp-msg1 { background: linear-gradient(135deg, #db4c85, #b83a6d); }
.theme-preview-rose .tp-msg2 { background: rgba(255,255,255,0.06); }
.theme-preview-rose .tp-input { background: rgba(255,255,255,0.05); }

.theme-preview-ocean {
  background: #0c1a28;
}
.theme-preview-ocean .tp-sidebar { background: rgba(41,152,217,0.12); }
.theme-preview-ocean .tp-main { background: rgba(255,255,255,0.02); }
.theme-preview-ocean .tp-header { background: rgba(41,152,217,0.1); }
.theme-preview-ocean .tp-msg1 { background: linear-gradient(135deg, #2998d9, #1a7ab5); }
.theme-preview-ocean .tp-msg2 { background: rgba(255,255,255,0.06); }
.theme-preview-ocean .tp-input { background: rgba(255,255,255,0.05); }

.theme-preview-amoled {
  background: #000;
}
.theme-preview-amoled .tp-sidebar { background: rgba(255,255,255,0.05); }
.theme-preview-amoled .tp-main { background: rgba(255,255,255,0.02); }
.theme-preview-amoled .tp-header { background: rgba(255,255,255,0.05); }
.theme-preview-amoled .tp-msg1 { background: linear-gradient(135deg, #5865f2, #4752c4); }
.theme-preview-amoled .tp-msg2 { background: rgba(255,255,255,0.04); }
.theme-preview-amoled .tp-input { background: rgba(255,255,255,0.04); }

.theme-preview-light {
  background: #fff;
}
.theme-preview-light .tp-sidebar { background: #f2f3f5; }
.theme-preview-light .tp-main { background: #fff; }
.theme-preview-light .tp-header { background: #e3e5e8; }
.theme-preview-light .tp-msg1 { background: linear-gradient(135deg, #5865f2, #4752c4); }
.theme-preview-light .tp-msg2 { background: #f2f3f5; }
.theme-preview-light .tp-input { background: #ebedef; }

.theme-label {
  display: block;
  padding: 8px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}
.theme-card.selected .theme-label {
  color: var(--accent-primary);
}

/* ===== Toggle Switch ===== */
.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
  gap: 16px;
}
.settings-toggle-row:last-child {
  border-bottom: none;
}

.settings-toggle-info {
  flex: 1;
  min-width: 0;
}

.settings-toggle-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.settings-toggle-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.settings-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.settings-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.settings-switch-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 12px;
  background: var(--text-muted);
  transition: all 0.25s;
}
.settings-switch-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.25s;
}
.settings-switch input:checked + .settings-switch-slider {
  background: var(--accent-primary);
}
.settings-switch input:checked + .settings-switch-slider::after {
  transform: translateX(20px);
}

/* ===== Font Size Range ===== */
.settings-font-size-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-font-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}
.settings-font-label-lg {
  font-size: 1.2rem;
}

.settings-range {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-active);
  outline: none;
}
.settings-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  border: 2px solid #fff;
}

.settings-range-val {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: center;
}

/* ===== Light Theme Overrides ===== */
[data-theme="light"] .login-container {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
}
[data-theme="light"] input[type="password"],
[data-theme="light"] input[type="text"] {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.12);
  color: var(--text-primary);
}
[data-theme="light"] input::placeholder {
  color: var(--text-faint);
}
[data-theme="light"] .msg-sender { color: var(--accent-primary); }
[data-theme="light"] .msg-time { color: var(--text-muted); }
[data-theme="light"] .msg-link { color: var(--accent-primary); }
[data-theme="light"] .chat-messages { color: var(--text-primary); }
[data-theme="light"] .message.sent .msg-bubble { color: #fff; }
[data-theme="light"] .avatar {
  background: var(--accent-gradient);
}
[data-theme="light"] .profile-side-panel {
  background: var(--bg-secondary);
  border-left-color: var(--border-color);
}
[data-theme="light"] .settings-close-btn { color: var(--text-muted); border-color: var(--text-muted); }

/* ===== Compact Mode ===== */
body.compact-mode .message {
  gap: 6px;
}
body.compact-mode .msg-bubble {
  padding: 6px 12px;
}
body.compact-mode .chat-messages {
  gap: 4px;
  padding: 12px 24px;
}

/* ===== Reduce Motion ===== */
body.reduce-motion,
body.reduce-motion * {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* ===== Chat Header Responsive ===== */
@media (max-width: 600px) {
  .chat-header {
    padding: 10px 12px;
    gap: 8px;
  }
  .chat-header-actions {
    gap: 4px;
  }
  .cha-search-bar span {
    display: none;
  }
  .cha-search-bar {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }
  .add-member-btn {
    font-size: 0.7rem;
    padding: 4px 8px;
    height: 30px;
  }
}

/* ===== Settings Responsive ===== */
@media (max-width: 768px) {
  .settings-layout {
    flex-direction: column;
  }
  .settings-sidebar {
    width: 100%;
    min-width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
  .settings-sidebar-scroll {
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
  }
  .settings-category-label { display: none; }
  .settings-nav-divider { display: none; }
  .settings-version { display: none; }
  .settings-nav-item {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
  .settings-close-area {
    position: fixed;
    top: 10px;
    right: 10px;
    padding: 0;
  }
  .settings-content-scroll {
    padding: 20px;
  }
  .theme-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }
}

/* Messages */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  position: relative;
}

.message.sent {
  justify-content: flex-end;
}

.message.received {
  justify-content: flex-start;
}

.message.sent .msg-avatar {
  order: 2;
}

.msg-bubble {
  max-width: 65%;
  padding: 10px 16px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.4;
  position: relative;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message.sent .msg-bubble {
  background: var(--bg-message-sent);
  border-bottom-right-radius: 4px;
}

.message.received .msg-bubble {
  background: var(--bg-message-recv);
  border-bottom-left-radius: 4px;
}

.msg-sender {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 4px;
}

.msg-time {
  display: block;
  font-size: 0.7rem;
  color: var (--text-muted);
  margin-top: 4px;
  text-align: right;
}

/* E2EE encrypted message indicator */
.msg-e2ee-failed .msg-bubble {
  opacity: 0.6;
  border: 1px dashed var(--text-muted);
}

.msg-link {
  color: var(--accent-secondary);
  text-decoration: underline;
  word-break: break-all;
}

.msg-link:hover {
  color: var(--accent-primary);
}

/* ========== IMAGE IN MESSAGE ========== */

.msg-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 10px;
  margin: 6px 0;
  cursor: pointer;
  display: block;
}

/* ========== FILE ATTACHMENT IN MESSAGE ========== */

.msg-file-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 6px 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.2s, border-color 0.2s;
  cursor: pointer;
}

.msg-file-attachment:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

.msg-file-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.msg-file-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.msg-file-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-file-size {
  font-size: 0.72rem;
  color: var(--text-faint);
}

.msg-file-download {
  font-size: 1.1rem;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color 0.2s;
}

.msg-file-attachment:hover .msg-file-download {
  color: var(--accent-primary);
}

/* ========== MEDIA EMBEDS (Video / PDF / Audio) ========== */

.msg-media-embed {
  margin: 6px 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.msg-video {
  width: 100%;
  max-height: 360px;
  display: block;
  border-radius: 10px 10px 0 0;
  background: #000;
}

.msg-pdf-embed {
  max-width: 100%;
}

.msg-pdf {
  width: 100%;
  height: 400px;
  border: none;
  display: block;
  border-radius: 10px 10px 0 0;
  background: #fff;
}

.msg-audio-embed {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-audio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.msg-audio {
  width: 100%;
  height: 36px;
  border-radius: 20px;
}

.msg-media-download {
  display: block;
  padding: 8px 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  text-align: center;
  transition: color 0.2s, background 0.2s;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-card);
}

.msg-media-download:hover {
  color: var(--accent-primary);
  background: var(--bg-hover);
}

/* ========== ATTACHMENT PREVIEW ========== */

.attachment-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-card);
}

.attachment-preview .preview-image {
  max-height: 80px;
  max-width: 120px;
  border-radius: 8px;
  object-fit: cover;
}

.preview-file {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 14px;
}

.preview-file-icon {
  font-size: 1.5rem;
}

.preview-file-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-secondary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-file-size {
  font-size: 0.72rem;
  color: var(--text-faint);
}

.cancel-image {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  font-size: 0.85rem;
  background: var(--danger);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.cancel-image:hover {
  background: var(--danger-bg);
}

/* ========== FILE UPLOAD BUTTON ========== */

.file-upload-btn {
  font-size: 1.3rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.file-upload-btn:hover {
  background: var(--bg-hover);
}

/* ========== VANISH MODE ========== */

.vanish-mode-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
  color: var(--text-muted);
}

.vanish-mode-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.vanish-mode-btn.vanish-active {
  color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.12);
}

.vanish-mode-btn.vanish-active::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid var(--bg-card);
}

.vanish-mode-menu {
  position: absolute;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 8px;
  width: 240px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.05);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 2px;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  opacity: 1;
}

.vanish-mode-menu.hidden {
  display: none;
}

.vanish-menu-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 6px 10px 4px;
}

.vanish-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border: none;
  background: none;
  border-radius: 10px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.15s;
  color: var(--text-primary);
}

.vanish-option:hover {
  background: var(--bg-hover);
}

.vanish-option-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}

.vanish-option-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.vanish-option-text strong {
  font-size: 0.88rem;
  font-weight: 600;
}

.vanish-option-text small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.vanish-option .vanish-check {
  opacity: 0;
  color: var(--accent-primary);
  font-weight: 700;
  font-size: 1rem;
  transition: opacity 0.15s;
}

.vanish-option.active .vanish-check {
  opacity: 1;
}

/* Vanish message styling */
.msg-vanish .msg-bubble {
  border-left: 2px solid var(--accent-primary);
}

.msg-vanish-seen .msg-bubble {
  border-left-color: #f59f00;
}

.msg-vanish-24h .msg-bubble {
  border-left-color: #ff6b6b;
}

.msg-vanish-countdown {
  display: block;
  font-size: 0.65rem;
  color: #ff6b6b;
  margin-top: 2px;
  font-style: italic;
}

.msg-vanish-seen-countdown {
  display: block;
  font-size: 0.65rem;
  color: #f59f00;
  margin-top: 2px;
  font-weight: 600;
  font-style: italic;
}

/* Vanish animation */
@-webkit-keyframes msgVanish {
  0% { opacity: 1; -webkit-transform: scale(1); transform: scale(1); }
  50% { opacity: 0.5; -webkit-transform: scale(0.97); transform: scale(0.97); }
  100% { opacity: 0; -webkit-transform: scale(0.9) translateY(-10px); transform: scale(0.9) translateY(-10px); }
}

@keyframes msgVanish {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.97); }
  100% { opacity: 0; transform: scale(0.9) translateY(-10px); }
}

.msg-vanishing {
  -webkit-animation: msgVanish 0.5s ease-out forwards;
  animation: msgVanish 0.5s ease-out forwards;
  pointer-events: none;
}

/* ========== LINK EMBED ========== */

.link-embed {
  margin-top: 8px;
  border-left: 3px solid var(--accent-primary);
  border-radius: 4px;
  background: var(--bg-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.link-embed .embed-image {
  width: 100%;
  max-height: 150px;
  object-fit: cover;
  display: block;
}

.embed-body {
  padding: 10px 12px;
}

.embed-site {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.embed-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-secondary);
  text-decoration: none;
  margin-bottom: 4px;
}

.embed-title:hover {
  text-decoration: underline;
}

.embed-desc {
  font-size: 0.8rem;
  color: var (--text-secondary);
  line-height: 1.4;
}

/* Typing indicator */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 24px 2px;
  color: var(--text-muted);
  font-size: 0.8rem;
  min-height: 22px;
}
.typing-indicator.hidden { display: none; }

.typing-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}
.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.typing-text {
  font-style: italic;
}

/* Message form */

.message-form {
  display: flex;
  padding: 16px 24px;
  gap: 10px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
}
.message-form .reply-bar {
  flex-basis: 100%;
  order: -1;
}

.message-form input {
  flex: 1;
}

.message-form button {
  width: 80px;
  flex-shrink: 0;
}

.img-upload-btn {
  font-size: 1.3rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.img-upload-btn:hover {
  background: var(--bg-hover);
}

/* ========== SCROLLBAR ========== */

::-webkit-scrollbar {
  width: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ========== PROFILE SYSTEM ========== */

/* Sidebar user avatar area */
.sidebar-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background 0.2s;
  flex: 1;
  min-width: 0;
}

.sidebar-user-info:hover {
  background: var(--bg-hover);
}

/* Avatar base */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: #fff;
  overflow: hidden;
  position: relative;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.avatar-xs { width: 24px; height: 24px; font-size: 0.55rem; }
.avatar-sm { width: 28px; height: 28px; font-size: 0.65rem; }
.avatar-md { width: 36px; height: 36px; font-size: 0.8rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 1.1rem; }
.avatar-xl { width: 80px; height: 80px; font-size: 1.8rem; }

.msg-avatar {
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
}

.msg-avatar:hover {
  transform: scale(1.1);
  box-shadow: 0 0 12px var(--shadow);
  border-radius: 50%;
}

/* Friend list avatar */
.friend-item {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  cursor: pointer;
  transition: background 0.2s;
  gap: 10px;
}

.friend-avatar {
  cursor: pointer;
  flex-shrink: 0;
}

/* ========== PROFILE POPUP (Discord-style) ========== */
.profile-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  background: var(--bg-overlay);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.profile-popup {
  background: linear-gradient(160deg, var(--bg-tertiary), var(--bg-primary));
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 600px;
  max-width: 92%;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 60px var(--shadow);
  animation: popupSlide 0.2s ease;
  display: flex;
  flex-direction: column;
}

@keyframes popupSlide {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.pp-banner {
  height: 100px;
  background: var(--accent-gradient-2);
}

.pp-header-zone {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 24px;
  margin-top: -36px;
  position: relative;
  z-index: 1;
}

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

.pp-avatar-el {
  width: 80px !important;
  height: 80px !important;
  font-size: 1.8rem !important;
  border: 5px solid var(--bg-tertiary) !important;
  border-radius: 50%;
  overflow: hidden;
}
.pp-avatar-el img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.pp-status-dot {
  position: absolute;
  bottom: 4px; right: 4px;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 4px solid var(--bg-tertiary);
}
.pp-status-dot.online { background: var(--success); }
.pp-status-dot.offline { background: var(--text-faint); }

.pp-header-btns {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-bottom: 8px;
}

.pp-msg-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.pp-msg-btn:hover { opacity: 0.85; }

.pp-icon-btn {
  width: 34px; height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pp-icon-btn:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}

.pp-body {
  padding: 16px 24px 20px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.pp-names {
  margin-bottom: 12px;
}

.pp-display-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.pp-username {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.pp-custom-status {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.pp-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 14px 0;
}

.pp-info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

.pp-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.pp-section-value {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-word;
}

/* Note section */
.pp-note-area {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 8px 10px;
  resize: vertical;
  min-height: 50px;
  max-height: 100px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.pp-note-area:focus {
  border-color: var(--accent-primary);
}
.pp-note-area::placeholder {
  color: var(--text-faint);
}

/* Tabs */
.pp-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-subtle);
  margin-bottom: 14px;
}

.pp-tab {
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
}
.pp-tab:hover {
  color: var(--text-secondary);
}
.pp-tab.pp-tab-active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.pp-tab-count {
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-left: 4px;
}
.pp-tab.pp-tab-active .pp-tab-count {
  color: var (--accent-primary);
}

.pp-tab-content {
  display: none;
  min-height: 80px;
}
.pp-tab-content.pp-tab-visible {
  display: block;
}

.pp-tab-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.pp-tab-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.15s;
  cursor: pointer;
}
.pp-tab-item:hover {
  background: var(--bg-hover);
}

.pp-tab-item-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.pp-tab-item-sub {
  font-size: 0.75rem;
  color: var(--text-faint);
}

.pp-tab-empty {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
  padding: 24px 16px;
}

.pp-activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: 8px;
  margin-bottom: 6px;
}

.pp-activity-icon {
  width: 36px; height: 36px;
  background: var(--bg-hover);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.pp-activity-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.pp-activity-time {
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-top: 2px;
}

/* ========== CALENDAR SYSTEM ========== */
.calendar-screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 24px;
  box-sizing: border-box;
  overflow-y: auto;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}

.calendar-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.calendar-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cal-month-year {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.cal-nav-btns {
  display: flex;
  gap: 6px;
}

.cal-nav-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.15s;
}
.cal-nav-btn:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}

.cal-today-btn {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
}

.cal-add-btn {
  background: var(--accent-gradient);
  border: none;
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.cal-add-btn:hover { opacity: 0.85; }

.cal-invites-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  color: var (--text-secondary);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
}
.cal-invites-btn:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}

.cal-invite-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--danger-bg);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.cal-invite-badge.hidden { display: none; }

.calendar-grid-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}
.cal-weekdays span {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 6px 0;
  letter-spacing: 0.5px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  flex: 1;
}

.cal-day {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 6px;
  min-height: 60px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.cal-day:hover {
  background: var(--bg-hover);
}
.cal-day.other-month {
  opacity: 0.3;
}
.cal-day.today .cal-day-num {
  background: var(--accent-secondary);
  color: #fff;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-day.selected {
  background: var(--bg-hover);
  box-shadow: inset 0 0 0 2px var(--accent-primary);
}

.cal-day-num {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-day-dots {
  display: flex;
  gap: 3px;
  margin-top: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-secondary);
}
.cal-dot.personal { background: #b794f6; }
.cal-dot.club { background: #fbbf24; }
.cal-dot.friend { background: #60a5fa; }

/* Calendar Day Panel */
.cal-day-panel {
  margin-top: 16px;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid var(--border-subtle);
}
.cal-day-panel.hidden { display: none; }

.cal-day-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.cal-day-panel-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.cal-day-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
}
.cal-day-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.cal-day-events {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cal-no-events {
  color: var(--text-faint);
  font-size: 0.88rem;
  text-align: center;
  padding: 20px 0;
  margin: 0;
}

.cal-event-card {
  display: flex;
  gap: 12px;
  background: var(--bg-card);
  border-radius: 10px;
  padding: 12px;
  transition: background 0.15s;
  align-items: flex-start;
}
.cal-event-card:hover {
  background: var(--bg-hover);
}

.cal-event-stripe {
  width: 4px;
  min-height: 40px;
  border-radius: 4px;
  flex-shrink: 0;
  align-self: stretch;
}
.cal-event-stripe.personal { background: #b794f6; }
.cal-event-stripe.club { background: #fbbf24; }
.cal-event-stripe.friend { background: #60a5fa; }

.cal-event-info {
  flex: 1;
  min-width: 0;
}

.cal-event-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.cal-event-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.cal-event-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 6px;
  word-break: break-word;
}

.cal-event-badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.cal-event-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(183, 148, 246, 0.15);
  color: #b794f6;
  font-weight: 600;
}
.cal-event-badge.club {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}
.cal-event-badge.friend {
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
}

.cal-series-badge {
  background: var(--bg-hover);
  color: var(--text-muted);
}

.cal-event-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.cal-evt-edit-btn,
.cal-evt-del-btn {
  background: var(--bg-hover);
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}
.cal-evt-edit-btn:hover { background: var(--bg-active); }
.cal-evt-del-btn:hover { background: rgba(237, 66, 69, 0.2); }

/* Calendar Modal */
.cal-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-overlay);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-modal-overlay.hidden { display: none; }

.cal-modal {
  background: var(--bg-tertiary);
  border-radius: 16px;
  width: 460px;
  max-width: 95vw;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 60px var(--shadow);
}

.cal-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
}
.cal-modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.cal-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
}
.cal-modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.cal-modal-body {
  padding: 18px 22px;
}

.cal-form-group {
  margin-bottom: 14px;
}
.cal-form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.cal-form-group input[type="text"],
.cal-form-group input[type="date"],
.cal-form-group input[type="time"],
.cal-form-group textarea,
.cal-form-group select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.cal-form-group input:focus,
.cal-form-group textarea:focus,
.cal-form-group select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.cal-form-row {
  display: flex;
  gap: 12px;
}
.cal-form-row .cal-form-group {
  flex: 1;
}

.cal-save-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 6px;
}
.cal-save-btn:hover { opacity: 0.85; }

.cal-form-msg {
  text-align: center;
  font-size: 0.82rem;
  margin-top: 8px;
  min-height: 1.2em;
  color: var(--danger);
}

/* Recurring toggle */
.cal-recurring-toggle {
  margin-bottom: 14px;
}

.cal-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.cal-toggle-label input[type="checkbox"] {
  display: none;
}

.cal-toggle-switch {
  width: 38px;
  height: 20px;
  border-radius: 10px;
  background: var(--text-muted);
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.cal-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.cal-toggle-label input:checked + .cal-toggle-switch {
  background: var(--accent-primary);
}
.cal-toggle-label input:checked + .cal-toggle-switch::after {
  transform: translateX(18px);
}

.cal-recurring-section.hidden { display: none; }

/* Day picker */
.cal-day-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cal-day-pick-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.cal-day-pick-btn:hover {
  background: var(--bg-hover);
}
.cal-day-pick-btn.selected {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

/* Period buttons */
.cal-period-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cal-period-btn {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cal-period-btn:hover {
  background: var(--bg-hover);
}
.cal-period-btn.selected {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.cal-period-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* Calendar invites list */
.cal-invites-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cal-invite-card {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 14px;
  border: 1px solid var(--border-subtle);
}

.cal-invite-from {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.cal-invite-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.cal-invite-detail {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.cal-invite-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.cal-invite-accept,
.cal-invite-decline {
  padding: 6px 16px;
  border-radius: 8px;
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.cal-invite-accept {
  background: var(--success);
  color: #fff;
}
.cal-invite-decline {
  background: var(--bg-hover);
  color: var(--text-secondary);
}
.cal-invite-accept:hover,
.cal-invite-decline:hover { opacity: 0.8; }

/* Calendar reminder toast */
.cal-reminder-toast {
  position: fixed;
  bottom: 80px;
  right: 24px;
  background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
  border: 1px solid var(--accent-primary);
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: 0 10px 40px var(--shadow);
  z-index: 9998;
  min-width: 260px;
  max-width: 340px;
  animation: toastIn 0.3s ease;
}

.cal-reminder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.cal-reminder-header span {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent-primary);
  letter-spacing: 0.5px;
}

.cal-reminder-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.cal-reminder-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.cal-reminder-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.cal-reminder-time {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Toast notification */
.toast-notification {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 8px 30px var(--shadow);
  z-index: 9999;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: none;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(20px); }
}

/* ========== CHAT HEADER ACTION BUTTONS ========== */

.cha-action-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0;
}
.cha-action-btn:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}
.cha-action-btn.cha-active {
  background: var(--bg-active);
  color: var(--accent-primary);
}
.cha-action-btn svg {
  pointer-events: none;
}

.cha-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger-bg);
  color: var(--text-primary);
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}
.cha-badge.hidden { display: none; }

/* ========== PINNED MESSAGES MODAL ========== */

.pinned-modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 2500;
  background: var(--bg-overlay);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.pinned-modal-overlay.hidden { display: none; }

.pinned-modal {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 480px;
  max-width: 92%;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px var(--shadow);
  animation: popupSlide 0.2s ease;
}

.pinned-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.pinned-modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.pinned-modal-close {
  width: 32px; height: 32px;
  border: none;
  background: var(--bg-hover);
  color: var(--text-muted);
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pinned-modal-close:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}

.pinned-modal-list {
  overflow-y: auto;
  padding: 12px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pinned-empty {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.9rem;
  padding: 40px 20px;
}

.pinned-msg-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
  position: relative;
  transition: background 0.15s;
}
.pinned-msg-card:hover {
  background: var(--bg-hover);
}

.pinned-msg-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.pinned-msg-sender {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--accent-primary);
}

.pinned-msg-time {
  font-size: 0.72rem;
  color: var(--text-faint);
}

.pinned-msg-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-word;
}

.pinned-msg-image {
  max-width: 200px;
  max-height: 140px;
  border-radius: 8px;
  margin-top: 6px;
}

.pinned-msg-unpin {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid rgba(231, 76, 60, 0.3);
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0;
}
.pinned-msg-card:hover .pinned-msg-unpin {
  opacity: 1;
}
.pinned-msg-unpin:hover {
  background: rgba(231, 76, 60, 0.3);
}

/* ========== SEARCH MESSAGES OVERLAY ========== */

.search-overlay {
  position: absolute;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 100%;
  max-height: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 0 0 0 14px;
  box-shadow: -4px 8px 30px var(--shadow);
  z-index: 200;
  display: flex;
  flex-direction: column;
  animation: pspSlideIn 0.2s ease;
}
.search-overlay.hidden { display: none; }

.search-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.search-bar-icon {
  color: var(--text-faint);
  flex-shrink: 0;
}

.search-bar-wrap input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.92rem;
  padding: 0;
}
.search-bar-wrap input::placeholder {
  color: var(--text-faint);
}

.search-close-btn {
  width: 28px; height: 28px;
  border: none;
  background: var(--bg-hover);
  color: var(--text-muted);
  border-radius: 50%;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.search-close-btn:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}

.search-results {
  overflow-y: auto;
  padding: 8px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-result-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.search-result-item:hover {
  background: var(--bg-hover);
}

.search-result-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.search-result-sender {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-primary);
}

.search-result-time {
  font-size: 0.7rem;
  color: var(--text-faint);
}

.search-result-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  word-break: break-word;
}

.search-result-text mark {
  background: var(--bg-active);
  color: var(--text-primary);
  border-radius: 2px;
  padding: 0 2px;
}

.search-empty {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.88rem;
  padding: 30px 16px;
}

/* ========== MESSAGE PIN ACTION (hover) ========== */

.msg-actions {
  position: absolute;
  top: -8px;
  right: 8px;
  display: none;
  gap: 2px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px;
  box-shadow: 0 4px 16px var(--shadow);
  z-index: 10;
}
.message:hover .msg-actions {
  display: flex;
}
.message.sent .msg-actions {
  right: auto;
  left: 48px;
}

.msg-action-btn {
  width: 28px; height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
}
.msg-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.msg-action-btn-danger:hover {
  background: rgba(237, 66, 69, 0.15);
  color: #ed4245;
}

/* ===== REPLY BAR ===== */
.reply-bar {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border-left: 3px solid var(--accent);
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  margin-bottom: -2px;
}
.reply-bar.hidden { display: none; }
.reply-bar-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.reply-bar-label {
  font-size: 0.72rem;
  color: var(--accent);
}
.reply-bar-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-bar-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.reply-bar-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ===== REPLY PREVIEW IN MESSAGE ===== */
.msg-reply-preview {
  background: rgba(255,255,255,0.04);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
  transition: background 0.15s;
}
.msg-reply-preview:hover {
  background: rgba(255,255,255,0.08);
}
.msg-reply-name {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
}
.msg-reply-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== FORWARDED TAG ===== */
.msg-forwarded-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.msg-forwarded-tag strong {
  color: var(--accent);
}

/* ===== EDITED TAG ===== */
.msg-edited-tag {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-left: 4px;
  opacity: 0.7;
}

/* ===== EDIT INPUT ===== */
.msg-edit-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text-primary);
  padding: 6px 8px;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}
.msg-edit-input:focus {
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 2px rgba(88,101,242,0.25);
}

/* ===== MESSAGE HIGHLIGHT (scroll-to on reply click) ===== */
.msg-highlight {
  animation: msgHighlight 1.5s ease;
}
@keyframes msgHighlight {
  0% { background: rgba(88,101,242,0.25); }
  100% { background: transparent; }
}

/* ===== REACTIONS ===== */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 2px 0 0 48px;
  margin-top: -2px;
}
.message.sent .msg-reactions {
  justify-content: flex-end;
  padding-left: 0;
  padding-right: 48px;
}
.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-primary);
}
.reaction-chip:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}
.reaction-chip.reaction-mine {
  background: rgba(88,101,242,0.15);
  border-color: var(--accent);
}
.reaction-count {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ===== FULL EMOJI REACTION PICKER ===== */
.emoji-picker-full {
  position: fixed;
  z-index: 1000;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 320px;
  height: 380px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 36px var(--shadow);
  overflow: hidden;
}
.emoji-picker-full.hidden { display: none; }

.emoji-picker-header {
  padding: 10px 10px 6px;
  border-bottom: 1px solid var(--border-color);
}
.emoji-picker-search {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.emoji-picker-search:focus {
  border-color: var(--accent);
}
.emoji-picker-search::placeholder {
  color: var(--text-muted);
}

.emoji-picker-categories {
  display: flex;
  padding: 4px 6px;
  gap: 2px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
  overflow-x: auto;
  scrollbar-width: none;
}
.emoji-picker-categories::-webkit-scrollbar { display: none; }
.emoji-cat-btn {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  opacity: 0.55;
}
.emoji-cat-btn:hover {
  background: var(--bg-hover);
  opacity: 1;
}
.emoji-cat-btn.active {
  background: var(--bg-hover);
  opacity: 1;
  box-shadow: 0 1px 0 var(--accent) inset, 0 -1px 0 var(--accent) inset;
}

.emoji-picker-grid {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  align-content: start;
}
.emoji-picker-grid::-webkit-scrollbar { width: 5px; }
.emoji-picker-grid::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}

.emoji-grid-btn {
  width: 100%;
  aspect-ratio: 1;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  padding: 0;
}
.emoji-grid-btn:hover {
  background: var(--bg-hover);
  transform: scale(1.2);
}

.emoji-picker-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ===== FORWARD MODAL ===== */
.forward-modal-body {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.forward-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  box-sizing: border-box;
}
.forward-search:focus {
  border-color: var(--accent);
}
.forward-target-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.forward-target-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-primary);
  transition: background 0.12s;
}
.forward-target-item:hover {
  background: var(--bg-hover);
}
.forward-target-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}
.forward-send-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.forward-send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}
.forward-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== VANISHING ANIMATION ===== */
.msg-vanishing {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.4s, transform 0.4s;
}

/* ========== PROFILE SIDE PANEL ========== */
.profile-side-panel {
  width: 340px;
  min-width: 340px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: width 0.2s;
}
.profile-side-panel.hidden {
  display: none;
}

.psp-banner {
  width: 100%;
  height: 60px;
  background: var(--accent-gradient-2);
  flex-shrink: 0;
}

.psp-avatar-wrap {
  position: relative;
  margin: -30px 0 0 20px;
  width: 64px;
  height: 64px;
}

.psp-avatar-el {
  width: 64px !important;
  height: 64px !important;
  font-size: 1.7rem !important;
  border: 4px solid var(--bg-secondary);
  border-radius: 50%;
  box-sizing: border-box;
}

.psp-status-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid var(--bg-secondary);
  box-sizing: border-box;
}
.psp-status-dot.online { background: var(--success); }
.psp-status-dot.offline { background: #747f8d; }

.psp-body {
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.psp-display-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.psp-username {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.psp-custom-status {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.psp-custom-status.hidden { display: none; }

.psp-card {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 12px;
  margin-top: 6px;
}
.psp-card.hidden { display: none; }

.psp-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.psp-section-value {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.psp-bio {
  white-space: pre-wrap;
  word-break: break-word;
}

.psp-expandable-card {
  padding: 0;
}

.psp-expand-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: background 0.15s;
}
.psp-expand-row:hover {
  background: var(--bg-card);
}

.psp-expand-arrow {
  font-size: 1rem;
  transition: transform 0.2s;
  color: var(--text-muted);
}
.psp-expand-arrow.psp-arrow-open {
  transform: rotate(90deg);
}

.psp-expand-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0 12px;
}

.psp-expand-list {
  padding: 4px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.psp-expand-list.hidden { display: none; }

.psp-mutual-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.psp-mutual-name {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.psp-club-icon {
  font-size: 1.1rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.psp-view-full-btn {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  border: none;
  border-radius: 8px;
  background: var(--bg-hover);
  color: var(--accent-primary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.psp-view-full-btn:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}

/* PSP responsive */
@media (max-width: 900px) {
  .profile-side-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    box-shadow: -8px 0 30px var(--shadow);
  }
}

@media (max-width: 600px) {
  .profile-side-panel {
    width: 280px;
    min-width: 280px;
  }
}

/* ========== CALENDAR OVERLAY ========== */
.calendar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 6000;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease;
}

.calendar-overlay-inner {
  width: 90%;
  max-width: 900px;
  height: 85vh;
  max-height: 750px;
  background: var(--bg-secondary);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.calendar-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.calendar-overlay-header h2 {
  font-size: 1.2rem;
  color: var(--text-primary);
  margin: 0;
}

.cal-overlay-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.cal-overlay-close:hover {
  background: var(--danger-bg);
  color: #fff;
}

.calendar-overlay-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.calendar-overlay-body .calendar-screen {
  height: 100%;
}

/* ========== GROUP MEMBERS PANEL ========== */
.group-members-panel {
  background: var(--bg-tertiary);
}

.gmp-banner {
  height: 70px;
  background: var(--accent-gradient);
  border-radius: 0;
}

.gmp-header {
  padding: 16px 16px 8px;
  text-align: center;
}

.gmp-icon {
  font-size: 2rem;
  margin-bottom: 4px;
}

.gmp-group-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.gmp-member-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.gmp-body {
  padding: 8px 12px 16px;
}

.gmp-members-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
}

.gmp-member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.15s;
}

.gmp-member-row:hover {
  background: var(--bg-hover);
}

.gmp-member-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.gmp-member-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gmp-member-username {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.gmp-member-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.gmp-member-status.online {
  background: var(--success);
  box-shadow: 0 0 6px rgba(81, 207, 102, 0.4);
}

.gmp-member-status.offline {
  background: var(--text-faint);
}

/* ========== CALLING UI ========== */

/* --- Incoming Call Modal --- */
.call-incoming-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 9000;
  background: var(--bg-overlay);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.call-incoming-overlay.hidden { display: none; }

.call-incoming-card {
  position: relative;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
  animation: popupSlide 0.3s ease;
  min-width: 320px;
}

.call-incoming-pulse {
  position: absolute;
  top: 50%; left: 50%;
  width: 120px; height: 120px;
  transform: translate(-50%, -70%);
  border-radius: 50%;
  background: var(--accent-primary);
  opacity: 0.15;
  animation: callPulse 2s ease-in-out infinite;
}

@keyframes callPulse {
  0%, 100% { transform: translate(-50%, -70%) scale(1); opacity: 0.15; }
  50% { transform: translate(-50%, -70%) scale(1.8); opacity: 0.04; }
}

.call-avatar {
  width: 88px !important;
  height: 88px !important;
  font-size: 2rem;
  border: 3px solid var(--accent-primary);
  z-index: 1;
}

.call-incoming-info {
  text-align: center;
  z-index: 1;
}

.call-incoming-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.call-incoming-type {
  font-size: 0.88rem;
  color: var(--text-secondary);
  animation: callTypeFlash 1.5s ease-in-out infinite;
}

@keyframes callTypeFlash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.call-incoming-actions {
  display: flex;
  gap: 32px;
  margin-top: 8px;
  z-index: 1;
}

.call-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: #fff;
}

.call-btn-accept {
  background: var(--success);
  box-shadow: 0 4px 20px rgba(81, 207, 102, 0.4);
  animation: callBtnRing 1s ease-in-out infinite;
}
.call-btn-accept:hover {
  background: #45b359;
  transform: scale(1.08);
}

@keyframes callBtnRing {
  0%, 100% { box-shadow: 0 4px 20px rgba(81, 207, 102, 0.4); }
  50% { box-shadow: 0 4px 36px rgba(81, 207, 102, 0.65); }
}

.call-btn-decline {
  background: var(--danger-bg);
  box-shadow: 0 4px 20px rgba(237, 66, 69, 0.35);
}
.call-btn-decline:hover {
  background: #d03336;
  transform: scale(1.08);
}

/* --- Active Call Overlay --- */
.call-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 8500;
  background: #0a0a0f;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.25s ease;
}
.call-overlay.hidden { display: none; }

.call-overlay-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Remote video full-screen */
.call-remote-video {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: #0a0a0f;
  image-rendering: auto;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: contents;
}

/* Audio-only screen (when no video) */
.call-audio-only {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary), var(--bg-tertiary));
  z-index: 1;
}
.call-audio-only.hidden { display: none; }

.call-audio-pulse {
  position: absolute;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: var(--accent-primary);
  opacity: 0.08;
  animation: callPulse 3s ease-in-out infinite;
}

/* Two participants side by side */
.call-participants {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 60px;
  z-index: 1;
  margin-bottom: 20px;
}

.call-participant {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.call-participant-name {
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 600;
  z-index: 1;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

/* Discord-style avatar ring — speaking indicator */
.call-avatar-ring {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  border-radius: 50%;
  padding: 6px;
  border: 3.5px solid transparent;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.call-avatar-ring.speaking {
  border-color: #43b581;
  box-shadow: 0 0 18px rgba(67, 181, 129, 0.35), 0 0 6px rgba(67, 181, 129, 0.2);
}

/* Mute indicator badge */
.call-mute-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ed4245;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  border: 3px solid var(--bg-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.call-mute-indicator.hidden { display: none; }

.call-participant-avatar-el {
  width: 120px !important;
  height: 120px !important;
  font-size: 2.8rem;
  border: 4px solid var(--border-color);
  z-index: 1;
  margin-bottom: 0;
}

@media (max-width: 500px) {
  .call-participants { gap: 30px; }
  .call-participant-avatar-el {
    width: 90px !important;
    height: 90px !important;
    font-size: 2rem;
  }
  .call-participant-name { font-size: 0.95rem; max-width: 100px; }
  .call-mute-indicator { width: 22px; height: 22px; }
  .call-mute-indicator svg { width: 12px; height: 12px; }
}

.call-timer {
  color: var(--text-secondary);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  z-index: 1;
}

/* Local video PIP */
.call-local-wrap {
  position: absolute;
  bottom: 100px;
  right: 24px;
  width: 240px;
  height: 180px;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.15);
  background: #111;
  z-index: 10;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  cursor: grab;
  transition: box-shadow 0.2s;
}
.call-local-wrap:hover {
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}
.call-local-wrap.hidden { display: none; }

.call-local-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1) translateZ(0);
  image-rendering: auto;
  will-change: contents;
}

/* Call status bar */
.call-status-bar {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 8px 22px;
  z-index: 10;
}

.call-status-text {
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Call controls bar */
.call-controls {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 0 32px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  z-index: 10;
}

.call-ctrl-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.call-ctrl-btn:hover {
  background: rgba(255,255,255,0.22);
  transform: scale(1.06);
}
.call-ctrl-btn.active {
  background: #fff;
  color: #1a1a1a;
}
.call-ctrl-btn.active:hover {
  background: #e0e0e0;
}

.call-ctrl-hangup {
  width: 60px;
  height: 60px;
  background: var(--danger-bg) !important;
  color: #fff !important;
}
.call-ctrl-hangup:hover {
  background: #d03336 !important;
  transform: scale(1.08);
}

/* Ringing animation for incoming call card */
@keyframes ringShake {
  0%, 100% { transform: rotate(0deg); }
  10% { transform: rotate(-8deg); }
  20% { transform: rotate(8deg); }
  30% { transform: rotate(-6deg); }
  40% { transform: rotate(6deg); }
  50% { transform: rotate(0deg); }
}

.call-incoming-card .call-avatar {
  animation: ringShake 1.2s ease-in-out infinite;
}

/* Screen share active indicator */
.call-ctrl-btn.screen-sharing {
  background: var(--success) !important;
  color: #fff !important;
}
.call-ctrl-btn.screen-sharing:hover {
  background: #45b359 !important;
}

/* Responsive */
@media (max-width: 600px) {
  .call-incoming-card {
    padding: 36px 32px;
    min-width: unset;
    width: 90%;
  }
  .call-local-wrap {
    width: 130px;
    height: 100px;
    bottom: 90px;
    right: 12px;
  }
  .call-controls {
    gap: 12px;
    padding: 20px 0 28px;
  }
  .call-ctrl-btn {
    width: 46px;
    height: 46px;
  }
  .call-ctrl-hangup {
    width: 54px;
    height: 54px;
  }
  .call-remote-avatar-el {
    width: 90px !important;
    height: 90px !important;
    font-size: 2.2rem;
  }
}

/* ===== GROUP CALL OVERLAY ===== */

.group-call-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 8600;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}
.group-call-overlay.hidden { display: none; }

.gc-overlay-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Group call header */
.gc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  z-index: 2;
}

.gc-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gc-header-icon {
  font-size: 1.3rem;
}

.gc-header-name {
  color: var(--text-primary);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.gc-participant-count {
  color: var(--text-secondary);
  font-size: 0.82rem;
  background: var(--bg-tertiary);
  padding: 3px 10px;
  border-radius: 12px;
}

.gc-header-timer {
  display: flex;
  align-items: center;
}

.gc-timer {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  background: var(--bg-tertiary);
  padding: 4px 14px;
  border-radius: 12px;
  font-weight: 500;
}

/* Video grid */
.gc-video-grid {
  flex: 1;
  display: grid;
  gap: 8px;
  padding: 12px;
  overflow: auto;
  background: var(--bg-primary);
}

.gc-video-grid.gc-grid-1 {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}
.gc-video-grid.gc-grid-2 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
}
.gc-video-grid.gc-grid-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.gc-video-grid.gc-grid-6 {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.gc-video-grid.gc-grid-many {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  grid-auto-rows: minmax(200px, 1fr);
}

/* Participant tile */
.gc-participant-tile {
  position: relative;
  background: var(--bg-secondary);
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid var(--border-color);
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.3s;
}
.gc-participant-tile:hover {
  border-color: var(--accent-primary);
}

.gc-tile-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0; left: 0;
  image-rendering: auto;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: contents;
}
/* Keep video element rendered (not display:none) so browser still plays audio.
   Use a dedicated class instead of global .hidden to avoid display:none !important. */
.gc-tile-video.gc-video-hidden {
  opacity: 0 !important;
  pointer-events: none;
  z-index: -1;
}

.gc-tile-audio-only {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
}
.gc-tile-audio-only.hidden { display: none; }

.gc-tile-avatar {
  width: 80px !important;
  height: 80px !important;
  font-size: 2rem;
  border: 3px solid var(--border-color);
}

.gc-tile-name {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  padding: 8px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 2;
}

.gc-tile-username,
.gc-tile-name span:first-child {
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.gc-mic-indicator {
  font-size: 0.75rem;
}

/* Group call: Speaking ring around avatar (audio-only mode) */
.gc-tile-speaking-ring {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 3.5px solid transparent;
  padding: 3px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.gc-tile-speaking-ring.speaking {
  border-color: #43b581;
  box-shadow: 0 0 12px rgba(67, 181, 129, 0.5);
}

/* Group call: Speaking border overlay (full tile, video mode) */
.gc-tile-speaking-border {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 16px;
  border: 3px solid transparent;
  pointer-events: none;
  z-index: 3;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.gc-tile-speaking-border.speaking {
  border-color: #43b581;
  box-shadow: inset 0 0 12px rgba(67, 181, 129, 0.25);
}

/* Group call: Mute badge (red circle with mic-off icon) */
.gc-mute-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ed4245;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.gc-mute-badge.hidden {
  display: none;
}

/* Group call controls */
.gc-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px 0 28px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  z-index: 2;
}

/* Incoming group call card extra styles */
.gc-incoming-card {
  text-align: center;
}
.gc-incoming-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  animation: ringShake 1.2s ease-in-out infinite;
}
.gc-incoming-participants {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 6px;
}

/* Active group call banner in chat */
.gc-active-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: linear-gradient(135deg, rgba(81, 207, 102, 0.15), rgba(81, 207, 102, 0.05));
  border-bottom: 1px solid rgba(81, 207, 102, 0.25);
  animation: fadeIn 0.3s ease;
}
.gc-active-banner.hidden { display: none; }

.gc-banner-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 500;
}

.gc-banner-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #51cf66;
  animation: callPulse 2s ease-in-out infinite;
  display: inline-block;
}

.gc-banner-join {
  padding: 6px 18px;
  border-radius: 8px;
  border: none;
  background: var(--success);
  color: #fff;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
}
.gc-banner-join:hover {
  background: #45b359;
  transform: scale(1.04);
}

/* Local tile mirror */
.gc-local-tile .gc-tile-video {
  transform: scaleX(-1) translateZ(0);
}

/* Responsive */
@media (max-width: 768px) {
  .gc-video-grid.gc-grid-2,
  .gc-video-grid.gc-grid-4 {
    grid-template-columns: 1fr;
  }
  .gc-video-grid.gc-grid-6 {
    grid-template-columns: 1fr 1fr;
  }
  .gc-video-grid.gc-grid-many {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
  .gc-header {
    padding: 10px 14px;
  }
  .gc-controls {
    gap: 12px;
    padding: 16px 0 22px;
  }
  .gc-tile-avatar {
    width: 60px !important;
    height: 60px !important;
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .gc-video-grid {
    gap: 4px;
    padding: 6px;
  }
  .gc-video-grid.gc-grid-6 {
    grid-template-columns: 1fr;
  }
  .gc-participant-tile {
    min-height: 120px;
    border-radius: 10px;
  }
}

/* ========== PERSISTENT CONTROLS (Discord-style sidebar bottom) ========== */
.persistent-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border-top: 1px solid var(--border-color);
  gap: 8px;
  flex-shrink: 0;
  min-height: 52px;
}

.pc-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 4px;
  margin: -2px -4px;
  transition: background 0.15s ease;
}

.pc-user-info:hover {
  background: rgba(255, 255, 255, 0.08);
}

.pc-user-info .avatar-xs {
  width: 32px !important;
  height: 32px !important;
  font-size: 0.7rem;
  flex-shrink: 0;
}

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

.pc-own-status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2.5px solid var(--bg-secondary);
  z-index: 1;
}
.pc-own-status-dot.online { background: #3ba55c; }
.pc-own-status-dot.idle { background: #faa61a; }
.pc-own-status-dot.dnd { background: #ed4245; }
.pc-own-status-dot.invisible { background: #747f8d; }

.pc-user-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pc-display-name {
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.pc-status {
  color: var(--text-secondary);
  font-size: 0.68rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.pc-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pc-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pc-btn svg {
  width: 32px !important;
  height: 32px !important;
}

.pc-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.pc-btn.pc-btn-active {
  color: #ed4245;
}

.pc-btn.pc-btn-active:hover {
  background: rgba(237, 66, 69, 0.15);
}

.pc-slash {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 3px;
  background: #ed4245;
  border-radius: 2px;
  transform: translate(-50%, -50%) rotate(-45deg);
  pointer-events: none;
}

.pc-slash.hidden {
  display: none;
}

/* ========== STATUS POPUP (bottom-left profile click) ========== */
.pc-status-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 8px;
  width: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 999;
  overflow: hidden;
  animation: pcStatusPopIn 0.15s ease;
}

@keyframes pcStatusPopIn {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.pc-status-popup.hidden {
  display: none;
}

.pc-status-popup-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 10px;
}

.pc-status-popup-header .avatar {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.pc-status-popup-header-text {
  min-width: 0;
}

.pc-status-popup-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-status-popup-username {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.pc-status-popup-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0 10px;
}

.pc-status-popup-section {
  padding: 8px 10px;
}

.pc-status-popup-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  padding: 0 4px;
}

.pc-status-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.pc-status-option:hover {
  background: rgba(255, 255, 255, 0.08);
}

.pc-status-option.active {
  background: rgba(88, 101, 242, 0.2);
}

.pc-status-option-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--bg-secondary);
}

.pc-status-option-dot.online { background: #3ba55c; }
.pc-status-option-dot.idle { background: #faa61a; }
.pc-status-option-dot.dnd { background: #ed4245; }
.pc-status-option-dot.invisible { background: #747f8d; }

.pc-status-option-info {
  min-width: 0;
}

.pc-status-option-label {
  font-weight: 600;
  font-size: 0.82rem;
}

.pc-status-option-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.pc-custom-status-input-wrap {
  padding: 6px 10px 10px;
}

.pc-custom-status-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.15s;
}

.pc-custom-status-input:focus {
  border-color: var(--accent-primary);
}

.pc-custom-status-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

/* ========== SPOTLIGHT / FOCUS VIEW ========== */
.gc-main-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Spotlight view container */
.gc-spotlight-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
  padding: 12px;
  gap: 12px;
}

.gc-spotlight-view.hidden {
  display: none;
}

/* The large spotlighted tile */
.gc-spotlight-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.gc-spotlight-content .gc-participant-tile.gc-spotlighted {
  width: 100%;
  height: 100%;
  min-height: 300px;
  max-height: 100%;
  border-radius: 16px;
  border: 2px solid var(--border-color);
}

.gc-spotlight-content .gc-participant-tile.gc-spotlighted .gc-tile-avatar {
  width: 120px !important;
  height: 120px !important;
  font-size: 3rem;
}

.gc-spotlight-content .gc-participant-tile.gc-spotlighted .gc-tile-name {
  padding: 12px 18px;
}

.gc-spotlight-content .gc-participant-tile.gc-spotlighted .gc-tile-name span:first-child {
  font-size: 1rem;
}

/* Exit spotlight button */
.gc-exit-spotlight {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s ease;
}

.gc-exit-spotlight:hover {
  background: rgba(0, 0, 0, 0.8);
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.03);
}

.gc-exit-spotlight svg {
  flex-shrink: 0;
}

/* Bottom strip for non-spotlighted tiles */
.gc-bottom-strip {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  height: 140px;
  min-height: 140px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.gc-bottom-strip.hidden {
  display: none;
}

.gc-bottom-strip::-webkit-scrollbar {
  height: 5px;
}

.gc-bottom-strip::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
}

.gc-bottom-strip::-webkit-scrollbar-track {
  background: transparent;
}

/* Tiles in the bottom strip should be small, fixed-size */
.gc-bottom-strip .gc-participant-tile {
  flex-shrink: 0;
  width: 180px;
  min-width: 180px;
  height: 100%;
  min-height: unset;
  border-radius: 12px;
}

.gc-bottom-strip .gc-participant-tile .gc-tile-avatar {
  width: 48px !important;
  height: 48px !important;
  font-size: 1.2rem;
}

.gc-bottom-strip .gc-participant-tile .gc-tile-name {
  padding: 4px 8px;
}

.gc-bottom-strip .gc-participant-tile .gc-tile-name span:first-child {
  font-size: 0.72rem;
}

.gc-bottom-strip .gc-participant-tile .gc-mute-badge {
  width: 22px;
  height: 22px;
  top: 6px;
  right: 6px;
}

.gc-bottom-strip .gc-participant-tile .gc-mute-badge svg {
  width: 11px;
  height: 11px;
}

/* Responsive spotlight */
@media (max-width: 768px) {
  .gc-bottom-strip {
    height: 110px;
    min-height: 110px;
  }
  .gc-bottom-strip .gc-participant-tile {
    width: 140px;
    min-width: 140px;
  }
  .gc-spotlight-content .gc-participant-tile.gc-spotlighted .gc-tile-avatar {
    width: 80px !important;
    height: 80px !important;
    font-size: 2rem;
  }
  .gc-exit-spotlight {
    top: 12px;
    left: 12px;
    padding: 6px 12px;
    font-size: 0.75rem;
  }
  .persistent-controls {
    padding: 8px 10px;
  }
}

@media (max-width: 480px) {
  .gc-bottom-strip {
    height: 90px;
    min-height: 90px;
    padding: 6px 8px;
    gap: 6px;
  }
  .gc-bottom-strip .gc-participant-tile {
    width: 120px;
    min-width: 120px;
  }
}

/* ========== DOWNLOAD CHAT HISTORY ========== */

.dl-chat-modal {
  width: 440px;
}

.dl-chat-body {
  padding: 20px;
}

.dl-chat-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 18px;
}

.dl-format-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dl-format-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.dl-format-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.15);
}

.dl-format-btn.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.3);
}

.dl-format-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.dl-format-icon {
  font-size: 1.6rem;
}

.dl-format-label {
  font-size: 0.95rem;
  font-weight: 700;
}

.dl-format-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.dl-format-btn.active .dl-format-sub {
  color: rgba(255,255,255,0.7);
}

.dl-chat-status {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  animation: fadeIn 0.2s ease;
}

.dl-status-waiting {
  background: rgba(245, 159, 0, 0.12);
  color: #f59f00;
  border: 1px solid rgba(245, 159, 0, 0.25);
}

.dl-status-success {
  background: rgba(81, 207, 102, 0.12);
  color: #51cf66;
  border: 1px solid rgba(81, 207, 102, 0.25);
}

.dl-status-error {
  background: rgba(255, 107, 107, 0.12);
  color: #ff6b6b;
  border: 1px solid rgba(255, 107, 107, 0.25);
}

/* Approval Banner (slides in from top) */
.dl-approval-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--accent-primary);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(124, 58, 237, 0.2);
  max-width: 560px;
  width: calc(100% - 32px);
  -webkit-animation: dlBannerSlide 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: dlBannerSlide 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dl-approval-banner.hidden {
  display: none;
}

@-webkit-keyframes dlBannerSlide {
  from { opacity: 0; -webkit-transform: translateX(-50%) translateY(-30px); transform: translateX(-50%) translateY(-30px); }
  to { opacity: 1; -webkit-transform: translateX(-50%) translateY(0); transform: translateX(-50%) translateY(0); }
}
@keyframes dlBannerSlide {
  from { opacity: 0; transform: translateX(-50%) translateY(-30px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.dl-approval-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.dl-approval-content {
  flex: 1;
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.4;
}

.dl-approval-content strong {
  color: var(--accent-primary);
}

.dl-approval-format {
  display: inline-block;
  background: var(--accent-primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
}

.dl-approval-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.dl-approve-btn,
.dl-deny-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dl-approve-btn {
  background: #51cf66;
  color: #fff;
}

.dl-approve-btn:hover {
  background: #40c057;
  transform: scale(1.05);
}

.dl-deny-btn {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.dl-deny-btn:hover {
  background: #ff6b6b;
  color: #fff;
  transform: scale(1.05);
}

/* Light theme adjustments */
[data-theme="light"] .dl-approval-banner {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(124, 58, 237, 0.15);
}

@media (max-width: 600px) {
  .dl-approval-banner {
    flex-wrap: wrap;
    gap: 10px;
  }
  .dl-approval-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .dl-format-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .dl-format-btn {
    padding: 14px 8px;
  }
}
