/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #020510;
  --bg-alt: #070d1c;
  --bg-panel: #0b1423;
  --bg-panel-soft: #111b2a;
  --accent: #2fa3ff;
  --accent-2: #8a6dff;
  --accent-soft: rgba(47, 163, 255, 0.22);
  --accent-soft-2: rgba(138, 109, 255, 0.28);
  --accent-green: #27e5a8;
  --danger: #ff5b6b;
  --danger-soft: rgba(255, 91, 107, 0.18);
  --text-main: #f5f7ff;
  --text-soft: #a8b0d8;
  --border-soft: rgba(255, 255, 255, 0.06);
  --shadow: 0 26px 60px rgba(0, 0, 0, 0.85);
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    system-ui, sans-serif;
  background:
    radial-gradient(circle at 0 0, rgba(47, 163, 255, 0.22) 0, transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(138, 109, 255, 0.25) 0, transparent 60%),
    linear-gradient(135deg, #01020a, #050816);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* 4D subtle moving background */
body::before {
  content: "";
  position: fixed;
  inset: -40%;
  pointer-events: none;
  background:
    radial-gradient(circle at 10% 0, rgba(47,163,255,0.22), transparent 60%),
    radial-gradient(circle at 90% 100%, rgba(138,109,255,0.3), transparent 70%);
  mix-blend-mode: screen;
  opacity: 0.75;
  animation: bgOrbit 40s linear infinite;
  z-index: -2;
}

@keyframes bgOrbit {
  0% {
    transform: translate3d(0,0,0) rotate(0deg);
  }
  50% {
    transform: translate3d(18px,-24px,0) rotate(180deg);
  }
  100% {
    transform: translate3d(0,0,0) rotate(360deg);
  }
}

/* Root container */
.app-root {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  position: relative;
}

/* Extra neon frame feel */
.app-root-neon::before {
  content: "";
  position: fixed;
  inset: 16px;
  border-radius: 28px;
  border: 1px solid rgba(47,163,255,0.4);
  box-shadow:
    0 0 40px rgba(47,163,255,0.4),
    0 0 90px rgba(138,109,255,0.4);
  opacity: 0.3;
  pointer-events: none;
  mix-blend-mode: screen;
  animation: framePulse 18s ease-in-out infinite;
  z-index: -1;
}

@keyframes framePulse {
  0% {
    opacity: 0.18;
    transform: scale(0.99);
  }
  50% {
    opacity: 0.45;
    transform: scale(1.01);
  }
  100% {
    opacity: 0.18;
    transform: scale(0.99);
  }
}

/* Floating particle layer */
.particle-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(255,255,255,0.12) 0, transparent 50%),
    radial-gradient(circle at 80% 10%, rgba(47,163,255,0.2) 0, transparent 50%),
    radial-gradient(circle at 20% 90%, rgba(39,229,168,0.16) 0, transparent 55%),
    radial-gradient(circle at 90% 80%, rgba(138,109,255,0.2) 0, transparent 55%);
  opacity: 0.4;
  mix-blend-mode: screen;
  animation: particleDrift 55s linear infinite;
  z-index: -1;
}

@keyframes particleDrift {
  0%   { transform: translate3d(0,0,0); }
  50%  { transform: translate3d(-30px,-20px,0); }
  100% { transform: translate3d(0,0,0); }
}

/* Screens */
.screen {
  width: 100%;
  max-width: 100%;
  height: 100vh;
}

