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

:root {
  --bg-deep: #050510;
  --bg-panel: rgba(12, 14, 28, 0.75);
  --bg-panel-solid: #0c0e1c;
  --bg-input: rgba(0, 0, 0, 0.35);
  --cyan: #00f0ff;
  --cyan-dim: rgba(0, 240, 255, 0.15);
  --magenta: #ff2d95;
  --magenta-dim: rgba(255, 45, 149, 0.15);
  --purple: #8b5cf6;
  --green: #00ff88;
  --yellow: #ffd60a;
  --red: #ff3366;
  --gray: #6b7280;
  --text: #e8eaf6;
  --text-dim: #8892b0;
  --border: rgba(0, 240, 255, 0.2);
  --border-glow: rgba(0, 240, 255, 0.5);
  --glass-blur: blur(20px);
  --font-display: 'Orbitron', sans-serif;
  --font-body: 'Inter', sans-serif;
  --shadow-glow: 0 0 30px rgba(0, 240, 255, 0.15), 0 0 60px rgba(255, 45, 149, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ─── Animated Background ─── */
.bg-animation {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--bg-deep);
  pointer-events: none;
}

.bg-gradient {
  position: absolute;
  inset: -50%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(0, 240, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(255, 45, 149, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
    conic-gradient(from 0deg at 50% 50%, #050510, #0a0520, #10051a, #050510);
  animation: gradientSpin 30s linear infinite;
}

@keyframes gradientSpin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}

#bg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.bg-grid {
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  background-image:
    linear-gradient(rgba(0, 240, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.04) 1px, transparent 1px);
  background-size: 60px 60px;
  animation: gridMove 15s linear infinite;
  z-index: 2;
  transform-origin: center center;
}

@keyframes gridMove {
  0% { transform: translate(0, 0) perspective(500px) rotateX(60deg); }
  100% { transform: translate(60px, 60px) perspective(500px) rotateX(60deg); }
}

.bg-stars {
  position: absolute;
  inset: 0;
  z-index: 2;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 30% 65%, rgba(0,240,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 55% 15%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 70% 45%, rgba(255,45,149,0.4), transparent),
    radial-gradient(1px 1px at 85% 75%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 15% 85%, rgba(0,240,255,0.3), transparent),
    radial-gradient(1.5px 1.5px at 45% 90%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 92% 10%, rgba(255,45,149,0.5), transparent),
    radial-gradient(1px 1px at 5% 50%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 60% 55%, rgba(0,240,255,0.4), transparent);
  animation: starsTwinkle 4s ease-in-out infinite alternate;
}

@keyframes starsTwinkle {
  0% { opacity: 0.4; }
  100% { opacity: 1; }
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  z-index: 3;
  animation: orbFloat 10s ease-in-out infinite;
}

.bg-orb-1 {
  width: 450px;
  height: 450px;
  background: rgba(0, 240, 255, 0.15);
  top: -15%;
  left: -10%;
}

.bg-orb-2 {
  width: 400px;
  height: 400px;
  background: rgba(255, 45, 149, 0.12);
  bottom: -15%;
  right: -10%;
  animation-delay: -3s;
  animation-duration: 12s;
}

.bg-orb-3 {
  width: 300px;
  height: 300px;
  background: rgba(139, 92, 246, 0.12);
  top: 40%;
  left: 55%;
  animation-delay: -5s;
  animation-duration: 14s;
}

.bg-orb-4 {
  width: 200px;
  height: 200px;
  background: rgba(0, 255, 136, 0.08);
  top: 20%;
  right: 30%;
  animation-delay: -7s;
  animation-duration: 9s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(40px, -30px) scale(1.08); }
  50% { transform: translate(-20px, 40px) scale(0.92); }
  75% { transform: translate(30px, 20px) scale(1.04); }
}

.bg-flow-lines {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}

.bg-flow-lines::before,
.bg-flow-lines::after {
  content: '';
  position: absolute;
  width: 200%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.15), transparent);
  animation: flowLine 8s linear infinite;
}

.bg-flow-lines::before {
  top: 30%;
  left: -100%;
  animation-duration: 6s;
}

.bg-flow-lines::after {
  top: 70%;
  left: -100%;
  background: linear-gradient(90deg, transparent, rgba(255, 45, 149, 0.12), transparent);
  animation-duration: 9s;
  animation-delay: -4s;
}

@keyframes flowLine {
  0% { transform: translateX(0); }
  100% { transform: translateX(50%); }
}

