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

:root {
  --bg:        #0c0c12;
  --bg-glass:  rgba(12, 12, 18, 0.40);
  --bg2:       #13131c;
  --bg2-glass: rgba(19, 19, 28, 0.45);
  --bg3:       #1a1a26;
  --bg3-glass: rgba(26, 26, 38, 0.80);
  --bg4:       #17172120;
  --hover:     #252535;
  --accent:    #7c6af7;
  --accent2:   #6457e8;
  --accent-glow: rgba(124,106,247,0.22);
  --text:      #e4e4f0;
  --text2:     #8888a8;
  --muted:     #55556a;
  --border:    #252535;
  --border2:   #303048;
  --green:     #3dd68c;
  --red:       #ff5572;
  --yellow:    #ffb340;
  --sidebar:   265px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Matrix rain background ── */
#matrix-bg {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 1;
}
#app { position: relative; z-index: 1; height: 100%; background: transparent; }

.hidden { display: none !important; }

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Loading ── */
#loading-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
.loading-content {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 22px;
}
.loading-logo {
  font-size: 50px; font-weight: 800;
  background: linear-gradient(135deg, var(--accent) 0%, #a78bfa 50%, #60a5fa 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: -2px;
  filter: drop-shadow(0 0 32px var(--accent-glow));
}
.loading-text { color: var(--text2); font-size: 13px; font-weight: 500; letter-spacing: 0.02em; }
.spinner {
  width: 30px; height: 30px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Layout ── */
#main-ui {
  display: flex;
  height: 100vh;                       /* fallback for very old browsers */
  height: calc(var(--vh, 1vh) * 100);  /* JS fallback for older Safari */
  height: 100dvh;                      /* dynamic viewport — fixes iOS Safari toolbar (wins if supported) */
}

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar); min-width: var(--sidebar);
  background: var(--bg2-glass);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
  border-right: 1px solid var(--border);
  overflow: hidden;
  transition: width 0.3s cubic-bezier(0.4,0,0.2,1),
              min-width 0.3s cubic-bezier(0.4,0,0.2,1),
              transform 0.3s cubic-bezier(0.4,0,0.2,1);
  z-index: 10;
}
#sidebar.collapsed {
  width: 0; min-width: 0; border-right: none;
}

/* ── Theme bar ── */
.sidebar-theme-bar {
  display: flex; gap: 6px; padding: 10px 16px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0; margin-top: auto;
}
.btn-theme {
  flex: 1; padding: 6px; border-radius: 8px; cursor: pointer;
  background: var(--bg3); border: 1.5px solid var(--border);
  font-size: 16px; transition: all 0.15s;
}
.btn-theme:hover { border-color: var(--accent); }
.btn-theme.active { border-color: var(--accent); background: var(--accent-glow); }

/* ══ MATRIX THEME ═══════════════════════════════════════════════════════════ */
[data-theme="matrix"] {
  --bg:           #000000;
  --bg-glass:     rgba(0, 0, 0, 0.45);
  --bg2:          #001a00;
  --bg2-glass:    rgba(0, 20, 0, 0.50);
  --bg3:          #002200;
  --bg3-glass:    rgba(0, 30, 0, 0.85);
  --bg4:          rgba(0, 40, 0, 0.15);
  --hover:        #003300;
  --accent:       #00dc50;
  --accent2:      #00b840;
  --accent-glow:  rgba(0, 220, 80, 0.20);
  --text:         #00ff66;
  --text2:        #00aa44;
  --muted:        #005522;
  --border:       #003300;
  --border2:      #004400;
  --green:        #00ff66;
  --red:          #ff4466;
  --yellow:       #aaff00;
}
[data-theme="matrix"] * {
  font-family: 'Courier New', Courier, monospace !important;
}
[data-theme="matrix"] .msg-bubble,
[data-theme="matrix"] .dm-bubble {
  background: #001800 !important;
  border: 1px solid #005500 !important;
  color: #00ff66 !important;
}
[data-theme="matrix"] .dm-bubble a,
[data-theme="matrix"] .msg-body a { color: #00ffaa !important; }
[data-theme="matrix"] .msg-card {
  background: rgba(0,20,0,0.6) !important;
  border-color: #003300 !important;
}
[data-theme="matrix"] input,
[data-theme="matrix"] textarea {
  color: #00ff66 !important;
  background: #001500 !important;
  border-color: #004400 !important;
}
[data-theme="matrix"] input::placeholder,
[data-theme="matrix"] textarea::placeholder { color: #005522 !important; }
[data-theme="matrix"] .composer-main {
  background: #001500 !important;
  border-color: #004400 !important;
}
[data-theme="matrix"] .avatar {
  filter: hue-rotate(100deg) saturate(2) !important;
}
[data-theme="matrix"] .app-logo .logo-text { color: #00ff66 !important; }
[data-theme="matrix"] #matrix-bg { opacity: 1; }
[data-theme="default"] #matrix-bg { opacity: 1; }


#sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9;
  backdrop-filter: blur(2px);
}

.sidebar-header {
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; gap: 8px;
}
.btn-sidebar-close {
  display: none; /* hidden on desktop */
  align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 50%; cursor: pointer;
  font-size: 16px; font-weight: 700; color: var(--text2);
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}
.btn-sidebar-close:hover { background: var(--hover); color: var(--text); }
.app-logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; letter-spacing: -0.5px; }
.logo-icon { font-size: 20px; }
.logo-text {
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.btn-lang-toggle {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 5px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  margin-left: auto;
}
.btn-lang-toggle:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.network-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text2); font-weight: 500;
  background: var(--bg3);
  padding: 4px 10px; border-radius: 20px;
  border: 1px solid var(--border);
}

/* Admin badge in profile */
.admin-badge {
  font-size: 9px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  color: white;
  padding: 2px 7px; border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 1px 6px var(--accent-glow);
}

/* WiFi channel as first item in channels list */
.wifi-channel-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 9px 14px;
  background: none; border: none;
  cursor: pointer; text-align: left;
  font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--text);
  border-left: 3px solid transparent;
  transition: all 0.15s;
  position: relative;
  margin-bottom: 2px;
}
.wifi-channel-item:hover { background: var(--hover); border-radius: 0 8px 8px 0; }
.wifi-channel-item.active, .wifi-channel-item:focus {
  background: rgba(124,106,247,0.12);
  border-left-color: var(--accent);
  color: var(--accent);
  outline: none;
}
.wifi-channel-icon { font-size: 16px; }
.wifi-channel-name { flex: 1; }