.screen-centered {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

/* Glass card (login / nickname) */
.glass-card {
  width: 380px;
  max-width: 92vw;
  padding: 26px 26px 22px;
  border-radius: 26px;
  background:
    radial-gradient(circle at top left, rgba(47, 163, 255, 0.25), transparent 55%),
    radial-gradient(circle at bottom right, rgba(138, 109, 255, 0.3), transparent 60%),
    linear-gradient(145deg, #111b2a, #060b16);
  box-shadow: 0 32px 70px rgba(0, 0, 0, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  overflow: hidden;
  transform-style: preserve-3d;
  animation: floatCard 10s ease-in-out infinite;
}

.login-card-orbit {
  position: absolute;
  inset: -40%;
  background:
    radial-gradient(circle at 0 0, rgba(47,163,255,0.45), transparent 60%),
    radial-gradient(circle at 100% 100%, rgba(138,109,255,0.4), transparent 60%);
  mix-blend-mode: screen;
  opacity: 0.55;
  filter: blur(2px);
  animation: orbitSoft 24s linear infinite;
  pointer-events: none;
}

@keyframes floatCard {
  0% { transform: translate3d(0, 0, 0) rotateX(0deg) rotateY(0deg); }
  50% { transform: translate3d(0, -8px, 10px) rotateX(3deg) rotateY(-3deg); }
  100% { transform: translate3d(0, 0, 0) rotateX(0deg) rotateY(0deg); }
}

@keyframes orbitSoft {
  0% { transform: translate3d(0,0,0) rotate(0deg); }
  100% { transform: translate3d(0,0,0) rotate(360deg); }
}

/* Login header */
.login-logo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.login-logo-row.small {
  margin-bottom: 10px;
}

.login-orb {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 0, #ffffff 0, transparent 55%),
    conic-gradient(from 210deg, #2fa3ff, #2fe9ff, #8a6dff, #2fa3ff);
  box-shadow: 0 0 24px rgba(47,163,255,0.9);
  animation: floatAvatar 8s ease-in-out infinite;
}

.login-orb.small {
  width: 32px;
  height: 32px;
}

.login-logo-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.login-brand {
  font-size: 16px;
  font-weight: 700;
}

.login-tagline {
  font-size: 12px;
  color: var(--text-soft);
}

.card-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 6px;
}

.card-sub {
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 14px;
}

/* Forms */
.form-vertical {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 12px;
  color: var(--text-soft);
}

.field-input {
  border-radius: 10px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: #060b16;
  color: var(--text-main);
  font-size: 14px;
  outline: none;
}

.field-input.small {
  padding: 6px 8px;
  font-size: 13px;
}

.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

/* login options */
.login-options-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2px;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-soft);
}

.checkbox-row input {
  accent-color: var(--accent);
}

.link-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
}

/* Hint box */
.hint-box {
  font-size: 11px;
  color: var(--text-soft);
  background: rgba(8, 16, 32, 0.9);
  border-radius: 10px;
  padding: 8px 9px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.hint-box ul {
  list-style: disc;
  padding-left: 18px;
}

/* Errors */
.form-error {
  min-height: 16px;
  font-size: 12px;
  color: var(--danger);
}

/* Buttons */
.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #020308;
  box-shadow: 0 0 26px rgba(47, 163, 255, 0.9);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(47, 163, 255, 1);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-ghost {
  background: rgba(7, 16, 29, 0.85);
  color: var(--text-soft);
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
}

.btn-ghost.small {
  font-size: 11px;
}

.btn-ghost:hover {
  background: rgba(15, 26, 45, 1);
}

/* login meta */
.login-footer-meta {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-soft);
  display: flex;
  justify-content: center;
  gap: 4px;
  opacity: 0.8;
}

.dot-sep {
  opacity: 0.6;
}

