/* ====================================================================
   HaiTeman — style.css (BRIGHT THEME)
   Mobile-first, Vibrant Colorful Light UI
   Warna terinspirasi dari logo: pink, hijau, cyan, biru, kuning
   ==================================================================== */

/* ─── 1. Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Logo Color Palette ── */
  --col-pink:   #FF2D78;
  --col-green:  #00CC44;
  --col-cyan:   #00CCFF;
  --col-blue:   #3344EE;
  --col-yellow: #FFD600;

  /* ── Background (Apple Light Canvas) ── */
  --bg-base:       #F2F3F7;
  --bg-layer-1:    rgba(255, 255, 255, 0.82);
  --bg-layer-2:    rgba(246, 246, 248, 0.9);
  --bg-layer-3:    rgba(235, 236, 240, 0.85);
  --bg-glass:      rgba(255, 255, 255, 0.72);
  --bg-glass-2:    rgba(255, 255, 255, 0.94);
  --bg-hover:      rgba(0, 122, 255, 0.08);

  /* ── Primary = Apple System Blue & Accents ── */
  --primary:       #007AFF;
  --primary-light: #389BFF;
  --primary-dark:  #0062D2;
  --primary-glow:  rgba(0, 122, 255, 0.28);

  /* ── Accent colors ── */
  --accent:        #FF2D55;
  --accent-light:  #FF6482;
  --success:       #34C759;
  --warning:       #FF9500;
  --danger:        #FF3B30;

  /* ── Text (Apple Typography) ── */
  --text-primary:   #1D1D1F;
  --text-secondary: #424245;
  --text-muted:     #636366; /* kontras ≥5:1 (WCAG AA) */
  --text-dim:       #6B6B70; /* placeholder ≥4.5:1 */

  /* ── Borders (Apple Hairline) ── */
  --border:        rgba(0, 0, 0, 0.08);
  --border-active: rgba(0, 122, 255, 0.6);

  /* ── Status ── */
  --status-online:  #34C759;
  --status-away:    #FF9500;
  --status-offline: #AEAEB2;

  /* ── Sizing ── */
  --sidebar-w:     285px;
  --header-h:      62px;
  --input-h:       68px;
  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     18px;
  --radius-xl:     24px;
  --radius-full:   9999px;

  /* ── Typography (Apple San Francisco System Stack) ── */
  --font:          -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --text-xs:       0.75rem;
  --text-sm:       0.8125rem;
  --text-base:     0.9375rem;
  --text-lg:       1.125rem;
  --text-xl:       1.25rem;

  /* ── Transitions ── */
  --trans-fast:    0.15s ease;
  --trans-mid:     0.25s ease;
  --trans-slow:    0.4s ease;

  /* ── Shadows (lighter for bright theme) ── */
  --shadow-sm:     0 2px 8px rgba(91,95,239,0.1);
  --shadow-md:     0 4px 24px rgba(91,95,239,0.15);
  --shadow-glow:   0 0 30px var(--primary-glow);
  --shadow-card:   0 8px 32px rgba(91,95,239,0.12), 0 2px 8px rgba(0,0,0,0.04);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-base);
  min-height: 100vh;
  min-height: 100dvh; /* dvh menimpa vh bila didukung */
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }
ul { list-style: none; }
.hidden { display: none !important; }

/* ─── 2. Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-layer-3); }
::-webkit-scrollbar-thumb { background: rgba(91,95,239,0.25); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ─── 3. Auth Pages ──────────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1rem;
  /* Bright gradient background */
  background: linear-gradient(135deg, #E8F0FF 0%, #FFF0F7 40%, #F0FFF8 70%, #FFFFF0 100%);
}

.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}
.auth-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.35;
  animation: floatGlow 8s ease-in-out infinite alternate;
}
.auth-glow-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, var(--col-cyan), var(--col-blue), transparent);
  top: -150px; left: -150px;
}
.auth-glow-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, var(--col-pink), var(--col-yellow), transparent);
  bottom: -100px; right: -100px;
  animation-delay: -4s;
}

@keyframes floatGlow {
  from { transform: translate(0,0) scale(1); }
  to   { transform: translate(25px, 20px) scale(1.08); }
}

.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
}