/* Prominent create-channel CTA */
.dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.dot.online {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse-dot 2.5s ease infinite;
}
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.sidebar-profile {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
  background: var(--bg3);
}
.avatar {
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: white;
  flex-shrink: 0; user-select: none;
  box-shadow: 0 2px 10px var(--accent-glow);
  overflow: hidden;
}
.avatar.lg { width: 38px; height: 38px; font-size: 15px; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.xs { width: 22px; height: 22px; font-size: 9px; }

.clickable-avatar {
  cursor: pointer;
  position: relative;
  transition: filter 0.2s;
}
.clickable-avatar:hover { filter: brightness(0.7); }
.clickable-avatar::after {
  content: '📷';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; opacity: 0;
  transition: opacity 0.2s;
}
.clickable-avatar:hover::after { opacity: 1; }
.profile-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pseudo-name-row { display: flex; align-items: center; gap: 6px; min-width: 0; cursor: pointer; }
.pseudo-name-row:hover .pseudo-display { color: var(--accent); }
.pseudo-name-row:hover .btn-edit-pseudo { color: var(--accent); opacity: 1; }
.pseudo-display { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; transition: color 0.15s; }
.btn-edit-pseudo {
  background: none; border: none; color: var(--text2);
  cursor: pointer; font-size: 14px; padding: 2px 5px; border-radius: 4px;
  flex-shrink: 0; transition: all 0.15s; line-height: 1; opacity: 0.7;
}
.btn-edit-pseudo:hover { color: var(--accent); opacity: 1; background: rgba(124,106,247,0.12); }
.sidebar-profile.editing { flex-wrap: wrap; }
.sidebar-profile.editing .pseudo-edit {
  width: 100%; flex-basis: 100%;
}
.pseudo-edit { display: flex; gap: 6px; align-items: center; width: 100%; }
.pseudo-edit input {
  flex: 1; background: var(--bg); border: 1.5px solid var(--accent);
  border-radius: 8px; color: var(--text);
  padding: 7px 12px; font-size: 14px;
  outline: none; min-width: 0; font-family: inherit;
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.pseudo-edit input:focus { border-color: var(--accent); }
.pseudo-edit button { background: none; border: none; cursor: pointer; padding: 4px 8px; border-radius: 6px; font-size: 13px; font-weight: 600; font-family: inherit; white-space: nowrap; }
#pseudo-save { color: var(--green); }
#pseudo-cancel { color: var(--red); }

/* Recovery buttons */
.profile-recovery-row { display: flex; gap: 6px; margin-top: 6px; }
.btn-recovery-small {
  flex: 1; font-size: 10px; font-weight: 600; padding: 4px 6px;
  border-radius: 6px; cursor: pointer; border: 1px solid var(--border2);
  background: var(--bg3); color: var(--text2);
  white-space: nowrap; transition: all 0.15s; font-family: inherit;
}
.btn-recovery-small:hover { border-color: var(--accent); color: var(--accent); }
.btn-recovery-restore { border-color: rgba(0,220,80,0.3); color: var(--green); }
.btn-recovery-restore:hover { border-color: var(--green); background: rgba(0,220,80,0.1); }

/* Recovery phrase modal */
.recovery-phrase-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin: 16px 0;
}
.recovery-word {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 8px; padding: 8px 10px;
  display: flex; align-items: center; gap: 8px;
}
.recovery-word-num { font-size: 10px; color: var(--muted); font-weight: 700; min-width: 16px; }
.recovery-word-text { font-size: 13px; font-weight: 600; color: var(--text); font-family: monospace; }
.recovery-warning {
  background: rgba(255,181,64,0.12); border: 1px solid rgba(255,181,64,0.3);
  border-radius: 10px; padding: 12px 14px; font-size: 12px;
  color: var(--yellow); margin-bottom: 12px; line-height: 1.5;
}
.recovery-input-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0;
}
.recovery-input-grid input {
  background: var(--bg3); border: 1px solid var(--border2); border-radius: 8px;
  color: var(--text); padding: 8px; font-size: 12px; text-align: center;
  font-family: monospace; outline: none; width: 100%;
}
.recovery-input-grid input:focus { border-color: var(--accent); }

.sidebar-sections { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.sidebar-section { overflow-y: auto; padding: 8px 0; }
.sidebar-section.channels-section { flex: 1; border-top: 1px solid var(--border); }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  color: var(--muted); text-transform: uppercase;
}
.btn-icon {
  background: var(--accent); border: none; color: #fff;
  cursor: pointer; font-size: 15px;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  transition: all 0.15s; line-height: 1;
  box-shadow: 0 2px 8px var(--accent-glow);
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--accent2); transform: scale(1.1); box-shadow: 0 3px 12px var(--accent-glow); }
.wall-badge {
  background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
  animation: badgePop 0.25s ease;
}
@keyframes badgePop { from { transform: scale(0); } to { transform: scale(1); } }

.user-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  cursor: pointer; border-radius: 8px;
  margin: 1px 8px;
  transition: background 0.12s;
}
.user-item:hover { background: var(--hover); }
.user-item.me { cursor: default; }
.user-item.me:hover { background: transparent; }
.user-name { font-size: 13px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.user-item.me .user-name { color: var(--text); font-weight: 500; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex-shrink: 0; box-shadow: 0 0 5px var(--green); }
.dm-unread {
  background: var(--accent); color: white;
  font-size: 10px; padding: 1px 6px;
  border-radius: 10px; font-weight: 700;
  min-width: 18px; text-align: center;
}

.dm-pending-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
  margin-left: auto;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.5);
  animation: dmPulse 1.5s ease-in-out infinite;
}
@keyframes dmPulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
  70%  { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

.channel-item {
  display: flex; flex-direction: column;
  margin: 1px 8px;
  cursor: pointer; border-radius: 8px;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.channel-item:hover > .channel-item-main { background: var(--hover); border-radius: 7px; }
.channel-item.active { border-color: rgba(124,106,247,0.3); }
.channel-item.active > .channel-item-main {
  background: linear-gradient(135deg, rgba(124,106,247,0.15), rgba(124,106,247,0.06));
  border-radius: 7px;
}
.channel-item.active .channel-name { color: var(--accent); font-weight: 600; }
.channel-item.dragging { opacity: 0.4; cursor: grabbing; }
.channel-item.drag-over { border-color: var(--accent); background: rgba(124,106,247,0.08); border-radius: 8px; }
.channel-item-main {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
}
.channel-prefix { color: var(--muted); font-size: 15px; flex-shrink: 0; line-height: 1; }
.channel-name { font-size: 13px; color: var(--text2); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-lock { font-size: 11px; }

/* ── Main content ── */
#content { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg-glass); backdrop-filter: blur(1px); -webkit-backdrop-filter: blur(1px); min-width: 0; }

/* ── Tab bar ── */
#tab-bar {
  height: 48px; min-height: 48px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  display: flex; align-items: center;
  padding: 0 12px; gap: 4px;
  flex-shrink: 0;
  overflow: hidden;
}
.tabbar-left {
  display: flex; align-items: center; gap: 4px;
  flex-shrink: 0;
}
.tabbar-logo {
  display: none;
  width: 26px; height: 26px;
  border-radius: 6px;
  flex-shrink: 0;
}
#tabs-container {
  display: flex; gap: 4px; align-items: center;
  overflow-x: auto; flex: 1;
}
#tabs-container::-webkit-scrollbar { height: 2px; }
#tabs-container::-webkit-scrollbar-thumb { background: var(--border); }
#btn-sidebar-toggle {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  background: transparent; border: none; cursor: pointer;
  gap: 4px; padding: 6px; margin-right: 4px;
  transition: background 0.15s;
}
#btn-sidebar-toggle:hover { background: var(--hover); }
.hamburger-icon,
.hamburger-icon::before,
.hamburger-icon::after {
  display: block; width: 18px; height: 2px;
  background: var(--text2); border-radius: 2px;
  transition: transform 0.25s, opacity 0.25s;
}
.hamburger-icon { position: relative; }
.hamburger-icon::before { content:''; position: absolute; top: -5px; left: 0; }
.hamburger-icon::after  { content:''; position: absolute; bottom: -5px; left: 0; }
/* Animate to × when open (sidebar not collapsed on mobile) */
#main-ui.sidebar-mobile-open .hamburger-icon { background: transparent; }
#main-ui.sidebar-mobile-open .hamburger-icon::before { transform: translateY(5px) rotate(45deg); background: var(--text); }
#main-ui.sidebar-mobile-open .hamburger-icon::after  { transform: translateY(-5px) rotate(-45deg); background: var(--text); }
.tab {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--text2); white-space: nowrap;
  transition: all 0.15s;
}
.tab:hover { background: var(--hover); color: var(--text); }
.tab.active {
  background: var(--bg3); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border2);
}
.tab-close { font-size: 14px; color: var(--muted); margin-left: 2px; opacity: 0; transition: opacity 0.1s; line-height: 1; }
.tab:hover .tab-close { opacity: 1; }
.tab-close:hover { color: var(--red); }