.bg-scanline {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 240, 255, 0.02) 2px,
    rgba(0, 240, 255, 0.02) 4px
  );
  pointer-events: none;
  animation: scanPulse 3s ease-in-out infinite;
}

.bg-scanline::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(180deg, transparent, rgba(0, 240, 255, 0.04), transparent);
  animation: scanBeam 6s linear infinite;
}

@keyframes scanBeam {
  0% { top: -120px; }
  100% { top: 100%; }
}

@keyframes scanPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

.bg-vignette {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(5, 5, 16, 0.6) 100%);
  pointer-events: none;
}

/* ─── Glass Panel ─── */
.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glow);
  position: relative;
  z-index: 10;
}

.glass-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.3), transparent 40%, rgba(255, 45, 149, 0.2));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* ─── Login ─── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  z-index: 10;
  position: relative;
}

.login-window {
  width: 400px;
  overflow: hidden;
  animation: panelEnter 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes panelEnter {
  from { opacity: 0; transform: translateY(30px) scale(0.95); filter: blur(10px); }
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.login-header {
  padding: 28px 28px 0;
  text-align: center;
}

/* ─── XYAWCHAT Brand Title ─── */
.app-brand-bar {
  text-align: center;
  padding: 14px 16px 10px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(0, 240, 255, 0.06) 0%, transparent 100%);
}

.app-brand-bar--login {
  padding: 8px 0 4px;
  background: none;
}

.app-brand-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.08), transparent);
  transform: translateX(-100%);
  animation: brandSweep 5s ease-in-out infinite;
  pointer-events: none;
}

.app-brand-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 900;
  margin: 0;
  line-height: 1.1;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  position: relative;
  display: inline-block;
  animation: brandFloat 4s ease-in-out infinite;
}

.app-brand-bar--login .app-brand-title {
  font-size: 32px;
  letter-spacing: 0.32em;
  text-indent: 0.32em;
}

.brand-word {
  display: inline-block;
  background: linear-gradient(90deg, var(--cyan), #e8feff, var(--cyan));
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: brandShimmer 3s linear infinite;
  filter: drop-shadow(0 0 10px rgba(0, 240, 255, 0.45));
}

.brand-word--accent {
  background: linear-gradient(90deg, var(--magenta), #ffc8f0, var(--magenta));
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  animation: brandShimmer 3s linear infinite reverse;
  filter: drop-shadow(0 0 10px rgba(255, 0, 200, 0.4));
}

.brand-title-line {
  width: 120px;
  height: 2px;
  margin: 8px auto 0;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--magenta), transparent);
  border-radius: 2px;
  animation: brandLinePulse 2.5s ease-in-out infinite;
}

@keyframes brandShimmer {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

@keyframes brandFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes brandSweep {
  0%, 100% { transform: translateX(-100%); opacity: 0; }
  45% { opacity: 1; }
  55% { transform: translateX(100%); opacity: 1; }
}

@keyframes brandLinePulse {
  0%, 100% { opacity: 0.5; width: 100px; box-shadow: 0 0 8px var(--cyan-dim); }
  50% { opacity: 1; width: 140px; box-shadow: 0 0 16px var(--magenta-dim); }
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.brand-icon {
  font-size: 32px;
  color: var(--cyan);
  text-shadow: 0 0 20px var(--cyan), 0 0 40px rgba(0, 240, 255, 0.5);
  animation: iconPulse 3s ease-in-out infinite;
}

.brand-icon.small {
  font-size: 16px;
}

@keyframes iconPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.1); }
}

.brand-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: 4px;
}

.brand-sub {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  color: var(--cyan);
  letter-spacing: 8px;
}

.login-tagline {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.login-body {
  padding: 24px 28px 28px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.3s ease;
}

.auth-tab:hover {
  color: var(--text);
  background: rgba(0, 240, 255, 0.05);
}

.auth-tab.active {
  background: linear-gradient(135deg, var(--cyan-dim), var(--magenta-dim));
  color: var(--cyan);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
}

.login-form label,
.captcha-block label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.login-form input,
.captcha-answer,
.status-message-input,
.chat-input,
.gif-search {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  margin-bottom: 14px;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.login-form input:focus,
.captcha-answer:focus,
.status-message-input:focus,
.chat-input:focus,
.gif-search:focus {
  outline: none;
  border-color: var(--border-glow);
  box-shadow: 0 0 0 3px var(--cyan-dim), 0 0 20px rgba(0, 240, 255, 0.1);
}

.login-form input::placeholder,
.chat-input::placeholder,
.gif-search::placeholder {
  color: rgba(136, 146, 176, 0.5);
}

.remember-login {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -4px 0 14px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.remember-login input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--cyan);
  cursor: pointer;
  flex-shrink: 0;
}

.remember-login span {
  line-height: 1.3;
}

.btn-primary {
  position: relative;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--cyan);
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.15), rgba(255, 45, 149, 0.1));
  border-radius: var(--radius-sm);
  color: var(--cyan);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.3s ease;
}