.auth-card {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1.5px solid rgba(91,95,239,0.12);
  border-radius: var(--radius-xl);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow-card);
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.logo-icon {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  margin: 0 auto 0.75rem;
  display: block;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  object-fit: cover;
}
/* Fallback emoji logo */
.logo-icon-emoji {
  font-size: 2.8rem;
  margin-bottom: 0.5rem;
}
.logo-text {
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -0.5px;
}
.logo-text .hai { color: #1A1A3E; }
.logo-text .t   { color: var(--col-pink); }
.logo-text .e   { color: var(--col-green); }
.logo-text .m   { color: var(--col-cyan); }
.logo-text .a   { color: var(--col-blue); }
.logo-text .n   { color: var(--col-yellow); }
.logo-sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ─── 4. Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.125rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 400px) { .form-row { grid-template-columns: 1fr; } }

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}
.required { color: var(--danger); }
.form-hint {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon {
  position: absolute;
  left: 0.875rem;
  font-size: var(--text-sm);
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
}
.form-input {
  width: 100%;
  padding: 0.75rem 0.875rem 0.75rem 2.5rem;
  background: var(--bg-layer-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  outline: none;
  transition: border-color var(--trans-fast), box-shadow var(--trans-fast), background var(--trans-fast);
  -webkit-appearance: none;
}
.form-input::placeholder { color: var(--text-dim); }
.form-input:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
select.form-input { padding-left: 0.875rem; }

.toggle-password {
  position: absolute;
  right: 0.75rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  padding: 0.25rem;
  transition: color var(--trans-fast);
}
.toggle-password:hover { color: var(--primary); }

/* Password strength */
.strength-bar-wrap {
  height: 4px;
  background: var(--bg-layer-3);
  border-radius: var(--radius-full);
  margin-top: 0.5rem;
  overflow: hidden;
}
.strength-bar {
  height: 100%;
  width: 0;
  border-radius: var(--radius-full);
  transition: width 0.3s ease, background 0.3s ease;
}

/* ─── 5. Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 700;
  transition: all var(--trans-fast);
  border: 1.5px solid transparent;
  user-select: none;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(91,95,239,0.35);
}
.btn-ghost {
  background: var(--bg-layer-3);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--primary);
  color: var(--primary);
}
.btn-full { width: 100%; }
.btn-sm { padding: 0.5rem 1rem; font-size: var(--text-sm); }

.btn-loader { animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background var(--trans-fast), color var(--trans-fast);
  flex-shrink: 0;
  font-size: 1rem;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--primary);
}

/* ─── 6. Alerts ──────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: 1.25rem;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.alert-error   { background: rgba(255,59,92,0.08); border: 1.5px solid rgba(255,59,92,0.2); color: #cc1133; }
.alert-success { background: rgba(0,204,68,0.08); border: 1.5px solid rgba(0,204,68,0.2); color: #008822; }
.alert-info    { background: rgba(91,95,239,0.08); border: 1.5px solid rgba(91,95,239,0.2); color: var(--primary); }
.alert-icon { font-size: 1rem; flex-shrink: 0; }

/* ─── 7. Auth Footer ─────────────────────────────────────────────── */
.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.link { color: var(--primary); font-weight: 600; }

/* ─── 8. Chat Layout ─────────────────────────────────────────────── */
.chat-page {
  display: flex;
  height: 100vh;
  height: 100dvh; /* dvh menimpa vh bila didukung */
  overflow: hidden;
  background: var(--bg-base);
}

/* ─── 9. Sidebar (Apple macOS Translucent Sidebar) ─────────────────── */
.sidebar {
  width: var(--sidebar-w);
  height: 100%;
  background: rgba(246, 246, 248, 0.85);
  backdrop-filter: blur(30px) saturate(190%);
  -webkit-backdrop-filter: blur(30px) saturate(190%);
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: transform var(--trans-mid);
  z-index: 200;
  box-shadow: 1px 0 16px rgba(0, 0, 0, 0.04);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: var(--header-h);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Apple Macintosh Window Traffic Lights */
.mac-window-controls {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-right: 0.625rem;
  flex-shrink: 0;
}
.mac-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
  transition: all var(--trans-fast);
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  cursor: pointer;
}
.mac-dot-close {
  background: #FF5F56;
  border: 0.5px solid #E0443E;
}
.mac-dot-minimize {
  background: #FFBD2E;
  border: 0.5px solid #DEA123;
}
.mac-dot-maximize {
  background: #27C93F;
  border: 0.5px solid #1AAB29;
}
.mac-dot:hover {
  filter: brightness(0.88);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.brand-name {
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.3px;
}
.brand-name .hai { color: var(--text-primary); }
.brand-name .t   { color: var(--col-pink); }
.brand-name .e   { color: var(--col-green); }
.brand-name .m   { color: var(--col-cyan); }
.brand-name .a   { color: var(--col-blue); }
.brand-name .n   { color: var(--col-yellow); }

.profile-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-bottom: 1.5px solid var(--border);
  flex-shrink: 0;
  background: linear-gradient(135deg, #F8F9FF, #FFF0F7);
}
.profile-info { flex: 1; min-width: 0; }
.profile-name {
  display: block;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-username {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.sidebar-search {
  padding: 0.75rem 0.75rem 0.5rem;
  flex-shrink: 0;
}
.sidebar-search .input-icon { font-size: var(--text-xs); }
.sidebar-search .form-input {
  font-size: var(--text-sm);
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  background: var(--bg-layer-3);
  border-radius: var(--radius-full);
  border-color: transparent;
}
.sidebar-search .form-input:focus { border-color: var(--primary); }

/* Sidebar sections */
.sidebar-section {
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.sidebar-section:not(:last-child) { border-bottom: 1.5px solid var(--border); }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.75rem 0.375rem;
}
.section-title {
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.room-list, .user-list {
  overflow-y: auto;
  max-height: 220px;
  padding: 0 0.375rem 0.5rem;
}

.room-item, .user-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--trans-fast);
  min-height: 38px;
}
.room-item:hover, .user-item:hover {
  background: var(--bg-hover);
  transform: translateX(2px);
}
.room-item.active {
  background: #007AFF;
  color: #fff;
  border-left: none;
  box-shadow: 0 3px 10px rgba(0, 122, 255, 0.32);
}
.room-item.has-unread .room-name { font-weight: 700; color: var(--text-primary); }

.room-icon { font-size: 1rem; flex-shrink: 0; }
.room-name {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.room-item.active .room-name { color: #ffffff; font-weight: 600; }

.room-empty {
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: 0.5rem 0.625rem;
}
.user-name {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* Badge */
.badge {
  font-size: var(--text-xs);
  font-weight: 800;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-full);
  padding: 0.125rem 0.4rem;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 0.75rem;
  border-top: 1.5px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-layer-3);
}

.sidebar-section-online { flex: 1; overflow: hidden; }
.sidebar-section-online .user-list { max-height: unset; }

/* ─── 10. Avatars & Status ───────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; }
.avatar-md { width: 36px; height: 36px; }
.avatar-lg { width: 72px; height: 72px; }

.avatar-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.avatar-wrap-sm { width: 28px; height: 28px; }

.status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-layer-1);
  background: var(--status-offline);
}
.status-online  .status-dot { background: var(--status-online); }
.status-away    .status-dot { background: var(--status-away); }
.status-offline .status-dot { background: var(--status-offline); }

/* ─── 11. Main Area ──────────────────────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  background: var(--bg-base);
  overflow: hidden;
}

/* ─── 12. Chat Header (Apple macOS Titlebar) ─────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(25px) saturate(185%);
  -webkit-backdrop-filter: blur(25px) saturate(185%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  z-index: 10;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.03);
}
#openSidebarBtn { display: none; }

.chat-title {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex: 1;
  min-width: 0;
}
.chat-title-icon { font-size: 1.375rem; flex-shrink: 0; }
.chat-title-name {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-title-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-title:hover .chat-title-name { color: var(--primary); }
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: nowrap;
}
#roomMembersBtn {
  white-space: nowrap;
  flex-shrink: 0;
}
#roomMembersBtn span { display: inline; }
@media (max-width: 480px) {
  #roomMembersBtn span { display: none; }
  #roomMembersBtn { padding: 0.4rem; border-radius: var(--radius-sm); }
}

/* ─── 13. Messages Area (Apple Canvas) ───────────────────────────── */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.25rem 0.5rem;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
  background: linear-gradient(180deg, #F2F3F7 0%, #EAEBF2 100%);
}

.welcome-screen {
  margin: auto;
  text-align: center;
  padding: 2rem 1rem;
  max-width: 320px;
}
.welcome-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.welcome-screen h3 { font-size: var(--text-lg); margin-bottom: 0.5rem; color: var(--text-primary); font-weight: 700; }
.welcome-screen p { color: var(--text-muted); font-size: var(--text-sm); margin-bottom: 1.5rem; }

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
}

/* ─── Flying In & Out Message Animations ─── */
.msg-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.625rem;
  animation: flyInOther 0.34s cubic-bezier(0.16, 1, 0.3, 1) both;
  transform-origin: left bottom;
}
.msg-group.own {
  align-items: flex-end;
  animation: flyInOwn 0.34s cubic-bezier(0.16, 1, 0.3, 1) both;
  transform-origin: right bottom;
}

@keyframes flyInOwn {
  0% {
    opacity: 0;
    transform: translate3d(28px, 16px, 0) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}
@keyframes flyInOther {
  0% {
    opacity: 0;
    transform: translate3d(-28px, 16px, 0) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}
@keyframes flyOutMsg {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
    max-height: 250px;
    margin-bottom: 0.625rem;
  }
  100% {
    opacity: 0;
    transform: translate3d(0, -22px, 0) scale(0.85);
    max-height: 0;
    margin-bottom: 0;
    padding: 0;
  }
}
.msg-group.msg-flying-out {
  animation: flyOutMsg 0.32s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
  pointer-events: none;
}

/* Date divider */
.date-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0 0.75rem;
}
.date-divider::before, .date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
}
.date-divider-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 0.25rem 0.75rem;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius-full);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

/* Message rows */
.msg-row {
  display: flex;
  gap: 0.625rem;
  align-items: flex-end;
  padding: 0.125rem 0;
}
.msg-group.own .msg-row { flex-direction: row-reverse; }

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  align-self: flex-end;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.msg-avatar.invisible { visibility: hidden; }

.msg-content-wrap {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}

.msg-sender-name {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.25rem;
  padding-left: 0.75rem;
}
.msg-group.own .msg-sender-name {
  padding-left: 0; padding-right: 0.75rem;
  text-align: right;
  color: var(--accent);
}

/* ─── Floating Message Bubbles (Others) ─── */
.msg-bubble {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 18px;
  border-bottom-left-radius: 5px;
  padding: 0.6875rem 0.95rem;
  font-size: var(--text-sm);
  line-height: 1.55;
  color: #1D1D1F;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03);
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.24s ease;
  will-change: transform, box-shadow;
}
.msg-bubble:hover {
  transform: translateY(-2.5px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.09), 0 2px 6px rgba(0, 0, 0, 0.05);
}

/* ─── Floating Message Bubbles (Apple iMessage Blue Gradient) ─── */
.msg-group.own .msg-bubble {
  background: linear-gradient(180deg, #1C85FF 0%, #0076FF 100%);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 18px;
  border-bottom-right-radius: 5px;
  color: #FFFFFF;
  box-shadow: 0 4px 18px rgba(0, 122, 255, 0.32), 0 1px 3px rgba(0, 0, 0, 0.08);
}
.msg-group.own .msg-bubble:hover {
  transform: translateY(-2.5px);
  box-shadow: 0 8px 26px rgba(0, 122, 255, 0.45), 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Message actions */
.msg-bubble-wrap { position: relative; display: flex; align-items: center; gap: 0.375rem; }
.msg-group.own .msg-bubble-wrap { flex-direction: row-reverse; }

.msg-actions { display: none; gap: 0.25rem; flex-shrink: 0; }
.msg-bubble-wrap:hover .msg-actions { display: flex; }
.msg-action-btn {
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--trans-fast);
  box-shadow: var(--shadow-sm);
}
.msg-action-btn:hover { background: var(--bg-hover); color: var(--primary); }
.msg-action-btn.danger:hover { background: rgba(255,59,92,0.08); color: var(--danger); }

.msg-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  padding: 0 0.75rem;
}
.msg-group.own .msg-time { text-align: right; }

.msg-system {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: 0.375rem 0;
  font-style: italic;
}
.msg-deleted { font-style: italic; opacity: 0.6; }

.messages-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ─── 14. Typing Indicator ───────────────────────────────────────── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 1.25rem;
  font-size: var(--text-xs);
  color: var(--text-muted);
  height: 28px;
  flex-shrink: 0;
}
.typing-dots { display: flex; gap: 3px; align-items: center; }
.typing-dots span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--primary);
  animation: typingBounce 1.2s ease-in-out infinite;
  opacity: 0.5;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; background: var(--accent); }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; background: var(--col-green); }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ─── 15. Input Area (Apple Floating Dock Capsule) ───────────────── */