/* ── Content header ── */
#content-header { border-bottom: 1px solid var(--border); background: var(--bg2-glass); backdrop-filter: blur(1px); -webkit-backdrop-filter: blur(1px); flex-shrink: 0; }
.ch-wall { padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; }
.ch-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; letter-spacing: -0.2px; }
.ch-sub { font-size: 12px; color: var(--text2); font-weight: 400; }
.ch-channel { padding: 12px 20px; display: flex; align-items: center; gap: 10px; }
.ch-channel-name { font-weight: 700; flex: 1; font-size: 15px; letter-spacing: -0.2px; }
.ch-members { font-size: 12px; color: var(--text2); }
.btn-leave {
  background: none; border: 1px solid var(--border);
  color: var(--text2); padding: 5px 13px;
  border-radius: 8px; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.btn-leave:hover { border-color: var(--red); color: var(--red); background: rgba(255,85,114,0.07); }
.btn-del-chan {
  background: none; border: 1px solid rgba(255,85,114,0.3);
  color: var(--red); padding: 5px 13px;
  border-radius: 8px; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; margin-left: 6px;
}
.btn-del-chan:hover { background: var(--red); color: white; border-color: var(--red); }
.ch-dm { padding: 12px 20px; display: flex; align-items: center; gap: 10px; }
.ch-dm-info { display: flex; flex-direction: column; gap: 2px; }
.ch-dm-name { font-weight: 700; font-size: 15px; letter-spacing: -0.2px; }
.ch-dm-status { font-size: 12px; color: var(--green); font-weight: 500; }
.dm-ctx-channel { font-size: 11px; color: var(--text2); background: var(--bg3); border-radius: 8px; padding: 1px 7px; display: inline-block; }

/* ── Messages ── */
#messages-area {
  flex: 1; overflow-y: auto;
  padding: 20px;
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
}
#messages-area::before {
  content: 'WeeAir';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-25deg);
  font-size: 72px;
  font-weight: 900;
  letter-spacing: -2px;
  color: var(--accent);
  opacity: 0.06;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  z-index: 0;
}
#messages-area.drag-over::after {
  content: '';
  position: absolute; inset: 8px;
  border: 2.5px dashed var(--accent);
  border-radius: 16px;
  background: rgba(124,106,247,0.07);
  pointer-events: none;
  z-index: 10;
}
#messages-area .drag-hint {
  position: absolute; inset: 0; z-index: 11;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; pointer-events: none;
}
#messages-area .drag-hint .dh-icon { font-size: 52px; }
#messages-area .drag-hint .dh-label { font-size: 18px; font-weight: 700; color: var(--accent); }
#messages-area .drag-hint .dh-limit { font-size: 12px; color: var(--text2); background: var(--bg2); padding: 3px 12px; border-radius: 20px; }
.msgs-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--muted); gap: 12px;
}
.msgs-empty-icon { font-size: 40px; opacity: 0.4; }
.msgs-empty-text { font-size: 14px; font-weight: 500; }

