/* ===== AEGISCHAT DESIGN SYSTEM v2 ===== */
:root {
  --bg-base:#14161B; --bg-surface:#1E222A; --bg-elevated:#262B33;
  --primary:#10B981; --primary-hover:#34D399;
  --primary-tint:rgba(16,185,129,.08); --primary-border:rgba(16,185,129,.15);
  --danger:#EF4444; --text:#F4F4F5; --text-muted:#A1A1AA; --border:#2A2F38;
  --st-online:#10B981; --st-offline:#71717A; --st-busy:#EF4444;
}
* { margin:0; padding:0; box-sizing:border-box;
  font-family:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,sans-serif; }
body { background:var(--bg-base); color:var(--text); min-height:100vh;
  /* Di HP, 100vh > tinggi yang benar-benar terlihat (address bar ikut dihitung).
     Body jadi lebih tinggi dari layar -> halaman bisa tergulung sedikit dan
     kolom input "melayang" di atas dasar layar. dvh = tinggi viewport dinamis,
     jadi tidak ada sisa ruang; baris vh di atasnya jadi fallback browser lama. */
  min-height:100dvh;
  overflow-x:hidden; width:100%; max-width:100vw; }

.icon-btn { display:inline-flex; align-items:center; justify-content:center; gap:6px;
  width:34px; height:34px; background:transparent; border:none; color:var(--text-muted);
  cursor:pointer; border-radius:8px; transition:color .18s, background .18s; }
.icon-btn svg { width:18px; height:18px; }
.icon-btn:hover { color:var(--text); background:var(--bg-elevated); }
.icon-btn.danger:hover { color:var(--danger); }
.icon-btn.sm { width:26px; height:26px; }
.icon-btn.sm svg { width:15px; height:15px; }
.spin { animation:lucide-spin 1s linear infinite; }
@keyframes lucide-spin { to { transform:rotate(360deg); } }

.logo { display:flex; align-items:center; gap:8px; font-size:20px; font-weight:700;
  color:var(--text); margin-bottom:40px; justify-content:center; }
.logo span { color:var(--primary); }
.logo-icon { width:28px; height:28px; background-color:var(--primary); flex:none; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'/><path d='M9 11.5l2 2 4-4'/></svg>");
  background-repeat:no-repeat; background-position:center; background-size:16px 16px; }

.auth-container { max-width:440px; margin:80px auto; background:var(--bg-surface);
  border:1px solid var(--border); border-radius:12px; padding:48px; }
h2 { color:var(--text); margin-bottom:8px; text-align:center; font-size:24px; font-weight:600; }
.subtitle { text-align:center; color:var(--text-muted); font-size:14px; margin-bottom:32px; }
.form-group { margin-bottom:20px; }
.form-group label { display:block; margin-bottom:8px; color:var(--text); font-size:12px; font-weight:500; }
.form-group input { width:100%; background:var(--bg-elevated); border:1px solid var(--border);
  border-radius:8px; padding:13px 14px; color:var(--text); font-size:14px; outline:none;
  transition:border-color .2s; }
.form-group input:focus { border-color:var(--primary); }
.btn { width:100%; background:var(--primary); color:#0B1512; border:none; border-radius:8px;
  padding:13px; font-size:14px; font-weight:600; cursor:pointer; margin-top:8px;
  transition:background .2s; }
.btn:hover { background:var(--primary-hover); }
.switch-mode { text-align:center; margin-top:24px; color:var(--text-muted); font-size:14px; }
.switch-mode a { color:var(--primary); text-decoration:none; font-weight:500; cursor:pointer; }
.error-msg { background:rgba(239,68,68,.08); border:1px solid rgba(239,68,68,.35); color:var(--danger);
  border-radius:8px; padding:12px 16px; margin-bottom:20px; font-size:14px; display:none; }
.success-msg { background:var(--primary-tint); border:1px solid var(--primary-border); color:var(--primary);
  border-radius:8px; padding:12px 16px; margin-bottom:20px; font-size:14px; display:none; }

/* ===== PASSWORD EYE TOGGLE (auth pages) ===== */
.pw-wrap { position:relative; }
.pw-wrap input { padding-right:42px; }
.pw-toggle { position:absolute; right:8px; top:50%; transform:translateY(-50%); width:28px; height:28px;
  background:transparent; border:none; color:var(--text-muted); cursor:pointer;
  display:flex; align-items:center; justify-content:center; transition:color .18s; }
.pw-toggle:hover { color:var(--text); }
.pw-toggle svg { width:16px; height:16px; }

.app-header { position:sticky; top:0; z-index:100; background:var(--bg-surface);
  border-bottom:1px solid var(--border); }
.navbar { display:flex; justify-content:space-between; align-items:center;
  padding:0 24px; height:60px; background:var(--bg-surface); gap:16px; }
.navbar .logo { margin-bottom:0; justify-content:flex-start; cursor:pointer;
  user-select:none; font-size:17px; gap:10px; }
.navbar .logo-icon { width:30px; height:30px; border-radius:50%; }
.navbar .logo:focus-visible { outline:1px solid var(--primary); outline-offset:2px; }
.navbar .logo.refreshing .logo-icon { animation:logo-spin .8s linear infinite; }
@keyframes logo-spin { to { transform:rotate(360deg); } }
.hamburger { display:none; background:transparent; border:none; color:var(--text);
  cursor:pointer; padding:6px; border-radius:8px; }