.btn-primary:hover {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.25), rgba(255, 45, 149, 0.15));
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.3);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-glow {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.2), transparent);
  animation: btnShine 3s ease-in-out infinite;
}

@keyframes btnShine {
  0% { left: -100%; }
  50%, 100% { left: 100%; }
}

.form-error {
  color: var(--red);
  font-size: 12px;
  text-align: center;
  margin-top: 8px;
  min-height: 18px;
  text-shadow: 0 0 10px rgba(255, 51, 102, 0.3);
}

.form-success {
  color: var(--green);
  font-size: 12px;
  text-align: center;
  margin-top: 8px;
  min-height: 18px;
  text-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}

.captcha-block { margin-bottom: 4px; }

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

.captcha-image {
  flex: 1;
  height: 50px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #0a0c18;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 20px rgba(0, 240, 255, 0.06), 0 0 12px rgba(0, 240, 255, 0.08);
}

.captcha-image svg {
  display: block;
  width: 100%;
  height: 100%;
}

.captcha-refresh {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  color: var(--cyan);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.3s;
}

.captcha-refresh:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 15px var(--cyan-dim);
  transform: rotate(180deg);
}

.captcha-answer {
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 14px;
}

/* ─── Main Window ─── */
.main-window {
  width: 560px;
  height: 620px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: panelEnter 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.main-window-top {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  cursor: move;
  user-select: none;
}

.main-window-top .app-brand-bar {
  border-bottom: 1px solid rgba(0, 240, 255, 0.08);
}

.panel-header {
  padding: 10px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.my-avatar-wrap {
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
}

.my-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.15);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.my-avatar-wrap:hover .my-avatar {
  border-color: var(--border-glow);
  box-shadow: 0 0 16px var(--cyan-dim);
}

.my-avatar-initial {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
}

.contact-avatar,
.chat-titlebar-avatar {
  position: relative;
  overflow: visible;
}

.avatar-face.avatar-has-image {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  padding: 0;
}

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

.contact-avatar .status-dot,
.chat-titlebar-avatar .status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  z-index: 2;
  border: 2px solid var(--bg-panel-solid);
}

.my-username {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
}

.live-badge {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--green);
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.3);
  padding: 2px 8px;
  border-radius: 4px;
  animation: livePulse 2s ease-in-out infinite;
}

.admin-badge {
  display: inline-block;
  margin-left: 6px;
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--magenta);
  background: rgba(255, 45, 149, 0.12);
  border: 1px solid rgba(255, 45, 149, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  vertical-align: middle;
  box-shadow: 0 0 10px rgba(255, 45, 149, 0.2);
}

.contact-name .admin-badge,
.chat-titlebar-name .admin-badge {
  font-size: 7px;
  margin-left: 4px;
  padding: 1px 5px;
}

.role-badge {
  display: inline-block;
  margin-left: 6px;
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 2px 6px;
  border-radius: 4px;
  vertical-align: middle;
}

.role-badge.role-bronze {
  color: #e8a86b;
  background: rgba(205, 127, 50, 0.15);
  border: 1px solid rgba(205, 127, 50, 0.45);
}

.role-badge.role-silver {
  color: #d8e4f0;
  background: rgba(192, 192, 192, 0.12);
  border: 1px solid rgba(192, 192, 192, 0.4);
}

.role-badge.role-gold {
  color: #ffd76a;
  background: rgba(255, 215, 0, 0.12);
  border: 1px solid rgba(255, 215, 0, 0.45);
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.15);
}

.role-badge.role-vip {
  color: #ff9de8;
  background: linear-gradient(135deg, rgba(255, 45, 149, 0.2), rgba(180, 80, 255, 0.15));
  border: 1px solid rgba(255, 120, 220, 0.55);
  box-shadow: 0 0 10px rgba(255, 45, 149, 0.25);
}

.contact-name .role-badge,
.chat-titlebar-name .role-badge,
.my-username .role-badge {
  font-size: 7px;
  margin-left: 4px;
  padding: 1px 5px;
}