.msg-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  position: relative;
  transition: all 0.15s;
  animation: fadeUp 0.2s ease;
}
.msg-card:hover { border-color: var(--border2); background: var(--bg3); }
.msg-card.mine {
  border-color: rgba(124,106,247,0.28);
  background: rgba(124,106,247,0.05);
}
.msg-card.mine:hover {
  border-color: rgba(124,106,247,0.42);
  background: rgba(124,106,247,0.09);
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.msg-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.msg-author { font-weight: 600; font-size: 13px; }
.msg-time { font-size: 11px; color: var(--muted); flex: 1; }
.msg-duration {
  font-size: 10px; font-weight: 700;
  color: var(--text2);
  background: rgba(255,255,255,0.08);
  padding: 1px 7px; border-radius: 8px;
  letter-spacing: 0.04em;
}
/* Legacy text expiry (kept for DMs) */
.msg-expiry {
  display: flex; align-items: center; gap: 3px;
  font-size: 11px; padding: 2px 9px;
  border-radius: 12px; font-weight: 600;
}
.msg-expiry.ok { color: var(--green); background: rgba(61,214,140,0.1); }
.msg-expiry.warn { color: var(--yellow); background: rgba(255,179,64,0.1); }
.msg-expiry.urgent { color: var(--red); background: rgba(255,85,114,0.1); animation: blink 1s ease infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Expiry progress bar */
.msg-expiry-bar {
  height: 2px;
  background: rgba(255,255,255,0.04);
  border-radius: 0 0 10px 10px;
  overflow: hidden;
  margin-top: 8px;
  opacity: 0.55;
}
.msg-expiry-fill {
  height: 100%;
  border-radius: 0 0 10px 10px;
  transition: width 1s linear, background 1s;
}
.msg-expiry-fill.ok { background: var(--green); }
.msg-expiry-fill.warn { background: var(--yellow); }
.msg-expiry-fill.urgent { background: var(--red); animation: blink 1s ease infinite; }

.msg-actions { display: flex; gap: 3px; opacity: 0; transition: opacity 0.15s; }
.msg-card:hover .msg-actions { opacity: 1; }
.msg-actions button {
  background: none; border: none; cursor: pointer;
  padding: 3px 8px; border-radius: 6px;
  font-size: 11px; color: var(--muted); font-weight: 500;
  transition: all 0.1s;
}
.msg-actions button:hover { background: var(--hover); color: var(--text); }
.msg-actions .btn-del:hover { color: var(--red); }
.msg-body { font-size: 14px; line-height: 1.65; word-break: break-word; }
.msg-img {
  max-width: 380px; max-height: 280px;
  border-radius: 10px; object-fit: cover;
  cursor: pointer; display: block; margin-top: 10px;
  transition: opacity 0.15s;
  box-shadow: 0 4px 18px rgba(0,0,0,0.3);
}
.msg-img:hover { opacity: 0.88; }
.msg-file {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px;
  margin-top: 8px; max-width: 300px;
  transition: border-color 0.15s;
}
.msg-file:hover { border-color: var(--border2); }
.msg-file-icon { font-size: 22px; }
.msg-file-info { flex: 1; min-width: 0; }
.msg-file-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-file-size { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* Inline PDF viewer */
.msg-pdf-wrap {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
  background: var(--bg3);
}
.msg-pdf-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.msg-pdf-header .msg-file-name { flex: 1; font-size: 12px; font-weight: 600; }
.btn-pdf-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 6px;
  transition: all 0.15s;
}
.btn-pdf-toggle:hover { background: var(--hover); color: var(--text); }
.msg-pdf-frame {
  width: 100%; height: 480px;
  border: none; display: block;
  background: #fff;
}

/* DM bubbles */
.dm-row { display: flex; gap: 10px; align-items: flex-end; animation: fadeUp 0.15s ease; margin-bottom: 6px; padding: 0 8px; }
.dm-row.sent { flex-direction: row-reverse; }
.dm-content { max-width: 72%; min-width: 60px; display: flex; flex-direction: column; }
.dm-row.sent .dm-content { align-items: flex-end; }
.dm-row.received .dm-content { align-items: flex-start; }
.dm-bubble {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 18px; padding: 10px 16px;
  font-size: 14px; line-height: 1.55;
  word-break: break-word; white-space: pre-wrap;
}
.dm-row.sent .dm-bubble {
  background: var(--accent); color: white;
  border-color: var(--accent);
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 3px 12px var(--accent-glow);
}
.dm-row.received .dm-bubble { border-radius: 18px 18px 18px 4px; }
.dm-ts { font-size: 10px; color: var(--muted); margin-top: 3px; padding: 0 4px; }
.dm-row.sent .dm-ts { text-align: right; }
.dm-img { max-width: 260px; max-height: 220px; border-radius: 12px; object-fit: cover; cursor: pointer; display: block; margin-top: 4px; }

/* Transfer progress */
.transfer-wrap { margin-top: 8px; }
.transfer-bar-bg { height: 3px; background: var(--hover); border-radius: 3px; overflow: hidden; }
.transfer-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.2s; }
.transfer-label { font-size: 10px; color: var(--muted); margin-top: 3px; }

/* ── Composer ── */
#composer {
  border-top: 1px solid var(--border);
  background: var(--bg2);
  padding: 8px 12px 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}
.security-tagline {
  text-align: center;
  font-size: 10px;
  color: var(--text);
  opacity: 0.75;
  margin-top: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}