.hamburger:hover { color:var(--primary); }
.hamburger svg { width:22px; height:22px; }
.nav-links { display:flex; gap:20px; list-style:none; align-items:center; margin-left:auto; }
.nav-links a { color:var(--text-muted); text-decoration:none; font-size:14px; font-weight:500;
  transition:color .2s; cursor:pointer; }
.nav-links a:hover { color:var(--text); }
.nav-links a.active { color:var(--primary); }
.logout:hover { color:var(--danger) !important; background:transparent; }
.nav-sep { width:1px; height:20px; background:var(--border); }
.nav-time { font-size:11px; color:var(--text-muted); font-variant-numeric:tabular-nums; }
.nav-user { display:flex; align-items:center; gap:8px; font-size:13px; font-weight:500;
  color:var(--text); white-space:nowrap; }

.avatar-initial { width:34px; height:34px; border-radius:50%; flex:none;
  background:var(--primary-tint); border:1px solid var(--primary-border); color:var(--primary);
  font-weight:600; font-size:17px; display:flex; align-items:center; justify-content:center; user-select:none; }
.avatar-initial.sm { width:28px; height:28px; font-size:14px; }
.contact-avatar { width:40px; height:40px; border-radius:50%; flex:none;
  background:var(--primary-tint); border:1px solid var(--primary-border); color:var(--primary);
  font-weight:600; font-size:13px; display:flex; align-items:center; justify-content:center; }
.status-dot { width:8px; height:8px; border-radius:50%; display:inline-block; margin-right:6px;
  background:var(--st-offline); flex:none; }
.status-dot.online, .status-dot.typing { background:var(--st-online); }
.status-dot.blocked { background:var(--st-busy); }

.main { display:grid; grid-template-columns:1fr; width:100%; max-width:100vw; overflow-x:hidden;
  /* 100vh di HP lebih tinggi dari layar yang benar-benar terlihat (address bar ikut dihitung),
     akibatnya kolom input terdorong ke bawah dan seluruh halaman ikut tergulung -> header chat hilang.
     dvh = tinggi viewport dinamis; baris vh di atasnya jadi fallback browser lama. */
  height:calc(100vh - 61px);
  height:calc(100dvh - 61px);
  min-height:0; overflow:hidden; }

.chat-area { display:flex; flex-direction:column; background:var(--bg-base);
  width:100%; max-width:100%; overflow-x:hidden; min-height:0; }
.chat-header { display:flex; justify-content:space-between; align-items:center;
  padding:10px 20px; background:var(--bg-surface); border-bottom:1px solid var(--border);
  flex-wrap:wrap; gap:12px; flex:0 0 auto; }
.chat-partner { display:flex; align-items:center; gap:12px; min-width:0; flex:1; }
.chat-header-info { min-width:0; }
.chat-header-info h3 { font-size:16px; font-weight:600; color:var(--text); margin-bottom:2px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; cursor:pointer; }
.partner-status { display:flex; align-items:center; font-size:12px; color:var(--text-muted); }
.chat-header-actions { display:flex; gap:8px; align-items:center; }
.ghost-btn { display:inline-flex; align-items:center; gap:6px; background:transparent;
  border:1px solid var(--border); color:var(--text); border-radius:8px; padding:7px 14px;
  font-size:12px; font-weight:500; cursor:pointer; transition:all .18s; }
.ghost-btn svg { width:16px; height:16px; }
.ghost-btn:hover { border-color:var(--primary); color:var(--primary); }
.ghost-btn.danger { border-color:rgba(239,68,68,.4); color:var(--danger); }
.ghost-btn.danger:hover { background:rgba(239,68,68,.1); border-color:var(--danger); }
/* ===== GROUPS ===== */
.groups-label { font-size:10px; font-weight:600; letter-spacing:.08em; text-transform:uppercase;
  color:var(--text-muted); padding:12px 16px 4px; }
.groups-empty { color:var(--text-muted); font-size:12px; padding:8px 16px; }
.contact-avatar svg { width:18px; height:18px; }
#chatPartnerAvatar svg { width:20px; height:20px; }
.member-pick-list { max-height:200px; overflow-y:auto; margin-top:8px; }
.member-pick { display:flex; align-items:center; gap:8px; font-size:13px; color:var(--text);
  padding:6px 4px; cursor:pointer; }
.member-pick input { accent-color:var(--primary); }
.sender-name { font-size:11px; font-weight:500; color:var(--primary); margin-bottom:4px; }
.message-checkbox { position:absolute; left:-30px; top:50%; transform:translateY(-50%);
  width:18px; height:18px; cursor:pointer; accent-color:var(--primary); }
.message.bulk-mode { margin-left:40px; }
.message.highlighted { background:var(--bg-elevated) !important; border-color:var(--primary) !important; }
/* ===== MESSAGES ===== */
.chat-messages { flex:1; overflow-y:auto; overflow-x:hidden; padding:24px;
  display:flex; flex-direction:column; gap:12px; width:100%; max-width:100%; }
.empty-state { margin:auto; text-align:center; color:var(--text-muted);
  display:flex; flex-direction:column; align-items:center; gap:14px; padding:40px; max-width:340px; }