.settings-referral-role {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.settings-referral-progress,
.settings-referral-assigned {
  font-size: 11px;
  color: var(--text-dim);
}

.settings-referral-assigned {
  color: var(--magenta);
}

@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 5px rgba(0, 255, 136, 0.2); }
  50% { box-shadow: 0 0 15px rgba(0, 255, 136, 0.4); }
}

.panel-controls {
  display: flex;
  gap: 6px;
}

.panel-btn,
.titlebar-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.panel-btn:hover,
.titlebar-btn:hover {
  border-color: var(--border-glow);
  color: var(--text);
}

.panel-btn.close:hover,
.titlebar-btn.close:hover {
  border-color: var(--red);
  color: var(--red);
  box-shadow: 0 0 10px rgba(255, 51, 102, 0.3);
}

/* ─── Toolbar ─── */
.toolbar {
  padding: 10px 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.status-selector {
  position: relative;
  flex-shrink: 0;
}

.status-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text);
  min-width: 120px;
  transition: all 0.3s;
}

.status-btn:hover {
  border-color: var(--border-glow);
}

.dropdown-arrow {
  font-size: 10px;
  margin-left: auto;
  color: var(--text-dim);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; }
  50% { box-shadow: 0 0 8px 2px currentColor; }
}

.status-dot.online, .status-btn.online .status-dot { background: var(--green); color: var(--green); }
.status-dot.away { background: var(--yellow); color: var(--yellow); }
.status-dot.busy { background: var(--red); color: var(--red); }
.status-dot.offline { background: var(--gray); color: var(--gray); animation: none; }

.status-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-glow);
  z-index: 100;
  min-width: 160px;
  overflow: hidden;
  animation: menuDrop 0.2s ease-out;
}

@keyframes menuDrop {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.status-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-body);
  color: var(--text);
  text-align: left;
  transition: background 0.2s;
}

.status-menu button:hover {
  background: var(--cyan-dim);
}

.status-message-input {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
  padding: 8px 12px;
  font-size: 12px;
}

.main-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 6px 14px 10px;
  border-top: 1px solid rgba(255, 51, 102, 0.12);
  background: rgba(0, 0, 0, 0.25);
}

.btn-settings {
  padding: 5px 12px;
  border: 1px solid rgba(0, 240, 255, 0.35);
  background: rgba(0, 240, 255, 0.08);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--cyan);
  cursor: pointer;
  transition: all 0.3s;
  touch-action: manipulation;
}

.btn-settings:hover {
  background: rgba(0, 240, 255, 0.15);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
}

.label-optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-dim);
  font-size: 10px;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.settings-overlay.hidden {
  display: none;
}

.settings-modal {
  width: 100%;
  max-width: 420px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 20px;
  border-radius: var(--radius);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.settings-header h2 {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 3px;
  color: var(--cyan);
  margin: 0;
}

.settings-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-dim);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
}

.settings-close:hover {
  color: var(--text);
  border-color: var(--border-glow);
}

.settings-section {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.settings-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.settings-section h3 {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--magenta);
  margin: 0 0 12px;
  text-transform: uppercase;
}

.settings-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin: 6px 0 0;
  line-height: 1.4;
}

.settings-avatar-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.settings-avatar-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
}

.settings-avatar-preview .avatar-image,
.settings-avatar-preview .my-avatar-initial {
  width: 100%;
  height: 100%;
}

.settings-btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--cyan);
  background: rgba(0, 240, 255, 0.1);
  color: var(--cyan);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 1px;
  cursor: pointer;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-form input,
.settings-invite-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
}

.settings-action-btn {
  padding: 10px 14px;
  border: 1px solid var(--cyan);
  background: rgba(0, 240, 255, 0.12);
  color: var(--cyan);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 1px;
  cursor: pointer;
  white-space: nowrap;
}

.settings-invite-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.settings-invite-row .settings-invite-input {
  flex: 1;
  min-width: 0;
  font-size: 11px;
}

.settings-invite-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
}

.settings-link-btn {
  border: none;
  background: none;
  color: var(--magenta);
  font-size: 11px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.settings-msg {
  font-size: 12px;
  margin: 8px 0 0;
  min-height: 16px;
}

.settings-msg.ok { color: var(--green); }
.settings-msg.err { color: var(--red); }

.btn-logout {
  width: auto;
  padding: 5px 12px;
  border: 1px solid rgba(255, 51, 102, 0.35);
  background: rgba(255, 51, 102, 0.08);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--red);
  cursor: pointer;
  transition: all 0.3s;
  touch-action: manipulation;
}