/* ==== APP SHELL ==== */
.app-shell {
  width: 100%;
  height: 100vh;
  background: linear-gradient(145deg, #07101d, #060b16);
  border-radius: 0;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  backdrop-filter: blur(26px);
  transform-style: preserve-3d;
}

.app-shell-glow {
  position: absolute;
  inset: -30%;
  background:
    radial-gradient(circle at 0 0, rgba(47,163,255,0.25), transparent 60%),
    radial-gradient(circle at 100% 100%, rgba(138,109,255,0.25), transparent 60%),
    radial-gradient(circle at 50% 100%, rgba(39,229,168,0.16), transparent 65%);
  mix-blend-mode: screen;
  opacity: 0.7;
  filter: blur(4px);
  pointer-events: none;
  animation: shellGlow 32s linear infinite;
}

@keyframes shellGlow {
  0% { transform: translate3d(-10px, 0, 0) rotate(0deg); }
  50% { transform: translate3d(6px, -12px, 0) rotate(180deg); }
  100% { transform: translate3d(-10px, 0, 0) rotate(360deg); }
}

/* main row inside shell */
.app-main-row {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

/* Global topbar */
.global-topbar {
  height: 56px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background:
    radial-gradient(circle at 0 0, rgba(47,163,255,0.18), transparent 55%),
    linear-gradient(135deg, #060c19, #030712);
  position: relative;
  z-index: 5;
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-orb {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 30% 0, #ffffff 0, transparent 55%),
    conic-gradient(from 210deg, #2fa3ff, #2fe9ff, #8a6dff, #2fa3ff);
  box-shadow: 0 0 18px rgba(47,163,255,0.9);
  animation: floatAvatar 8s ease-in-out infinite;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
}

.brand-status {
  font-size: 11px;
  color: var(--text-soft);
}

.brand-right {
  display: flex;
  gap: 6px;
}

.top-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: #07101d;
  color: var(--text-soft);
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}

.top-icon-btn:hover {
  background: #0e182a;
  box-shadow: 0 0 14px rgba(47,163,255,0.7);
}

.top-icon-btn:active {
  transform: scale(0.96);
}

/* Sidebar */
.sidebar {
  width: 32%;
  min-width: 260px;
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #0b1522, #050811);
  position: relative;
  z-index: 2;
}

/* Side header */
.side-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}

.side-actions {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.avatar-me {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 30% 0, #fff 0, transparent 52%),
    conic-gradient(from 210deg, #2fa3ff, #2fe9ff, #8a6dff, #2fa3ff);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #020308;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 0 18px rgba(47, 163, 255, 0.8);
  position: relative;
  overflow: hidden;
  transform-style: preserve-3d;
  animation: floatAvatar 8s ease-in-out infinite;
}

.avatar-me.has-photo {
  background: #050b15;
  box-shadow: 0 0 16px rgba(47, 163, 255, 0.6);
  background-size: cover;
  background-position: center;
  color: transparent;
}

.me-info span {
  display: block;
}

.me-name {
  font-size: 14px;
  font-weight: 600;
}

.me-tag {
  font-size: 11px;
  color: var(--text-soft);
}

@keyframes floatAvatar {
  0% { transform: translate3d(0,0,0); }
  50% { transform: translate3d(0,-3px,4px); }
  100% { transform: translate3d(0,0,0); }
}

/* Search & tabs */
.side-tools {
  padding: 10px 10px 6px;
  border-bottom: 1px solid var(--border-soft);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 999px;
  background: #08111e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 8px;
}

.search-box input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font-size: 13px;
}

.search-icon {
  font-size: 14px;
  opacity: 0.85;
}

.pill-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.pill {
  flex: 1;
  text-align: center;
  padding: 6px 0;
  border-radius: 999px;
  background: #08111e;
  color: var(--text-soft);
  font-size: 12px;
  border: none;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.12s ease;
}

.pill.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #020308;
  font-weight: 600;
}

.pill:active {
  transform: scale(0.97);
}

/* filter chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.chip {
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  padding: 4px 9px;
  font-size: 11px;
  background: #060b16;
  color: var(--text-soft);
  cursor: pointer;
}

.chip.active {
  background: rgba(47,163,255,0.22);
  color: var(--accent);
  border-color: var(--accent-soft);
}

.new-group-btn {
  width: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background: #07101d;
  color: var(--text-soft);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.16s ease, border 0.16s ease;
}

.new-group-btn span {
  font-size: 13px;
  margin-right: 4px;
}

.new-group-btn:hover {
  background: #0d1728;
  border-color: var(--accent-soft);
}

/* Chat list */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 6px 10px;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: 18px;
  cursor: pointer;
  position: relative;
  transition:
    background 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease,
    filter 0.18s ease;
  overflow: hidden;
}

.chat-item:hover {
  background: radial-gradient(circle at 0 0, rgba(47, 163, 255, 0.35), transparent 60%),
              linear-gradient(135deg, rgba(10, 20, 40, 0.95), rgba(5, 10, 25, 0.98));
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.95);
  transform: translate3d(0, -2px, 8px);
  filter: saturate(1.15);
}

.chat-item.active {
  background: radial-gradient(circle at 0 0, rgba(47, 163, 255, 0.4), transparent 55%),
    linear-gradient(135deg, rgba(47, 163, 255, 0.28), rgba(138, 109, 255, 0.22));
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.9);
  transform: translate3d(0,-1px,0);
}