.composer-toolbar {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
}
.composer-toolbar-right { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.expiry-label { font-size: 11px; color: var(--muted); margin-right: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.expiry-selector { display: flex; align-items: center; gap: 4px; flex: 1; justify-content: center; }
.expiry-btn {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); padding: 4px 12px;
  border-radius: 14px; font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.expiry-btn:hover { border-color: var(--accent); color: var(--accent); }
.expiry-btn.active {
  background: rgba(124,106,247,0.14);
  border-color: var(--accent); color: var(--accent);
}
.composer-main {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 8px 8px 8px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.composer-main:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.btn-attach {
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: 4px; border-radius: 6px;
  transition: color 0.15s; flex-shrink: 0;
  display: flex; align-items: center;
}
.btn-attach:hover { color: var(--accent); }
.mic-active { color: #e53e3e !important; animation: mic-pulse 1s ease-in-out infinite; }
@keyframes mic-pulse { 0%,100% { opacity:1; } 50% { opacity:.4; } }
#message-input {
  flex: 1; background: none; border: none;
  color: var(--text); font-size: 14px;
  outline: none; resize: none;
  font-family: inherit; line-height: 1.5;
  max-height: 120px; overflow-y: auto;
}
#message-input::placeholder { color: var(--muted); }
.btn-send {
  background: var(--accent); border: none; color: white;
  width: 34px; height: 34px; border-radius: 10px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.15s;
  box-shadow: 0 2px 10px var(--accent-glow);
}
.btn-send:hover:not(:disabled) {
  background: var(--accent2);
  transform: scale(1.06);
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-send:disabled {
  background: var(--hover); color: var(--muted);
  cursor: not-allowed; box-shadow: none;
}

#file-preview {
  margin-top: 10px; padding: 10px 12px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 12px;
  display: flex; align-items: center; gap: 10px;
}
#file-preview img { max-height: 56px; max-width: 72px; border-radius: 6px; object-fit: cover; }
.fp-info { flex: 1; min-width: 0; }
.fp-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-size { font-size: 11px; color: var(--muted); margin-top: 1px; }
.btn-rm-file { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 17px; padding: 2px 4px; line-height: 1; transition: color 0.15s; }
.btn-rm-file:hover { color: var(--red); }

/* ── Drag & Drop overlay (removed — drop zone is now #messages-area) ── */
#drop-overlay { display: none !important; }

#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.78);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(10px);
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 24px 26px;
  width: 400px; max-width: 92vw;
  animation: modalIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 24px 64px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.9) translateY(-12px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 18px; letter-spacing: -0.3px; }
.modal-body { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 11px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 0.08em; }
.form-input {
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: 10px; color: var(--text);
  padding: 10px 13px; font-size: 14px;
  outline: none; transition: all 0.15s;
  font-family: inherit;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-hint { font-size: 11px; color: var(--muted); }
.form-error { font-size: 12px; color: var(--red); font-weight: 500; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal-create-header {
  text-align: center; padding: 8px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px; margin-top: -4px;
}
.modal-create-icon {
  font-size: 36px; margin-bottom: 8px;
  filter: drop-shadow(0 4px 10px rgba(124,106,247,0.4));
}
.modal-create-title {
  font-size: 20px; font-weight: 800; letter-spacing: -0.4px;
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.modal-create-subtitle { font-size: 12px; color: var(--muted); margin-top: 4px; }
.modal-actions.centered { justify-content: center; gap: 12px; }
.modal-actions.centered .btn-primary {
  padding: 11px 32px; font-size: 14px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  box-shadow: 0 4px 18px var(--accent-glow);
}
.btn {
  padding: 9px 18px; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
  border: none; font-family: inherit;
  letter-spacing: 0.01em;
}
.btn-primary {
  background: var(--accent); color: white;
  box-shadow: 0 2px 10px var(--accent-glow);
}
.btn-primary:hover {
  background: var(--accent2);
  box-shadow: 0 4px 14px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--bg3); color: var(--text2);
  border: 1px solid var(--border2);
}
.btn-secondary:hover { border-color: var(--text2); color: var(--text); background: var(--hover); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { opacity: 0.85; transform: translateY(-1px); }

/* ── Toasts ── */
#toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 999; pointer-events: none;
}
.toast {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 12px; padding: 12px 16px;
  font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  max-width: 320px;
  animation: slideR 0.25s ease, fadeOut 0.3s ease 2.7s forwards;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.04);
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }
@keyframes slideR { from { opacity: 0; transform: translateX(80px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* ── Lightbox ── */
#lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.95);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; cursor: zoom-out;
  backdrop-filter: blur(12px);
}
#lightbox img {
  max-width: 92vw; max-height: 92vh;
  border-radius: 12px; object-fit: contain;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}

/* ── Visibility toggle ── */
.btn-visibility {
  background: none; border: 1px solid var(--border);
  color: var(--text2); cursor: pointer;
  font-size: 11px; font-weight: 500; padding: 3px 10px;
  border-radius: 12px; margin-top: 3px;
  transition: all 0.15s;
}
.btn-visibility:hover { border-color: var(--accent); color: var(--accent); background: rgba(124,106,247,0.08); }
.btn-visibility.visibility-off { border-color: var(--muted); color: var(--muted); opacity: 0.65; }

.btn-push-toggle {
  background: none; border: 1px solid var(--border);
  color: var(--text2); cursor: pointer;
  font-size: 13px; padding: 2px 6px;
  border-radius: 10px; flex-shrink: 0;
  line-height: 1; transition: all 0.15s;
}
.btn-push-toggle:hover { border-color: var(--accent); background: rgba(124,106,247,0.08); }
.btn-push-toggle.push-active { border-color: var(--accent); color: var(--accent); }

/* ── Media in messages ── */
.msg-video {
  max-width: 400px; width: 100%;
  border-radius: 10px; display: block; margin-top: 8px;
  background: #000;
  box-shadow: 0 4px 18px rgba(0,0,0,0.3);
  cursor: pointer;
}
.msg-video-wrap {
  position: relative; display: inline-block;
  max-width: 400px; width: 100%; margin-top: 8px; cursor: pointer;
}
.msg-video-wrap .msg-video { margin-top: 0; pointer-events: none; }
.msg-video-play {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 42px; color: rgba(255,255,255,0.9);
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  background: rgba(0,0,0,0.18);
  border-radius: 10px;
  transition: background 0.15s;
}
.msg-video-wrap:hover .msg-video-play { background: rgba(0,0,0,0.32); }

/* ── TikTok-style Video Viewer ── */
#video-viewer {
  position: fixed; inset: 0; z-index: 2000;
  background: #000;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  touch-action: none; user-select: none;
}
#video-viewer.hidden { display: none; }
#video-viewer-player {
  max-width: 100%; max-height: 100dvh;
  width: 100%; object-fit: contain;
  outline: none;
}
#video-viewer-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(0,0,0,0.55); color: #fff;
  border: none; font-size: 18px; cursor: pointer;
  z-index: 2001; padding: 6px 11px; border-radius: 50%;
  line-height: 1;
}
#video-viewer-counter {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 13px; font-weight: 600;
  background: rgba(0,0,0,0.5); padding: 4px 14px; border-radius: 20px;
  pointer-events: none;
}
.video-nav-hint {
  position: absolute; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.55); font-size: 22px;
  pointer-events: none; transition: opacity 0.2s;
}
.video-nav-hint.up { top: 52px; }
.video-nav-hint.down { bottom: 14px; }
.video-nav-hint.disabled { opacity: 0.15; }
/* swipe animation */
@keyframes swipeUp { from { transform: translateY(0); opacity:1 } to { transform: translateY(-60px); opacity:0 } }
@keyframes swipeDown { from { transform: translateY(0); opacity:1 } to { transform: translateY(60px); opacity:0 } }
.video-viewer-anim-up { animation: swipeUp 0.25s ease forwards; }
.video-viewer-anim-down { animation: swipeDown 0.25s ease forwards; }

.msg-audio { width: 100%; max-width: 360px; display: block; margin-top: 8px; accent-color: var(--accent); }

/* ── CSV table ── */
.msg-csv-wrap { margin-top: 8px; }
.msg-csv-label { font-size: 12px; color: var(--text2); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; font-weight: 500; }
.btn-dl-inline { color: var(--accent); text-decoration: none; font-size: 12px; font-weight: 600; }
.btn-dl-inline:hover { text-decoration: underline; }
.msg-csv-scroll { overflow-x: auto; max-height: 220px; border-radius: 8px; border: 1px solid var(--border); }
.msg-csv-table { border-collapse: collapse; font-size: 12px; min-width: 100%; }
.msg-csv-table th {
  background: var(--bg3); padding: 7px 12px;
  text-align: left; font-weight: 700;
  color: var(--text2); border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0;
}
.msg-csv-table td { padding: 6px 12px; border-bottom: 1px solid var(--border); color: var(--text); white-space: nowrap; }
.msg-csv-table tr:last-child td { border-bottom: none; }
.msg-csv-table tr:hover td { background: rgba(255,255,255,0.025); }