.btn-logout:hover {
  background: rgba(255, 51, 102, 0.15);
  box-shadow: 0 0 15px rgba(255, 51, 102, 0.2);
}

/* ─── Main Content ─── */
.main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.sidebar {
  width: 220px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.15);
}

.sidebar-header {
  padding: 12px 16px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-title { color: var(--cyan); }

.sidebar-icon-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  background: rgba(0, 240, 255, 0.08);
  color: var(--cyan);
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: all 0.2s;
}

.sidebar-icon-btn:hover {
  border-color: var(--border-glow);
  box-shadow: 0 0 10px var(--cyan-dim);
}

.add-friend-panel {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.add-friend-panel.hidden {
  display: none;
}

.add-friend-input {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
  padding: 8px 10px;
  font-size: 12px;
}

.add-friend-send {
  flex-shrink: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--cyan-dim);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 1px;
  cursor: pointer;
  touch-action: manipulation;
}

.add-friend-send:hover {
  border-color: var(--border-glow);
}

.friend-requests {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 45, 149, 0.04);
}

.friend-requests.hidden {
  display: none;
}

.friend-request {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(0, 240, 255, 0.06);
  font-size: 11px;
}

.friend-request:last-child {
  border-bottom: none;
}

.friend-request-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
}

.friend-request.incoming .friend-request-text {
  color: var(--text);
}

.friend-request-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.friend-request-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  touch-action: manipulation;
}

.friend-request-btn.accept {
  color: var(--green);
}

.friend-request-btn.accept:hover {
  border-color: var(--green);
  background: rgba(0, 255, 136, 0.1);
}

.friend-request-btn.decline {
  color: var(--red);
}

.friend-request-btn.decline:hover {
  border-color: var(--red);
  background: rgba(255, 51, 102, 0.1);
}

.friend-request-pending {
  color: var(--yellow);
  font-size: 10px;
  flex-shrink: 0;
}

.friend-request-hint {
  color: var(--text-dim);
  font-weight: 400;
}

.online-count {
  color: var(--green);
  font-weight: 400;
}

.contact-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all 0.3s ease;
  user-select: none;
  animation: contactFadeIn 0.4s ease-out backwards;
  position: relative;
}

.contact-item:nth-child(1) { animation-delay: 0.05s; }
.contact-item:nth-child(2) { animation-delay: 0.1s; }
.contact-item:nth-child(3) { animation-delay: 0.15s; }
.contact-item:nth-child(4) { animation-delay: 0.2s; }
.contact-item:nth-child(5) { animation-delay: 0.25s; }

@keyframes contactFadeIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.contact-item:hover {
  background: var(--cyan-dim);
  border-color: var(--border);
  transform: translateX(4px);
}

.contact-item.active {
  background: linear-gradient(90deg, var(--cyan-dim), transparent);
  border-color: rgba(0, 240, 255, 0.3);
}

.contact-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  font-family: var(--font-display);
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
}

.contact-avatar .status-dot {
  width: 10px;
  height: 10px;
}

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

.contact-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.contact-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-status-msg {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-item.offline-contact .contact-name { color: var(--gray); }

.no-contacts {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.6;
}

/* ─── Welcome ─── */
.welcome-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.welcome-panel::before {
  content: '';
  position: absolute;
  width: 200px;
  height: 200px;
  border: 1px solid var(--border);
  border-radius: 50%;
  animation: welcomeRing 10s linear infinite;
}

@keyframes welcomeRing {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.welcome-content {
  text-align: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.welcome-ring {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ringPulse 3s ease-in-out infinite;
  box-shadow: 0 0 30px var(--cyan-dim);
}

@keyframes ringPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 20px var(--cyan-dim); }
  50% { transform: scale(1.05); box-shadow: 0 0 40px rgba(0, 240, 255, 0.3); }
}

.ring-inner {
  font-size: 28px;
  color: var(--cyan);
  text-shadow: 0 0 15px var(--cyan);
}

.welcome-content h2 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text);
  margin-bottom: 20px;
}

.welcome-greeting {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.welcome-line {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--cyan);
  margin: 0;
  line-height: 1.5;
}

/* ─── Statusbar ─── */
.statusbar {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.2);
}

.e2e-meter {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 4px 8px;
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  cursor: help;
}

.e2e-meter--secure {
  border-color: rgba(0, 255, 136, 0.35);
  box-shadow: 0 0 12px rgba(0, 255, 136, 0.15);
}

.e2e-meter-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 14px;
}

