/* ============ WA Gateway V2 — premium styles (glassmorphism + motion) ==== */
:root {
  --bg: #0b1120;
  --bg-soft: #0f172a;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-strong: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.1);
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --brand: #22c55e;
  --brand-2: #14b8a6;
  --accent: #6366f1;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 16px;
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, 0.5);
}
:root.light {
  --bg: #eef2f7;
  --bg-soft: #ffffff;
  --panel: rgba(255, 255, 255, 0.75);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --border: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --text-dim: #64748b;
  --shadow: 0 10px 40px -14px rgba(15, 23, 42, 0.25);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(34, 197, 94, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(99, 102, 241, 0.18), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.glass {
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.glass-strong {
  background: var(--panel-strong);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--border);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; cursor: pointer; transition: all .18s ease;
  color: #04170c; background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 8px 24px -8px rgba(34,197,94,.6); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-ghost { background: var(--panel); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--panel-strong); box-shadow: none; }
.btn-danger { background: linear-gradient(135deg, #f43f5e, #ef4444); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 10px; }

.input {
  width: 100%; padding: 11px 14px; border-radius: 12px; font-size: 14px;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.light .input { background: rgba(255,255,255,.9); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
label.fld { display: block; font-size: 13px; color: var(--text-dim); margin: 0 0 6px; font-weight: 500; }

.chip { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; letter-spacing: .02em; }
.chip-green { background: rgba(34,197,94,.16); color: #4ade80; }
.chip-amber { background: rgba(245,158,11,.16); color: #fbbf24; }
.chip-gray { background: rgba(148,163,184,.16); color: #94a3b8; }
.chip-red { background: rgba(239,68,68,.16); color: #f87171; }
.chip-indigo { background: rgba(99,102,241,.18); color: #a5b4fc; }
/* FASE 53: badge "Butuh Admin" di baris sidebar. flex-shrink:0 wajib — badge
   berbagi baris dengan nama chat ber-truncate; tanpa ini nama panjang
   memerasnya jadi tak terbaca. Denyut menarik mata tanpa memindahkan layout
   (animasi opacity/box-shadow saja, TIDAK menyentuh ukuran). */
.chip-pulse {
  flex: 0 0 auto;
  padding: 2px 7px;
  font-size: 10px;
  animation: chipPulse 1.8s ease-in-out infinite;
}
@keyframes chipPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(245,158,11,.45); }
  50% { opacity: .72; box-shadow: 0 0 0 4px rgba(245,158,11,0); }
}
/* Hormati preferensi sistem: denyut abadi adalah pemicu bagi sebagian orang. */
@media (prefers-reduced-motion: reduce) {
  .chip-pulse { animation: none; }
}

.fade-in { animation: fadeIn .35s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.pop-in { animation: popIn .25s cubic-bezier(.2,.8,.2,1) both; }
@keyframes popIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }

/* sidebar */
.nav-item { display:flex; align-items:center; gap:12px; padding:11px 14px; border-radius:12px;
  color: var(--text-dim); font-weight:600; font-size:14px; cursor:pointer; transition: all .15s;
  /* FASE 87: pertahanan berlapis melawan scrollbar mendatar di menu.
     `width:100%` + box-sizing:border-box (reset global baris 29) menjamin padding
     & border item aktif TIDAK menambah lebar. `min-width:0` mematahkan aturan
     flex bawaan (min-width:auto) yang membuat item menolak menyusut di bawah
     lebar kontennya — tanpa ini satu label panjang bisa melebarkan seisi menu. */
  width: 100%; min-width: 0; }
/* Label boleh terpangkas; ia TIDAK boleh mendorong lebar sidebar. */
.nav-item .nv-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, rgba(34,197,94,.22), rgba(20,184,166,.14));
  color: var(--text); border: 1px solid rgba(34,197,94,.25); }

/* FASE 54: item nav yang tak bisa dipakai (belum ada instance dipilih).
   Tetap TERLIHAT — menyembunyikannya membuat menu seolah tak pernah ada. */
.nav-item.nav-disabled { opacity: .42; cursor: not-allowed; }
.nav-item.nav-disabled:hover { background: transparent; color: var(--text-dim); }

/* FASE 54: tabel basis pengetahuan. Pembungkus menggulir SENDIRI supaya isi
   panjang tak pernah memaksa body ikut menggulir mendatar. */
.ai-table-wrap { overflow-x: auto; }
.ai-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ai-table th, .ai-table td { padding: 10px 12px; text-align: left; vertical-align: top; }
.ai-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
.ai-table tbody tr { border-top: 1px solid rgba(148,163,184,.16); }
.ai-table tbody tr:hover { background: rgba(148,163,184,.06); }
/* Isi panjang dipangkas jadi 3 baris — satu baris tabel tak boleh setinggi layar. */
.ai-kb-content {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; white-space: pre-wrap; color: var(--text-dim); line-height: 1.5;
}
.ai-kb-off { opacity: .5; }

/* chat */
.bubble { max-width: 74%; padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height:1.45;
  word-wrap: break-word; white-space: pre-wrap; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.bubble.me { background: linear-gradient(135deg, #16a34a, #15803d); color: #fff; border-bottom-right-radius: 4px; }
.bubble.them { background: var(--panel-strong); color: var(--text); border-bottom-left-radius: 4px; }

/* Fase 6: profil scrollbar ramping 6px ala WA Web (track transparan) */
.scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.scroll::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,.45); }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* Fase 6: scrollbar tipis untuk textarea komposer (auto-grow s/d 120px) */
.slim-scroll::-webkit-scrollbar { width: 6px; }
.slim-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.slim-scroll::-webkit-scrollbar-track { background: transparent; }
.slim-scroll { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* Refinement scrollbar list chat agar tidak tumpang tindih / menghasilkan bayangan */
#chat-list {
  scrollbar-gutter: stable;
  padding-right: 4px;
}
#chat-list::-webkit-scrollbar { width: 5px; }
#chat-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 99px; }
#chat-list::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); }
#chat-list::-webkit-scrollbar-track { background: transparent; }

.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { animation: slideIn .3s ease both; }
@keyframes slideIn { from { opacity:0; transform: translateX(20px);} to {opacity:1; transform:none;} }

.hidden { display: none !important; }
.avatar { width: 40px; height: 40px; border-radius: 12px; display:flex; align-items:center; justify-content:center;
  font-weight:700; color:#04170c; background: linear-gradient(135deg, var(--brand), var(--brand-2)); flex: 0 0 auto; }
.avatar.indigo { background: linear-gradient(135deg,#818cf8,#6366f1); color:#fff; }

/* ---- Context menu ala desktop (right-click) ---- */
.ctx-menu { position: fixed; z-index: 9999; min-width: 200px; padding: 6px;
  background: var(--panel-strong, #1e293b); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.45);
  animation: ctxIn .12s ease both; backdrop-filter: blur(12px); }
@keyframes ctxIn { from { opacity:0; transform: scale(.96) translateY(-4px);} to {opacity:1; transform:none;} }
.ctx-item { display:flex; align-items:center; gap:10px; width:100%; padding:9px 12px;
  border-radius:8px; font-size:13.5px; color: var(--text); cursor:pointer; text-align:left;
  background:none; border:none; transition: background .12s; }
.ctx-item:hover { background: rgba(127,127,127,.16); }
.ctx-item.danger { color: var(--danger); }
.ctx-ico { width:18px; text-align:center; flex:0 0 auto; }
.ctx-sep { height:1px; margin:5px 4px; background: var(--border); }

/* ---- Pesan ditarik (revoked) — FASE 74: konten asli tetap tampil, cukup badge ---- */
.revoked-badge { font-size: 9.5px; font-style: italic; opacity: .8; margin-right: 2px; }
.bubble.revoked { outline: 1px dashed rgba(127,127,127,.35); outline-offset: -1px; }

/* ---- Optimistic UI: jam pending berdenyut halus (ala WA Web) ---- */
.pending-clock { display:inline-block; animation: pendingPulse 1.2s ease-in-out infinite; }
@keyframes pendingPulse { 0%,100% { opacity:.45; } 50% { opacity:1; } }

/* ---- Indikator "Sedang mengetik…" ---- */
.typing-label { color: var(--brand) !important; font-weight: 600; font-style: italic; }

/* ---- Perekam voice note ---- */
.rec-dot { width:10px; height:10px; border-radius:50%; background:#ef4444; flex:0 0 auto;
  animation: recBlink 1s ease-in-out infinite; }
@keyframes recBlink { 0%,100% { opacity:.25; transform:scale(.85);} 50% { opacity:1; transform:scale(1);} }

/* ---- Drawer kontak (Mulai Obrolan Baru) ---- */
.drawer-in { animation: drawerIn .22s cubic-bezier(.2,.8,.2,1) both; }
@keyframes drawerIn { from { opacity:0; transform: translateX(-14px); } to { opacity:1; transform:none; } }

/* ================= FASE 4 ================= */

/* ---- Drawer Info Kontak (profil lawan bicara, slide dari kanan) ---- */
.profile-drawer-in { animation: profileIn .24s cubic-bezier(.2,.8,.2,1) both;
  box-shadow: -18px 0 40px -18px rgba(0,0,0,.5); }
@keyframes profileIn { from { opacity:0; transform: translateX(24px); } to { opacity:1; transform:none; } }
.profile-pic { width:132px; height:132px; border-radius:50%; object-fit:cover;
  border:3px solid var(--brand); box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); }

/* ---- Lightbox media fullscreen (glassmorphism, zoom/rotate/cycle) ---- */
.lb-overlay { position:fixed; inset:0; z-index:70; display:flex; flex-direction:column;
  background: rgba(2,6,23,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fadeIn .18s ease both; }
.lb-top { display:flex; align-items:center; gap:8px; padding:12px 16px;
  background: linear-gradient(180deg, rgba(2,6,23,.75), transparent); color:#e2e8f0; }
.lb-title { flex:1; min-width:0; font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; opacity:.85; }
.lb-btn { display:inline-flex; align-items:center; justify-content:center; width:38px; height:38px;
  border-radius:10px; border:1px solid rgba(255,255,255,.14); background:rgba(255,255,255,.08);
  color:#fff; font-size:16px; cursor:pointer; transition: background .15s, transform .12s; }
.lb-btn:hover { background:rgba(255,255,255,.18); transform: translateY(-1px); }
.lb-stage { flex:1; min-height:0; display:flex; align-items:center; justify-content:center;
  overflow:hidden; position:relative; }
.lb-stage img, .lb-stage video { max-width:92%; max-height:92%; border-radius:10px;
  transition: transform .18s ease; user-select:none; }
.lb-stage img { cursor: grab; }
.lb-stage img.dragging { cursor: grabbing; transition:none; }
.lb-nav { position:absolute; top:50%; transform: translateY(-50%); z-index:2;
  width:46px; height:46px; border-radius:50%; border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.1); color:#fff; font-size:22px; cursor:pointer;
  display:flex; align-items:center; justify-content:center; transition: background .15s; }
.lb-nav:hover { background:rgba(255,255,255,.24); }
.lb-nav.prev { left:18px; } .lb-nav.next { right:18px; }
.lb-counter { font-size:12px; opacity:.75; padding:0 6px; white-space:nowrap; }

/* ---- Highlight hasil pencarian ---- */
mark.hl { background: rgba(245,158,11,.45); color: inherit; border-radius:3px; padding:0 1px; }
.search-hit-current { outline: 2px solid var(--warn); outline-offset: 2px; }
.search-flash { animation: searchFlash 1.2s ease both; }
@keyframes searchFlash { 0% { box-shadow: 0 0 0 4px rgba(245,158,11,.65); }
  100% { box-shadow: 0 0 0 4px rgba(245,158,11,0); } }
.search-sec { font-size:11px; text-transform:uppercase; letter-spacing:.06em;
  color: var(--text-dim); padding: 8px 10px 2px; font-weight:700; }

/* ---- Sidebar chat collapsible (avatar-only) ---- */
#chats-grid {
  --sb-w: 320px;
}
.sb-toggle {
  display:none; position:absolute; z-index:15; top:50%;
  left: calc(var(--sb-w, 320px) - 6px);
  transform: translateY(-50%);
  width:28px; height:28px; border-radius:50%; border:1px solid var(--border);
  background: var(--bg-soft); color: var(--text); font-size:15px; font-weight:700;
  cursor:pointer; align-items:center; justify-content:center;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  transition: left .2s ease, background .15s, opacity .15s;
  opacity: .85;
}
.sb-toggle:hover { background: var(--panel-strong); opacity: 1; }
@media (min-width: 768px) {
  .sb-toggle { display:flex; }
  #chats-grid.sb-collapsed { --sb-w: 76px; }
  #chats-grid.sb-collapsed .sb-hide { display:none !important; }
  #chats-grid.sb-collapsed #chat-list > button { justify-content:center; padding:8px 4px; }
  #chats-grid.sb-collapsed #chat-list .chat-item-body { display:none !important; }
  #chats-grid.sb-collapsed .unread-dot { display:flex; }
  /* Fase 6: mode ketiga — sidebar disembunyikan TOTAL (fokus penuh ke room) */
  #chats-grid.sb-hidden { --sb-w: 0px; }
  #chats-grid.sb-hidden > .glass:first-of-type { display:none !important; }
}
.unread-dot { display:none; position:absolute; top:-4px; right:-4px; min-width:17px; height:17px;
  border-radius:999px; background: var(--brand); color:#04170c; font-size:10px; font-weight:800;
  align-items:center; justify-content:center; padding:0 4px; border:2px solid var(--bg-soft); }

/* ================= FASE 5 ================= */

/* ---- Chevron mengambang ke pesan terbaru + badge pesan baru ---- */
.scroll-bottom { position:absolute; right:18px; bottom:96px; z-index:12;
  width:42px; height:42px; border-radius:50%; border:1px solid var(--border);
  background: var(--panel-strong); color: var(--text); font-size:22px; font-weight:700;
  cursor:pointer; display:flex; align-items:center; justify-content:center;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); transition: transform .15s, background .15s;
  animation: chevIn .18s ease both; }
.scroll-bottom:hover { transform: translateY(-2px); background: var(--bg-soft); }
@keyframes chevIn { from { opacity:0; transform: translateY(8px);} to { opacity:1; transform:none; } }
.sb-badge { position:absolute; top:-6px; right:-6px; min-width:19px; height:19px;
  border-radius:999px; background: var(--brand); color:#04170c; font-size:11px; font-weight:800;
  display:flex; align-items:center; justify-content:center; padding:0 5px;
  border:2px solid var(--panel-strong); animation: recBlinkOnce .3s ease both; }
@keyframes recBlinkOnce { from { transform:scale(.5);} to { transform:scale(1);} }

/* ---- Dropzone drag-and-drop media (overlay blur di panel chat) ---- */
.dropzone { position:absolute; inset:0; z-index:30; display:flex; align-items:center;
  justify-content:center; border-radius:inherit;
  background: rgba(2,6,23,.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fadeIn .12s ease both; pointer-events:none; }
.dz-inner { border:2px dashed var(--brand); border-radius:20px; padding:36px 52px;
  text-align:center; font-size:17px; font-weight:700; color:var(--text);
  background: rgba(34,197,94,.08); line-height:1.9; }

/* ---- Popover autocomplete mention @anggota grup ---- */
.mention-pop { position:absolute; left:12px; right:12px; bottom:100%; margin-bottom:6px;
  max-height:240px; overflow-y:auto; z-index:40; padding:6px;
  background: var(--panel-strong); border:1px solid var(--border); border-radius:14px;
  box-shadow: 0 -10px 34px rgba(0,0,0,.45); animation: ctxIn .12s ease both; }
.mention-item { display:flex; align-items:center; gap:10px; width:100%; padding:8px 10px;
  border-radius:9px; font-size:13.5px; color:var(--text); cursor:pointer; text-align:left;
  background:none; border:none; transition: background .1s; }
.mention-item:hover, .mention-item.active { background: rgba(127,127,127,.18); }
.mention-item .mi-num { margin-left:auto; font-size:11px; color:var(--text-dim); white-space:nowrap; }

/* ---- Tag mention di bubble (nama bersih menggantikan @62812…) ---- */
.mention { color:#53bdeb; font-weight:600; }
.bubble.me .mention { color:#bfe7ff; }

/* ---- Pratinjau media pra-kirim: strip thumbnail multi-file ---- */
.mm-thumb { width:52px; height:52px; flex:0 0 auto; border-radius:10px; overflow:hidden;
  border:2px solid transparent; cursor:pointer; background:var(--bg-soft);
  display:flex; align-items:center; justify-content:center; font-size:20px; position:relative; }
.mm-thumb img { width:100%; height:100%; object-fit:cover; display:block; }
.mm-thumb.active { border-color: var(--brand); }
.mm-thumb .mm-x { position:absolute; top:-1px; right:-1px; width:16px; height:16px; border-radius:50%;
  background:rgba(2,6,23,.75); color:#fff; font-size:10px; line-height:16px; text-align:center; }

/* ---- Stories viewer (lightbox status + progress bar otomatis) ---- */
.story-overlay { position:fixed; inset:0; z-index:80; display:flex; flex-direction:column;
  background: rgba(2,6,23,.95); backdrop-filter: blur(12px); animation: fadeIn .16s ease both; }
.story-top { padding:14px 18px 8px; color:#e2e8f0; }
.story-progress { display:flex; gap:5px; margin-bottom:10px; }
.story-bar { flex:1; height:3px; border-radius:99px; background: rgba(255,255,255,.22); overflow:hidden; }
.story-bar > i { display:block; height:100%; width:0; background:#fff; border-radius:99px; }
.story-bar.done > i { width:100%; }
.story-bar.running > i { animation: storyRun var(--story-dur, 5s) linear both; }
@keyframes storyRun { from { width:0; } to { width:100%; } }
.story-head { display:flex; align-items:center; gap:10px; }
.story-stage { flex:1; min-height:0; display:flex; align-items:center; justify-content:center;
  position:relative; overflow:hidden; padding:10px 0 24px; }
.story-stage img, .story-stage video { max-width:min(94vw,520px); max-height:100%; border-radius:14px; }
.story-text { max-width:min(92vw,520px); padding:48px 34px; border-radius:18px; text-align:center;
  font-size:22px; font-weight:600; line-height:1.5; color:#fff; white-space:pre-wrap; word-break:break-word;
  background: linear-gradient(135deg,#0f766e,#166534); }
.story-caption { position:absolute; left:0; right:0; bottom:0; padding:14px 22px 18px; text-align:center;
  color:#f1f5f9; font-size:14px; background: linear-gradient(0deg, rgba(2,6,23,.8), transparent); }
.story-nav { position:absolute; top:0; bottom:0; width:34%; z-index:3; cursor:pointer; background:none; border:none; }
.story-nav.prev { left:0; } .story-nav.next { right:0; }

/* ---- Drawer "Info Pesan" ---- */
.msginfo-row { display:flex; align-items:center; gap:10px; padding:9px 4px;
  border-bottom:1px dashed var(--border); font-size:13.5px; }
.msginfo-row:last-child { border-bottom:none; }
.msginfo-when { margin-left:auto; font-size:11.5px; color:var(--text-dim); white-space:nowrap; text-align:right; }

/* ================= FASE 6 ================= */

/* ---- Status dual-panel: panggung pemutaran gelap di panel kanan ---- */
.story-panel { background:#080d19; border:1px solid var(--border); }
.light .story-panel { background:#101726; }
.story-embed { position:absolute; inset:0; z-index:5; display:flex; flex-direction:column;
  background:#0a0f1d; color:#e2e8f0; animation: fadeIn .16s ease both; }
.story-reply { display:flex; gap:8px; padding:10px 14px 14px; align-items:center;
  background: linear-gradient(0deg, rgba(2,6,23,.85), transparent); }

/* ---- Daftar status kiri: avatar dalam ring SVG tersegmen ---- */
.st-ava { position:relative; width:48px; height:48px; flex:0 0 auto;
  display:flex; align-items:center; justify-content:center; }
.st-ring { position:absolute; inset:0; }
.st-row .avatar { box-shadow: 0 0 0 2px var(--bg-soft); }

/* ---- Switch toggle (modal Pengaturan) ---- */
.switch { position:relative; display:inline-block; width:44px; height:25px; flex:0 0 auto; cursor:pointer; }
.switch input { opacity:0; width:0; height:0; }
.switch i { position:absolute; inset:0; border-radius:999px; background: rgba(148,163,184,.35);
  transition: background .18s; }
.switch i::before { content:""; position:absolute; width:19px; height:19px; left:3px; top:3px;
  border-radius:50%; background:#fff; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.switch input:checked + i { background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.switch input:checked + i::before { transform: translateX(19px); }

/* ---- Sensor Privasi Layar: konten sensitif blur permanen; HANYA elemen tepat
       di bawah kursor yang jernih (hover), langsung buram lagi saat kursor pergi. */
.privacy-shield #chat-list > button,
.privacy-shield #chat-messages .bubble,
.privacy-shield #chat-header-info,
.privacy-shield #profile-body,
.privacy-shield #contact-list > button,
.privacy-shield #starred-list > div,
.privacy-shield #status-list .st-row,
.privacy-shield .story-embed .story-stage,
.privacy-shield #switcher-name, .privacy-shield #switcher-status,
.privacy-shield #user-name, .privacy-shield #user-email {
  filter: blur(8px);
  transition: filter 0.2s;
}
.privacy-shield #chat-list > button:hover,
.privacy-shield #chat-messages .bubble:hover,
.privacy-shield #chat-header-info:hover,
.privacy-shield #profile-body:hover,
.privacy-shield #contact-list > button:hover,
.privacy-shield #starred-list > div:hover,
.privacy-shield #status-list .st-row:hover,
.privacy-shield .story-embed .story-stage:hover,
.privacy-shield #switcher-name:hover, .privacy-shield #switcher-status:hover,
.privacy-shield #user-name:hover, .privacy-shield #user-email:hover {
  filter: blur(0px) !important;
}

/* ================= FASE 7 ================= */

/* ---- Navbar UTAMA (rail kiri ekstrem) collapsible dua-state ----
   Ciut: rail 76px, seluruh teks/judul/string sistem disembunyikan, hanya ikon
   menu minimalis terpusat horizontal. Bentang: dimensi flex standar (w-72).
   Preferensi persist di localStorage `v2_nv_collapsed`; kelas diterapkan
   sinkron saat init app.js agar layout tidak berkedip pasca hard-refresh. */
#main-nav { transition: width .2s ease, padding .2s ease; }
#main-nav.nv-collapsed { width: 76px; padding: 16px 10px; }
#main-nav.nv-collapsed .nv-hide { display: none !important; }
#main-nav.nv-collapsed #nv-brand { justify-content: center; padding: 4px 0; }
#main-nav.nv-collapsed #nv-switcher { padding: 8px 6px; }
#main-nav.nv-collapsed #switcher-btn { justify-content: center; padding: 6px 0; }
#main-nav.nv-collapsed .nav-item { justify-content: center; padding: 11px 0; }
#main-nav.nv-collapsed .nav-item .nv-label { display: none !important; }
#main-nav.nv-collapsed #nv-user { flex-direction: column; padding: 10px 6px; gap: 8px; }

/* ================= FASE 14 — high-fidelity fluid UI ================= */

/* ---- §1 Guardrail komposer 4096 char: shake + border crimson sementara ---- */
.input-shake-error { animation: inputShake .42s cubic-bezier(.36,.07,.19,.97) both;
  border-color: #ef4444 !important; box-shadow: 0 0 0 3px rgba(239,68,68,.22) !important; }
@keyframes inputShake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}
/* Toast center-top high-fidelity (dipakai untuk peringatan guardrail & limit) */
#toasts.toasts-top { position: fixed; top: 18px; left: 50%; right: auto; bottom: auto;
  transform: translateX(-50%); z-index: 9997; display: flex; flex-direction: column;
  align-items: center; gap: 8px; pointer-events: none; }
#toasts.toasts-top .toast { pointer-events: auto; }

/* ---- §2 Grup: avatar partisipan + nama pengirim + grouping berurutan ----
   Wrapper adalah lingkaran (inisial di belakang); <img> menutupinya. Bila foto
   gagal dimuat, bindAvatarFallback melepas <img> → inisial tetap tampil. */
.bubble-avatar-wrapper { width: 32px; height: 32px; border-radius: 50%; margin-right: 8px;
  flex: 0 0 auto; position: relative; overflow: hidden; cursor: zoom-in;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; align-self: flex-end;
  background: linear-gradient(135deg, #818cf8, #6366f1);
  box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.bubble-avatar-wrapper img { position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block; }
.group-sender-title { font-size: 0.75rem; color: #388e3c; font-weight: 600; display: block;
  margin-bottom: 2px; cursor: pointer; }
.bubble.them .group-sender-title { color: #4ade80; }
.consecutive-indent { margin-left: 40px; }

/* ---- §5 Bintang di footer bubble (SVG mengkilap) ---- */
.star-timestamp-icon { width: 11px; height: 11px; vertical-align: -1px; margin-right: 3px;
  fill: #f5c451; filter: drop-shadow(0 0 1px rgba(245,196,81,.55));
  animation: starPop .3s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes starPop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---- §4 Drawer: seksi Media / Dokumen / Blokir ---- */
.pf-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-dim); font-weight: 700; margin: 20px 0 8px; }
.pf-media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pf-media-cell { position: relative; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden;
  background: var(--bg-soft); cursor: pointer; border: 1px solid var(--border);
  transition: transform .16s cubic-bezier(.4,0,.2,1); }
.pf-media-cell:hover { transform: scale(1.04); }
.pf-media-cell img, .pf-media-cell video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-media-cell .pf-media-badge { position: absolute; bottom: 3px; right: 4px; font-size: 12px;
  text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.pf-doc-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  background: var(--bg-soft); text-decoration: none; color: inherit; margin-bottom: 6px;
  border: 1px solid var(--border); transition: background .14s; }
.pf-doc-row:hover { background: var(--panel-strong); }
.pf-starred-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border-radius: 10px;
  background: var(--bg-soft); cursor: pointer; margin-bottom: 6px; border: 1px solid var(--border);
  transition: background .14s; }
.pf-starred-row:hover { background: var(--panel-strong); }
.btn-block { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; cursor: pointer;
  color: #f87171; background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.35);
  transition: background .16s, transform .12s; position: relative; }
.btn-block:hover { background: rgba(239,68,68,.18); }
.btn-block.blocked { color: var(--text); background: var(--panel); border-color: var(--border); }
.btn-block .spinner-glass { position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; border-radius: inherit; background: rgba(255,255,255,.04);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
/* Komposer saat kontak diblokir: sembunyikan semua kecuali banner peringatan */
.composer-blocked-note { display: none; text-align: center; font-size: 12.5px; padding: 10px;
  color: var(--text-dim); line-height: 1.5; }
#chat-composer.is-blocked > *:not(.composer-blocked-note) { display: none !important; }
#chat-composer.is-blocked .composer-blocked-note { display: block; }

/* ---- §7 Badge tanggal mengambang + tombol drop-anchor ---- */
.floating-date-badge { position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 11; padding: 4px 14px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  color: var(--text); background: var(--panel-strong);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border); box-shadow: 0 4px 14px rgba(0,0,0,.3);
  opacity: 0; pointer-events: none; will-change: opacity;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.floating-date-badge.visible { opacity: 1; }
/* Tombol chevron: denyut lembut saat ada pesan baru belum terlihat */
.scroll-bottom.has-unread { animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* ---- §8 Transisi GPU: slide antar-view, workspace naik, shimmer skeleton ---- */
.view-anim-in { animation: viewSlideIn .28s cubic-bezier(0.4, 0, 0.2, 1) both; }
@keyframes viewSlideIn { from { opacity: 0; transform: translateX(15px); } to { opacity: 1; transform: translateX(0); } }
.workspace-rise { animation: workspaceRise .25s cubic-bezier(0.4, 0, 0.2, 1) both; }
@keyframes workspaceRise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.shimmer-skel { position: relative; overflow: hidden; border-radius: 12px;
  background: rgba(255,255,255,0.03); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.shimmer-skel::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%,
    rgba(255,255,255,0.08) 40%, rgba(255,255,255,0.14) 50%, rgba(255,255,255,0.08) 60%, transparent 80%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.skel-line { height: 12px; border-radius: 7px; margin: 7px 0; }

/* Drawer info kanan: paksa layer HW saat slide-in (paritas swift) */
#profile-drawer { will-change: transform; }

/* ================= FASE 15 ================= */

/* ---- §2 Draf per-room: prefiks amber miring di preview sidebar ---- */
.draft-label { color: var(--warn); font-style: italic; font-weight: 700; margin-right: 4px; }

/* ---- §3 Drawer stiker (popover di atas komposer, glassmorphic) ---- */
.sticker-pop { position: absolute; left: 12px; right: 12px; bottom: 100%; margin-bottom: 6px;
  z-index: 40; padding: 10px; background: var(--panel-strong); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 -10px 34px rgba(0,0,0,.45); animation: ctxIn .12s ease both;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.sticker-pop-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sticker-pop-head > span { flex: 1; }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px;
  max-height: 260px; overflow-y: auto; }
.sticker-cell { border: 1px solid var(--border); border-radius: 12px; background: var(--bg-soft);
  padding: 6px; cursor: pointer; transition: transform .14s, background .14s; aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center; }
.sticker-cell:hover { transform: scale(1.06); background: var(--panel-strong); }
.sticker-cell img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }

/* ---- §4 Editor media pra-kirim: canvas kerja + overlay interaksi ---- */
.mm-canvas-holder { position: relative; display: inline-block; max-width: 100%; }
.mm-canvas-holder canvas { display: block; max-width: 100%; max-height: 50vh; border-radius: 10px; }
.mm-overlay { position: absolute; inset: 0; width: 100% !important; height: 100% !important;
  touch-action: none; pointer-events: none; }
.tool-active { border-color: var(--brand) !important; background: rgba(34,197,94,.16) !important;
  color: var(--brand) !important; }
.mm-color { width: 32px; height: 32px; padding: 2px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg-soft); cursor: pointer; flex: 0 0 auto; }

/* ---- §4 Trim video: dual-anchor range slider di satu track ---- */
.mm-trim-track { position: relative; flex: 1; height: 26px; min-width: 160px; }
.mm-trim-track input[type="range"] { position: absolute; inset: 0; width: 100%; margin: 0;
  background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.mm-trim-track input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 99px;
  background: var(--border); margin-top: 11px; }
.mm-trim-track input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto;
  width: 16px; height: 16px; border-radius: 50%; background: var(--brand); border: 2px solid #fff;
  margin-top: -6px; cursor: ew-resize; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.mm-trim-track input[type="range"]::-moz-range-track { height: 4px; border-radius: 99px; background: var(--border); }
.mm-trim-track input[type="range"]::-moz-range-thumb { pointer-events: auto; width: 14px; height: 14px;
  border-radius: 50%; background: var(--brand); border: 2px solid #fff; cursor: ew-resize; }

/* ---- §7 Komposer grup pengumuman (read-only): fade + banner kaca ---- */
.composer-readonly-note { display: none; text-align: center; font-size: 12.5px; padding: 11px 14px;
  margin-bottom: 8px; border-radius: 12px; color: var(--text-dim); line-height: 1.55;
  background: var(--panel); border: 1px solid var(--border);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
#chat-composer.is-readonly .composer-readonly-note { display: block; }
#chat-composer.is-readonly #composer-row { opacity: .6; pointer-events: none; }
#chat-composer.is-readonly #btn-send-chat { display: none; }
#chat-composer.is-readonly #qr-suggest,
#chat-composer.is-readonly #reply-bar,
#chat-composer.is-readonly #sticker-pop,
#chat-composer.is-readonly #mention-pop { display: none !important; }
/* Blokir kontak (Fase 14) menang atas read-only: semua disembunyikan. */
#chat-composer.is-blocked .composer-readonly-note { display: none; }

/* ================================================================== */
/* ============ FASE 16 — poll, sync monitor, responsif ============= */
/* ================================================================== */

/* ---- §4 Bubble POLLING native (hasil suara realtime) ----
   FASE 46 — AKAR bloat vertikal: `.bubble` memakai `white-space: pre-wrap`
   (WAJIB, supaya line break pesan TEKS terjaga). Efek sampingnya, newline +
   indentasi template literal pollHtml ikut DIRENDER sebagai baris kosong →
   terukur tinggi opsi 150px & bubble 608px. `white-space: normal` di sini
   mengembalikan kartu ke tinggi isinya; menambal padding/margin TIDAK akan
   menyentuh penyebab ini. */
.poll-box { max-width: 300px; white-space: normal; }
/* Pertanyaan tetap pre-wrap: satu-satunya teks poll yang boleh multi-baris. */
.poll-title { font-weight: 700; margin-bottom: 2px; white-space: pre-wrap; }
.poll-sub { font-size: 11px; color: inherit; opacity: .7; margin-bottom: 6px; }
/* Satu baris per opsi: track & isian jadi LATAR teks, bukan bar terpisah di
   bawahnya — menghapus celah "melayang" antar opsi sekaligus memadatkan tinggi. */
.poll-opt { position: relative; display: flex; align-items: center; gap: 8px; margin-top: 4px;
  padding: 5px 9px; border-radius: 9px; font-size: 13px; overflow: hidden; }
/* Track & isian memakai currentColor → ikut warna bubble me/them DAN tema
   gelap/terang. Aturan lama `rgba(255,255,255,.12)` tak terlihat di :root.light
   (putih di atas --panel-strong yang nyaris putih). */
.poll-opt::before { content: ""; position: absolute; inset: 0; background: currentColor; opacity: .09; }
.poll-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: currentColor;
  opacity: .2; transition: width .5s cubic-bezier(.22, 1, .36, 1); }
.poll-opt-name { position: relative; min-width: 0; overflow-wrap: anywhere; }
.poll-opt-count { position: relative; margin-left: auto; flex: 0 0 auto; font-weight: 700;
  opacity: .85; font-variant-numeric: tabular-nums; }
.poll-hint { font-size: 10.5px; opacity: .55; margin-top: 6px; font-style: italic; }

/* ---- §4 Badge "Sekali Lihat" (FASE 76: footer, dekat timestamp) & "diedit" ---- */
.viewonce-badge { font-size: 9.5px; font-style: italic; opacity: .85; margin-right: 2px; }
.edited-tag { font-size: 9.5px; font-style: italic; opacity: .8; margin-right: 2px; }

/* ---- FASE 79: placeholder "Sekali Lihat" PERSIST (media tak tertangkap) ---- */
.viewonce-locked { display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  font-style: italic; opacity: .82; }
.viewonce-locked span { opacity: .95; }

/* ---- FASE 80.1: LOG PANGGILAN — chip sistem RAMPING di TENGAH (ala WhatsApp) ---- */
.call-syschip { display: inline-flex; align-items: center; margin: 3px auto; max-width: 100%; }
/* FASE 80.2: chip MELEBAR mengikuti teks (fit-content, nowrap) — TANPA ellipsis
   agar status "Tidak dijawab"/"Diblokir otomatis (non-kontak)" tak terpotong. */
.call-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 14px;
  border-radius: 999px; background: rgba(127,127,127,.12); font-size: 12.5px;
  width: fit-content; max-width: 100%; white-space: nowrap; }
.call-chip-ico { font-size: 14px; flex: 0 0 auto; line-height: 1; }
.call-chip-text { font-weight: 500; white-space: nowrap; }
.call-chip-time { font-size: 10.5px; opacity: .6; flex: 0 0 auto; }
.call-chip.call-answered .call-chip-ico { color: #22c55e; }
.call-chip.call-rejected .call-chip-ico { color: #ef4444; }
.call-chip.call-missed   .call-chip-ico { color: #f59e0b; }
/* baris di menu "Panggilan" (ikon lingkaran) */
.call-row-icon.call-answered { color: #22c55e; }
.call-row-icon.call-rejected { color: #ef4444; }
.call-row-icon.call-missed   { color: #f59e0b; }
/* ---- FASE 79: baris di menu "Panggilan" ---- */
.call-row-icon { font-size: 18px; width: 40px; height: 40px; flex: 0 0 auto; display: flex;
  align-items: center; justify-content: center; border-radius: 50%; background: rgba(127,127,127,.14); }
.call-sub.call-answered { color: #22c55e !important; }
.call-sub.call-rejected { color: #ef4444 !important; }
.call-sub.call-missed   { color: #f59e0b !important; }

/* ---- FASE 80: alert DERING panggilan masuk (realtime) ---- */
.ringing-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px;
  background: var(--glass, rgba(20,28,46,.92)); border: 1px solid var(--border); backdrop-filter: blur(10px);
  box-shadow: 0 12px 40px rgba(0,0,0,.42); animation: ringingIn .28s cubic-bezier(.2,.9,.3,1.2) both; }
.ringing-card.ringing-out { animation: ringingOut .2s ease both; }
@keyframes ringingIn { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes ringingOut { to { opacity: 0; transform: translateY(10px) scale(.97); } }
.ringing-pulse { font-size: 22px; width: 46px; height: 46px; flex: 0 0 auto; display: flex; align-items: center;
  justify-content: center; border-radius: 50%; background: rgba(34,197,94,.18); color: #22c55e;
  animation: ringingPulse 1s ease-in-out infinite; }
@keyframes ringingPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,.5); } 50% { box-shadow: 0 0 0 10px rgba(34,197,94,0); } }
.ringing-title { font-size: 12px; font-weight: 600; opacity: .8; }
.ringing-name { font-size: 15px; font-weight: 700; }
.ringing-dots { display: inline-flex; gap: 3px; margin-top: 3px; }
.ringing-dots span { width: 5px; height: 5px; border-radius: 50%; background: #22c55e; opacity: .5;
  animation: ringingDot 1.1s infinite; }
.ringing-dots span:nth-child(2) { animation-delay: .18s; }
.ringing-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes ringingDot { 0%,100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
.ringing-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.ringing-dismiss { background: none; border: none; color: var(--text-dim); font-size: 16px; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.ringing-dismiss:hover { background: rgba(127,127,127,.16); }

/* ---- FASE 77: kotak kutipan balasan (klik → lompat ke pesan asli) ---- */
.quoted-ref { border-left: 3px solid rgba(255,255,255,.4); padding: 2px 8px; margin-bottom: 4px;
  opacity: .85; font-size: 12px; border-radius: 4px; background: rgba(0,0,0,.12);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quoted-ref-jump { cursor: pointer; transition: background .12s, opacity .12s; }
.quoted-ref-jump:hover { background: rgba(0,0,0,.22); opacity: 1; }

/* ---- FASE 18 §2: placeholder pesan yang sedang dipulihkan (E2E desync) ----
   Bubble transien: tak ada baris DB di baliknya, ditambal di tempat begitu
   versi terdekripsi tiba. Tampil "kaca buram" agar jelas BUKAN pesan final. */
.bubble.healing { background: rgba(255, 255, 255, .07); backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px); border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: none; }
.healing-tag { display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-style: italic; opacity: .82; }
.healing-lock { display: inline-block; animation: healingPulse 1.6s ease-in-out infinite; }
/* FASE 22: keadaan AKHIR — tak ada denyut (proses sudah berhenti), opasitas turun
   agar jelas terbaca "selesai & gagal", bukan "sedang berjalan". */
.bubble.healing.heal-failed { border-style: dashed; opacity: .72; }
.bubble.healing.heal-failed .healing-tag { font-style: normal; }
@keyframes healingPulse { 0%, 100% { opacity: .45; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) {
  .healing-lock { animation: none; opacity: .85; }
}

/* ---- §5 Indikator progres sinkronisasi riwayat (top-sidebar) ---- */
.sync-progress { margin-top: 8px; padding: 8px 10px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--border);
  animation: syncIn .3s cubic-bezier(.22, 1, .36, 1); }
@keyframes syncIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.sync-track { height: 5px; border-radius: 99px; background: var(--border); overflow: hidden; }
.sync-fill { height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width .6s cubic-bezier(.22, 1, .36, 1); }
.sync-fill.indeterminate { width: 38% !important; animation: syncSlide 1.4s ease-in-out infinite; }
@keyframes syncSlide { 0% { transform: translateX(-110%); } 100% { transform: translateX(300%); } }
.sync-label { font-size: 11px; margin-top: 5px; color: var(--text-dim); line-height: 1.45; }
/* Stall (>45 dtk tanpa chunk, khas iPhone terkunci) → amber peringatan. */
.sync-progress.stalled { border-color: rgba(245, 158, 11, .55); background: rgba(245, 158, 11, .08); }
.sync-progress.stalled .sync-fill { background: var(--warn); animation: syncPulse 1.6s ease-in-out infinite; }
.sync-progress.stalled .sync-label { color: var(--warn); font-weight: 600; }
@keyframes syncPulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ---- §4 Micro-interactions (GPU-accelerated: transform/opacity saja) ---- */
.nav-item, .btn, .chat-item, .ctx-item { will-change: transform; }
.nav-item { transition: transform .16s ease, background .16s ease; }
.nav-item:hover { transform: translateX(3px); }
.btn { transition: transform .14s ease, filter .14s ease, background .14s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.97); }
#chat-list > * { transition: transform .15s ease, background .15s ease; }
#chat-list > *:hover { transform: translateX(2px); }
.bubble { transition: box-shadow .2s ease; }
.gm-tools { opacity: .5; }
.gm-tools:hover { opacity: 1; }

/* ---- §4 Responsif: ultra-wide → workspace lebih lapang ---- */
@media (min-width: 1920px) {
  #chats-grid { --sb-w: 380px; }
  .bubble { max-width: 62ch; }
}

/* ---- §4 Responsif: tablet (≤1024px) — navbar utama auto-rapat ---- */
@media (max-width: 1024px) {
  #main-nav { width: 220px; }
}

/* ---- §4 Responsif: ponsel (≤768px) — pola master-detail penuh layar.
   Daftar chat & room bertukar tempat via .room-open (di-toggle openChat/
   closeActiveChat); navbar utama menjadi ikon rapat agar ruang maksimal. ---- */
@media (max-width: 768px) {
  #main-nav { width: 64px; padding: 10px 6px; }
  #main-nav .nv-hide, #main-nav .nv-label { display: none; }
  main { padding: 8px !important; }
  #chats-grid { grid-template-columns: 1fr !important; }
  /* Default mobile: hanya daftar chat; room & toggle sidebar disembunyikan. */
  #chats-grid > .glass:nth-of-type(2) { display: none; }
  #chats-grid .sb-toggle { display: none; }
  /* Room dibuka → panel daftar disembunyikan, room tampil penuh layar. */
  #chats-grid.room-open > .glass:nth-of-type(1) { display: none; }
  #chats-grid.room-open > .glass:nth-of-type(2) { display: flex; }
  #profile-drawer { width: 100% !important; }
  .bubble { max-width: 86%; }
  #toasts { width: calc(100vw - 24px); right: 12px; }
}

/* ===== Pemutar audio ala WhatsApp Web =====================================
   Satu baris rapat: tombol putar, gelombang, durasi. Dibuat setinggi ~32px
   supaya gelembung pesan tidak memanjang ke bawah seperti <audio controls>
   bawaan (yang juga tidak mengikuti tema dan menampilkan "0:00 / 0:00" untuk
   OGG/Opus WhatsApp — durasi kini datang dari server). */
.wa-audio {
  display: flex; align-items: center; gap: 8px;
  width: 232px; max-width: 100%; height: 32px;
}
.wa-audio-el { display: none; }
.wa-audio-btn {
  flex: 0 0 auto; width: 28px; height: 28px; padding: 0;
  border-radius: 50%; border: none; cursor: pointer;
  font-size: 10px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent, #22c55e); color: #fff;
  transition: transform .12s ease, filter .12s ease;
}
.wa-audio-btn:hover { filter: brightness(1.08); }
.wa-audio-btn:active { transform: scale(.93); }
/* Gelombang: batang statis + lapisan terisi yang melebar mengikuti posisi. */
.wa-audio-wave {
  position: relative; flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; gap: 2px;
  height: 20px; cursor: pointer; overflow: hidden;
}
.wa-audio-wave > span {
  flex: 1 1 auto; min-width: 2px; border-radius: 2px;
  background: currentColor; opacity: .32;
}
.wa-audio-fill {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: var(--accent, #22c55e); opacity: .5;
  border-radius: 3px; pointer-events: none;
  transition: width .1s linear;
}
.wa-audio-time {
  flex: 0 0 auto; font-size: 11px; line-height: 1;
  opacity: .7; font-variant-numeric: tabular-nums;
}
/* Pesan suara (PTT) ditandai mikrofon kecil, seperti WhatsApp. */
.wa-audio.is-ptt .wa-audio-time::before {
  content: "🎤"; font-size: 9px; margin-right: 3px; opacity: .8;
}

/* ===== Overlay sinkronisasi awal (ala WA Web) ==============================
   Menahan tampilan setelah QR berhasil dipindai sampai riwayat siap, supaya
   daftar chat yang pertama kali dilihat sudah lengkap (nama kontak, pin,
   avatar) — bukan terisi bertahap di depan mata pengguna. */
.pair-sync {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg, #0b1120);
  transition: opacity .3s ease;
}
.pair-sync.hidden { opacity: 0; pointer-events: none; }
.pair-sync-card {
  width: min(380px, 88vw); text-align: center; padding: 28px 26px;
}
.pair-sync-spinner {
  width: 46px; height: 46px; margin: 0 auto 20px;
  border: 3px solid color-mix(in srgb, var(--accent, #22c55e) 22%, transparent);
  border-top-color: var(--accent, #22c55e);
  border-radius: 50%; animation: pair-spin .9s linear infinite;
}
@keyframes pair-spin { to { transform: rotate(360deg); } }
.pair-sync-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.pair-sync-sub { font-size: 13px; opacity: .72; margin-bottom: 18px; }
.pair-sync-track {
  height: 4px; border-radius: 4px; overflow: hidden;
  background: color-mix(in srgb, currentColor 14%, transparent);
}
.pair-sync-track > i {
  display: block; height: 100%; width: 8%;
  background: var(--accent, #22c55e);
  border-radius: 4px; transition: width .4s ease;
}
.pair-sync-hint { font-size: 11px; opacity: .5; margin-top: 14px; }

/* ===== Stiker tanpa gelembung ==============================================
   WhatsApp menggambar stiker langsung di atas latar percakapan: tidak ada
   gelembung, tidak ada padding, hanya jam kecil di kanan bawah gambar. */
.bubble.bubble-sticker {
  background: none !important;
  box-shadow: none !important;
  border: none !important;
  padding: 0 !important;
  position: relative;
}
.bubble.bubble-sticker .bubble-meta {
  position: absolute; right: 6px; bottom: 4px;
  padding: 1px 6px; border-radius: 8px;
  background: rgba(2, 6, 23, .55);
  color: #fff; font-size: 10px; line-height: 1.4;
  opacity: 1 !important; margin-top: 0 !important;
  backdrop-filter: blur(2px);
}
/* Gambar stiker sendiri tidak perlu sudut membulat gelembung. */
.bubble.bubble-sticker .chat-media { display: block; }

/* ===== Avatar pengirim di GRUP ============================================
   WhatsApp menaruh foto pengirim sejajar BARIS PERTAMA pesan, bukan di dasar
   gelembung, dan gelembungnya sedikit menjorok ke arah foto. */
.bubble-avatar-wrapper { align-self: flex-start !important; margin-right: 4px !important; }
.bubble-avatar-wrapper + .bubble { margin-left: -2px; }

/* ===== Kartu pratinjau tautan =============================================
   Data (judul, deskripsi, thumbnail) dikirim WhatsApp di dalam pesan itu
   sendiri — tidak ada pengambilan dari web. */
.link-preview {
  /* LEBAR TETAP. Tanpa ini kartu menyusut mengikuti lebar asli gambar
     thumbnail (peta WhatsApp kecil), sehingga kartunya jadi sempit dan
     memanjang ke bawah — kebalikan dari WhatsApp Web yang melebar. */
  display: block; width: 272px; max-width: 100%;
  margin-bottom: 6px; border-radius: 10px; overflow: hidden;
  background: rgba(2, 6, 23, .28); text-decoration: none; color: inherit;
  border: 1px solid rgba(148, 163, 184, .18);
}
.link-preview:hover { background: rgba(2, 6, 23, .38); }
.link-preview .lp-thumb {
  /* Rasio lanskap tetap: gambar mengisi lebar dan dipotong, tidak menentukan
     tinggi kartu sendiri. */
  display: block; width: 100%; height: 132px; object-fit: cover;
}
.link-preview .lp-body { padding: 7px 9px; }
.link-preview .lp-title {
  font-weight: 600; font-size: 13px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.link-preview .lp-desc {
  font-size: 11.5px; opacity: .75; margin-top: 2px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.link-preview .lp-host { font-size: 10.5px; opacity: .55; margin-top: 4px; }

/* ===== Kartu kontak (vCard) ===============================================
   WhatsApp menampilkan kontak sebagai kartu: avatar inisial, nama, nomor, dan
   aksi. Sebelumnya hanya teks "[vcard]". */
.vcard-card {
  /* Ringkas seperti WhatsApp: satu baris identitas, lalu tombol aksi. */
  width: 250px; max-width: 100%; border-radius: 10px; overflow: hidden;
  background: rgba(2, 6, 23, .28); border: 1px solid rgba(148, 163, 184, .18);
  margin-bottom: 4px;
}
.vcard-card .vc-head { display: flex; align-items: center; gap: 9px; padding: 7px 9px; }
.vcard-card .vc-avatar {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, #818cf8, #6366f1);
}
.vcard-card .vc-info { min-width: 0; }
.vcard-card .vc-action {
  display: block; width: 100%; padding: 6px 10px; border: none; cursor: pointer;
  background: rgba(148, 163, 184, .12); color: var(--brand, #22c55e);
  font-size: 12.5px; font-weight: 600;
  border-top: 1px solid rgba(148, 163, 184, .18);
}
.vcard-card .vc-action:hover { background: rgba(148, 163, 184, .2); }
/* Peta tanpa thumbnail: kotak abu dengan ikon, bukan area kosong. */
.lp-mapfallback {
  height: 132px; display: flex; align-items: center; justify-content: center;
  font-size: 30px; background: rgba(148, 163, 184, .12);
}

/* ===== Gelembung berisi kartu saja =========================================
   Kartu lokasi/kontak sudah membawa bingkainya sendiri. Padding gelembung di
   sekelilingnya menyisakan pita kosong di bawah kartu, jadi dirapatkan dan
   jamnya ditempelkan langsung di bawah kanan. */
.bubble.bubble-card { padding: 3px 3px 1px; }
.bubble.bubble-card .link-preview,
.bubble.bubble-card .vcard-card { margin-bottom: 0; border: none; }
.bubble.bubble-card .bubble-meta { margin-top: 1px; padding: 0 5px 1px 0; }
/* Kartu mengisi lebar gelembung, bukan sebaliknya. */
.bubble.bubble-card .link-preview,
.bubble.bubble-card .vcard-card { width: 272px; }
/* Aksi terakhir tidak perlu garis bawah — ia sudah menyentuh tepi kartu. */
.vcard-card .vc-action:last-child { border-bottom: none; }
