:root {
  --primary: #128c7e;
  --primary-dark: #075e54;
  --bg-main: #e9edef;
  --card-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --text-main: #111b21;
  --text-muted: #54656f;
  --line-color: #d9e1e4;
  --bubble-mine: #d9fdd3;
  --bubble-other: #ffffff;
  --hover: #f0f2f5;
  --active: #e9f7f3;
  --input-bg: #ffffff;
  --messages-bg: #efe7dc;
  --tool-bg: #f0f2f5;
  --menu-bg: #ffffff;
}

/* Tema Terang: nuansa bersih dan modern */
body[data-theme="light"] {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg-main: #f8fafc;
  --card-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --text-main: #111b21;
  --text-muted: #54656f;
  --line-color: #d9e1e4;
  --bubble-mine: #d9fdd3;
  --bubble-other: #ffffff;
  --hover: #f0f2f5;
  --active: #e9f7f3;
  --input-bg: #ffffff;
  --messages-bg: #efe7dc;
  --tool-bg: #f0f2f5;
  --menu-bg: #ffffff;
}

/* Header Topbar Tema Terang bernuansa Biru Elegan */
body[data-theme="light"] .topbar {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  border-bottom-color: #1e40af;
  border-right-color: #1e40af;
  color: #ffffff;
}

body[data-theme="light"] .topbar .brand-title b,
body[data-theme="light"] .topbar .ghost {
  color: #ffffff;
}

body[data-theme="light"] .topbar .brand-title small {
  color: #dbeafe;
}

body[data-theme="light"] .topbar .brand-mark.small {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
}

body[data-theme="light"] .topbar .account-photo {
  border: 1.5px solid rgba(255, 255, 255, 0.4);
}

body[data-theme="light"] .topbar .ghost {
  border-color: rgba(255, 255, 255, 0.35);
}

body[data-theme="light"] .topbar .ghost:hover {
  background: rgba(255, 255, 255, 0.18);
}

body[data-theme="light"] .account-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

body[data-theme="light"] .account-btn:active {
  background: rgba(255, 255, 255, 0.24);
}

body[data-theme="light"] .topbar #new-chat {
  background: #2563eb;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
}

body[data-theme="light"] .topbar #new-chat:hover {
  background: #3b82f6;
}

body[data-theme="dark"] {
  --primary: #00a884;
  --primary-dark: #008f72;
  --bg-main: #0b141a;
  --card-bg: #111b21;
  --sidebar-bg: #111b21;
  --text-main: #e9edef;
  --text-muted: #8696a0;
  --line-color: #233138;
  --bubble-mine: #005c4b;
  --bubble-other: #202c33;
  --hover: #202c33;
  --active: #2a3942;
  --input-bg: #202c33;
  --messages-bg: #0b141a;
  --tool-bg: #202c33;
  --menu-bg: #233138;
}

body[data-theme="fullcolor"] {
  --primary: #db2777;
  --primary-dark: #be185d;
  --bg-main: #4c1d95;
  --card-bg: #ffffff;
  --text-main: #1e1b4b;
  --text-muted: #6d28d9;
  --line-color: #ddd6fe;
  --bubble-mine: #7c3aed;
  --bubble-other: #fff7ed;
  --hover: #fae8ff;
  --active: #e9d5ff;
  --input-bg: #ffffff;
  --messages-bg: #fdf2f8;
  --sidebar-bg: #ffffff;
  --tool-bg: #fae8ff;
  --menu-bg: #ffffff;
  background: linear-gradient(135deg, #6d28d9, #db2777 48%, #f59e0b);
}

/* Tema Hijau: nuansa WhatsApp terang dengan latar chat krem. */
body[data-theme="green"] {
  --primary: #128c7e;
  --primary-dark: #075e54;
  --bg-main: #e9edef;
  --card-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --text-main: #111b21;
  --text-muted: #54656f;
  --line-color: #d9e1e4;
  --bubble-mine: #d9fdd3;
  --bubble-other: #ffffff;
  --hover: #f0f2f5;
  --active: #e9f7f3;
  --input-bg: #ffffff;
  --messages-bg: #efe7dc;
  --tool-bg: #f0f2f5;
  --menu-bg: #ffffff;
}

/* Warna mention @ agar kontras dan terbaca jelas di tema hijau */
body[data-theme="green"] .mention-tag {
  background: rgba(18, 140, 126, 0.16);
  color: #075e54;
}

body[data-theme="green"] .bubble.mine .mention-tag {
  background: rgba(7, 94, 84, 0.16);
  color: #075e54;
}



body[data-theme="green"] .topbar {
  background: #075e54;
  border-bottom-color: #075e54;
  color: #ffffff;
}

body[data-theme="green"] .topbar .brand-title b,
body[data-theme="green"] .topbar .brand-title small,
body[data-theme="green"] .topbar .ghost {
  color: #ffffff;
}

body[data-theme="green"] .topbar .ghost {
  border-color: rgba(255,255,255,.35);
}

body[data-theme="green"] .topbar .ghost:hover {
  background: rgba(255,255,255,.16);
}

body[data-theme="green"] .account-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

body[data-theme="green"] .account-btn:active {
  background: rgba(255, 255, 255, 0.24);
}

body[data-theme="green"] .messages {
  background-color: var(--messages-bg);
  background-image: radial-gradient(rgba(84,101,111,.18) .75px, transparent .75px);
}

body[data-theme="green"] .bubble.mine {
  color: #111b21;
  border-color: #b7e8ae;
}

body[data-theme="green"] .bubble.mine .sender-name,
body[data-theme="green"] .bubble.mine .bubble-more {
  color: #276749;
}

body[data-theme="green"] .sender-name { color: #128c7e; }
body[data-theme="green"] .brand-mark { background: linear-gradient(135deg, #128c7e, #075e54); box-shadow: 0 10px 20px rgba(7,94,84,.28); }

#new-chat {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  font-size: 18px;
  flex-shrink: 0;
}

/* Tata letak desktop: identitas akun di kiri, header percakapan di atas panel kanan. */
@media (min-width: 769px) {
  .topbar {
    width: 484px;
    position: relative;
    z-index: 20;
    padding: 0 16px;
    border-right: 1px solid var(--line-color);
  }

/* Tarik tampilan awal (Ruang Percakapan AlfaChat) agar mentok ke paling atas */
  .empty {
    position: fixed;
    top: 0;
    left: 484px;
    right: 0;
    bottom: 0;
    height: 100vh;
    background: var(--card-bg);
    z-index: 25;
  }
  
  /* Tarik panel kanan mentok ke puncak layar agar tampilan awal (.empty) tidak menyisakan ruang atas */
  .chat-panel {
    margin-top: -64px;
    height: calc(100% + 64px);
    position: relative;
    z-index: 25;
  }

  /* Beri ruang 64px pada #conversation saat chat dibuka agar tidak tertimpa .chat-head */
  #conversation {
    padding-top: 64px;
  }

  /* Tempelkan header percakapan tepat di baris atas sebelah kanan */
  .chat-head {
    position: fixed;
    top: 0;
    left: 484px;
    right: 0;
    height: 64px;
    z-index: 30;
    background: var(--card-bg);
    border: none;
    border-bottom: 1px solid var(--line-color);
    border-radius: 0;
  }

  .topbar-actions {
    position: fixed;
    left: 14px;
    bottom: 14px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 5px;
    border-radius: 12px;
    background: var(--primary-dark);
    box-shadow: 0 6px 18px rgba(15, 23, 42, .2);
  }

  .topbar-actions .ghost,
  .topbar-actions .icon-btn,
  .topbar-actions #logout {
    position: relative;
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 8px;
    font-size: 15px;
    color: #fff;
    border-color: rgba(255, 255, 255, .35);
  }

  .topbar-actions .ghost:hover,
  .topbar-actions .icon-btn:hover,
  .topbar-actions #logout:hover {
    background: rgba(255, 255, 255, .18);
    color: #fff;
    transform: none;
  }

  /* Tooltip keterangan saat kursor diarahkan ke tombol */
  .topbar-actions [data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 4px 9px;
    border-radius: 7px;
    background: #0f172a;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(15, 23, 42, .25);
    transition: opacity .15s ease, transform .15s ease;
  }

  .topbar-actions [data-tip]:hover::after,
  .topbar-actions [data-tip]:focus-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }
body.store-account #logout,
body.store-account #lock-setup-logout,
body.store-account #lock-logout { display: none !important; }

body {
  margin: 0;
  background: var(--bg-main);
  color: var(--text-main);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button, input, textarea { 
  font: inherit; 
  color: var(--text-main);
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--line-color);
}

.ghost:hover {
  background: var(--hover);
  color: var(--text-main);
}

.btn-secondary {
  background: var(--tool-bg);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #cbd5e1;
}

input, textarea {
  border: 1px solid var(--line-color);
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--input-bg);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

input:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin: 12px 0 6px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Auth Section */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at top right, #dbeafe, transparent 40%), radial-gradient(circle at bottom left, #eff6ff, transparent 40%), var(--bg-main);
}

.login-card {
  width: min(420px, 100%);
  background: var(--card-bg);
  border: 1px solid var(--line-color);
  border-radius: 20px;
  padding: 36px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
  text-align: center;
}

.login-card h1 {
  font-size: 26px;
  font-weight: 800;
  margin: 12px 0 4px;
}

.login-card .sub { color: var(--text-muted); margin-bottom: 20px; }
.login-card form { text-align: left; }
.login-card form input, .login-card form button { width: 100%; }
.login-card form button { margin-top: 14px; }
.login-card small { display: block; color: var(--text-muted); margin-top: 18px; }
.app-lock { position: fixed; inset: 0; z-index: 90; }
.lock-identity { margin: 0 0 10px; color: var(--text-main); font-size: 15px; font-weight: 700; line-height: 1.4; letter-spacing: 0.1px; }
.lock-fields { text-align: left; }
.lock-fields input, .lock-fields button { width: 100%; }
.lock-fields .ghost { margin-top: 8px; }
body[data-theme="dark"] .login-wrap { background: var(--bg-main); }

.brand-mark {
  width: 52px;
  height: 52px;
  margin: auto;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-radius: 16px;
  color: #fff;
  font-size: 28px;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.3);
}

.brand-mark span { color: #f59e0b; }
.brand-mark.small { width: 40px; height: 40px; font-size: 22px; border-radius: 12px; }
.account-photo { width: 40px; height: 40px; border-radius: 12px; object-fit: cover; flex-shrink: 0; }
.brand-mark.large { width: 72px; height: 72px; font-size: 38px; border-radius: 22px; }

/* Main App Layout */
.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  padding: 0 24px;
  border-bottom: 1px solid var(--line-color);
}

.account-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  color: inherit;
  padding: 6px 8px;
  border-radius: 12px;
  text-align: left;
}
.account-btn:hover { background: var(--hover); transform: none; }
.icon-btn { width: 40px; height: 40px; padding: 0; font-size: 18px; }

.settings {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 30;
  display: flex;
  justify-content: flex-start;
}
.settings-card {
  width: min(380px, 100%);
  height: 100%;
  background: var(--card-bg);
  box-shadow: 8px 0 30px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
}
.settings-head { display: flex; align-items: center; gap: 8px; padding: 16px; border-bottom: 1px solid var(--line-color); flex-shrink: 0; }
.settings-head b { font-size: 18px; }
.settings-menu {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--line-color) transparent;
}
.settings-menu::-webkit-scrollbar { width: 6px; }
.settings-menu::-webkit-scrollbar-thumb { background: var(--line-color); border-radius: 999px; }
.settings-menu button {
  display: flex;
  flex: 0 0 auto;
  gap: 12px;
  align-items: center;
  background: transparent;
  color: inherit;
  text-align: left;
  border-radius: 12px;
}
.settings-menu button span:first-child {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #eff6ff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.settings-menu small { display: block; color: var(--text-muted); font-size: 12px; font-weight: 500; }
.settings-page { padding: 16px 20px; overflow: auto; }
.settings-page p, .settings-page li { color: var(--text-muted); font-size: 14px; }
.settings.settings-ai-knowledge-fullscreen { background: var(--card-bg); }
.settings.settings-ai-knowledge-fullscreen .settings-card {
  width: 100%;
  max-width: none;
  box-shadow: none;
}
.settings.settings-ai-knowledge-fullscreen .settings-page {
  flex: 1;
  min-height: 0;
  padding: 20px clamp(16px, 4vw, 56px);
}
.ai-knowledge-search-label { display: block; margin: 8px 0 6px; font-size: 13px; font-weight: 600; }
.ai-knowledge-search {
  width: 100%;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line-color);
  border-radius: 9px;
  background: var(--input-bg);
  color: var(--text-main);
  font: inherit;
}
.ai-knowledge-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 10px; }
.ai-knowledge-list .ai-knowledge-card { margin-top: 0; }
.ai-knowledge-upload, .ai-knowledge-form { display: grid; gap: 8px; }
.ai-knowledge-upload { padding: 12px; border: 1px solid var(--line-color); border-radius: 10px; }
.ai-knowledge-upload small { color: var(--text-muted); }
.ai-knowledge-upload input[type="file"] { width: 100%; color: var(--text-main); }
.ai-knowledge-draft { display: grid; gap: 8px; }
.ai-knowledge-draft textarea, .ai-knowledge-draft input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line-color);
  border-radius: 9px;
  background: var(--input-bg);
  color: var(--text-main);
  font: inherit;
}
.ai-knowledge-draft textarea { resize: vertical; }
.ai-knowledge-form input:not([type="checkbox"]), .ai-knowledge-form textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line-color);
  border-radius: 9px;
  background: var(--input-bg);
  color: var(--text-main);
  font: inherit;
}
.ai-knowledge-active { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.ai-knowledge-active input { width: auto; }
.ai-knowledge-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-knowledge-card { padding: 12px; margin-top: 10px; border: 1px solid var(--line-color); border-radius: 10px; }
.ai-knowledge-card b { overflow-wrap: anywhere; }
.ai-knowledge-card p { margin: 8px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-knowledge-card small { display: block; margin-bottom: 8px; color: var(--text-muted); overflow-wrap: anywhere; }
.online-users-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.online-users-toolbar p { margin: 0; font-weight: 700; color: var(--text-main); }
.online-users-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.online-user-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; border: 1px solid var(--line-color); border-radius: 12px; background: var(--card-bg); }
.online-user-details { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.online-user-details b { color: var(--text-main); overflow-wrap: anywhere; }
.online-user-details small { color: var(--text-muted); overflow-wrap: anywhere; }
.online-user-indicator { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .14); }
.online-users-note { margin-top: 12px; }
.profile-card { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.profile-card .avatar, .profile-card img.avatar { width: 72px; height: 72px; border-radius: 18px; font-size: 20px; object-fit: cover; }
.profile-avatar-preview {
  cursor: zoom-in;
  transition: transform .15s ease, box-shadow .15s ease;
}
.profile-avatar-preview:hover,
.profile-avatar-preview:focus-visible {
  transform: scale(1.04);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
  outline: none;
}
.profile-card b, .profile-card small { display: block; }
.profile-card small { color: var(--text-muted); font-weight: 600; margin-top: 2px; }
.avatar-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.avatar-actions button { padding: 8px 12px; }
.theme-choices { display: flex; flex-direction: column; gap: 8px; }
.theme-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  color: var(--text-main);
  border: 2px solid var(--line-color);
  text-align: left;
}
.theme-choice span { width: 36px; height: 24px; border-radius: 8px; display: inline-block; }
.theme-choice.active { border-color: var(--primary); }
.wall-choices button { width: 64px; height: 42px; border-radius: 10px; border: 2px solid transparent; padding: 0; }
.wall-choices button.active { border-color: #2563eb; }

.brand-title b { font-size: 16px; font-weight: 800; display: block; }
.brand-title small { color: var(--text-muted); font-size: 12px; }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 64px 420px minmax(0, 1fr);
  margin: 0;
  width: 100%;
  background: var(--card-bg);
  border: none;
  border-radius: 0;
  overflow: hidden;
}

/* Sidebar */
.quick-navigation {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px 84px;
  border-right: 1px solid var(--line-color);
  background: var(--sidebar-bg);
  z-index: 18;
}
.quick-nav-btn {
  display: grid;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  place-items: center;
  padding: 5px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
}
.quick-nav-ai { text-decoration: none; }
.quick-nav-btn:hover,
.quick-nav-btn:focus-visible,
.quick-nav-btn[aria-current="page"] {
  background: var(--hover);
  color: var(--primary);
}
.quick-nav-btn svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.quick-nav-label { display: none; }
.quick-nav-history { display: none; }
.quick-navigation button:disabled { opacity: .4; cursor: default; transform: none; }
.sidebar {
  grid-column: 2;
  grid-row: 1;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line-color);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.chat-panel { grid-column: 3; grid-row: 1; min-width: 0; }

.side-head {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.side-head h2 { font-size: 18px; font-weight: 800; margin: 0; }
.side-head button { width: 34px; height: 34px; padding: 0; border-radius: 10px; font-size: 18px; }

.search {
  margin: 0 16px 12px;
  border-radius: 12px;
  background: var(--input-bg);
}

.conversation-tools { position: relative; flex: 0 0 auto; }
.conversation-search-row { display: flex; align-items: center; }
.conversation-search-row #search { flex: 1 1 auto; min-width: 0; }
.conversation-filter-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 16px 12px;
}
.conversation-filter-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid var(--line-color);
  border-radius: 11px;
  background: var(--input-bg);
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.conversation-filter-btn svg {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.conversation-filter-btn:hover { background: var(--hover); color: var(--text-main); }
.conversation-filter-btn.active,
.conversation-filter-btn[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--tool-bg);
  color: var(--primary);
}
.conversation-filter-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

#conversation-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}
.conversation-department-heading {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 18px 5px;
  background: var(--sidebar-bg);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Memperhalus dan memepetkan scrollbar ke kanan pada Chrome/Edge/Safari */
#conversation-list::-webkit-scrollbar {
  width: 6px;
}

#conversation-list::-webkit-scrollbar-track {
  background: transparent;
}