.empty-state svg { width:44px; height:44px; stroke-width:1.5; }
.empty-state p { font-size:13px; line-height:1.6; }
.message { position:relative; max-width:65%; padding:12px 14px; word-wrap:break-word;
  border-radius:10px; }
.message.received { align-self:flex-start; background:var(--bg-surface);
  border-bottom-left-radius:2px; }
.message.sent { align-self:flex-end; background:var(--primary-tint);
  border:1px solid var(--primary-border); border-bottom-right-radius:2px; }
.msg-cipher { font-family:'JetBrains Mono','Courier New',monospace; word-break:break-all;
  font-size:12px; color:var(--text-muted); line-height:1.6; }
.message:not(.ciphertext) { font-size:14px; line-height:1.55; color:var(--text); }
.message:not(.ciphertext) .msg-cipher { font-size:inherit; line-height:inherit; color:inherit;
  /* teks hasil dekripsi: biarkan pecah di antara kata, jangan di tengah kata.
     URL panjang tetap pecah via overflow-wrap; .msg-link punya break-all sendiri. */
  word-break:normal; overflow-wrap:break-word; }
.bubble-actions { position:absolute; top:-14px; right:8px; display:flex; gap:4px;
  opacity:0; pointer-events:none; transition:opacity .18s ease; z-index:2; }
.message:hover .bubble-actions,
.message:focus-within .bubble-actions { opacity:1; pointer-events:auto; }
.bubble-actions .icon-btn { background:var(--bg-elevated); border:1px solid var(--border);
  box-shadow:0 2px 8px rgba(0,0,0,.35); }
.bubble-actions .icon-btn.danger { color:var(--danger); background:var(--bg-elevated); }
.msg-meta { display:flex; justify-content:flex-end; align-items:center; gap:3px;
  font-size:11px; color:var(--text-muted); margin-top:6px; font-variant-numeric:tabular-nums; }
.msg-meta .receipt { display:inline-flex; }
.msg-meta .receipt svg { width:14px; height:14px; }
.msg-meta .receipt.read { color:var(--primary); }
.msg-meta .receipt.unread { color:var(--text-muted); }

/* ===== ENCRYPTED FILE CARD ===== */
.file-message { padding:8px 10px; }
.file-card { display:grid; grid-template-columns:40px 1fr auto; gap:10px; align-items:center;
  background:var(--bg-elevated); border-radius:12px; padding:12px; min-width:240px; max-width:100%; }
.file-thumb { width:40px; height:40px; border-radius:8px; background:var(--primary-tint);
  display:flex; align-items:center; justify-content:center; flex:none; }
.file-thumb svg { width:20px; height:20px; color:var(--primary); }
.file-meta-col { display:flex; flex-direction:column; min-width:0; gap:3px; }
.file-name { font-size:13px; font-weight:500; color:var(--text);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; width:100%; }
.file-sub { display:flex; align-items:center; flex-wrap:wrap; gap:8px; font-size:11px;
  color:var(--text-muted); }
.badge-enc { display:inline-flex; align-items:center; gap:4px; font-size:10px; font-weight:600;
  color:var(--primary); background:var(--primary-tint); padding:2px 7px; border-radius:4px; }
.badge-enc svg { width:11px; height:11px; }
.file-decrypt-btn { display:inline-flex; align-items:center; gap:5px; height:30px; padding:0 12px;
  background:transparent; border:1px solid var(--primary-border); color:var(--primary);
  border-radius:8px; font-size:11px; font-weight:700; cursor:pointer; transition:all .18s; flex:none; }
.file-decrypt-btn svg { width:13px; height:13px; }
.file-decrypt-btn:hover:not(:disabled) { background:var(--primary-tint); border-color:var(--primary); }
.file-decrypt-btn:disabled { opacity:.6; cursor:wait; }
.file-preview { max-width:100%; max-height:280px; border-radius:8px; margin-top:8px; display:block; cursor:pointer; transition:opacity .15s; }
.file-preview:hover { opacity:0.9; }
/* ===== LIGHTBOX PEMBESAR GAMBAR ===== */
.image-lightbox-overlay { position:fixed; inset:0; background:rgba(5,6,8,.92);
  backdrop-filter:blur(4px); -webkit-backdrop-filter:blur(4px);
  display:none; align-items:center; justify-content:center;
  z-index:5000; cursor:zoom-out; padding:16px; box-sizing:border-box; }
.image-lightbox-overlay.active { display:flex; }
.image-lightbox-overlay img { max-width:94vw; max-height:92vh; object-fit:contain;
  border-radius:8px; box-shadow:0 10px 30px rgba(0,0,0,.8); cursor:default; }
.lightbox-close { position:absolute; top:16px; right:20px; background:transparent;
  border:none; color:#fff; font-size:32px; line-height:1; cursor:pointer;
  opacity:.8; padding:4px 10px; border-radius:6px; transition:opacity .15s, background .15s; }
.lightbox-close:hover { opacity:1; background:rgba(255,255,255,.15); }
.file-actions-row { display:flex; gap:8px; margin-top:8px; }
.mini-btn { display:inline-flex; align-items:center; gap:5px; height:28px; padding:0 12px;
  background:transparent; border:1px solid var(--border); color:var(--text);
  border-radius:8px; font-size:11px; font-weight:600; cursor:pointer; transition:all .18s; }