.input-area {
  display: flex;
  flex-direction: column;
  padding: 0.625rem 1rem;
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 28px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  margin: 0 1.25rem 1.25rem 1.25rem;
  flex-shrink: 0;
  transition: all var(--trans-mid);
}
.input-area:focus-within {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 40px rgba(0, 122, 255, 0.16), 0 0 0 2px rgba(0, 122, 255, 0.35);
}
@media (max-width: 767px) {
  .input-area {
    margin: 0 0.5rem 0.5rem 0.5rem;
    border-radius: 22px;
  }
}

/* Attachment preview bar above input row */
.attachment-preview-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-layer-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  animation: fadeIn 0.2s ease;
}
.attachment-preview-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.35rem;
}
.attachment-preview-thumb img,
.attachment-preview-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.attachment-preview-info {
  flex: 1;
  min-width: 0;
}
.attachment-preview-name {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-preview-size {
  display: block;
  font-size: 0.6875rem;
  color: var(--text-muted);
}
.attachment-preview-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-full);
  transition: all var(--trans-fast);
}
.attachment-preview-remove:hover {
  color: var(--danger);
  background: rgba(255,59,92,0.1);
}

/* Voice recording bar */
.voice-record-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  background: linear-gradient(135deg, rgba(255,45,120,0.08), rgba(91,95,239,0.08));
  border: 1.5px solid rgba(255,45,120,0.3);
  border-radius: var(--radius-lg);
  margin-bottom: 0.5rem;
  animation: fadeIn 0.2s ease;
}
.voice-record-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
}
.voice-record-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulseDot 1s infinite alternate;
}
@keyframes pulseDot {
  from { opacity: 0.4; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1.15); }
}
.voice-record-timer {
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 700;
}
.voice-record-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 24px;
}
.voice-record-wave span {
  width: 3px;
  height: 6px;
  background: var(--accent);
  border-radius: 2px;
  animation: waveBar 1.2s ease-in-out infinite alternate;
}
.voice-record-wave span:nth-child(2) { animation-delay: 0.15s; background: var(--primary); }
.voice-record-wave span:nth-child(3) { animation-delay: 0.3s; background: var(--col-cyan); }
.voice-record-wave span:nth-child(4) { animation-delay: 0.45s; background: var(--col-green); }
.voice-record-wave span:nth-child(5) { animation-delay: 0.6s; background: var(--col-yellow); }
.voice-record-wave span:nth-child(6) { animation-delay: 0.75s; background: var(--col-pink); }
.voice-record-wave span:nth-child(7) { animation-delay: 0.9s; background: var(--primary); }
.voice-record-wave span:nth-child(8) { animation-delay: 1.05s; background: var(--col-green); }