#conversation-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
}

#conversation-list::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.6);
}


.conversation-row {

  width: calc(100% - 12px);
  margin: 4px 6px;
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  border-radius: 12px;
  background: transparent;
  color: var(--text-main);
  text-align: left;
  border: none;
}

.conversation-row:hover { background: var(--hover); }
.conversation-row.active { background: var(--active); }

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
}

.conversation-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.conversation-top, .conversation-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.conversation-info b { flex: 1; min-width: 0; display: block; font-size: 14px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.conversation-time { margin-left: auto; color: var(--text-muted); font-size: 11px; flex-shrink: 0; }
.conversation-preview { flex: 1; min-width: 0; color: var(--text-muted); font-size: 12px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
body[data-theme="dark"] .conversation-time { color: #d1d7db; }
.unread-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #22c55e;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.mention-badge {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.pinned-chat-badge {
  font-size: 13px;
  line-height: 1;
  opacity: 0.75;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}

#pin-conversation-btn.active {
  background: var(--hover);
  color: var(--primary);
  opacity: 1;
}

/* Chat Panel */
.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--card-bg);
}

#conversation {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
}

/* Drag and Drop Overlay */
.chat-drop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
  animation: fadeIn 0.15s ease-out;
}

.drop-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px 40px;
  background: var(--card-bg);
  border: 2px dashed var(--primary);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  color: var(--text-main);
  text-align: center;
  max-width: 90%;
}

.drop-icon {
  font-size: 42px;
  animation: bounce 1s infinite alternate;
}

.drop-overlay-content b {
  font-size: 16px;
  color: var(--text-main);
}

.drop-overlay-content small {
  color: var(--text-muted);
  font-size: 13px;
}

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

.empty {
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
}

.empty h2 { color: var(--text-main); margin-top: 16px; font-weight: 800; }

.chat-head {
  flex-shrink: 0;
  height: 64px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line-color);
}

.mobile-chat-title { display: none; }

.chat-info { flex: 1; min-width: 0; overflow: hidden; }
.chat-info b { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.chat-info small { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: 12px; }
.day-chip {
  align-self: center;
  margin: 8px auto;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--menu-bg);
  color: var(--text-muted);
  border: 1px solid var(--line-color);
  font-size: 12px;
  font-weight: 600;
}