/* skeleton */
.chat-item.skeleton {
  opacity: 0.5;
}

.shimmer-line {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.12), rgba(255,255,255,0.04));
  background-size: 180% 100%;
  animation: shimmer 1.6s infinite;
}

.shimmer-line.small {
  width: 80%;
  height: 8px;
}

.shimmer-line.tiny {
  width: 40px;
  height: 7px;
}

@keyframes shimmer {
  0% { background-position: -40% 0; }
  100% { background-position: 140% 0; }
}

.chat-item-main-line,
.chat-item-last-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-item-name,
.chat-item-snippet {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #101a2b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  position: relative;
  overflow: hidden;
}

.chat-avatar.has-photo {
  background-size: cover;
  background-position: center;
  color: transparent;
}

.status-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid #0b1522;
  background: #ff5b6b;
}

.status-dot.online {
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(39, 229, 168, 0.9);
}

.chat-meta {
  flex: 1;
}

.chat-title {
  font-size: 14px;
  font-weight: 500;
}

.chat-last {
  font-size: 12px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 11px;
}

.chat-time {
  color: var(--text-soft);
}

/* ===== MAIN AREA ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 0 0, rgba(47,163,255,0.12) 0, transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(138,109,255,0.20) 0, transparent 60%),
    radial-gradient(circle at 50% 100%, rgba(39,229,168,0.12) 0, transparent 65%),
    #020510;
  position: relative;
  z-index: 1;
}

.main-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #0a1423, #050811);
}

.main-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.main-chat-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.main-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #101a2b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  overflow: hidden;
}

.main-chat-avatar.has-photo {
  background-size: cover;
  background-position: center;
  color: transparent;
}

.main-title {
  font-size: 15px;
  font-weight: 600;
}

.main-sub {
  font-size: 12px;
  color: var(--text-soft);
}

.main-head-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.head-meta {
  font-size: 11px;
  color: var(--text-soft);
}

/* Header icon buttons (phone + menu + search) */
.icon-head-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #07101d;
  color: var(--text-soft);
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}

.icon-head-btn:hover {
  background: #0e182a;
  box-shadow: 0 0 14px rgba(47, 163, 255, 0.7);
}

.icon-head-btn:active {
  transform: scale(0.95);
}

/* Subheader ala Telegram */
.subheader-row {
  height: 38px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  background: rgba(3,6,16,0.88);
  font-size: 11px;
}

.subheader-left {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.subheader-pill {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-soft);
  cursor: pointer;
}

.subheader-pill.active {
  background: rgba(47,163,255,0.2);
  border-color: var(--accent-soft);
  color: var(--accent);
}

.subheader-right {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-soft);
}

.subheader-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent-green);
  box-shadow: 0 0 10px rgba(39,229,168,0.9);
}

/* Messages */
.messages {
  flex: 1;
  padding: 14px 18px 10px;
  overflow-y: auto;
  position: relative;
}

.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 13px;
  color: var(--text-soft);
  gap: 6px;
}