@keyframes waveBar {
  0% { height: 4px; }
  50% { height: 20px; }
  100% { height: 8px; }
}

.voice-record-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.voice-cancel-btn {
  color: var(--text-muted);
  width: 36px;
  height: 36px;
}
.voice-cancel-btn:hover {
  color: var(--danger);
  background: rgba(255,59,92,0.1);
}
.voice-send-btn {
  background: linear-gradient(135deg, var(--col-pink), var(--primary));
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(255,45,120,0.3);
  transition: transform var(--trans-fast);
}
.voice-send-btn:hover {
  transform: scale(1.08);
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  width: 100%;
}
/* ─── Action Menu (+ Button & Submenu) ─── */
.input-action-menu-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.action-menu-toggle-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(0, 122, 255, 0.16);
  background: rgba(0, 122, 255, 0.08);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 6px rgba(0, 122, 255, 0.08);
  flex-shrink: 0;
  user-select: none;
  outline: none;
}
.action-menu-toggle-btn:hover {
  background: rgba(0, 122, 255, 0.15);
  color: var(--primary-dark);
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.2);
}
.action-menu-toggle-btn:active {
  transform: scale(0.95);
}
.action-menu-toggle-btn .plus-icon {
  font-size: 1.45rem;
  font-weight: 500;
  line-height: 1;
  display: inline-block;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center;
  margin-top: -1px;
}
.action-menu-toggle-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 4px 14px var(--primary-glow);
}
.action-menu-toggle-btn.active .plus-icon {
  transform: rotate(45deg);
}

/* Submenu Popover Container */
.input-action-submenu {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  min-width: 220px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.04);
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 150;
  transform-origin: bottom left;
  animation: submenuPopIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes submenuPopIn {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.input-action-submenu.hidden {
  display: none !important;
}

/* Submenu Item */
.submenu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  color: var(--text-primary);
  font-family: inherit;
  transition: background var(--trans-fast), transform var(--trans-fast);
  user-select: none;
  outline: none;
}
.submenu-item:hover {
  background: rgba(0, 122, 255, 0.08);
  transform: translateX(2px);
}
.submenu-item:active {
  transform: scale(0.98);
}