/* Sticky Pin Banner Bar Styling */
.pin-bar {
  flex-shrink: 0;
  background: #ecfdf5;
  border-bottom: 1px solid #bbf7d0;
  padding: 8px 16px;
}
body[data-theme="dark"] .pin-bar { background: #064e3b; border-color: #047857; }
.pin-bar button { background: transparent; color: #166534; padding: 0; font-size: 13px; text-align: left; }
body[data-theme="dark"] .pin-bar button { color: #a7f3d0; }
.pin-bar b { margin-right: 6px; }

.message-selection-toolbar {
  display: none;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-color);
  background: var(--card-bg);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
}

.message-selection-actions { display: flex; align-items: center; gap: 8px; }

.ticks { margin-left: 6px; color: #94a3b8; letter-spacing: -1px; }
.ticks.read { color: #38bdf8; }
.edited { margin-right: 6px; opacity: 0.75; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.reaction-chip { background: var(--input-bg); color: var(--text-main); border-radius: 999px; padding: 2px 6px; font-size: 12px; }
.react-row { display: flex; gap: 4px; padding: 4px; }
.react-row button { background: transparent; padding: 4px; font-size: 18px; }
.composer-tool.recording { background: #ef4444; color: #fff; }
.forward-list { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; padding-right: 4px; }
.forward-list button { text-align: left; }

.forward-external-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}

.btn-forward-ext {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color, #e2e8f0);
  background: var(--input-bg, #f8fafc);
  color: var(--text-main, #1e293b);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-forward-ext:hover {
  background: var(--hover-bg, #f1f5f9);
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.btn-forward-gchat .ext-icon {
  font-size: 20px;
}

.btn-forward-wa .ext-icon {
  font-size: 20px;
}

.btn-forward-ext .ext-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.btn-forward-ext .ext-text strong {
  font-size: 13.5px;
  color: var(--text-main, #0f172a);
}

.btn-forward-ext .ext-text small {
  font-size: 11px;
  opacity: 0.75;
}

.forward-divider {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #64748b);
  margin: 6px 0 2px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.forward-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-color, #e2e8f0);
}

.forward-conv-item {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color, #e2e8f0);
  background: var(--card-bg, #ffffff);
  color: var(--text-main, #1e293b);
  cursor: pointer;
  transition: background 0.15s;
}

.forward-conv-item:hover {
  background: var(--hover-bg, #f1f5f9);
}

.forward-empty-notice {
  font-size: 12px;
  color: var(--text-muted, #64748b);
  padding: 8px 0;
}

.key-box {
  flex-shrink: 0;
  background: #fffbe2;
  border-bottom: 1px solid #fef3c7;
  padding: 10px 18px;
}

.key-header { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; color: #b45309; }
.key-box input { width: 100%; margin: 6px 0; padding: 6px 10px; font-size: 12px; }
.key-box small { color: #d97706; font-size: 11px; }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--messages-bg);
  background-image: radial-gradient(#cbd5e1 0.75px, transparent 0.75px);
  background-size: 18px 18px;
}

.bubble {
  position: relative;
  max-width: 70%;
  padding: 10px 28px 10px 14px;
  border-radius: 16px 16px 16px 4px;
  background: var(--bubble-other);
  border: 1px solid var(--line-color);
  color: var(--text-main);
  align-self: flex-start;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.bubble.mine {
  align-self: flex-end;
  background: var(--bubble-mine);
  color: #111b21;
  border-color: #b7e8ae;
  border-radius: 16px 16px 4px 16px;
}

.bubble small { display: block; text-align: right; font-size: 10px; color: #54656f; opacity: 0.85; margin-top: 4px; }
.message-text ol, .message-text ul, .file-caption ol, .file-caption ul { margin: 4px 0; padding-left: 22px; }
.message-text blockquote, .file-caption blockquote { margin: 5px 0; padding-left: 10px; border-left: 3px solid var(--primary); color: var(--text-muted); }
.inline-code { padding: 1px 5px; border-radius: 5px; background: rgba(15, 23, 42, .12); font-family: Consolas, monospace; font-size: .92em; }
.bubble.mine .inline-code { background: rgba(15, 23, 42, .08); }
.sender-name { display: block; font-size: 11px; font-weight: 700; margin-bottom: 4px; color: #1d4ed8; }
.direct-chat .sender-name { display: none; }
body[data-theme="dark"] .messages {
  background-color: var(--messages-bg);
  background-image: radial-gradient(#233138 0.75px, transparent 0.75px);
}
body[data-theme="dark"] .sender-name { color: #7fd1c3; }
body[data-theme="dark"] .bubble { color: var(--text-main); }
body[data-theme="dark"] .bubble.mine { color: #e9edef; border-color: #005c4b; }
body[data-theme="dark"] .bubble.mine .sender-name { color: #53bdeb; }
body[data-theme="dark"] .bubble.mine .bubble-more { color: #8696a0; }
body[data-theme="dark"] .bubble small,
body[data-theme="dark"] .bubble.mine small { color: #8696a0; }

body[data-theme="fullcolor"] .sender-name { color: #c026d3; }
body[data-theme="fullcolor"] .bubble.mine { color: #ffffff; border-color: #6d28d9; }
body[data-theme="fullcolor"] .bubble.mine .sender-name { color: #fed7aa; }
body[data-theme="fullcolor"] .bubble.mine .bubble-more { color: #e9d5ff; }
body[data-theme="fullcolor"] .bubble.mine small { color: rgba(255, 255, 255, 0.85); }

.bubble.mine .sender-name { color: #1e40af; }
.bubble-more {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  color: #64748b;
  font-size: 14px;
  line-height: 1;
}
.bubble.mine .bubble-more { color: #54656f; }
.bubble-more:hover { background: rgba(15, 23, 42, 0.08); color: #0f172a; transform: none; }
.bubble.mine .bubble-more:hover { background: rgba(15, 23, 42, 0.08); color: #0f172a; }

.composer {
  flex-shrink: 0;
  padding: 12px 18px;
  display: flex;
  gap: 10px;
  border-top: 1px solid var(--line-color);
  background: var(--card-bg);
  position: relative;
}

.composer textarea {
  flex: 1;
  resize: none;
  border-radius: 12px;
  line-height: 1.4;
  max-height: 160px;
  overflow-y: auto;
  color: var(--text-main);
  background: var(--input-bg);
}
.composer-input-wrap {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
}
.composer-input-wrap textarea {
  width: 100%;
  min-width: 0;
}
.format-toolbar {
  position: fixed;
  z-index: 80;
  left: 8px;
  top: 8px;
  display: flex;
  align-items: center;
  gap: 3px;
  max-width: calc(100vw - 24px);
  overflow-x: auto;
  padding: 5px;
  border: 1px solid var(--line-color);
  border-radius: 14px;
  background: var(--menu-bg);
  color: var(--text-main);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .22);
}
.format-toolbar button {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 4px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-main);
  font-size: 15px;
}
.format-toolbar button:hover { background: var(--hover); transform: none; }
.format-divider { width: 1px; height: 22px; flex: 0 0 1px; margin: 0 3px; background: var(--line-color); }
.pasted-image-draft {
  display: grid;
  grid-template-columns: minmax(260px, 380px) minmax(0, 1fr) 44px;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 10px;
  margin: 0 18px 8px;
  padding: 8px 10px;
  border: 1px solid var(--line-color);
  border-radius: 12px;
  background: var(--card-bg);
}
.pasted-image-draft > img { width: 100%; height: 260px; grid-row: 1; object-fit: contain; cursor: zoom-in; border-radius: 8px; background: var(--tool-bg); }
.pasted-image-copy { min-width: 0; flex: 1; }
.pasted-image-copy b, .pasted-image-copy small { display: block; }
.pasted-image-copy b { color: var(--text-main); font-size: 13px; }
.pasted-image-copy small { color: var(--text-muted); font-size: 12px; }
.pasted-image-draft > button { grid-column: 3; grid-row: 1; width: 42px; min-width: 42px; height: 42px; padding: 6px; border: 1px solid var(--line-color); border-radius: 50%; background: var(--tool-bg); color: var(--primary); font-size: 20px; }
.pasted-image-draft > button:hover { background: var(--primary); color: #fff; border-color: var(--primary); transform: none; }
.pasted-image-list { grid-column: 1 / -1; display: flex; gap: 7px; max-width: 100%; overflow-x: auto; padding: 2px 0; }
.pasted-image-thumb { position: relative; flex: 0 0 48px; width: 48px; height: 48px; padding: 2px; border: 1px solid var(--line-color); border-radius: 7px; background: var(--card-bg); }
.pasted-image-thumb.active { border: 2px solid var(--primary); padding: 1px; }
.pasted-image-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: 4px; }
.pasted-image-thumb span { position: absolute; right: 2px; bottom: 2px; min-width: 15px; padding: 1px 3px; border-radius: 8px; background: rgba(15,23,42,.78); color: #fff; font-size: 10px; line-height: 13px; }
.file-caption { margin-top: 8px; color: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
.composer-tool {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  padding: 0;
  border-radius: 12px;
  background: var(--tool-bg);
  color: var(--text-main);
  font-size: 20px;
}
.composer-tool:hover { background: var(--hover); color: var(--text-main); transform: none; }
.attach-menu, .attach-form {
  position: absolute;
  left: 18px;
  bottom: 72px;
  z-index: 40;
  width: 230px;
  background: var(--menu-bg);
  color: var(--text-main);
  border: 1px solid var(--line-color);
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.16);
  padding: 8px;
}
.attach-form { width: min(320px, calc(100% - 36px)); }
.attach-menu button, .attach-form button.ghost {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  background: transparent;
  color: var(--text-main);
  text-align: left;
}
.attach-menu button:hover, .attach-form button.ghost:hover { background: var(--hover); transform: none; }
.attach-menu span { width: 24px; text-align: center; }
.attach-form input { width: 100%; margin-top: 8px; }
.attach-form b { display: block; margin-bottom: 4px; }
.attach-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.attach-actions button { width: auto; }
#contact-results, #sticker-grid { max-height: 160px; overflow: auto; margin-top: 8px; }
#sticker-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
#sticker-grid button { background: transparent; font-size: 28px; padding: 4px; }
#sticker-grid button:hover { background: var(--hover); transform: none; }
.contact-hit, .poll-choice, .event-card, .contact-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--tool-bg);
  color: var(--text-main);
  border-radius: 10px;
  margin-top: 6px;
}
.contact-hit:hover, .poll-choice:hover { background: var(--hover); transform: none; }
.chat-image, .chat-video { max-width: 260px; max-height: 280px; border-radius: 12px; display: block; cursor: pointer; background: #fff; }
.sticker-msg { font-size: 48px; line-height: 1; }
.emoji-panel {
  margin: 0 18px;
  padding: 10px;
  border: 1px solid var(--line-color);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: var(--menu-bg);
}
.emoji-panel input { width: 100%; margin-bottom: 7px; }
.emoji-category-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  padding: 2px 0 6px;
  margin-bottom: 5px;
  border-bottom: 1px solid var(--line-color);
  scrollbar-width: thin;
}
.emoji-category-tab {
  flex: 0 0 34px;
  width: 34px;
  min-width: 34px;
  height: 32px;
  padding: 2px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 19px;
}
.emoji-category-tab.active { color: var(--primary); background: var(--hover); box-shadow: inset 0 -2px 0 var(--primary); }
.emoji-category-tab:hover { background: var(--hover); transform: none; }
.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 4px;
  max-height: 230px;
  overflow-y: auto;
  align-content: start;
}
.emoji-picker-grid button {
  background: transparent;
  color: inherit;
  font-size: 22px;
  line-height: 1;
  padding: 4px;
  border-radius: 8px;
}
.emoji-picker-grid button:hover { background: var(--hover); transform: none; }
.emoji-section-title { grid-column: 1 / -1; padding: 4px 2px; color: var(--text-muted); font-size: 12px; font-weight: 700; }
.emoji-empty { grid-column: 1 / -1; padding: 18px 8px; color: var(--text-muted); font-size: 13px; text-align: center; }

.reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 18px;
  padding: 8px 12px;
  border-left: 3px solid var(--primary);
  background: #eff6ff;
  border-radius: 10px 10px 0 0;
}
body[data-theme="dark"] .reply-bar {
  background: #1e293b;
}
.reply-copy { min-width: 0; }
.reply-copy b { display: block; color: var(--primary); font-size: 12px; }
.reply-copy span {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quote {
  border-left: 3px solid #60a5fa;
  background: rgba(15, 23, 42, 0.06);
  border-radius: 8px;
  padding: 6px 8px;
  margin-bottom: 6px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background .15s ease, box-shadow .15s ease;
}
.quote:hover, .quote:focus-visible { background: rgba(59, 130, 246, .16); outline: 2px solid #60a5fa; outline-offset: 1px; }
.bubble.mine .quote { background: rgba(0, 0, 0, 0.05); border-left-color: var(--primary); }
body[data-theme="dark"] .bubble.mine .quote { background: rgba(255, 255, 255, 0.08); border-left-color: #00a884; }
body[data-theme="fullcolor"] .bubble.mine .quote { background: rgba(255, 255, 255, 0.16); border-left-color: #fff; }
.bubble.message-jump-highlight { animation: message-jump-highlight 1.8s ease-out; }
@keyframes message-jump-highlight {
  0%, 35% { box-shadow: 0 0 0 4px rgba(37, 99, 235, .65); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}
.msg-menu {
  position: fixed;
  z-index: 200;
  min-width: 180px;
  background: #1f2c34;
  color: #fff;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}
.msg-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
}
.msg-menu button:hover { background: #2a3942; transform: none; }
.msg-menu button.danger { color: #fca5a5; }

/* Mention Highlight & Popup Suggestion */
.mention-tag {
  background: rgba(37, 99, 235, 0.15);
  color: #2563eb;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
}
body[data-theme="dark"] .mention-tag {
  background: rgba(0, 168, 132, 0.25);
  color: #00a884;
}
.bubble.mine .mention-tag {
  background: rgba(37, 99, 235, 0.15);
  color: #1d4ed8;
}
body[data-theme="dark"] .bubble.mine .mention-tag {
  background: rgba(0, 168, 132, 0.25);
  color: #25d366;
}
body[data-theme="fullcolor"] .bubble.mine .mention-tag {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.mention-popup {
  position: absolute;
  bottom: 68px;
  left: 60px;
  z-index: 50;
  width: 240px;
  max-height: 180px;
  overflow-y: auto;
  background: var(--menu-bg);
  color: var(--text-main);
  border: 1px solid var(--line-color);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}
.mention-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--line-color);
  color: var(--text-main);
}
.mention-item:hover { background: var(--hover); }

/* Lightbox Modal CSS */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(5px);
}
.lightbox-content {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 8px;
  object-fit: contain;
  transform-origin: center center;
  transition: transform .15s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
#lightbox-img { cursor: zoom-in; touch-action: none; user-select: none; -webkit-user-drag: none; }
#lightbox-img.can-pan { cursor: grab; }
#lightbox-img.is-panning { cursor: grabbing; transition: none; }
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 25px;
  color: #fff;
  font-size: 36px;
  font-weight: bold;
  cursor: pointer;
}
.lightbox-toolbar {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: calc(100vw - 20px);
  overflow-x: auto;
  padding: 7px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 14px;
  background: rgba(24, 32, 38, .96);
  box-shadow: 0 8px 26px rgba(0,0,0,.45);
}
.lightbox-toolbar button, .lightbox-action {
  flex: 0 0 42px;
  width: 42px;
  min-width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #f8fafc;
  font-size: 23px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}
.lightbox-toolbar button:hover, .lightbox-action:hover { background: rgba(255,255,255,.15); color: #fff; transform: none; }
.lightbox-toolbar #lightbox-close { font-size: 29px; }
.lightbox-emoji-picker {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 70px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: min(440px, calc(100vw - 24px));
  max-height: min(54vh, 390px);
  padding: 10px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 12px;
  background: rgba(24, 32, 38, .97);
  box-shadow: 0 8px 26px rgba(0,0,0,.45);
}
.lightbox-emoji-picker .emoji-picker-search { width: 100%; flex: 0 0 auto; margin: 0; background: #141a1d; color: #f8fafc; border-color: rgba(255,255,255,.18); }
.lightbox-emoji-picker .emoji-category-tabs { flex: 0 0 auto; border-color: rgba(255,255,255,.14); }
.lightbox-emoji-picker .emoji-category-tab { color: #b7c0c5; }
.lightbox-emoji-picker .emoji-category-tab.active { color: #00a884; background: rgba(255,255,255,.08); box-shadow: inset 0 -2px 0 #00a884; }
.lightbox-emoji-picker .emoji-picker-grid { max-height: none; min-height: 100px; color: #f8fafc; }
.lightbox-emoji-picker .emoji-section-title, .lightbox-emoji-picker .emoji-empty { color: #b7c0c5; }
.lightbox-emoji-picker .emoji-picker-grid button:hover, .lightbox-emoji-picker .emoji-category-tab:hover { background: rgba(255,255,255,.12); }
.lightbox-caption {
  margin-top: 14px;
  color: #fff;
  display: flex;
  gap: 16px;
  align-items: center;
}
@media (max-width: 600px) {
  .lightbox-toolbar { bottom: 8px; gap: 2px; padding: 5px; }
  .lightbox-toolbar button, .lightbox-action { flex-basis: 36px; width: 36px; min-width: 36px; height: 38px; font-size: 20px; }
  .lightbox-emoji-picker { bottom: 58px; max-height: 58vh; }
  .lightbox-content { max-width: 96vw; max-height: 76vh; }
}
.lightbox-btn {
  background: #2563eb;
  color: #fff;
  padding: 6px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}

/* Tab Navigation Modal Grup & Galeri Media */
.group-tab-nav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line-color);
  margin-bottom: 14px;
}
.tab-btn {
  background: transparent;
  color: var(--text-muted);
  border-radius: 0;
  border-bottom: 2px solid transparent;
  padding: 8px 12px;
  font-weight: 600;
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: transparent;
}
.media-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}
.media-gallery-item {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--line-color);
}
.danger-text { color: #ef4444; border-color: #fca5a5; }

/* Modal General */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
  z-index: 100;
}

.modal-card {
  width: min(480px, 90%);
  background: var(--card-bg);
  color: var(--text-main);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  max-height: 90vh;
  overflow-y: auto;
}

.search-results-box {
  max-height: 120px;
  overflow-y: auto;
  border: 1px solid var(--line-color);
  border-radius: 8px;
  margin-top: 4px;
}

.search-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--line-color);
}
.search-item:hover { background: var(--hover); }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.mobile-back { display: none; }
.mobile-navigation { display: flex; }

.quick-page-modal { z-index: 100; }
.quick-page-card {
  width: min(680px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
}
.quick-page-card .modal-header-flex { margin-bottom: 14px; }
.quick-page-card .modal-header-flex h2 { margin: 0; }
.quick-page-content-list { display: flex; flex-direction: column; gap: 8px; }
.quick-page-empty { padding: 22px 10px; text-align: center; color: var(--text-muted); }
.call-log-row,
.status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line-color);
  border-radius: 12px;
  background: var(--card-bg);
}
.call-log-icon {
  display: grid;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  background: var(--tool-bg);
  color: var(--primary);
  font-size: 19px;
}
.call-log-icon.missed { color: #ef4444; }
.call-log-details,
.status-row-details { flex: 1 1 auto; min-width: 0; }
.call-log-details strong,
.call-log-details small,
.status-row-details strong,
.status-row-details small { display: block; }
.call-log-details small,
.status-row-details small { margin-top: 3px; color: var(--text-muted); }
.call-log-row > button,
.status-row > button { flex: 0 0 auto; padding: 7px 10px; }
.status-compose {
  display: grid;
  gap: 9px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line-color);
  border-radius: 12px;
  background: var(--input-bg);
}
.status-compose textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  box-sizing: border-box;
}
.status-attach-button { justify-self: start; }
.status-compose-actions { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.status-compose-actions button { padding: 8px 12px; }
.status-preview {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: min(60vh, 480px);
  object-fit: contain;
  object-position: center;
  border-radius: 10px;
  background: var(--tool-bg);
}
.status-row { align-items: flex-start; }
.status-row img {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: min(65vh, 600px);
  object-fit: contain;
  object-position: center;
  border-radius: 10px;
  background: var(--tool-bg);
}
.status-row-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0 0; }
.quick-page-modal.status-viewer-open .quick-page-card { width: min(820px, calc(100% - 24px)); }
.status-feed { display: flex; flex-direction: column; gap: 12px; }
.status-feed-section-heading { display: none; }
.status-own-section {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-color);
}
.status-contact-card {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-main);
  text-align: left;
}
.status-contact-card:hover { background: var(--hover); }
.status-avatar-ring {
  display: grid;
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 3px solid var(--line-color);
  border-radius: 50%;
}
.status-avatar-ring.unseen { border-color: #22c55e; }
.status-avatar-ring.own { border-style: dashed; }
.status-avatar-initial {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  background: var(--tool-bg);
  color: var(--primary);
  font-size: 15px;
  font-weight: 700;
}
.status-contact-details { display: block; min-width: 0; }
.status-contact-details strong,
.status-contact-details small { display: block; }
.status-contact-details small { margin-top: 4px; color: var(--text-muted); }
.status-add-button {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border-radius: 50%;
  font-size: 25px;
  line-height: 1;
}
.status-feed-list { display: flex; flex-direction: column; gap: 4px; }
.status-story-viewer { display: flex; flex-direction: column; gap: 12px; }
.status-story-progress { display: flex; gap: 4px; }
.status-story-progress span { position: relative; height: 3px; flex: 1 1 0; overflow: hidden; border-radius: 99px; background: var(--line-color); }
.status-story-progress span.complete { background: var(--primary); }
.status-story-progress span.current i {
  position: absolute;
  inset: 0;
  background: var(--primary);
  transform: scaleX(0);
  transform-origin: left center;
}
.status-story-progress.auto:not(.video) span.current i { animation: status-story-fill 15s linear forwards; }
.status-story-progress.paused span.current i { animation-play-state: paused; }
.status-story-progress.video span.current i { transition: transform 120ms linear; }
@keyframes status-story-fill { to { transform: scaleX(1); } }
.status-story-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status-story-meta small { color: var(--text-muted); text-align: right; }
.status-more-wrap { position: relative; flex: 0 0 auto; margin-left: auto; }
.status-more-button { width: 38px; height: 38px; padding: 0; font-size: 24px; line-height: 1; }
.status-story-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  min-width: 150px;
  padding: 5px;
  border: 1px solid var(--line-color);
  border-radius: 10px;
  background: var(--card-bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}
.status-story-menu[hidden] { display: none; }
.status-story-menu button { width: 100%; padding: 9px 10px; text-align: left; }
.status-story-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  max-height: 68vh;
  overflow: auto;
  border-radius: 14px;
  background: #0b141a;
}
.status-story-stage > img,
.status-story-stage > video {
  display: block;
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
  background: #0b141a;
}
.status-story-stage.text-only { background: var(--primary-dark); color: #fff; }
.status-story-caption {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 12px 14px;
  color: var(--text-main);
  background: var(--card-bg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.status-story-caption a { color: var(--primary); text-decoration: underline; }
.status-story-stage.text-only .status-story-caption {
  width: min(100%, 620px);
  padding: 32px 22px;
  color: #fff;
  background: transparent;
  font-size: clamp(20px, 4vw, 32px);
  text-align: center;
}
.status-story-controls { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.status-story-controls button { padding: 8px 12px; }
.status-zoom-button { width: 40px; height: 40px; margin-left: auto; padding: 8px; }
.status-zoom-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.status-story-stage > img.status-story-zoomable { cursor: zoom-in; }
.status-viewers-button { display: inline-flex; align-items: center; gap: 7px; }
.status-viewers-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.status-reaction-bar {
  display: flex;
  flex: 1 1 100%;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
.status-reaction-button {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line-color);
  border-radius: 50%;
  background: var(--input-bg);
  color: var(--text-main);
  font-size: 21px;
}
.status-story-controls .status-reaction-button { padding: 0; }
.status-reaction-button:hover { background: var(--hover); transform: translateY(-1px); }
.status-text-reply {
  display: flex;
  flex: 1 1 260px;
  min-width: 220px;
  height: 40px;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 12px;
  border: 1px solid var(--line-color);
  border-radius: 22px;
  background: var(--input-bg);
}
.status-text-reply-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 32px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-main);
  font-size: 14px;
}
.status-text-reply-send {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}
.status-text-reply-send:disabled {
  opacity: .55;
  cursor: wait;
}
.status-reply-link {
  display: flex;
  width: 100%;
  min-width: 0;
  margin: 2px 0 8px;
  padding: 8px 10px;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border: 0;
  border-left: 3px solid #60a5fa;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.06);
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.status-reply-link:hover,
.status-reply-link:focus-visible {
  background: rgba(59, 130, 246, .16);
  outline: 2px solid #60a5fa;
  outline-offset: 1px;
}
.status-reply-link b {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: #2563eb;
}
.status-reply-link span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 12px;
}
.status-reply-emoji {
  min-width: 44px;
  font-size: 28px;
  line-height: 1.15;
  text-align: center;
}
.status-reply-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.status-viewers {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 180px;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--line-color);
  border-radius: 10px;
}
.status-viewers small,
.status-viewers span { color: var(--text-muted); }

@media (max-width: 768px) {
  .quick-page-modal.status-feed-open {
    display: block;
    padding: 0;
    background: var(--card-bg);
    backdrop-filter: none;
  }
  .quick-page-modal.status-feed-open .quick-page-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: calc(10px + env(safe-area-inset-top)) 16px calc(10px + env(safe-area-inset-bottom));
    overflow: hidden;
    border-radius: 0;
    box-sizing: border-box;
  }
  .quick-page-modal.status-feed-open .modal-header-flex { flex: 0 0 auto; margin-bottom: 8px; }
  .quick-page-modal.status-feed-open #quick-page-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: 12px;
  }
  .status-feed-section-heading {
    display: block;
    margin: 6px 0 0;
    font-size: 17px;
    font-weight: 700;
  }
  .status-own-section {
    position: relative;
    display: block;
    padding-bottom: 10px;
  }
  .status-own-section .status-contact-card { width: 100%; min-height: 84px; padding: 8px 0; }
  .status-own-section .status-add-button {
    position: absolute;
    top: 48px;
    left: 48px;
    z-index: 1;
    width: 28px;
    height: 28px;
    border: 2px solid var(--card-bg);
    font-size: 19px;
  }
  .status-contact-card { min-height: 84px; gap: 14px; padding: 8px 0; }
  .status-avatar-ring { flex-basis: 68px; width: 68px; height: 68px; overflow: hidden; }
  .status-avatar-initial { width: 58px; height: 58px; }
  .status-contact-details strong { font-size: 16px; }
  .status-contact-details small { font-size: 14px; }
  .status-feed-list { gap: 2px; }

  .quick-page-modal.status-viewer-open {
    display: block;
    padding: 0;
    background: #0b141a;
    backdrop-filter: none;
  }
  .quick-page-modal.status-viewer-open .quick-page-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: calc(10px + env(safe-area-inset-top)) 14px calc(10px + env(safe-area-inset-bottom));
    overflow: hidden;
    border-radius: 0;
    box-sizing: border-box;
    background: #0b141a;
    color: #fff;
  }
  .quick-page-modal.status-viewer-open .modal-header-flex { flex: 0 0 auto; margin-bottom: 10px; }
  .quick-page-modal.status-viewer-open .modal-header-flex h2,
  .quick-page-modal.status-viewer-open .status-story-meta strong { color: #fff; }
  .quick-page-modal.status-viewer-open .close-icon-btn {
    border-color: rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .08);
    color: #fff;
  }
  .quick-page-modal.status-viewer-open #quick-page-content { flex: 1 1 auto; min-height: 0; overflow: hidden; }
  .quick-page-modal.status-viewer-open .status-story-viewer { min-height: 100%; }
  .quick-page-modal.status-viewer-open .status-story-progress,
  .quick-page-modal.status-viewer-open .status-story-meta,
  .quick-page-modal.status-viewer-open .status-story-controls { flex: 0 0 auto; }
  .quick-page-modal.status-viewer-open .status-story-meta { flex: 0 0 auto; flex-wrap: nowrap; }
  .quick-page-modal.status-viewer-open .status-story-meta > strong {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .quick-page-modal.status-viewer-open .status-story-meta > small {
    flex: 0 0 auto;
    order: 0;
    color: #aab7bf;
    text-align: right;
    white-space: nowrap;
  }
  .quick-page-modal.status-viewer-open .status-more-wrap { margin-left: 0; }
  .quick-page-modal.status-viewer-open .status-story-stage {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: hidden;
    border-radius: 0;
    touch-action: pan-y;
  }
  .quick-page-modal.status-viewer-open .status-story-stage > img,
  .quick-page-modal.status-viewer-open .status-story-stage > video {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
  }
  .quick-page-modal.status-viewer-open .status-story-caption {
    flex: 0 0 auto;
    max-height: 20vh;
    overflow-y: auto;
    padding: 10px 16px;
    color: #fff;
    background: transparent;
    text-align: center;
  }
  .quick-page-modal.status-viewer-open .status-story-controls { justify-content: center; }
  .quick-page-modal.status-viewer-open .status-reaction-button,
  .quick-page-modal.status-viewer-open .status-viewers-button { color: #fff; }
  .quick-page-modal.status-viewer-open .status-viewers-button {
    border-color: rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .08);
  }

  .pasted-image-draft { grid-template-columns: minmax(180px, 240px) minmax(0, 1fr) 40px; gap: 8px; margin-right: 8px; margin-left: 8px; }
  .pasted-image-draft > img { height: 190px; }
  .pasted-image-draft > button { width: 38px; min-width: 38px; height: 38px; font-size: 18px; }
  .conversation-tools { z-index: 5; padding: 12px 12px 8px; }
  .conversation-search-row #search { margin: 0; min-height: 44px; }
  .conversation-filter-buttons { margin: 8px 0 0; gap: 8px; }
  .conversation-filter-btn { min-height: 42px; gap: 5px; padding: 7px 6px; font-size: 12px; }
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    margin: 0;
    border-radius: 0;
    width: 100%;
  }
  .sidebar,
  .chat-panel { grid-column: 1; grid-row: 1; }
  .chat-panel { display: none; }
  .layout.chat-open .chat-panel { display: flex; }
  .layout.chat-open .sidebar { display: none; }
  .mobile-back { display: block; }
  .mobile-navigation {
    grid-column: 1;
    grid-row: 2;
    flex-direction: row;
    justify-content: space-around;
    gap: 2px;
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line-color);
    background: var(--card-bg);
  }
  .mobile-navigation .quick-nav-btn {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    height: 52px;
    padding: 3px 1px;
    border: 0;
    border-radius: 8px;
    color: var(--text-muted);
  }
  .mobile-navigation .quick-nav-btn svg { width: 21px; height: 21px; }
  .quick-nav-label {
    display: block;
    font-size: 9px;
    line-height: 1.1;
    white-space: nowrap;
  }
  .quick-nav-history { display: flex; }
  .mobile-navigation .quick-nav-btn:disabled {
    opacity: 0.45;
    cursor: default;
    transform: none;
  }

  @media (max-width: 380px) {
    .quick-nav-label { font-size: 8px; }
  }
  .message-selection-toolbar:not([hidden]) { display: flex; }
  .message-selection-actions button { min-height: 40px; padding: 8px 12px; }
  #forward-selected-messages { background: var(--primary); color: #fff; }
  #forward-selected-messages:disabled { opacity: 0.5; cursor: default; }
  .bubble.selected-for-forward {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }
}

.group-members-scroll {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--line-color);
  border-radius: 12px;
  padding: 4px 12px;
  margin-top: 8px;
}

.modal-group-detail {
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px 24px;
}

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

.modal-header-flex h2 {
  margin: 0;
  font-size: 20px;
}

.close-icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 16px;
  display: grid;
  place-items: center;
}

.modal-body-scroll {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.members-scroll-box {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line-color);
  border-radius: 12px;
  padding: 4px 12px;
  background: var(--input-bg);
}

.member-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-color);
}
.member-item-row:last-child { border-bottom: none; }

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

.chat-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--line-color);
}

.chat-header-avatar[role="button"] {
  cursor: zoom-in;
  transition: transform .15s ease, border-color .15s ease;
}

.chat-header-avatar[role="button"]:hover,
.chat-header-avatar[role="button"]:focus-visible {
  transform: scale(1.04);
  border-color: var(--primary);
  outline: none;
}

.profile-photo-modal {
  background: rgba(0, 0, 0, .92);
  z-index: 1300;
  padding: 12px;
  backdrop-filter: blur(8px);
}

.profile-photo-viewer {
  width: min(720px, 92vw);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  max-height: calc(100dvh - 24px);
}

.profile-photo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
  min-height: 44px;
}

.profile-photo-header b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.profile-photo-close {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.profile-photo-close:hover,
.profile-photo-close:focus-visible {
  background: rgba(255, 255, 255, .22);
  outline: none;
}

.profile-photo-full {
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 80px);
  object-fit: contain;
  border-radius: 12px;
  user-select: none;
  box-shadow: 0 18px 55px rgba(0, 0, 0, .42);
}

.chat-header-avatar-mark {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  font-size: 15px;
}

.danger-icon-btn {
  color: #dc2626;
}

.danger-icon-btn:hover {
  color: #fff;
  background: #dc2626;
  border-color: #dc2626;
}

.conversation-row .avatar-img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--line-color);
}

.chat-date-wrap {
  position: relative;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}

.chat-date-btn {
  width: 100%;
  height: 100%;
  padding: 0;
  border-radius: 10px;
  background: var(--tool-bg);
  color: var(--text-main);
  font-size: 18px;
  display: grid;
  place-items: center;
}

#chat-date {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

#chat-date::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}
/* Mobile chat layout */
@media (max-width: 768px) {
  html, body { width: 100%; min-width: 0; }
  .app { height: 100vh; height: 100dvh; min-height: 0; }

  .topbar {
    height: 58px;
    min-height: 58px;
    flex: 0 0 58px;
    gap: 6px;
    padding: 0 10px;
  }
  .account-btn { min-width: 0; gap: 8px; padding: 6px 4px; }
  .brand-mark.small, .account-photo { width: 38px; height: 38px; flex: 0 0 38px; }
  .brand-title { min-width: 0; }
  .brand-title b { font-size: 15px; white-space: nowrap; }
  .brand-title small {
    display: block;
    max-width: clamp(82px, 25vw, 150px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
  }
  .topbar-actions { display: flex; flex-direction: row; flex: 0 0 auto; align-items: center; gap: 6px; }
  .topbar-actions .icon-btn {
    display: grid;
    place-items: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    text-decoration: none;
  }
  #logout { padding: 8px 10px; font-size: 13px; white-space: nowrap; }

  .layout {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    width: 100%;
    border: 0;
    border-radius: 0;
  }
  .mobile-chat-title {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 8px 14px 2px;
    color: var(--text-main);
    font-size: 16px;
    font-weight: 700;
    line-height: 22px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-chat-title-open {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
  }
  .mobile-chat-title-open:disabled {
    opacity: 1;
    cursor: default;
    transform: none;
  }
  .mobile-chat-title-open span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-chat-title-open small {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    line-height: 15px;
  }
  #mobile-chat-back { display: none; }
  #conversation.group-chat .chat-head,
  #conversation.direct-chat .chat-head { display: none; }
  #conversation.group-chat .mobile-chat-title,
  #conversation.direct-chat .mobile-chat-title {
    min-height: 44px;
    padding: 4px 10px;
    border-bottom: 1px solid var(--line-color);
  }
  #conversation.group-chat #mobile-chat-back,
  #conversation.direct-chat #mobile-chat-back {
    display: grid;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    padding: 0;
    place-items: center;
    font-size: 26px;
    line-height: 1;
  }
  #conversation.group-chat #mobile-group-actions-toggle,
  #conversation.direct-chat #mobile-group-actions-toggle {
    display: grid;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    padding: 0;
    place-items: center;
    font-size: 25px;
    line-height: 1;
  }
  #conversation.group-chat .chat-head,
  #conversation.direct-chat .chat-head {
    display: none;
    flex-wrap: wrap;
    justify-content: flex-start;
    min-height: 0;
    height: auto;
    padding: 8px 10px;
    gap: 7px;
    border-bottom: 1px solid var(--line-color);
  }
  #conversation.group-chat .chat-head #back-to-list,
  #conversation.group-chat .chat-head .chat-info-wrap,
  #conversation.direct-chat .chat-head #back-to-list,
  #conversation.direct-chat .chat-head .chat-info-wrap {
    display: none;
  }
  #conversation.group-chat.mobile-chat-actions-open .chat-head,
  #conversation.direct-chat.mobile-chat-actions-open .chat-head { display: flex; }
  #conversation.group-chat.mobile-chat-actions-open #chat-search,
  #conversation.direct-chat.mobile-chat-actions-open #chat-search {
    flex: 1 1 90px;
    width: auto;
    min-width: 90px;
  }
  .chat-head { height: auto; min-height: 56px; padding: 8px 10px; gap: 7px; }
  .mobile-back {
    display: grid;
    flex: 0 0 38px;
    width: 38px;
    height: 40px;
    padding: 0;
    place-items: center;
    font-size: 27px;
    line-height: 1;
  }
  .chat-info-wrap { display: none; }
  .chat-header-avatar, .chat-header-avatar-mark { width: 36px; height: 36px; flex: 0 0 36px; }
  .chat-info { min-width: 0; flex: 1 1 auto; }
  .chat-info b, .chat-info small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .chat-info b { font-size: 14px; }
  .chat-info small { font-size: 11px; }
  #chat-search {
    width: clamp(82px, 25vw, 112px);
    min-width: 0;
    flex: 0 1 clamp(82px, 25vw, 112px);
    padding: 9px 10px;
    font-size: 14px;
  }
  .chat-date-wrap { width: 36px; height: 36px; flex: 0 0 36px; }
  #group-settings-btn { width: 36px; height: 36px; flex: 0 0 36px; padding: 0; }

  .messages { padding: 12px 10px; gap: 8px; }
  .bubble { max-width: 88%; padding: 10px 26px 10px 12px; font-size: 15px; }
  .sender-name { font-size: 12px; }
  .bubble small { font-size: 11px; }

  .composer {
    display: grid;
    grid-template-columns: 40px 40px minmax(120px, 1fr) 48px;
    align-items: end;
    gap: 6px;
    padding: 8px 10px;
  }
  .composer textarea {
    width: 100%;
    min-width: 0;
    min-height: 56px;
    max-height: 120px;
    align-self: stretch;
    padding: 10px 11px;
    font-size: 17px;
    line-height: 24px;
  }
  .composer-tool { width: 40px; height: 48px; border-radius: 15px; font-size: 20px; }
  .send-button { width: 48px; height: 48px; }
}

@media (max-width: 380px) {
  .topbar { padding-right: 8px; padding-left: 8px; }
  .chat-head { padding-right: 8px; padding-left: 8px; gap: 5px; }
  #chat-search { width: 84px; flex-basis: 84px; }
  .composer {
    grid-template-columns: 36px 36px minmax(110px, 1fr) 46px;
    gap: 5px;
    padding-right: 8px;
    padding-left: 8px;
  }
  .composer-tool { width: 36px; height: 46px; font-size: 18px; }
  .send-button { width: 46px; height: 46px; }
}
.send-button {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.16);
}
.send-button:hover { background: var(--primary-dark); transform: none; }
.send-button svg { width: 22px; height: 22px; display: block; fill: currentColor; }

@media (max-width: 768px) { .send-button { width: 48px; height: 48px; } }
@media (max-width: 380px) { .send-button { width: 46px; height: 46px; } }
.message-info-card { width: min(420px, 90%); }
.message-info-summary { margin: 0 0 12px; color: var(--text-muted); font-size: 14px; }
.message-reader-list { display: grid; gap: 2px; max-height: 48vh; overflow-y: auto; }
.message-reader-row { display: flex; align-items: center; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--line-color); }
.message-reader-row:last-child { border-bottom: 0; }
.message-reader-avatar { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; }
.message-reader-details { min-width: 0; display: flex; flex-direction: column; }
.message-reader-details b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-reader-details small, .message-info-empty { color: var(--text-muted); font-size: 13px; }
.message-info-empty { margin: 4px 0 8px; }
/* Alur mulai chat: personal atau grup */
.new-chat-card { width: min(520px, 92vw); padding: 22px; }
.new-chat-header { margin-bottom: 12px; }
.new-chat-header h2 { margin: 0; font-size: 22px; }
.new-chat-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 14px; background: var(--tool-bg); }
.new-chat-modes button { padding: 10px 12px; border-radius: 10px; background: transparent; color: var(--text-muted); font-size: 14px; }
.new-chat-modes button.active { background: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(15, 23, 42, .12); }
.new-chat-modes button:hover:not(.active) { background: var(--hover); color: var(--text-main); transform: none; }
.new-chat-hint { margin: 10px 2px 14px; color: var(--text-muted); font-size: 13px; }
.new-chat-card label { margin-top: 12px; }
.new-chat-card label span { color: var(--text-muted); font-weight: 500; text-transform: none; letter-spacing: 0; }
.new-chat-card .include-all-stores-option { display: flex; align-items: center; gap: 9px; margin: 12px 0 14px; padding: 10px 12px; border: 1px solid var(--line-color); border-radius: 10px; background: var(--input-bg); color: var(--text-main); font-size: 13px; font-weight: 600; text-transform: none; letter-spacing: 0; cursor: pointer; }
.new-chat-card .include-all-stores-option input { width: 18px; height: 18px; flex: 0 0 18px; margin: 0; accent-color: var(--primary); }
.new-chat-card .include-all-stores-option span { color: inherit; }

.new-chat-results { max-height: 220px; }
.new-chat-search-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.new-chat-search-item > div:first-child { min-width: 0; flex: 1; }
.new-chat-search-item > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-item-check { width: 24px; height: 24px; flex: 0 0 24px; display: grid; place-items: center; border-radius: 50%; color: var(--primary); font-size: 18px; font-weight: 800; }
.new-chat-search-item.selected { background: color-mix(in srgb, var(--primary) 12%, var(--card-bg)); color: var(--text-main); }
.new-chat-search-item.selected .search-item-check { background: var(--primary); color: #fff; font-size: 14px; }
.new-chat-selected-wrap { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line-color); border-radius: 12px; background: var(--input-bg); }
.selected-members-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.selected-members-heading b { font-size: 13px; }
.selected-members-heading small { color: var(--text-muted); font-size: 11px; text-align: right; }
.selected-members { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.selected-members-empty { color: var(--text-muted); font-size: 12px; }
.selected-member-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 5px 7px 5px 10px; border-radius: 999px; background: var(--tool-bg); font-size: 12px; }
.selected-member-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remove-selected-member { width: 22px; height: 22px; flex: 0 0 22px; padding: 0; border-radius: 50%; background: transparent; color: var(--text-muted); font-size: 17px; line-height: 1; }
.remove-selected-member:hover { background: var(--hover); color: var(--text-main); transform: none; }
.new-chat-group-fields { margin-top: 8px; }
.new-chat-card .new-chat-actions { margin-top: 18px; }
.new-chat-card #create-chat:disabled { opacity: .5; cursor: not-allowed; transform: none; }
@media (max-width: 520px) {
  .new-chat-card { width: calc(100% - 24px); padding: 18px; border-radius: 16px; }
  .new-chat-header h2 { font-size: 20px; }
  .new-chat-modes button { min-height: 44px; padding: 9px 7px; font-size: 13px; }
  .selected-members-heading { align-items: flex-start; flex-direction: column; gap: 2px; }
  .selected-members-heading small { text-align: left; }
}
.contact-profile-card { width: min(380px, 92vw); }
.contact-profile-card .profile-card { margin-bottom: 14px; }
.contact-profile-card .profile-card b { overflow-wrap: anywhere; }
.contact-profile-details { border-top: 1px solid var(--line-color); padding-top: 8px; }
.contact-profile-details p { margin: 9px 0; color: var(--text-muted); font-size: 14px; overflow-wrap: anywhere; }
.contact-profile-details b { color: var(--text-main); }


.messages[data-wall="plain"] { background-image: none; background-color: #f8fafc; }
.messages[data-wall="green"] { background-color: #e7f6ef; background-image: none; }
.messages[data-wall="blue"] { background-color: #e8f1fb; background-image: none; }

/* Pastikan pilihan latar ruang percakapan (wallpaper) selalu menimpa latar bawaan tema */
body .messages[data-wall="plain"] {
  background-color: #f8fafc;
  background-image: none;
}

body .messages[data-wall="green"] {
  background-color: #e7f6ef;
  background-image: none;
}

body .messages[data-wall="blue"] {
  background-color: #e8f1fb;
  background-image: none;
}


.group-member-search {
  width: 100%;
  padding: 9px 12px;
  margin: 10px 0 12px;
  border: 1px solid var(--line-color);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text-main);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease;
}

.group-member-search:focus {
  border-color: var(--primary);
}


/* ========================================================
   MODAL PANGGILAN SUARA (VOICE CALL) & TOMBOL TELEPON
   ======================================================== */
.call-modal {
  z-index: 1200;
  background: rgba(11, 20, 26, 0.85);
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.call-card {
  width: min(340px, 90vw);
  background: #111b21;
  border: 1px solid #222e35;
  border-radius: 24px;
  padding: 32px 24px 28px;
  text-align: center;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  color: #e9edef;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  box-sizing: border-box;
}

.call-avatar-wrap {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  position: relative;
}

.call-avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: #00a884;
  color: #fff;
  font-size: 34px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 3px solid #202c33;
}

/* Animasi lingkaran berdenyut saat berdering */
.pulse-ring::before {
  content: '';
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
  border-radius: 50%;
  border: 2px solid #00a884;
  animation: call-pulse 1.8s infinite;
}

@keyframes call-pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 0.2; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.call-title {
  font-size: 19px;
  font-weight: 600;
  color: #e9edef;
  margin: 0 0 6px;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-sub {
  font-size: 14px;
  color: #8696a0;
  margin: 0 0 28px;
}

.call-mic-warning {
  color: #ffb4a2;
  line-height: 1.45;
  margin-top: -18px;
}

.call-actions {
  display: flex;
  justify-content: center;
  gap: 28px;
  width: 100%;
}

.call-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease;
}

.call-btn:hover {
  transform: scale(1.08);
}

.call-btn-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 24px;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.call-btn-label {
  font-size: 12px;
  color: #8696a0;
  font-weight: 500;
}

.btn-hangup .call-btn-icon {
  background: #ea4335;
}

.btn-hangup:hover .call-btn-icon {
  background: #c5221f;
}

.btn-answer .call-btn-icon {
  background: #00a884;
}

.btn-answer:hover .call-btn-icon {
  background: #02906f;
}

.btn-control .call-btn-icon {
  background: #2a3942;
  color: #d1d7db;
}

.btn-control.active .call-btn-icon {
  background: #f59e0b;
  color: #fff;
}


/* ========================================================
   TAMPILAN VIDEO CALL & ROTASI KAMERA
   ======================================================== */
.call-card-active {
  transition: all 0.3s ease;
  width: min(360px, 92vw);
}

.call-card-video-mode {
  width: min(540px, 94vw);
  max-width: 96vw;
  max-height: 92vh;
  max-height: 92dvh;
  padding: 16px;
  background: #0b141a;
  border-radius: 20px;
  overflow: hidden;
}

.call-video-stage {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  margin-bottom: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.call-fullscreen-btn,
.call-fit-toggle-btn {
  position: absolute;
  top: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(17, 27, 33, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 20;
  backdrop-filter: blur(4px);
  transition: all 0.2s ease;
  padding: 0;
}

.call-fullscreen-btn {
  right: 10px;
}

.call-fit-toggle-btn {
  right: 52px;
}

.call-fullscreen-btn:hover,
.call-fit-toggle-btn:hover {
  background: rgba(0, 168, 132, 0.85);
  transform: scale(1.08);
}

.call-video-remote {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  transition: object-fit 0.2s ease;
}

.call-video-remote.is-cover {
  object-fit: cover;
}

.call-video-local {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 110px;
  height: 82px;
  object-fit: contain;
  border-radius: 8px;
  border: 2px solid #00a884;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
  background: #000;
  z-index: 10;
}

@media (max-width: 480px) {
  .call-card-video-mode {
    width: 95vw;
    max-width: 95vw;
    max-height: 94vh;
    max-height: 94dvh;
    padding: 12px 10px 14px;
    overflow: hidden;
  }
  .call-video-stage {
    aspect-ratio: 4 / 3;
    max-height: 52vh;
    max-height: 52dvh;
    margin-bottom: 8px;
  }
  .call-video-local {
    width: 80px;
    height: 106px;
    bottom: 6px;
    right: 6px;
  }
  .call-actions {
    gap: 14px;
  }
  .call-btn-icon {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
  .call-sub {
    margin: 0 0 14px;
  }
}