.empty-orb {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 0, #ffffff 0, transparent 55%),
    conic-gradient(from 210deg, #2fa3ff, #2fe9ff, #8a6dff, #2fa3ff);
  opacity: 0.85;
  margin-bottom: 8px;
  box-shadow: 0 0 32px rgba(47,163,255,0.9);
  animation: floatAvatarBig 10s ease-in-out infinite;
}

.empty-title {
  font-size: 15px;
}

.empty-sub {
  font-size: 12px;
}

.empty-tips {
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.85;
}

.empty-tips span {
  color: var(--accent);
  font-weight: 600;
}

.msg-row {
  margin-bottom: 10px;
  display: flex;
}

.msg-row.me {
  justify-content: flex-end;
}

.msg-bubble {
  max-width: 70%;
  padding: 8px 11px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  animation: msgIn 0.18s ease-out;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.65);
  cursor: default;
  transform-origin: 100% 100%;
  overflow: hidden;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.msg-row.me .msg-bubble {
  border-bottom-right-radius: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #050811;
}

.msg-row.other .msg-bubble {
  border-bottom-left-radius: 4px;
  background: var(--bg-panel-soft);
}

/* group color variations */
.msg-row.other .msg-bubble.group-color-0 {
  background: linear-gradient(135deg, #101b35, #182645);
}
.msg-row.other .msg-bubble.group-color-1 {
  background: linear-gradient(135deg, #132235, #1e3048);
}
.msg-row.other .msg-bubble.group-color-2 {
  background: linear-gradient(135deg, #151f37, #223157);
}
.msg-row.other .msg-bubble.group-color-3 {
  background: linear-gradient(135deg, #141f30, #23324a);
}
.msg-row.other .msg-bubble.group-color-4 {
  background: linear-gradient(135deg, #151e33, #27355a);
}

.msg-bubble::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 0 0, rgba(255, 255, 255, 0.12), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(0, 0, 0, 0.4), transparent 60%);
  mix-blend-mode: soft-light;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.msg-bubble:hover::after {
  opacity: 1;
}

.msg-author {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 3px;
  opacity: 0.9;
}

.msg-text {
  white-space: pre-wrap;
}

.msg-time {
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.75;
  text-align: right;
}

.msg-attachment img {
  max-width: 260px;
  border-radius: 10px;
  margin-top: 5px;
  display: block;
}

.msg-attachment a {
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
}

/* Deleted */
.msg-deleted {
  font-style: italic;
  opacity: 0.8;
}

/* Reply chip */
.reply-chip {
  font-size: 11px;
  padding: 4px 7px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid rgba(255, 255, 255, 0.28);
  margin-bottom: 4px;
}

.reply-chip span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-chip .reply-from {
  font-weight: 600;
  margin-bottom: 2px;
}

/* Typing */
.typing {
  font-size: 11px;
  color: var(--text-soft);
  padding: 0 16px 4px;
  min-height: 14px;
}

.typing span.dots {
  display: inline-block;
  width: 30px;
  text-align: left;
}

.typing span.dots::after {
  content: "";
  display: inline-block;
  width: 18px;
  height: 4px;
  border-radius: 4px;
  background: radial-gradient(circle, var(--accent), transparent);
  animation: typingDots 1s infinite;
}

@keyframes typingDots {
  0% {
    transform: translateX(0);
    opacity: 0.2;
  }
  50% {
    transform: translateX(5px);
    opacity: 0.9;
  }
  100% {
    transform: translateX(0);
    opacity: 0.2;
  }
}

/* Input bar */
.input-bar {
  padding: 8px 12px 12px;
  border-top: 1px solid var(--border-soft);
  background: #060b16;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-tools-top {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mini-tool-btn {
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  padding: 3px 8px;
  font-size: 10px;
  background: #07101d;
  color: var(--text-soft);
  cursor: pointer;
}

/* Reply preview */
.reply-preview {
  display: none;
  align-items: center;
  justify-content: space-between;
  border-radius: 12px;
  padding: 6px 10px;
  background: #0b1522;
  border-left: 3px solid var(--accent);
  font-size: 12px;
  color: var(--text-soft);
}

.reply-preview-main {
  max-width: 90%;
}

.reply-preview-title {
  font-weight: 600;
  margin-bottom: 2px;
  color: var(--text-main);
}

.reply-preview-snippet {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-preview-close {
  border: none;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 16px;
}

/* Input row */
.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
}

.input-inner {
  flex: 1;
  border-radius: 999px;
  background: #0b1522;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  min-width: 0;
}

.input-inner input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font-size: 14px;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 18px;
  transition: color 0.16s ease, transform 0.12s ease;
}

.icon-btn:hover {
  color: var(--accent);
}

.icon-btn:active {
  transform: scale(0.9);
}

.send-btn {
  border-radius: 999px;
  border: none;
  background: var(--accent-green);
  color: #020306;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(39, 229, 168, 0.9);
  font-size: 18px;
  transition: transform 0.12s ease, box-shadow 0.16s ease;
}

.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(39, 229, 168, 1);
}

.send-btn:active {
  transform: scale(0.95);
}

/* Emoji picker */
.emoji-picker {
  position: fixed;
  bottom: 86px;
  right: 26px;
  background: #060b16;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px;
  max-width: 260px;
  max-height: 220px;
  overflow: auto;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.9);
  z-index: 15;
  display: none;
}

.emoji-picker span {
  font-size: 20px;
  padding: 4px;
  cursor: pointer;
  display: inline-block;
}

.emoji-picker span:hover {
  background: #101a2b;
  border-radius: 8px;
}

/* Overlay panels (group & forward & profile) */
.overlay-panel {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 15, 0.86);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 18;
}

.panel-card {
  width: 360px;
  max-width: 90%;
  padding: 18px 16px;
  border-radius: 18px;
  background: linear-gradient(145deg, #111b2a, #060b16);
  border: 1px solid var(--border-soft);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.9);
  font-size: 13px;
  color: var(--text-main);
  position: relative;
  overflow: hidden;
}

.panel-card::before {
  content: "";
  position: absolute;
  inset: -40%;
  background:
    radial-gradient(circle at 0 0, rgba(47,163,255,0.35), transparent 60%),
    radial-gradient(circle at 100% 100%, rgba(138,109,255,0.3), transparent 60%);
  mix-blend-mode: screen;
  opacity: 0.4;
  pointer-events: none;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.panel-head h3 {
  font-size: 15px;
}

.panel-close {
  border: none;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 18px;
}

.panel-section-title {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 8px;
  margin-bottom: 4px;
}

.member-item,
.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 6px;
  border-radius: 8px;
}

.member-item span,
.user-item span {
  font-size: 13px;
}

.member-item button,
.user-item button {
  font-size: 11px;
  border-radius: 999px;
  border: none;
  padding: 4px 10px;
  cursor: pointer;
}

.btn-kick {
  background: #301019;
  color: #ff96a3;
}

.btn-invite {
  background: #10281e;
  color: var(--accent-green);
}

/* Message context menu */
.msg-menu {
  position: fixed;
  z-index: 30;
  background: #050811;
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 170px;
  display: none;
}

.msg-menu ul {
  list-style: none;
}

.msg-menu li {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg-menu li:hover {
  background: #111b2a;
}

.msg-menu li.danger {
  color: #ff9aa7;
}

.msg-menu li.disabled {
  opacity: 0.4;
  cursor: default;
}

.msg-menu li.disabled:hover {
  background: transparent;
}

/* Center modal (global confirm popup) */
.center-modal-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 10% 0, rgba(47,163,255,0.25), transparent 55%),
              rgba(2, 4, 12, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.center-modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.center-modal-card {
  width: 340px;
  max-width: 90%;
  border-radius: 22px;
  padding: 16px 18px 14px;
  background:
    radial-gradient(circle at top left, rgba(47,163,255,0.3), transparent 60%),
    linear-gradient(145deg, #10182b, #050916);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 28px 60px rgba(0,0,0,0.95);
  transform: translateY(10px) scale(0.94);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.center-modal-overlay.show .center-modal-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.center-modal-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.center-modal-body {
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 14px;
}

.center-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-btn {
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  border: none;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.modal-btn.ghost {
  background: #081020;
  color: var(--text-soft);
}

.modal-btn.danger {
  background: linear-gradient(135deg, #ff5b6b, #ff9aa7);
  color: #210208;
}

.modal-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.7);
}

.modal-btn:active {
  transform: scale(0.95);
}

/* Chat context menu */
.chat-context-menu {
  position: fixed;
  z-index: 40;
  background: #050811;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.95);
  border: 1px solid rgba(255,255,255,0.1);
  min-width: 200px;
  display: none;
}

.chat-context-menu ul {
  list-style: none;
}

.chat-context-menu li {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
}

.chat-context-menu li:hover {
  background: #111b2a;
}

.chat-context-menu li.danger {
  color: #ff9aa7;
}

.chat-context-menu li.separator {
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin: 2px 8px 4px;
  cursor: default;
}

/* Mobile long-press actions */
.mobile-chat-actions {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: linear-gradient(to bottom, rgba(0,0,0,0.65), rgba(0,0,0,0));
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8px;
}

.mobile-chat-actions.hidden {
  display: none;
}

.mobile-chat-actions-inner {
  width: 100%;
  max-width: 480px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
}

.mobile-action-cancel {
  border-radius: 999px;
  border: none;
  background: #07101d;
  color: var(--text-soft);
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.mobile-chat-actions-buttons {
  display: flex;
  gap: 8px;
}

.mobile-chat-actions-buttons button {
  border-radius: 999px;
  border: none;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  background: #07101d;
  color: var(--text-soft);
}

.mobile-chat-actions-buttons button:nth-child(2) {
  background: var(--danger-soft);
  color: #ff9aa7;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #101a2b;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.8);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.toast.show {
  opacity: 1;
  pointer-events: all;
}

/* Profil card */
.profile-card {
  backdrop-filter: blur(20px);
}

.profile-main {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
}

.profile-avatar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.profile-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 0, #fff 0, transparent 52%),
    conic-gradient(from 210deg, #2fa3ff, #2fe9ff, #8a6dff, #2fa3ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  color: #020308;
  box-shadow: 0 0 24px rgba(47,163,255,0.9);
  overflow: hidden;
  animation: floatAvatarBig 10s ease-in-out infinite;
}

.profile-avatar.has-photo {
  background-size: cover;
  background-position: center;
  color: transparent;
}

.btn-small {
  padding: 6px 10px;
  font-size: 12px;
}

.profile-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-meta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-soft);
}

.profile-meta div span:first-child {
  opacity: 0.7;
}

.profile-section {
  margin-top: 8px;
}

.call-log-list {
  max-height: 170px;
  overflow-y: auto;
  margin-top: 4px;
}

.call-log-item {
  padding: 6px 8px;
  border-radius: 10px;
  background: #0b1522;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.call-log-main {
  display: flex;
  flex-direction: column;
}

.call-log-name {
  font-weight: 600;
}

.call-log-meta {
  font-size: 11px;
  color: var(--text-soft);
}

.call-log-type.outgoing::before {
  content: "⬆ ";
}
.call-log-type.incoming::before {
  content: "⬇ ";
}
.call-log-type.missed::before {
  content: "⚠ ";
}

.profile-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.profile-contact-name {
  font-size: 15px;
  font-weight: 600;
}

.profile-contact-status {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 4px;
}

/* Mobile */
.mobile-toggle {
  display: none; /* diparkir untuk future JS */
}

.btn-back-mobile {
  display: none;
  border: none;
  background: #07101d;
  border-radius: 999px;
  color: var(--text-soft);
  padding: 4px 9px;
  font-size: 12px;
}

/* Floating dock desktop */
.floating-dock {
  position: absolute;
  right: 18px;
  bottom: 16px;
  display: flex;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(3,6,16,0.92);
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 18px 40px rgba(0,0,0,0.9);
  z-index: 10;
}

.dock-btn {
  border-radius: 999px;
  border: none;
  padding: 6px 9px;
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
}

.dock-btn.active {
  background: rgba(47,163,255,0.2);
  color: var(--accent);
}

.dock-icon {
  font-size: 14px;
}

/* Bottom nav mobile ala WA */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 54px;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: rgba(3,6,16,0.96);
  display: none;
  align-items: center;
  justify-content: space-around;
  z-index: 20;
  transition: opacity .25s ease, transform .25s ease;
}

.mb-nav-btn {
  flex: 1;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.mb-nav-btn.active {
  color: var(--accent);
}

.mb-nav-icon {
  font-size: 18px;
}

.mobile-bottom-nav.hidden {
  opacity: 0;
  transform: translateY(20px);
}

/* Tiny helpers */
.user-item.selected {
  background: rgba(47,163,255,0.25);
  border-left: 3px solid var(--accent);
}

.msg-bubble audio {
  width: 100%;
}

.msg-row.other .msg-bubble {
  padding: 12px 14px !important;
}

.ctx-selected {
  background: rgba(255,255,255,0.06);
}

.input-inner input#messageInput {
  width: 100%;
  max-width: 100%;
  border: none;
  background: transparent;
  color: #fff;
  outline: none;
  font-size: 14px;
  white-space: normal;
  word-break: break-word;
}

@keyframes floatAvatarBig {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  50%  { transform: translate3d(0, -4px, 10px) rotate(3deg); }
  100% { transform: translate3d(0, 0, 0) rotate(0deg); }
}

/* ============================================
   RESPONSIVE LAYOUT (DESKTOP vs MOBILE)
   ============================================ */

/* Desktop & tablet lebar */
@media (min-width: 861px) {
  /* full WA/Telegram style */
  .sidebar {
    display: flex;
  }
  .main {
    display: flex;
  }
  .mobile-bottom-nav {
    display: none !important;
  }
  .btn-back-mobile {
    display: none;
  }
}

/* Mobile */
@media (max-width: 860px) {
  .screen {
    height: 100vh;
  }

  .app-shell {
    height: 100vh;
    border-radius: 0;
  }

  /* Default: chat mode (sesuai class awal show-chat) */
  .sidebar {
    display: none;
    width: 100%;
    min-width: 0;
  }

  .app-shell.show-list .sidebar {
    display: flex;
  }
  .app-shell.show-list .main {
    display: none;
  }

  .app-shell.show-chat .sidebar {
    display: none;
  }
  .app-shell.show-chat .main {
    display: flex;
  }

  .btn-back-mobile {
    display: inline-flex;
  }

  .side-actions {
    display: none;
  }

  .floating-dock {
    display: none;
  }

  .mobile-bottom-nav {
    display: flex;
    opacity: 1;
    transform: translateY(0);
  }

  .messages {
    padding-bottom: 70px; /* kasih ruang untuk bottom nav */
  }

  .global-topbar {
    padding: 8px 10px;
  }

  .brand-status {
    display: none;
  }

  .input-inner input#messageInput {
    font-size: 13px;
  }
}

/* == AUTO REMOVE BOTTOM NAV WHEN IN CHAT SCREEN == */
/* Smooth transition for mobile bottom nav */
.mobile-bottom-nav {
  transition: opacity .25s ease, transform .25s ease;
}

/* On mobile chat screen, hide bottom nav so input bar tidak ketutup */
#screen-app.chat-open .mobile-bottom-nav {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* Saat chat aktif, input bar nempel ke bawah */
.app-shell.show-chat .input-bar {
  margin-bottom: 0 !important;
}