.submenu-icon-wrap {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.submenu-item:hover .submenu-icon-wrap {
  transform: scale(1.12);
}

.submenu-icon-wrap.icon-attach {
  background: rgba(0, 122, 255, 0.12);
}
.submenu-icon-wrap.icon-voice {
  background: rgba(255, 45, 120, 0.12);
}
.submenu-icon-wrap.icon-video {
  background: rgba(0, 204, 255, 0.14);
}
.submenu-icon-wrap.icon-emoji {
  background: rgba(255, 214, 0, 0.2);
}

.submenu-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.submenu-title {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
}
.submenu-item:hover .submenu-title {
  color: var(--primary);
}
.submenu-desc {
  font-size: 0.6875rem;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Media in message bubbles */
.msg-attachment {
  margin-bottom: 0.375rem;
}
.msg-attachment-img {
  max-width: 100%;
  max-height: 280px;
  min-width: 140px;
  min-height: 100px;
  border-radius: var(--radius-md);
  object-fit: cover;
  cursor: pointer;
  display: block;
  transition: transform var(--trans-fast), filter var(--trans-fast);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.msg-attachment-img:hover {
  filter: brightness(0.95);
  transform: scale(1.01);
}
.msg-attachment-video {
  max-width: 100%;
  width: 320px;
  max-height: 280px;
  border-radius: var(--radius-md);
  display: block;
  background: #000;
}
/* Document card */
.msg-attachment-doc {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  background: rgba(0,0,0,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  min-width: 220px;
  max-width: 340px;
  transition: background var(--trans-fast);
}
.msg-group.own .msg-attachment-doc {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.25);
  color: #fff;
}
.msg-attachment-doc:hover {
  background: rgba(0,0,0,0.08);
  text-decoration: none;
}
.msg-group.own .msg-attachment-doc:hover {
  background: rgba(255,255,255,0.28);
}
.doc-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}
.doc-info {
  flex: 1;
  min-width: 0;
}
.doc-name {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-size {
  display: block;
  font-size: 0.6875rem;
  opacity: 0.75;
}
.doc-download {
  font-size: 1.1rem;
  flex-shrink: 0;
  opacity: 0.8;
}

/* Voice Note Player in Bubble */
.msg-attachment-voice {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.625rem;
  background: rgba(0,0,0,0.04);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  min-width: 220px;
  max-width: 320px;
  transition: background var(--trans-fast);
}
.msg-group.own .msg-attachment-voice {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.3);
  color: #fff;
}
.voice-play-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--col-pink), var(--primary));
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(91,95,239,0.3);
  transition: transform var(--trans-fast);
}
.msg-group.own .voice-play-btn {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.voice-play-btn:hover {
  transform: scale(1.08);
}
.voice-track-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.voice-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(0,0,0,0.1);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
}
.msg-group.own .voice-progress-bar {
  background: rgba(255,255,255,0.3);
}
.voice-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--col-pink), var(--primary));
  border-radius: 3px;
  transition: width 0.1s linear;
}
.msg-group.own .voice-progress-fill {
  background: #fff;
}
.voice-time-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.msg-group.own .voice-time-row {
  color: rgba(255,255,255,0.85);
}

/* ─── Video Note Message in Bubble (Portrait) ────────────────────── */
.msg-attachment-video-note {
  width: 220px;
  height: 330px;
  aspect-ratio: 2 / 3;
  border-radius: 22px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: #000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.06);
  margin-bottom: 0.35rem;
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.24s ease;
}
.msg-attachment-video-note:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}
.video-note-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 20px;
  display: block;
}
.video-note-overlay-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: opacity var(--trans-fast);
  border-radius: 20px;
}
.video-note-overlay-btn.playing {
  opacity: 0;
}
.video-note-overlay-btn:hover {
  opacity: 1;
}
.video-note-play-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #007AFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
}
.video-note-badge {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  border: 0.5px solid rgba(255, 255, 255, 0.2);
}

/* ─── Video Note Modal (Portrait) ────────────────────────────────── */
.video-note-modal-card {
  max-width: 360px;
  width: 90vw;
  text-align: center;
  padding: 1.25rem;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(30px) saturate(190%);
  -webkit-backdrop-filter: blur(30px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}
.video-note-portrait-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1rem 0;
}
.video-note-portrait-wrap {
  width: 230px;
  height: 350px;
  border-radius: 24px;
  overflow: hidden;
  position: relative;
  border: 3px solid rgba(0, 122, 255, 0.35);
  background: #000;
  box-shadow: 0 10px 30px rgba(0, 122, 255, 0.2);
}
.video-note-portrait-wrap .video-note-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 21px;
  display: block;
  transform: scaleX(-1);
}
.video-note-ring {
  position: absolute;
  inset: -3px;
  border-radius: 24px;
  border: 3.5px solid var(--danger);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--trans-fast);
}
.video-note-ring.recording {
  opacity: 1;
  animation: ringPulse 1.2s infinite;
}
@keyframes ringPulse {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.03); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}
.video-note-timer {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  font-variant-numeric: tabular-nums;
  border: 0.5px solid rgba(255, 255, 255, 0.2);
}
.video-note-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.75rem;
}
.video-note-action-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-full);
  border: none;
  background: linear-gradient(135deg, var(--col-pink), var(--primary));
  color: #fff;
  font-weight: 700;
  font-size: var(--text-sm);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255,45,120,0.35);
  transition: all var(--trans-fast);
}
.video-note-action-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 20px rgba(255,45,120,0.45);
}
.record-dot-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
}
.video-note-tip {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 0.85rem;
}

/* ─── Lightbox Modal ─────────────────────────────────────────────── */
.lightbox-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease;
}
.lightbox-modal img {
  max-width: 92vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: scaleIn 0.25s ease;
}
.lightbox-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  width: 42px;
  height: 42px;
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.35rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--trans-fast);
}
.lightbox-close:hover {
  background: rgba(255,255,255,0.4);
}

/* ─── Maximize Header ─── */
.input-maximize-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.5rem 0.6rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  margin-bottom: 0.5rem;
  animation: fadeIn 0.2s ease;
}
.input-area.is-maximized .input-maximize-header {
  display: flex;
}
.maximize-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.maximize-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(0, 122, 255, 0.1);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.maximize-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.maximize-hint strong {
  color: var(--text-secondary);
}
.btn-restore-normal {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--trans-fast);
}
.btn-restore-normal:hover {
  background: rgba(0, 122, 255, 0.12);
  color: var(--primary);
  border-color: rgba(0, 122, 255, 0.3);
}