/* ── TXT preview ── */
.msg-txt-wrap { margin-top: 8px; }
.msg-txt {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px;
  font-size: 12px; line-height: 1.6; color: var(--text2);
  overflow-x: auto; max-height: 200px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

/* ── PDF / file download ── */
.btn-dl {
  color: var(--accent); text-decoration: none;
  font-size: 12px; font-weight: 600;
  padding: 4px 10px;
  border: 1px solid rgba(124,106,247,0.4);
  border-radius: 7px; white-space: nowrap;
  transition: all 0.15s;
}
.btn-dl:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* ── Channel header extras ── */
.badge-readonly {
  font-size: 11px; font-weight: 600;
  background: rgba(255,179,64,0.12); color: var(--yellow);
  padding: 3px 10px; border-radius: 12px;
}
.ch-max { font-size: 12px; color: var(--muted); }
.btn-settings {
  background: none; border: 1px solid var(--border);
  color: var(--text2); padding: 5px 10px;
  border-radius: 8px; font-size: 14px;
  cursor: pointer; transition: all 0.15s;
}
.btn-settings:hover { border-color: var(--accent); color: var(--accent); background: rgba(124,106,247,0.08); }

/* ── Channel header with inline members ── */
.ch-channel { padding: 10px 20px 0; display: flex; flex-direction: column; gap: 0; }
.ch-channel-top { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; flex-wrap: wrap; }
.ch-channel-name { font-weight: 700; font-size: 15px; letter-spacing: -0.2px; }
.ch-member-count { font-size: 12px; color: var(--muted); margin-right: auto; }
.ch-actions { display: flex; align-items: center; gap: 6px; }

/* ── Sidebar channel item — actions + members ── */
.channel-item-actions {
  display: flex; gap: 4px; align-items: center;
  margin-left: auto; flex-shrink: 0;
  padding: 0;
}
.ch-action-btn {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); font-size: 13px; border-radius: 7px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.12s; flex-shrink: 0;
  padding: 0;
}
.ch-action-btn:hover { background: var(--hover); border-color: var(--border2); color: var(--text); }
.ch-action-btn.leave { border-color: rgba(255,85,114,0.3); color: var(--red); }
.ch-action-btn.leave:hover { background: rgba(255,85,114,0.12); border-color: var(--red); }
.ch-action-btn.delete { border-color: rgba(255,85,114,0.3); color: var(--red); }
.ch-action-btn.delete:hover { background: rgba(255,85,114,0.12); border-color: var(--red); }
.ch-action-btn.disabled { opacity: 0.45; cursor: not-allowed; }

.channel-item-members {
  display: flex; flex-direction: column; gap: 1px;
  padding: 4px 8px 8px;
  border-top: 1px solid rgba(124,106,247,0.12);
  margin: 0 4px;
}
.ch-sidebar-member {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 6px; border-radius: 6px;
  cursor: pointer; font-size: 12px; color: var(--text2);
  transition: all 0.1s;
}
.ch-sidebar-member:hover { background: rgba(124,106,247,0.1); color: var(--accent); }
.ch-sidebar-member.me { cursor: default; color: var(--text); font-weight: 500; }
.ch-sidebar-member.me:hover { background: transparent; color: var(--text); }
.ch-sidebar-member-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-sidebar-me { color: var(--muted); font-weight: 400; font-size: 10px; }

/* ── Simplified channel header ── */
.ch-channel-simple {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 20px;
}
.ch-channel-simple .ch-channel-name { font-weight: 700; font-size: 15px; letter-spacing: -0.2px; }
}
.ch-member-chip {
  display: flex; align-items: center; gap: 5px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px 3px 3px;
  font-size: 12px; transition: border-color 0.12s;
  cursor: default;
}
.ch-member-chip:hover { border-color: var(--border2); }
.ch-member-chip.me { border-color: rgba(124,106,247,0.35); background: rgba(124,106,247,0.08); }
.ch-chip-name { color: var(--text2); white-space: nowrap; }
.ch-member-chip.me .ch-chip-name { color: var(--text); font-weight: 600; }
.ch-chip-me { color: var(--muted); font-weight: 400; font-size: 11px; }
.ch-chip-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.ch-chip-dot.owner { background: var(--accent); box-shadow: 0 0 4px var(--accent-glow); }
.ch-chip-dot.admin { background: #a78bfa; }
.ch-member-crown {
  font-size: 11px; margin-left: 4px;
  color: #f5c518;
  filter: drop-shadow(0 1px 3px rgba(245,197,24,0.5));
  flex-shrink: 0;
}

/* ── Members panel — hidden, kept for DOM ── */
#members-panel { display: none !important; }

/* ── Channel settings modal ── */
.settings-section { background: var(--bg3); border-radius: 10px; padding: 14px 16px; border: 1px solid var(--border); }
.settings-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 10px; }
.members-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.member-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  background: var(--bg4);
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}
.member-row:hover { border-color: var(--border2); }
.member-name { flex: 1; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-badge { font-size: 10px; padding: 2px 8px; border-radius: 8px; font-weight: 700; white-space: nowrap; letter-spacing: 0.04em; }
.role-badge.owner { background: rgba(124,106,247,0.15); color: var(--accent); }
.role-badge.admin { background: rgba(167,139,250,0.15); color: #a78bfa; }
.btn-kick {
  background: none; border: 1px solid rgba(255,85,114,0.3);
  color: var(--red); font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: 7px;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn-kick:hover { background: var(--red); color: white; border-color: var(--red); }

/* ── Members panel ── */
#members-panel {
  width: 220px; min-width: 220px;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px; overflow-y: auto;
}
.mp-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }

/* ── TradingView Widget ── */
.tv-widget-wrap {
  width: 100%; height: 500px;
  margin-top: 10px; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border);
}
.tv-widget-wrap iframe { width: 100%; height: 100%; border: none; display: block; }

/* ── Link preview ── */
.msg-link { color: var(--accent); text-decoration: none; word-break: break-all; }
.msg-link:hover { text-decoration: underline; }

.link-preview {
  display: flex; align-items: stretch;
  margin-top: 10px; max-width: 460px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px; overflow: hidden;
  text-decoration: none; color: inherit;
  transition: border-color 0.15s, background 0.15s;
  background: var(--bg3);
}
.link-preview:hover { border-color: var(--accent); background: var(--hover); }