.e2e-bar {
  width: 4px;
  height: 6px;
  border-radius: 2px;
  background: rgba(107, 114, 128, 0.5);
  transition: height 0.3s, background 0.3s, box-shadow 0.3s;
}

.e2e-bar.mid {
  height: 10px;
  background: var(--yellow);
  box-shadow: 0 0 6px rgba(255, 214, 10, 0.4);
}

.e2e-bar.on {
  height: 14px;
  background: var(--green);
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.5);
}

.e2e-bar.off {
  height: 5px;
  background: rgba(255, 51, 102, 0.4);
}

.e2e-meter-label {
  font-family: var(--font-display);
  font-size: 8px;
  letter-spacing: 1.5px;
  color: var(--green);
}

.e2e-meter:not(.e2e-meter--secure) .e2e-meter-label {
  color: var(--yellow);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: statusPulse 1.5s ease-in-out infinite;
}

.connection-status.connected { color: var(--green); }
.connection-status.disconnected { color: var(--red); }
.connection-status.connecting { color: var(--yellow); }

.statusbar-right {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 2px;
}

.unread-badge {
  background: var(--magenta);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
  box-shadow: 0 0 12px var(--magenta-dim);
  flex-shrink: 0;
  line-height: 1.2;
  animation: unreadPop 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes unreadPop {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.contact-item:has(.unread-badge) {
  background: rgba(255, 0, 200, 0.06);
  border-left: 2px solid var(--magenta);
}

/* ─── Chat Windows ─── */
.chat-windows {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.chat-window {
  position: absolute;
  width: 400px;
  height: 500px;
  background: var(--bg-panel);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glow);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  touch-action: manipulation;
  animation: chatOpen 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 320px;
  min-height: 380px;
  overflow: hidden;
}

@keyframes chatOpen {
  from { opacity: 0; transform: scale(0.85) translateY(20px); filter: blur(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}

.chat-window.gif-picker-open {
  width: 440px;
  height: 640px;
  transition: width 0.3s ease, height 0.3s ease;
}

.chat-window.nudge-shake {
  animation: nudgeShake 0.5s ease-in-out;
}

@keyframes nudgeShake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-6px, -3px); }
  30% { transform: translate(6px, 3px); }
  45% { transform: translate(-4px, 2px); }
  60% { transform: translate(4px, -2px); }
  75% { transform: translate(-2px, 0); }
}

.chat-titlebar {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  cursor: move;
  user-select: none;
  background: rgba(0, 0, 0, 0.2);
}

.chat-titlebar-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.chat-titlebar-text {
  min-width: 0;
  flex: 1;
}

.chat-titlebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-display);
  color: white;
}

.chat-titlebar-name {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
}

.chat-titlebar-status {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-titlebar-avatar .status-dot {
  width: 9px;
  height: 9px;
}

.titlebar-buttons {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.chat-close-btn {
  display: flex;
}

/* ─── Messages ─── */
.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: block;
  -webkit-overflow-scrolling: touch;
}

.chat-message {
  max-width: 100%;
  padding: 4px 0;
  font-size: 13px;
  line-height: 1.6;
  word-wrap: break-word;
  animation: msgSlide 0.3s ease-out;
}

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

.chat-message .msg-sender {
  display: inline;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan-dim);
}

.chat-message.sent .msg-sender { color: var(--magenta); text-shadow: 0 0 10px var(--magenta-dim); }

.chat-message .msg-time {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
  opacity: 0.6;
}

.chat-message.system {
  text-align: center;
  color: var(--text-dim);
  font-size: 11px;
  font-style: italic;
  padding: 6px;
  animation: msgSlide 0.3s ease-out;
}

.chat-message.gif-message .msg-gif {
  display: block;
  max-width: 280px;
  max-height: 280px;
  border-radius: var(--radius-sm);
  margin: 6px 0 4px;
  border: 1px solid var(--border);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.1);
}

.typing-indicator {
  padding: 4px 14px;
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
  min-height: 20px;
}

.typing-indicator.active {
  color: var(--cyan);
  animation: typingGlow 1.5s ease-in-out infinite;
}

@keyframes typingGlow {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; text-shadow: 0 0 10px var(--cyan-dim); }
}

/* ─── Chat Input ─── */
.chat-input-area {
  position: relative;
  flex-shrink: 0;
  z-index: 20;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.85);
}

.chat-toolbar {
  position: relative;
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(0, 240, 255, 0.06);
}

.chat-tool-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.chat-tool-btn:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-dim);
  transform: translateY(-2px);
}

.chat-tool-btn.gif-btn {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 800;
  color: var(--magenta);
  letter-spacing: 0.5px;
}