/* ─── Message Input Wrap & Inline Actions ─── */
.message-input-wrap {
  flex: 1;
  background: var(--bg-layer-3);
  border: 1.5px solid var(--border);
  border-radius: 22px;
  transition: border-color var(--trans-fast), box-shadow var(--trans-fast), background var(--trans-fast);
  display: flex;
  align-items: flex-end;
  position: relative;
  overflow: hidden;
}
.message-input-wrap:focus-within {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.message-input {
  flex: 1;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  padding: 0.65rem 0.5rem 0.65rem 1rem;
  background: none;
  border: none;
  outline: none;
  resize: none;
  color: var(--text-primary);
  font-size: var(--text-base);
  line-height: 1.5;
  min-height: 40px;
  max-height: 180px;
  overflow-y: auto;
  -webkit-appearance: none;
}
.message-input::placeholder { color: var(--text-dim); }

.input-inline-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 0.5rem 0.4rem 0;
  align-self: flex-end;
  flex-shrink: 0;
}
.btn-inline-tool {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  transition: all 0.18s ease;
  user-select: none;
  outline: none;
}
.btn-inline-tool:hover {
  background: rgba(0, 122, 255, 0.1);
  color: var(--primary);
  transform: scale(1.08);
}
.btn-inline-tool:active {
  transform: scale(0.92);
}
.btn-inline-tool.active {
  background: var(--primary);
  color: #fff;
}

/* ─── Maximized Input Area State ─── */
.input-area.is-maximized {
  position: relative;
  border-radius: 22px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.16), 0 0 0 2px rgba(0, 122, 255, 0.35);
  background: rgba(255, 255, 255, 0.98);
  margin-top: 0.5rem;
}

.input-area.is-maximized .input-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: 1fr auto;
  grid-template-areas:
    "input input input"
    "actions space send";
  gap: 0.625rem;
  align-items: center;
  width: 100%;
}

.input-area.is-maximized .message-input-wrap {
  grid-area: input;
  width: 100%;
  min-height: 200px;
  height: 35vh;
  max-height: 52vh;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: #ffffff;
  border-color: rgba(0, 122, 255, 0.4);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.04);
}

.input-area.is-maximized .message-input {
  max-height: none;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 0.85rem 1rem;
}

.input-area.is-maximized .input-inline-actions {
  padding: 0.35rem 0.65rem;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  background: rgba(246, 246, 248, 0.7);
  border-radius: 0 0 13px 13px;
  width: 100%;
  justify-content: flex-end;
}

.input-area.is-maximized .input-action-menu-wrap {
  grid-area: actions;
}

.input-area.is-maximized .send-btn {
  grid-area: send;
}

.send-btn {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  color: #fff;
  border-radius: 50%;
  font-size: 1rem;
  transition: all var(--trans-fast);
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.send-btn:hover:not(:disabled) {
  transform: scale(1.1) rotate(-5deg);
  box-shadow: 0 6px 20px rgba(91,95,239,0.4);
}
.send-btn:disabled { opacity: 0.35; background: var(--bg-layer-3); box-shadow: none; color: var(--text-muted); }

/* ─── 16. Emoji Picker ───────────────────────────────────────────── */
.emoji-picker {
  position: absolute;
  bottom: calc(var(--input-h) + 8px);
  left: 1rem;
  width: min(320px, calc(100vw - 2rem));
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  z-index: 100;
  padding: 0.75rem;
  animation: fadeUp 0.2s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
}
.emoji-grid button {
  font-size: 1.375rem;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: background var(--trans-fast), transform var(--trans-fast);
  line-height: 1;
}
.emoji-grid button:hover {
  background: var(--bg-hover);
  transform: scale(1.25);
}

/* ─── 17. Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(91,95,239,0.15);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
@media (min-width: 600px) {
  .modal-overlay { align-items: center; padding: 1rem; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 1.75rem;
  width: 100%;
  max-width: 480px;
  animation: slideUp 0.25s ease;
  max-height: 90dvh;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-card);
}
@media (min-width: 600px) {
  .modal { border-radius: var(--radius-xl); animation: scaleIn 0.2s ease; }
}
@keyframes slideUp { from { transform: translateY(40px); } to { transform: none; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: none; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1.5px solid var(--border);
}
.modal-header h3 { font-size: var(--text-lg); font-weight: 700; color: var(--text-primary); }
.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* Radio group */
.radio-group { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-layer-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  transition: all var(--trans-fast);
  font-weight: 500;
}
.radio-label:has(input:checked) {
  border-color: var(--primary);
  background: rgba(91,95,239,0.08);
  color: var(--primary);
}
.radio-label input { display: none; }

/* User search results */
.user-search-results {
  max-height: 220px;
  overflow-y: auto;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-layer-3);
  margin-top: 0.5rem;
}
.user-search-results li {
  padding: 0.625rem 0.875rem;
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: background var(--trans-fast);
}
.user-search-results li:hover { background: var(--bg-hover); }

/* ─── 18. Profile Edit ───────────────────────────────────────────── */
.profile-edit { display: flex; flex-direction: column; align-items: center; gap: 1.25rem; }
.profile-edit form { width: 100%; }

.avatar-edit-wrap { position: relative; display: inline-flex; }
.avatar-edit-btn {
  position: absolute;
  bottom: 0; right: 0;
  width: 26px; height: 26px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  border: 2px solid #fff;
  transition: background var(--trans-fast);
}
.avatar-edit-btn:hover { background: var(--primary-dark); }

/* ─── 19. Toast ──────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: calc(100vw - 2rem);
  pointer-events: none;
}
.toast {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideInRight 0.3s ease;
  pointer-events: auto;
  min-width: 200px;
}
.toast-success { border-left: 4px solid var(--success); }
.toast-error   { border-left: 4px solid var(--danger); }
.toast-info    { border-left: 4px solid var(--primary); }

@keyframes slideInRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes fadeOut { to { opacity: 0; transform: scale(0.95); } }

/* ─── 20. Sidebar Overlay (mobile) ──────────────────────────────── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(91,95,239,0.2);
  z-index: 150;
  backdrop-filter: blur(4px);
}

/* ─── 21. Mobile Responsive ──────────────────────────────────────── */
@media (max-width: 767px) {
  :root { --sidebar-w: 82vw; }

  .sidebar {
    position: fixed;
    left: 0; top: 0;
    height: 100%;
    transform: translateX(-100%);
    box-shadow: 4px 0 32px rgba(91,95,239,0.15);
  }
  .sidebar.open { transform: translateX(0); }

  #openSidebarBtn { display: flex; }
  #closeSidebarBtn { display: flex; }

  .main-area { width: 100%; }
  .msg-content-wrap { max-width: 88%; }
  .emoji-picker { position: fixed; bottom: calc(var(--input-h) + 8px); left: 0; right: 0; margin: 0 1rem; width: unset; }
  .auth-card { padding: 1.5rem 1.25rem; }
}