.lp-img {
  width: 110px; min-height: 80px;
  object-fit: cover; flex-shrink: 0;
  border-right: 1px solid var(--border);
}
.lp-info {
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 3px;
  flex: 1; min-width: 0;
}
.lp-site { font-size: 10px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 700; }
.lp-title { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-desc { font-size: 12px; color: var(--text2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lp-url { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.link-preview-yt {
  display: block;
  border-left: 3px solid #ff0000;
  max-width: 480px; aspect-ratio: 16/9;
  padding: 0;
}
.link-preview-yt iframe { width: 100%; height: 100%; display: block; border: none; }

/* ── Share button states ── */
.btn-share { background: none; border: 1px solid var(--border); color: var(--text2); padding: 5px 10px; border-radius: 8px; font-size: 13px; cursor: pointer; transition: all 0.15s; }
.btn-share:hover { border-color: var(--accent); color: var(--accent); background: rgba(124,106,247,0.08); }
.btn-share-locked { opacity: 0.35; cursor: not-allowed !important; }
.btn-share-locked:hover { border-color: var(--border) !important; color: var(--text2) !important; background: none !important; }

/* ── Channel owner badge ── */
.channel-owner-badge {
  font-size: 11px;
  color: var(--yellow);
  opacity: 0.85;
  line-height: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 0 3px rgba(255,179,64,0.4));
}
.chan-member-count {
  font-size: 10px; color: var(--muted);
  margin-left: auto; flex-shrink: 0;
  white-space: nowrap;
}

/* ── Clickable member chip ── */
.ch-member-chip.clickable { cursor: pointer; }
.ch-member-chip.clickable:hover {
  border-color: var(--accent);
  background: rgba(124,106,247,0.12);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px var(--accent-glow);
}
.ch-member-chip.clickable:hover .ch-chip-name { color: var(--accent); }

/* ── Responsive Sidebar ── */
@media (max-width: 700px) {
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    width: var(--sidebar) !important; min-width: var(--sidebar) !important;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    border-right: 1px solid var(--border) !important;
    z-index: 10;
  }
  #sidebar.collapsed { transform: translateX(-100%); }
  #main-ui.sidebar-mobile-open #sidebar { transform: translateX(0); }
  #main-ui.sidebar-mobile-open #sidebar-backdrop { display: block; }
  #content { width: 100%; }

  /* Hamburger: inline in tab-bar on mobile */
  #btn-sidebar-toggle {
    position: static;
    background: transparent;
    border-radius: 8px;
    min-width: 40px; min-height: 40px;
    flex-shrink: 0;
  }
  /* Show close button inside sidebar on mobile */
  .btn-sidebar-close { display: flex; }
  /* Hide hamburger when sidebar is open (close btn takes over) */
  #main-ui.sidebar-mobile-open #btn-sidebar-toggle { opacity: 0; pointer-events: none; }
  #tab-bar { padding-left: 4px; height: 40px; min-height: 40px; }
  .tabbar-logo { display: block; }

  /* Modals: slide up from bottom */
  #modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100% !important; width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 92vh; overflow-y: auto;
    padding: 20px 16px 32px;
  }

  /* Channel header: compact */
  .ch-channel { padding: 6px 12px; flex-wrap: wrap; gap: 4px; }
  .ch-wall { padding: 6px 12px; }
  .ch-dm { padding: 6px 12px; }
  .ch-channel-name { font-size: 13px; }
  .ch-dm-name { font-size: 13px; }
  .btn-leave, .btn-del-chan { padding: 4px 10px; font-size: 11px; min-height: 32px; }

  /* Composer — compact new layout */
  #composer { padding: 6px 10px 8px; }
  .composer-toolbar { margin-bottom: 5px; gap: 4px; }
  .expiry-btn { padding: 3px 8px; font-size: 10px; min-height: 28px; }
  .btn-attach { min-width: 36px; min-height: 36px; font-size: 17px; padding: 2px; }
  .composer-main { padding: 6px 6px 6px 10px; gap: 4px; }
  #btn-send { min-width: 38px; min-height: 38px; width: 38px; height: 38px; }
  #message-input { font-size: 16px; padding: 4px 2px; max-height: 80px; }

  /* Message cards */
  .msg-card { padding: 8px 10px; margin: 2px 6px; }
  .msg-author { font-size: 12px; }
  .msg-time { font-size: 10px; }
  .msg-text { font-size: 14px; line-height: 1.45; }

  /* Sidebar items — bigger tap targets */
  .channel-item { min-height: 40px; padding: 8px 10px; font-size: 13px; }
  .ch-sidebar-member { min-height: 38px; padding: 5px 8px; }
  .tab { padding: 5px 10px; font-size: 12px; min-height: 32px; }
  .tab-close { opacity: 1; min-width: 24px; min-height: 24px; font-size: 14px; }

  /* DM rows */
  .dm-row { padding: 8px 10px; }
  .dm-bubble { font-size: 14px; padding: 10px 13px; }

  /* Profile in sidebar */
  .sidebar-profile { padding: 10px 12px; min-height: 56px; }

  /* Call panel */
  #call-panel { height: 260px; }

  /* Incoming call: full width at top */
  #incoming-call { top: 8px; right: 8px; left: 8px; min-width: unset; }

  /* Group call banner */
  #group-call-banner { flex-direction: column; align-items: flex-start; gap: 6px; margin: 6px 8px 0; }

  /* Prevent horizontal overflow */
  body { overflow-x: hidden; }
}

/* ── Very small screens (≤ 400px) ── */
@media (max-width: 400px) {
  :root { --sidebar: 240px; }

  .modal { padding: 16px 12px 28px; }
  .modal-title { font-size: 16px; }
  .msg-card { margin: 2px 4px; }
  #call-panel { height: 200px; }
  .btn-group-call-video, .btn-group-call-audio { font-size: 14px; padding: 3px 6px; }
  .expiry-btn { padding: 3px 7px; font-size: 10px; }
  .call-panel-actions { gap: 4px; }
  .call-panel-btn { padding: 0 8px; font-size: 11px; }
}

/* ── Call overlay ── */
/* ── Call panel (embedded in content) ── */
#call-panel {
  flex-shrink: 0;
  display: flex; flex-direction: column;
  height: 500px; min-height: 44px; max-height: 85vh;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: #0d0d14;
  position: relative;
  /* no transition during resize, only for minimize */
}
#call-panel.animating { transition: height 0.25s ease; }
#call-panel.hidden { display: none !important; }
#call-panel.minimized { height: 44px; }
#call-panel.minimized #jitsi-container { display: none; }
#call-panel.minimized #call-resize-handle { display: none; }