.chat-tool-btn.gif-btn:hover {
  border-color: var(--magenta);
  box-shadow: 0 0 12px var(--magenta-dim);
}

.chat-tool-btn.voice-call-btn:hover {
  border-color: var(--green);
  box-shadow: 0 0 12px rgba(0, 255, 136, 0.2);
}

.chat-tool-btn.voice-memo-btn:hover {
  border-color: var(--purple);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.25);
}

.chat-tool-btn.voice-memo-btn.recording {
  border-color: var(--red);
  background: rgba(255, 51, 102, 0.2);
  animation: memoPulse 0.8s ease-in-out infinite;
}

@keyframes memoPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 51, 102, 0.3); }
  50% { box-shadow: 0 0 18px rgba(255, 51, 102, 0.6); }
}

.chat-message.voice-message .msg-voice-wrap {
  display: block;
  margin: 6px 0 4px;
  max-width: 260px;
}

.msg-voice {
  width: 100%;
  height: 36px;
  border-radius: var(--radius-sm);
}

.msg-voice-label {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
}

.msg-lock {
  font-size: 10px;
  opacity: 0.7;
  margin-left: 2px;
}

.chat-input-row {
  display: flex;
  padding: 10px 12px;
  gap: 8px;
}

.chat-input {
  flex: 1;
  margin-bottom: 0;
  padding: 10px 14px;
}

.btn-send {
  padding: 10px 18px;
  border: 1px solid var(--cyan);
  background: linear-gradient(135deg, var(--cyan-dim), var(--magenta-dim));
  border-radius: var(--radius-sm);
  color: var(--cyan);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.3s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.btn-send:hover {
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
  transform: translateY(-1px);
}

/* ─── Emoticon Picker ─── */
.emoticon-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-glow);
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  z-index: 200;
  margin-bottom: 4px;
  animation: menuDrop 0.2s ease-out;
}

.emoticon-picker button {
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.emoticon-picker button:hover {
  background: var(--cyan-dim);
  border-color: var(--border);
  transform: scale(1.15);
}

/* ─── GIF Picker ─── */
.gif-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4);
  z-index: 200;
  height: 340px;
  display: flex;
  flex-direction: column;
  animation: menuDrop 0.25s ease-out;
}

.gif-picker-header {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

.gif-search { margin-bottom: 0; padding: 8px 12px; font-size: 13px; }

.gif-picker-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.gif-picker-close:hover {
  color: var(--red);
  border-color: var(--red);
}

.gif-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 10px;
  min-height: 280px;
}

.gif-item {
  border: 2px solid transparent;
  padding: 0;
  background: rgba(0, 0, 0, 0.5);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  min-height: 150px;
  height: 150px;
  transition: all 0.25s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.gif-item:hover {
  border-color: var(--magenta);
  box-shadow: 0 0 20px var(--magenta-dim);
  transform: scale(1.02);
}

.gif-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.gif-loading, .gif-empty, .gif-error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--text-dim);
}

.gif-error { color: var(--red); }

.gif-powered {
  padding: 6px 10px;
  text-align: right;
  border-top: 1px solid var(--border);
}

.gif-powered img { opacity: 0.5; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(0, 240, 255, 0.2);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 240, 255, 0.35);
}

/* ─── Voice Call ─── */
.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 16, 0.75);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease;
}

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

.call-modal {
  width: 320px;
  padding: 32px 28px;
  text-align: center;
  animation: panelEnter 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.call-ring {
  width: 90px;
  height: 90px;
  margin: 0 auto 20px;
  border: 2px solid var(--green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: callRingPulse 1.5s ease-in-out infinite;
}

.call-overlay:has(#call-accept:not(.hidden)) .call-ring {
  border-color: var(--cyan);
  animation: callRingPulse 0.8s ease-in-out infinite;
}

@keyframes callRingPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.4); transform: scale(1); }
  50% { box-shadow: 0 0 0 16px rgba(0, 255, 136, 0); transform: scale(1.05); }
}

.call-ring-inner {
  font-size: 32px;
  color: var(--green);
  font-family: var(--font-display);
}

#call-username {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

#call-status-text {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 24px;
}

.call-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.call-btn {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  border: 1px solid;
  transition: all 0.3s;
}

.call-btn.accept {
  background: rgba(0, 255, 136, 0.15);
  border-color: var(--green);
  color: var(--green);
}