@media (min-width: 768px) {
  #closeSidebarBtn { display: none; }
  .sidebar-overlay { display: none !important; }
}

/* ─── 22. Colorful Accents ───────────────────────────────────────── */
/* Animated rainbow border for active channel */
.room-item.active {
  background: linear-gradient(white, white) padding-box,
              linear-gradient(135deg, var(--col-pink), var(--col-cyan), var(--col-green)) border-box;
  border: 2px solid transparent;
  padding-left: 0.625rem;
}

/* Colored scrollbar */
.messages-area::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--col-pink), var(--col-cyan));
}

/* ─── 23. Utility ────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.25rem; }

/* ─── 24. Avatar Click to DM & Channel Invite Tabs ───────────────── */
.msg-avatar-clickable {
  cursor: pointer !important;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}
.msg-avatar-clickable:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 14px rgba(0, 122, 255, 0.4);
}
.msg-sender-clickable {
  cursor: pointer !important;
  transition: color 0.15s ease;
}
.msg-sender-clickable:hover {
  color: var(--primary) !important;
  text-decoration: underline;
}
.member-dm-hint {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(0, 122, 255, 0.1);
  color: var(--primary);
  opacity: 0.85;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.user-item:hover .member-dm-hint {
  opacity: 1;
  background: rgba(0, 122, 255, 0.2);
}

/* Channel Modal Segmented Tabs */
.channel-modal-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.05);
  padding: 3px;
  border-radius: var(--radius-full);
  margin-bottom: 1.25rem;
  gap: 4px;
}
.channel-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.45rem 0.75rem;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}
.channel-tab-btn.active {
  background: #fff;
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.tab-badge {
  background: var(--col-pink);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 800;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-full);
  display: inline-flex;
}

/* Share Link Box */
.share-link-box {
  background: linear-gradient(135deg, rgba(0, 122, 255, 0.05), rgba(88, 86, 214, 0.08));
  border: 1px solid rgba(0, 122, 255, 0.2);
  border-radius: 16px;
  padding: 0.875rem 1rem;
  margin-bottom: 1.25rem;
}
.share-link-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: var(--text-xs);
  color: var(--text-primary);
}
.btn-text-sm {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-text-sm:hover {
  text-decoration: underline;
}
.share-link-input-wrap {
  display: flex;
  gap: 0.5rem;
}
.share-link-input-wrap input {
  font-size: 0.75rem !important;
  padding: 0.4rem 0.65rem !important;
  background: #fff !important;
}
.share-link-hint {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.45rem;
  line-height: 1.4;
}

/* Join Requests List */
.join-request-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.join-request-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.join-request-actions {
  display: flex;
  gap: 0.35rem;
}
.btn-xs {
  font-size: 0.6875rem !important;
  padding: 0.3rem 0.65rem !important;
  border-radius: var(--radius-full) !important;
  font-weight: 600 !important;
}
.btn-success {
  background: #34C759 !important;
  color: #fff !important;
  border: none !important;
}
.btn-success:hover {
  background: #28a745 !important;
  box-shadow: 0 2px 8px rgba(52, 199, 89, 0.35) !important;
}
.btn-danger {
  background: #FF3B30 !important;
  color: #fff !important;
  border: none !important;
}
.btn-danger:hover {
  background: #d32f2f !important;
  box-shadow: 0 2px 8px rgba(255, 59, 48, 0.35) !important;
}

/* ─── 25. User Profile Bar & Custom Status ────────────────────────── */
.user-profile-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.user-profile-bar:hover {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 20px rgba(0, 122, 255, 0.1);
  transform: translateY(-1px);
}
.user-bar-info {
  flex: 1;
  min-width: 0;
}
.user-bar-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.user-bar-status {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 2px;
}
.user-bar-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  flex-shrink: 0;
}
.user-bar-btn:hover {
  background: rgba(0, 122, 255, 0.12);
  color: var(--primary);
  transform: scale(1.08);
}

/* Quick status chips */
.quick-status-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.chip-btn {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: var(--bg-layer-2);
  border-radius: var(--radius-full);
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip-btn:hover {
  background: rgba(0, 122, 255, 0.1);
  border-color: rgba(0, 122, 255, 0.3);
  color: var(--primary);
  transform: scale(1.04);
}

/* Toggle Switch (iOS / Mac Style) */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #e5e5ea;
  transition: .3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 24px;
}
.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.toggle-switch input:checked + .toggle-slider {
  background-color: #34C759;
}
.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* Batch Select Row */
.batch-select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 12px;
  margin-bottom: 0.75rem;
  font-size: var(--text-xs);
}
.batch-select-all {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.batch-buttons {
  display: flex;
  gap: 0.35rem;
}

/* Channel Avatar Edit */
.channel-avatar-preview-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 0.75rem auto;
  cursor: pointer;
}
.channel-avatar-preview {
  width: 100%;
  height: 100%;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(0, 122, 255, 0.1), rgba(88, 86, 214, 0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  border: 2px dashed rgba(0, 122, 255, 0.3);
  overflow: hidden;
  transition: all 0.2s ease;
}
.channel-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.channel-avatar-preview-wrap:hover .channel-avatar-preview {
  border-color: var(--primary);
  transform: scale(1.03);
}
.avatar-change-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Room Item Avatar Custom Image */
.room-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  object-fit: cover;
}