/* Audio call mode: stays collapsed, bar has a live indicator */
#call-panel.audio-mode #call-panel-bar { background: rgba(30,15,60,0.95); border-bottom: 2px solid var(--accent); }
#call-panel.audio-mode #call-status::before {
  content: '●';
  color: #48bb78;
  margin-right: 5px;
  animation: audio-pulse 1.2s ease-in-out infinite;
}
@keyframes audio-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
#call-resize-handle {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 6px; cursor: ns-resize;
  background: transparent;
  z-index: 10;
}
#call-resize-handle:hover, #call-resize-handle.dragging {
  background: rgba(99,179,237,0.45);
}
#call-panel-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; height: 44px; flex-shrink: 0;
  background: rgba(0,0,0,0.6); gap: 12px;
}
#call-info {
  display: flex; align-items: center; gap: 10px; color: white; min-width: 0; flex: 1;
}
#call-peer-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#call-status { font-size: 12px; color: rgba(255,255,255,0.55); }
#call-duration { font-size: 12px; color: rgba(255,255,255,0.45); font-variant-numeric: tabular-nums; }
.call-panel-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.call-panel-btn {
  height: 32px; border-radius: 16px; padding: 0 12px;
  border: none; cursor: pointer; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,0.12); color: white;
  transition: all 0.2s; white-space: nowrap;
}
.call-panel-btn:hover { background: rgba(255,255,255,0.22); }
.call-panel-btn.danger { background: #e53e3e; }
.call-panel-btn.danger:hover { background: #c53030; }
#jitsi-container { flex: 1; width: 100%; min-height: 0; }
#jitsi-container iframe { width: 100%; height: 100%; border: none; }
.call-btn {
  height: 38px; border-radius: 20px; padding: 0 16px;
  border: none; cursor: pointer; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.15); color: white;
  transition: all 0.2s; flex-shrink: 0; white-space: nowrap;
}
.call-btn:hover { background: rgba(255,255,255,0.25); transform: scale(1.08); }
.call-btn.danger { background: #e53e3e; }
.call-btn.danger:hover { background: #c53030; }
.call-btn.accept { background: #38a169; width: auto; border-radius: 24px; padding: 0 18px; font-size: 14px; font-weight: 600; height: 44px; }
.call-btn.accept:hover { background: #2f855a; }
.call-btn.off { background: rgba(255,100,100,0.3); }

/* ── Incoming call panel ── */
#incoming-call {
  position: fixed; top: 20px; right: 20px; z-index: 1100;
  background: var(--bg2, #1a1a2e); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px; padding: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  min-width: 220px; box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  animation: slideInRight 0.3s ease;
}
#incoming-call.hidden { display: none !important; }
@keyframes slideInRight { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
#incoming-name { font-size: 17px; font-weight: 700; color: var(--text, white); }
#incoming-type { font-size: 12px; color: var(--muted, #aaa); }
#incoming-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ── DM call buttons ── */
.btn-call-video, .btn-call-audio {
  background: none; border: none; cursor: pointer; font-size: 18px;
  padding: 4px 6px; border-radius: 8px;
  transition: background 0.15s; color: var(--muted);
}
.btn-call-video:hover, .btn-call-audio:hover { background: var(--hover); color: var(--text); }

.btn-group-call-video, .btn-group-call-audio {
  background: rgba(124,106,247,0.12); border: 1px solid rgba(124,106,247,0.3);
  cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 8px;
  transition: background 0.15s; color: var(--accent); margin-left: 4px;
}
.btn-group-call-video:hover, .btn-group-call-audio:hover { background: rgba(124,106,247,0.25); }

#group-call-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(90deg, rgba(72,187,120,0.15), rgba(72,187,120,0.08));
  border: 1px solid rgba(72,187,120,0.35); border-radius: 8px;
  margin: 6px 16px 0; padding: 8px 14px; font-size: 13px;
}
#group-call-banner strong { color: var(--text); }
.btn-join-group-call {
  background: #48bb78; color: #fff; border: none; border-radius: 6px;
  padding: 5px 14px; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background 0.15s; white-space: nowrap;
}
.btn-join-group-call:hover { background: #38a169; }

/* ── Channel iframe embed ── */
.btn-iframe-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px; padding: 5px 12px;
  background: var(--bg3, rgba(255,255,255,0.07)); border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: 8px; cursor: pointer; font-size: 12px; color: var(--text2, #aaa);
  transition: background 0.15s, color 0.15s;
}
.btn-iframe-toggle:hover { background: var(--hover); color: var(--text); }
.msg-iframe-wrap { margin-top: 8px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border, rgba(255,255,255,0.12)); }
.msg-iframe-wrap.hidden { display: none; }
.msg-iframe { width: 100%; height: 480px; border: none; display: block; background: #fff; }

/* ── DM bubble reaction button ── */
.dm-bubble-wrap {
  position: relative; display: inline-flex; align-items: flex-end; gap: 4px;
  max-width: 100%;
}
.btn-dm-react {
  background: none; border: none; cursor: pointer;
  font-size: 14px; padding: 2px 3px; border-radius: 6px;
  color: var(--muted); opacity: 0; flex-shrink: 0;
  transition: opacity 0.15s, background 0.15s; line-height: 1;
  align-self: center;
}
.dm-row:hover .btn-dm-react { opacity: 1; }
.btn-dm-react:hover { background: var(--hover); }
.dm-reactions {
  display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px;
}
.dm-reactions .reaction-chip { font-size: 12px; padding: 1px 6px; }

/* ── Composer Emoji Picker ── */
.composer-emoji-picker {
  position: fixed; z-index: 1050;
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,0.55);
  width: 310px; overflow: hidden;
  animation: fadeIn 0.12s ease;
}
.cep-tabs {
  display: flex; gap: 2px; padding: 8px 8px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto; flex-shrink: 0;
}
.cep-tabs::-webkit-scrollbar { height: 2px; }
.cep-tab {
  background: none; border: none; cursor: pointer;
  font-size: 18px; padding: 5px 7px; border-radius: 8px 8px 0 0;
  transition: background 0.1s; flex-shrink: 0; line-height: 1;
}
.cep-tab:hover { background: var(--hover); }
.cep-tab.active { background: var(--bg3); border-bottom: 2px solid var(--accent); }
.cep-body { padding: 6px; max-height: 200px; overflow-y: auto; }
.cep-cat { display: flex; flex-wrap: wrap; gap: 1px; }
.cep-emoji {
  background: none; border: none; cursor: pointer;
  font-size: 20px; padding: 4px 5px; border-radius: 6px;
  transition: background 0.1s, transform 0.1s; line-height: 1.2;
}
.cep-emoji:hover { background: var(--hover); transform: scale(1.2); }

/* ── Credentials management ── */
.cred-row { transition: background 0.15s; }
.cred-row:hover { background: var(--hover) !important; }

/* ── Emoji Reactions ── */
.msg-reactions {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 6px; min-height: 0;
}
.reaction-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 12px; padding: 2px 8px;
  font-size: 13px; cursor: pointer; color: var(--text2);
  transition: all 0.15s; line-height: 1.4;
}
.reaction-chip:hover { border-color: var(--accent); background: var(--hover); }
.reaction-chip.mine {
  background: rgba(124,106,247,0.15);
  border-color: rgba(124,106,247,0.5);
  color: var(--accent);
}
.reaction-chip span { font-size: 11px; font-weight: 600; }
.btn-react {
  background: none; border: none; cursor: pointer;
  font-size: 15px; padding: 2px 4px; border-radius: 6px;
  color: var(--muted); opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  line-height: 1;
}
.msg-card:hover .btn-react { opacity: 1; }
.btn-react:hover { background: var(--hover); }
.reaction-picker {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 12px; padding: 6px 8px;
  display: flex; gap: 4px; z-index: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: fadeIn 0.1s ease;
}
.reaction-picker button {
  background: none; border: none; cursor: pointer;
  font-size: 22px; padding: 4px 6px; border-radius: 8px;
  transition: background 0.1s, transform 0.1s; line-height: 1;
}
.reaction-picker button:hover {
  background: var(--hover); transform: scale(1.25);
}