.mini-btn svg { width:13px; height:13px; }
.mini-btn:hover { border-color:var(--primary); color:var(--primary); }
/* ===== COMPOSER ===== */
.chat-input { display:flex; gap:8px; padding:12px 20px; background:var(--bg-surface);
  border-top:1px solid var(--border); align-items:center; flex-wrap:wrap; flex:0 0 auto; }
.chat-input > input[type="text"] { flex:1; min-width:170px; height:42px;
  background:var(--bg-base); color:var(--text); border:1px solid var(--border);
  border-radius:8px; padding:0 14px; outline:none; font-size:14px; transition:border-color .2s; }
.chat-input > input[type="text"]:focus { border-color:var(--primary); }
.key-wrap { position:relative; display:flex; align-items:center; width:200px; height:42px;
  background:var(--bg-base); border:1px solid var(--border); border-radius:8px;
  transition:border-color .2s; flex:none; overflow:hidden; gap:0; }
.key-wrap:focus-within { border-color:var(--primary); }
/* input: TANPA padding kiri/kanan. Ikon & tombol mata adalah flex item biasa,
   jadi teks tidak mungkin menumpuk ikon (penyebab bug lama: icon absolute). */
.key-wrap input, .key-wrap input[type="text"], .key-wrap input[type="password"] {
  flex:1 1 auto; min-width:0; height:100%; background:transparent; border:none; border-radius:0;
  outline:none; box-shadow:none; color:var(--primary); font-size:13px; padding:0 2px 0 0;
  letter-spacing:0.5px; font-family:'JetBrains Mono',monospace; }
.key-ico { flex:none; margin:0 7px 0 12px; width:15px; height:15px; color:var(--text-muted); pointer-events:none; }
.key-toggle { flex:none; margin:0 5px 0 2px; width:28px; height:28px; background:transparent;
  border:none; color:var(--text-muted); cursor:pointer; border-radius:6px;
  display:flex; align-items:center; justify-content:center; transition:color .18s; }
.key-toggle:hover { color:var(--text); }
/* Hilangkan SEMUA kotak yang muncul saat tombol mata disentuh/di-tap:
   ring fokus + highlight tap mobile -> itulah yang bikin kelihatan "kotak berbeda". */
.key-toggle:focus, .key-toggle:focus-visible, .key-toggle:active {
  outline:none; box-shadow:none; background:transparent; }
.key-toggle, .key-ico { -webkit-appearance:none; appearance:none; -webkit-tap-highlight-color:transparent; }
.key-wrap, .key-wrap input { -webkit-tap-highlight-color:transparent; }
.key-toggle svg { width:15px; height:15px; }
.encrypt-btn { display:inline-flex; align-items:center; gap:6px; height:42px; padding:0 16px;
  background:transparent; border:1px solid var(--primary); color:var(--primary);
  border-radius:8px; font-size:12px; font-weight:700; letter-spacing:.06em;
  cursor:pointer; transition:all .18s; flex:none; }
.encrypt-btn svg { width:14px; height:14px; }
.encrypt-btn:hover:not(:disabled) { background:var(--primary-tint); color:var(--primary-hover);
  border-color:var(--primary-hover); }
.encrypt-btn:disabled { opacity:.45; cursor:not-allowed; }
.send-btn { display:inline-flex; align-items:center; justify-content:center; width:46px;
  height:42px; background:var(--primary); color:#0B1512; border:none; border-radius:8px;
  cursor:pointer; transition:background .18s; flex:none; }
.send-btn svg { width:17px; height:17px; }
.send-btn:hover:not(:disabled) { background:var(--primary-hover); }
.send-btn:disabled { opacity:.6; cursor:wait; }
.file-label { width:42px; height:42px; border:1px solid var(--border); border-radius:8px; flex:none; }
.file-label:hover { border-color:var(--primary); color:var(--primary); background:var(--primary-tint); }

/* ===== TOASTS ===== */
#toastRoot { position:fixed; bottom:24px; left:50%; transform:translateX(-50%);
  display:flex; flex-direction:column; align-items:center; gap:8px; z-index:9999; }
.toast { display:flex; align-items:center; gap:9px; background:var(--bg-elevated);
  border:1px solid var(--border); border-left:3px solid var(--primary); color:var(--text);
  font-size:13px; padding:10px 16px; border-radius:8px; white-space:nowrap;
  box-shadow:0 8px 24px rgba(0,0,0,.45); animation:toast-in .2s ease; }