.call-btn.accept:hover {
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

.call-btn.reject {
  background: rgba(255, 51, 102, 0.1);
  border-color: var(--red);
  color: var(--red);
}

.call-btn.reject:hover {
  box-shadow: 0 0 20px rgba(255, 51, 102, 0.3);
}

.call-btn.hangup {
  background: rgba(255, 51, 102, 0.15);
  border-color: var(--red);
  color: var(--red);
}

.call-btn.hangup:hover {
  box-shadow: 0 0 20px rgba(255, 51, 102, 0.3);
}

/* ─── Mobile ─── */
@media (max-width: 768px) {
  body {
    overflow: auto;
    align-items: flex-start;
    min-height: 100dvh;
  }

  .login-screen {
    min-height: 100dvh;
    padding: 12px;
    align-items: flex-start;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .login-window {
    width: 100%;
    max-width: 100%;
    margin-top: 20px;
  }

  .main-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100dvh;
    max-width: 100%;
    transform: none;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .main-window.chat-hidden {
    visibility: hidden;
    pointer-events: none;
  }

  .main-window-top .app-brand-bar {
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .app-brand-title {
    font-size: 22px;
    letter-spacing: 0.22em;
    text-indent: 0.22em;
  }

  .app-brand-bar--login .app-brand-title {
    font-size: 26px;
    letter-spacing: 0.26em;
    text-indent: 0.26em;
  }

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

  .sidebar {
    width: 100%;
    max-height: 38dvh;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .contact-item {
    padding: 14px 12px;
    min-height: 56px;
  }

  .add-friend-input {
    font-size: 16px;
  }

  .friend-request-btn {
    width: 36px;
    height: 36px;
  }

  .welcome-panel {
    flex: 1;
    min-height: 0;
  }

  .welcome-panel::before,
  .welcome-panel .welcome-content {
    display: none;
  }

  .toolbar {
    gap: 6px;
    padding: 8px 10px;
  }

  .status-row {
    gap: 6px;
  }

  .status-btn {
    min-width: 0;
    padding: 6px 10px;
    font-size: 11px;
  }

  .status-message-input {
    font-size: 16px;
    padding: 8px 10px;
  }

  .main-footer {
    padding: 6px 12px max(10px, env(safe-area-inset-bottom));
  }

  .chat-close-btn {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .chat-titlebar {
    gap: 8px;
  }

  .chat-titlebar-info {
    min-width: 0;
    flex: 1;
  }

  .status-btn {
    min-height: 44px;
  }

  .statusbar {
    padding-bottom: 8px;
  }

  .chat-window {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100dvh !important;
    max-width: 100% !important;
    border-radius: 0;
    border-left: none;
    border-right: none;
    z-index: 1000 !important;
  }

  .chat-window.gif-picker-open {
    width: 100% !important;
    height: 100dvh !important;
  }

  .chat-window .gif-picker {
    position: absolute;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 55dvh;
    max-height: 400px;
    border-radius: var(--radius) var(--radius) 0 0;
    z-index: 30;
  }

  .chat-input-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 8px;
  }

  .chat-input {
    flex: 1;
    min-width: 0;
    font-size: 16px;
  }

  .btn-send {
    padding: 12px 20px;
    font-size: 12px;
    min-width: 80px;
  }

  .chat-titlebar {
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .chat-tool-btn,
  .panel-btn,
  .titlebar-btn,
  .btn-send,
  .btn-primary,
  .call-actions .call-btn {
    min-height: 44px;
    min-width: 44px;
  }

  .chat-input-row {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .gif-picker {
    height: 45dvh;
  }

  .gif-grid {
    grid-template-columns: repeat(2, 1fr);
    min-height: 200px;
  }

  .call-overlay {
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .call-modal {
    width: 100%;
    max-width: 340px;
  }

  .call-actions .call-btn {
    flex: 1;
    min-width: 120px;
    padding: 14px 16px;
  }

  .e2e-meter {
    padding: 3px 6px;
    gap: 4px;
  }

  .e2e-meter-bars {
    height: 12px;
  }

  .e2e-meter-label {
    font-size: 7px;
  }

  .bg-orb-1, .bg-orb-2 {
    width: 250px;
    height: 250px;
  }
}

@media (max-width: 380px) {
  .app-brand-title {
    font-size: 18px;
    letter-spacing: 0.18em;
    text-indent: 0.18em;
  }

  .app-brand-bar--login .app-brand-title {
    font-size: 22px;
  }

  .auth-tab {
    font-size: 10px;
    padding: 8px 6px;
  }

  .gif-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .gif-item {
    min-height: 120px;
    height: 120px;
  }
}