/* Profile Modal Status Snippet Quote */
.profile-status-quote {
  background: linear-gradient(135deg, rgba(0, 122, 255, 0.05), rgba(88, 86, 214, 0.05));
  border-left: 3px solid var(--primary);
  border-radius: 0 12px 12px 0;
  padding: 0.6rem 0.85rem;
  font-size: 0.8125rem;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  font-style: italic;
}
.profile-bio-text {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 12px;
  padding: 0.6rem 0.85rem;
}


/* ═══════════════════════════════════════════════════════════════════
   30. Perbaikan UI/UX (proporsi, kontras, mobile)
   ═══════════════════════════════════════════════════════════════════ */

/* #1 Nama room aktif terlihat (latar aktif putih bergaris pelangi) */
.room-item.active .room-name { color: var(--text-primary); font-weight: 700; }
.room-item.active .room-icon { color: inherit; }

/* #4 Kontras bubble milik sendiri & pesan terhapus (teks putih ≥4.5:1) */
.msg-group.own .msg-bubble {
  background: linear-gradient(180deg, #0A6CDB 0%, #0062D2 100%);
}
.msg-deleted { opacity: 1; color: var(--text-muted); }
.msg-group.own .msg-deleted { color: rgba(255, 255, 255, 0.95); }

/* #7 Emoji picker: latar solid & di atas area pesan */
.emoji-picker {
  background: #FFFFFF;
  opacity: 1;
  z-index: 450;
  isolation: isolate;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
}

/* #3 Safe-area iOS & mencegah auto-zoom input (font ≥16px di layar kecil) */
.input-area { margin-bottom: max(1.25rem, env(safe-area-inset-bottom)); }
.sidebar-footer { padding-bottom: max(0.75rem, env(safe-area-inset-bottom)); }
.chat-header { padding-top: env(safe-area-inset-top); height: calc(var(--header-h) + env(safe-area-inset-top)); }
.toast-container { top: max(1rem, env(safe-area-inset-top)); }
@media (max-width: 767px) {
  .input-area { margin-bottom: max(0.5rem, env(safe-area-inset-bottom)); }
  .form-input, .message-input, select.form-input, textarea.form-input { font-size: 16px; }
}

/* #2 Pencarian calon anggota (admin) */
.invite-search-results {
  margin-top: 0.5rem;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.invite-search-results:empty { display: none; }
.invite-result {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-md);
  background: var(--bg-hover);
}
.invite-result .invite-result-info { flex: 1; min-width: 0; }
.invite-result .invite-result-name {
  display: block;
  font-weight: 600;
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.invite-result .invite-result-username { font-size: var(--text-xs); color: var(--text-muted); }
.invite-hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: 0.375rem; }

/* #5 Target sentuh minimal 44×44 px di HP / layar sentuh */
@media (max-width: 767px), (pointer: coarse) {
  .icon-btn,
  .btn-inline-tool,
  .send-btn,
  .action-menu-toggle-btn,
  .msg-action-btn,
  .voice-play-btn,
  .lightbox-close,
  .member-dm-hint,
  .btn-icon-xs {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .room-item, .user-item { min-height: 44px; }
  #roomMembersBtn, #logoutBtn, .chip-btn, .btn-sm, .btn-xs, .btn-restore-normal, .btn-text-sm, .btn-text-xs { min-height: 44px; }
  .emoji-grid button { min-height: 44px; }
  .msg-avatar-clickable { width: 36px; height: 36px; }
  .msg-sender-clickable { display: inline-block; padding: 0.375rem 0.75rem 0.25rem; margin-top: -0.375rem; }
  /* Tombol hapus pesan: tampil saat bubble disentuh/difokuskan (tidak ada hover di HP) */
  .msg-bubble-wrap:focus-within .msg-actions { display: flex; }
}

/* #6 Fokus keyboard selalu terlihat */
button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible:not(.message-input),
[data-action]:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #0062D2 !important;
  outline-offset: 2px;
}
.message-input:focus-visible { outline: none; } /* sudah ditandai oleh cincin .input-area:focus-within */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* #9 Gambar di bubble tidak terpotong */
.msg-attachment-img {
  object-fit: contain;
  width: auto;
  height: auto;
  max-height: 320px;
  background: rgba(0, 0, 0, 0.04);
}

/* #9 Indikator pesan baru */
.main-area { position: relative; }
.new-msg-indicator {
  position: absolute;
  left: 50%;
  bottom: calc(var(--input-h) + 2.25rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  min-height: 44px;
  padding: 0.5rem 1.125rem;
  border-radius: var(--radius-full);
  background: #0062D2;
  color: #FFFFFF;
  font-size: var(--text-sm);
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 98, 210, 0.35);
  animation: fadeUp 0.2s ease;
}
.new-msg-indicator:hover { background: #0052B0; }

/* #9 Progres unggah lampiran */
.upload-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.375rem 0.25rem 0.5rem;
}
.upload-progress-track {
  flex: 1;
  height: 6px;
  border-radius: var(--radius-full);
  background: rgba(0, 98, 210, 0.15);
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  width: 0;
  background: #0062D2;
  border-radius: inherit;
  transition: width 0.15s linear;
}
.upload-progress-text {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  min-width: 7.5rem;
  text-align: right;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Tablet/layar sentuh: input juga 16px (cegah auto-zoom iPad) */
@media (pointer: coarse) {
  .form-input, .message-input, select.form-input, textarea.form-input { font-size: 16px; }
}
/* HP sempit: tombol di dalam kolom ketik tetap setinggi 44px tetapi lebih ramping,
   agar kolom ketik tidak terlalu sempit (lebar ≥24px memenuhi WCAG 2.5.8 AA) */
@media (max-width: 400px) {
  .btn-inline-tool { min-width: 34px; padding-left: 0; padding-right: 0; }
  .input-inline-actions { gap: 0; }
}