.toast svg { width:16px; height:16px; flex:none; }
.toast.success svg { color:var(--primary); }
.toast.error { border-left-color:var(--danger); }
.toast.error svg { color:var(--danger); }
.toast.hide { opacity:0; transition:opacity .25s; }
@keyframes toast-in { from { opacity:0; transform:translateY(8px); } }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width:8px; height:8px; }
::-webkit-scrollbar-track { background:var(--bg-base); }
::-webkit-scrollbar-thumb { background:var(--border); border-radius:4px; }
::-webkit-scrollbar-thumb:hover { background:#3A404A; }
/* ===== MODALS ===== */
.contacts-modal-overlay { position:fixed; inset:0; background:rgba(5,6,8,.78);
  display:none; align-items:center; justify-content:center; z-index:1000; }
.contacts-modal-overlay.active { display:flex; }
/* Dialog harus di atas .profile-page (z-index:3000), kalau tidak popup sukses
   update profil tersembunyi di balik halaman profil */
#appDialogOverlay { z-index:4000; }
.contacts-modal { background:var(--bg-surface); border:1px solid var(--border);
  border-radius:12px; width:90%; max-width:420px; max-height:80vh;
  display:flex; flex-direction:column; overflow:hidden; }
/* Daftar anggota modal info grup: boleh mengecil & di-scroll, supaya tombol
   aksi di bawahnya (Tambah Anggota / Bubarkan Grup / Keluar Grup) tidak
   terpotong di layar laptop pendek (mis. 1024x600). Disaring hanya untuk
   #groupInfoOverlay agar modal lain tidak terpengaruh. */
#groupInfoOverlay .contacts-modal > * { flex:0 0 auto; }
#groupInfoOverlay .contacts-modal > #groupMembersList,
#groupInfoOverlay .contacts-modal > #adminLeavePick,
#groupInfoOverlay .contacts-modal > #addMemberPick { flex:1 1 auto; min-height:0; overflow-y:auto; }
.contacts-modal-header { display:flex; justify-content:space-between; align-items:center;
  padding:16px 20px; border-bottom:1px solid var(--border); font-size:16px;
  font-weight:600; color:var(--text); }
.contacts-modal-close { background:transparent; border:none; color:var(--text-muted);
  cursor:pointer; padding:4px; border-radius:6px; display:flex; transition:color .18s; }
.contacts-modal-close:hover { color:var(--text); }
.contacts-modal-close svg { width:18px; height:18px; }
.contacts-modal .search-box { margin:16px 20px 10px; padding:0; background:transparent; border:none; }
.search-box { padding:0 14px; display:flex; align-items:center; gap:10px; height:42px;
  background:var(--bg-elevated); border:1px solid var(--border); border-radius:8px; }
.search-box svg { width:16px; height:16px; color:var(--text-muted); flex:none; }
.search-box input { background:transparent; border:none; outline:none; color:var(--text);
  width:100%; font-size:14px; }
#contactsListModal { padding:4px 20px 20px; overflow-y:auto; flex:1; }
.contact { display:flex; align-items:center; gap:12px; padding:10px 12px; cursor:pointer;
  margin-bottom:4px; transition:background .18s; border:1px solid transparent; border-radius:10px; }
.contact:hover { background:var(--bg-elevated); }
.contact.active { background:var(--primary-tint); border-color:var(--primary-border); }
.contact-info { flex:1; min-width:0; }
.contact-name { font-size:14px; font-weight:500; color:var(--text); margin-bottom:2px; }
.contact-status { font-size:12px; color:var(--text-muted); display:flex; align-items:center; }
.contact-blocked { opacity:.55; }
.contact-blocked .contact-name { color:var(--text-muted); }
.contact-empty { text-align:center; color:var(--text-muted); padding:36px 20px;
  display:flex; flex-direction:column; align-items:center; gap:10px; font-size:13px; }
.contact-empty svg { width:34px; height:34px; stroke-width:1.5; }

.guide-modal-overlay { position:fixed; inset:0; background:rgba(5,6,8,.78);
  display:none; align-items:center; justify-content:center; z-index:1000; }
.guide-modal-overlay.active { display:flex; }
.guide-modal { background:var(--bg-surface); border:1px solid var(--border);
  border-radius:12px; width:92%; max-width:900px; height:88vh;
  display:flex; flex-direction:column; overflow:hidden; }
.guide-frame { width:100%; flex:1; border:none; background:var(--bg-base); }

.key-modal { max-width:340px; }
.key-modal-body { padding:20px; }
.key-modal-body p { color:var(--text-muted); font-size:13px; margin-bottom:12px; overflow-wrap:anywhere; }
.key-modal-body > input { width:100%; padding:10px 12px; background:var(--bg-elevated);
  border:1px solid var(--border); color:var(--text); font-size:14px; border-radius:8px;
  outline:none; transition:border-color .2s; }
.key-modal-body > input:focus { border-color:var(--primary); }
.key-modal-actions { display:flex; gap:8px; margin-top:16px; justify-content:flex-end; }
.key-modal-actions button { padding:8px 16px; font-size:11px; font-weight:700;
  letter-spacing:.05em; cursor:pointer; border-radius:8px; transition:all .18s; }
#keyModalCancel { background:transparent; color:var(--text-muted); border:1px solid var(--border); }
#keyModalCancel:hover { color:var(--text); border-color:#3A404A; }
#keyModalOk { background:var(--primary); color:#0B1512; border:1px solid var(--primary); }
/* App dialog (dialog.js) */
#appDialogCancel { background:transparent; color:var(--text-muted); border:1px solid var(--border); }
#appDialogCancel:hover { color:var(--text); border-color:#3A404A; }
#appDialogOk { background:var(--primary); color:#0B1512; border:1px solid var(--primary); }
#appDialogOk:hover { filter:brightness(1.1); }
#appDialogOk.danger { background:var(--danger); border-color:var(--danger); }
/* Pesan popup boleh punya baris baru (instruksi bertingkat) */
#appDialogMessage { white-space:pre-line; }
.dialog-links { display:flex; flex-wrap:wrap; gap:8px; margin-top:14px; }
.dialog-link { display:inline-block; padding:8px 14px; font-size:11px; font-weight:700; letter-spacing:.04em;
  border-radius:8px; text-decoration:none; color:var(--primary); border:1px solid var(--primary);
  background:transparent; transition:all .18s; }
.dialog-link:hover { background:var(--primary); color:#0B1512; }
/* Tautan di dalam pesan terdekripsi */
.msg-link { color:var(--primary); text-decoration:underline; word-break:break-all; }
.msg-link:hover { opacity:.8; }
/* ===== POPUP KUOTA PENYIMPANAN (quota-ui.js) ===== */
#quotaCancel { background:transparent; color:var(--text-muted); border:1px solid var(--border); }
#quotaCancel:hover { color:var(--text); border-color:#3A404A; }
#quotaDelete { background:var(--danger); color:#fff; border:1px solid var(--danger); }
#quotaDelete:hover { filter:brightness(1.1); }
#quotaDelete:disabled { opacity:.6; cursor:default; }
#quotaIncoming { color:var(--danger) !important; font-weight:600; }
#quotaList label:hover { border-color:var(--primary); }
/* ===== PROFILE PAGE ===== */
.profile-page { position:fixed; inset:0; background:var(--bg-base); z-index:3000; overflow-y:auto; }
.profile-page-header { display:grid; grid-template-columns:1fr auto 1fr; align-items:center;
  padding:14px 24px; background:var(--bg-surface); border-bottom:1px solid var(--border);
  position:sticky; top:0; }
.profile-page-header .back-btn { justify-self:start; }
.profile-page-header > span { grid-column:2; text-align:center; font-size:16px; font-weight:600; color:var(--text); }
.back-btn { display:inline-flex; align-items:center; gap:6px; background:transparent;
  border:none; color:var(--text-muted); font-size:14px; font-weight:500; cursor:pointer;
  padding:6px 10px; border-radius:8px; transition:color .18s; }
.back-btn svg { width:16px; height:16px; }
.back-btn:hover { color:var(--text); }

/* ===== HOME PAGE (BERANDA) ===== */
.home-page { position:fixed; inset:61px 0 0 0; background:#050505; z-index:90;
  display:none; flex-direction:column; overflow-y:auto; border-radius:0px; }
.home-page-header { display:flex; justify-content:space-between; align-items:center;
  padding:14px 24px; background:var(--bg-surface); border-bottom:1px solid var(--border);
  border-radius:0px; }
.home-page-header span { font-size:16px; font-weight:600; color:var(--text); }
.home-page-content { max-width:700px; margin:0 auto; padding:30px 24px; width:100%; border-radius:0px; }
.home-chat-item { display:flex; align-items:center; gap:14px; padding:12px 16px;
  background:var(--bg-surface); border:1px solid var(--border); border-radius:0px;
  cursor:pointer; transition:border-color .18s, background .18s; }
.home-chat-item:hover { background:var(--bg-elevated); border-color:var(--primary); }
.home-chat-info { flex:1; min-width:0; }
.home-chat-name { font-size:15px; font-weight:600; color:var(--text); margin-bottom:3px; }
.home-chat-preview { font-size:13px; color:var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.home-chat-meta { font-size:11px; color:var(--text-muted); text-align:right; white-space:nowrap; }

.profile-page-content { max-width:600px; margin:0 auto; padding:40px 24px; text-align:center; }
.profile-avatar-large { width:140px; height:140px; border-radius:50%; margin:0 auto 20px;
  background:var(--primary-tint); border:1px solid var(--primary-border);
  display:flex; align-items:center; justify-content:center; font-size:64px; color:var(--primary); }
.profile-name-large { font-size:24px; font-weight:600; color:var(--text); margin-bottom:6px; }
.profile-username-large { font-size:14px; color:var(--text-muted); margin-bottom:24px; }
.profile-edit-actions, .profile-block-actions { display:flex; gap:12px;
  justify-content:center; margin-bottom:28px; }
.profile-action-btn { display:inline-flex; align-items:center; gap:7px; background:var(--primary);
  color:#0B1512; border:none; border-radius:8px; padding:10px 20px; font-size:13px;
  font-weight:600; cursor:pointer; transition:background .18s; }
.profile-action-btn svg { width:15px; height:15px; }
.profile-action-btn:hover { background:var(--primary-hover); }
.profile-block-actions { padding:16px; border:1px solid rgba(239,68,68,.3);
  border-radius:12px; max-width:400px; margin:0 auto 28px; }
.profile-block-btn { background:transparent; color:var(--danger); border:1px solid rgba(239,68,68,.4);
  border-radius:8px; padding:10px 20px; font-size:13px; font-weight:600; cursor:pointer; transition:all .18s; }
.profile-block-btn:hover:not(:disabled) { background:rgba(239,68,68,.1); border-color:var(--danger); }
.profile-block-btn:disabled { color:var(--st-offline); border-color:var(--border);
  cursor:not-allowed; opacity:.6; }
/* Tombol Unblock = aksi memulihkan (bukan destruktif) -> hijau primary,
   supaya jelas beda dari "Block"/"Remove Friend" yang merah. */
.profile-block-btn.unblock-btn { color:var(--primary); border-color:var(--primary-border);
  background:var(--primary-tint); }
.profile-block-btn.unblock-btn:hover:not(:disabled) { background:rgba(16,185,129,.14);
  border-color:var(--primary); color:var(--primary-hover); }
.profile-info-section { text-align:left; max-width:400px; margin:0 auto; background:var(--bg-surface);
  border:1px solid var(--border); border-radius:12px; padding:20px; }
.info-block { margin-bottom:16px; }
.info-block:last-child { margin-bottom:0; }
.info-label { font-size:11px; color:var(--text-muted); margin-bottom:4px;
  text-transform:uppercase; letter-spacing:.06em; font-weight:600; }
.info-value { font-size:14px; color:var(--text); }
.profile-input { width:100%; padding:10px 14px; background:var(--bg-elevated);
  border:1px solid var(--border); color:var(--text); font-size:14px; border-radius:8px; outline:none; }
.profile-input:focus { border-color:var(--primary); }
#profileOtpSectionInline p { color:var(--text-muted); font-size:13px; margin-bottom:16px; }
#profileOtpErrorInline { color:var(--danger); font-size:13px; margin-top:10px; display:none; }

.avatar-grid { display:grid; grid-template-columns:repeat(5,1fr); gap:10px; margin-top:12px; }
.avatar-option { width:100%; aspect-ratio:1; background:var(--bg-base); border:1px solid var(--border);
  border-radius:10px; display:flex; align-items:center; justify-content:center;
  cursor:pointer; transition:all .18s; font-size:28px; }
.avatar-option:hover { border-color:var(--primary); }
.avatar-option.selected { border-color:var(--primary); background:var(--primary-tint); }
.avatar-emoji { font-size:32px; }

/* ===== RESPONSIVE <768px ===== */
@media (max-width:768px) {
  .hamburger { display:block; }
  .navbar { padding:0 12px; gap:8px; }
  .nav-links { position:fixed; top:60px; right:0; background:var(--bg-surface);
    border-left:1px solid var(--border); border-bottom:1px solid var(--border);
    flex-direction:column; padding:20px; gap:14px; width:220px; align-items:stretch;
    transform:translateX(100%); transition:transform .3s ease; z-index:999;
    border-radius:0 0 0 12px; }
  .nav-links.show { transform:translateX(0); }
  .nav-links li { width:100%; }
  .nav-links a { display:block; padding:10px 12px; border:1px solid var(--border);
    border-radius:8px; text-align:center; }
  .nav-sep { display:none; }
  .chat-header { padding:8px 12px; }
  .chat-header-info h3 { font-size:14px; }
  .partner-status { font-size:11px; }
  .ghost-btn { padding:6px 10px; font-size:11px; }
  .chat-messages { padding:12px; }
  .message { max-width:85%; }
  .file-card { min-width:0; width:100%; grid-template-columns:36px 1fr auto; gap:8px; padding:10px; }
  .file-thumb { width:36px; height:36px; }
  .chat-input { padding:10px 12px; gap:6px; }
  .chat-input > input[type="text"] { flex:1 1 100%; min-width:0; }
  .key-wrap { flex:1 1 90px; width:auto; min-width:0; }
  .key-wrap input { font-size:12px; }
  .encrypt-btn { padding:0 12px; font-size:11px; flex:none; }
  .send-btn, .icon-btn.file-label { flex:none; }
  /* Ruang aman untuk home-bar iPhone */
  .chat-input { padding-bottom:calc(10px + env(safe-area-inset-bottom, 0px)); }
  .msg-cipher { font-size:11px; }
}
/* Layar sangat sempit: tombol ENKRIPSI cukup ikon saja biar tidak berdesakan */
@media (max-width:400px) {
  .encrypt-btn span { display:none; }
  .encrypt-btn { padding:0 10px; }
  .key-wrap { flex:1 1 70px; }
}
@media (min-width:769px) { .hamburger { display:none; } }






/* Invite badge di navbar Contacts */
.nav-badge { display:inline-flex; align-items:center; justify-content:center; min-width:17px; height:17px; padding:0 5px; margin-left:6px; background:#e5484d; color:#fff; font-size:10.5px; font-weight:700; line-height:1; border-radius:999px; }
.nav-badge[hidden] { display:none; }

/* Unread badge per kontak/grup */
.msg-badge { margin-left:auto; flex:none; min-width:18px; height:18px; padding:0 5px; background:#e5484d; color:#fff; font-size:11px; font-weight:700; line-height:1; border-radius:999px; display:inline-flex; align-items:center; justify-content:center; }

/* Toast notifikasi */
.toast-wrap { position:fixed; bottom:84px; right:16px; z-index:4500; display:flex; flex-direction:column; gap:8px; }
@keyframes toast-out { to { opacity:0; transform:translateX(12px); } }
.toast { background:var(--bg-elevated); border:1px solid var(--border); border-left:3px solid var(--primary); border-radius:8px; padding:10px 14px; min-width:220px; max-width:320px; cursor:pointer; box-shadow:0 8px 24px rgba(0,0,0,.4); animation:toast-in .2s ease, toast-out .3s ease 9.7s forwards; }
.toast-title { font-size:12px; font-weight:700; color:var(--primary); margin-bottom:2px; }
.toast-body { font-size:13px; color:var(--text); }
@keyframes toast-in { from { opacity:0; transform:translateX(12px); } to { opacity:1; transform:none; } }

/* Toggle bahasa */
.lang-toggle { background:transparent; border:1px solid var(--border); border-radius:999px; padding:2px 8px; font-size:15px; line-height:1; cursor:pointer; transition:all .18s; }
.lang-toggle:hover { border-color:var(--primary); color:var(--primary); }
.auth-lang-toggle { position:fixed; top:14px; right:14px; z-index:5000; font-size:18px; }

.chat-partner{cursor:pointer}

.home-chat-item{position:relative}
.home-chat-hide{opacity:.55;flex-shrink:0}
.home-chat-hide:hover{opacity:1}

.receipt.sending{color:var(--text-muted);animation:pulseSending 1.2s ease-in-out infinite}
.receipt.sending svg{width:14px;height:14px}
.receipt.failed{color:#ef4444}
@keyframes pulseSending{0%,100%{opacity:.35}50%{opacity:1}}

/* ===== Secret key modal (input + tombol mata) ===== */
.key-wrap-modal { width:100%; height:44px; margin-top:4px; flex:none; }
/* Specificity dinaikkan (.key-modal-body .key-wrap input = 0,2,1) supaya MENANG
   atas `.key-modal-body > input { padding:10px 12px }` (0,1,1) yang bikin teks
   menabrak ikon kunci di modal. padding kiri/kanan wajib 32px. */
.key-wrap-modal input { font-size:14px; }

/* ===== Upload/download progress bar =====
   Baris penuh di atas input, tidak melayang -> aman di layar HP sempit. */
#uploadBar {
  flex:1 1 100%;
  width:100%;
  box-sizing:border-box;
  flex-wrap:nowrap;
  order:-1;
}
#uploadBar #uploadBarText {
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  flex:0 1 auto;
  min-width:0;
}
#uploadBar .upload-bar-track {
  flex:1 1 60px;
  min-width:60px;
  height:6px;
  background:rgba(255,255,255,.15);
  border-radius:3px;
  overflow:hidden;
}
#uploadBar #uploadBarFill {
  height:100%;
  width:0;
  background:#4ade80;
  transition:width .15s;
}
#uploadBar #uploadBarRetry {
  flex:none;
  padding:4px 12px;
  font-size:12px;
  border-radius:6px;
  border:1px solid rgba(255,255,255,.25);
  background:#3b82f6;
  color:#fff;
  cursor:pointer;
}
@media (max-width:768px) {
  #uploadBar { padding:7px 10px; gap:8px; font-size:12px; }
  #uploadBar #uploadBarRetry { padding:4px 10px; font-size:11px; }
}

/* ===== BALAS PESAN (reply/quote) ===== */
/* Bar kutipan di atas composer, muncul saat membalas. Lebar penuh. */
.chat-input .reply-bar { flex:0 0 100%; width:100%; display:flex; align-items:center; gap:10px; background:var(--bg-base); border:1px solid var(--border); border-left:3px solid var(--primary); border-radius:8px; padding:8px 10px; margin-bottom:2px; }
.reply-bar-body { flex:1; min-width:0; }
.reply-bar-title { font-size:11px; font-weight:700; color:var(--primary); margin-bottom:2px; }
.reply-bar-text { font-size:12px; color:var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.chat-input .reply-bar .icon-btn { flex:0 0 auto; }
/* Kutipan di dalam bubble pesan */
.quote-block { display:block; width:100%; text-align:left; border-left:3px solid var(--primary); background:rgba(255,255,255,.05); border-radius:6px; padding:6px 8px; margin-bottom:6px; cursor:pointer; font:inherit; color:inherit; }
.quote-block:hover { background:rgba(255,255,255,.1); }
.quote-name { font-size:11px; font-weight:700; color:var(--primary); margin-bottom:1px; }
.quote-text { font-size:12px; color:var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
/* pan-y: scroll vertikal tetap jalan, gesture horizontal diserahkan ke JS */
.message { touch-action:pan-y; }
/* Saat bubble digeser ke kanan */
.message.swiping { transition:none; }
.message.swipe-ready { border-color:var(--primary) !important; }
.message.flash { animation:msgFlash 1.1s ease-out; }
@keyframes msgFlash { 0% { background:var(--primary-tint); } 100% { background:transparent; } }

/* ===== PRIVASI LAYAR (blur saat fokus hilang) =====
   Lihat public/js/privacy.js. Isi chat ditutup begitu jendela/tab kehilangan
   fokus (mis. pindah ke alat screenshot). Ini TIDAK memblokir screenshot secara
   mutlak -- itu memang tidak mungkin di web, dan watermark sudah dihapus atas
   permintaan pengguna karena mengganggu tampilan. */

.privacy-blur { position:fixed; inset:0; display:none; flex-direction:column;
  align-items:center; justify-content:center; gap:6px; z-index:6000; cursor:pointer;
  background:rgba(10,11,14,.92); -webkit-backdrop-filter:blur(22px); backdrop-filter:blur(22px); }
.privacy-blur.active { display:flex; }
.privacy-blur-icon { font-size:40px; line-height:1; margin-bottom:6px; }
.privacy-blur-title { color:var(--text); font-size:16px; font-weight:600; }
.privacy-blur-hint { color:var(--text-muted); font-size:13px; }

@media (max-width:480px) { .privacy-blur-icon { font-size:34px; } }
