/* VeliTalk Web — warna mengikuti tema yang dipilih di HP (--accent) */
:root {
  --accent: #5B4CDB;
  --accent-2: #8b7ff0;
  --accent-soft: rgba(91, 76, 219, .12);
  --ink: #1F2333;
  --muted: #7A8094;
  --line: #E6E8F0;
  --bg: #F4F5FB;
  --card: #FFFFFF;
  --danger: #DC2626;
  --online: #22C55E;
  --read: #0EA5E9;
  --radius: 18px;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); overflow: hidden; }
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Login ---------- */
.login {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--accent-2), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--accent) 70%, #ff7aa8), transparent 60%),
    var(--accent);
}
.login-card {
  width: min(920px, 100%); background: var(--card); border-radius: 28px; display: flex; gap: 32px; padding: 40px;
  box-shadow: 0 30px 80px rgba(0,0,0,.25);
}
.login-left { flex: 1; min-width: 0; }
.login-left h1 { font-size: 28px; margin: 18px 0 14px; line-height: 1.2; }
.login-left ol { padding-left: 20px; line-height: 2; font-size: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--accent); font-size: 18px; }
.brand img { width: 40px; height: 40px; border-radius: 12px; }
.login-right { width: 290px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.qr-box {
  width: 264px; height: 264px; display: grid; place-items: center; border-radius: 22px; padding: 12px;
  border: 3px solid var(--accent-soft); background: #fff; position: relative;
}
.qr-box img, .qr-box canvas { width: 236px !important; height: 236px !important; }
.qr-box.expired::after {
  content: 'Kode kedaluwarsa'; position: absolute; inset: 0; display: grid; place-items: center; border-radius: 20px;
  background: rgba(255,255,255,.92); font-weight: 700; color: var(--muted);
}
.login-foot { color: rgba(255,255,255,.85); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn { border: 0; border-radius: 22px; padding: 10px 18px; font-weight: 700; background: var(--accent); color: #fff; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- Tata letak ---------- */
.app { height: 100%; display: flex; padding: 14px; gap: 14px;
  background: linear-gradient(135deg, var(--accent) 0, var(--accent) 140px, var(--bg) 140px); }
.side { width: 380px; flex-shrink: 0; background: var(--card); border-radius: 24px; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 10px 30px rgba(20, 20, 60, .08); }
.main { flex: 1; min-width: 0; background: var(--card); border-radius: 24px; display: flex; overflow: hidden; position: relative;
  box-shadow: 0 10px 30px rgba(20, 20, 60, .08); }

.side-head { display: flex; align-items: center; gap: 12px; padding: 16px 14px 10px 18px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--accent-soft); flex-shrink: 0; }
.avatar.sm { width: 32px; height: 32px; }
.avatar.lg { width: 96px; height: 96px; }
.ava-letter { display: grid; place-items: center; color: #fff; font-weight: 800; background: var(--accent); }
.me-text { flex: 1; min-width: 0; }
.me-name { font-weight: 800; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-sub { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--online); box-shadow: 0 0 8px var(--online); display: inline-block; }
.dot.off { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--ink); display: grid; place-items: center; flex-shrink: 0; }
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 44px; background: #fff; border-radius: 14px; box-shadow: 0 12px 30px rgba(0,0,0,.15); padding: 6px; z-index: 30; min-width: 190px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 10px; }
.menu button:hover { background: var(--accent-soft); }
.menu .danger { color: var(--danger); }

.search { margin: 4px 14px 8px; display: flex; align-items: center; gap: 8px; background: var(--bg); border-radius: 22px; padding: 0 14px; color: var(--muted); }
.search input { border: 0; background: none; outline: none; padding: 11px 0; flex: 1; }
.pills { display: flex; gap: 6px; margin: 0 14px 6px; background: #E9EAF3; padding: 4px; border-radius: 24px; }
.pills button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 20px; font-weight: 700; color: var(--muted); }
.pills button.on { background: var(--accent); color: #fff; }
.badge { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 800; text-align: center; }
.pills button.on .badge { background: #fff; color: var(--accent); }

.list { flex: 1; overflow-y: auto; padding: 4px 6px 12px; }
.item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 16px; cursor: pointer; }
.item:hover { background: var(--bg); }
.item.on { background: var(--accent-soft); }
.item .avatar-wrap { position: relative; }
.item .online { position: absolute; right: 1px; bottom: 1px; width: 12px; height: 12px; border-radius: 50%; background: var(--online); border: 2px solid #fff; }
.item .body { flex: 1; min-width: 0; }
.item .top { display: flex; gap: 8px; align-items: baseline; }
.item .name { flex: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .time { font-size: 12px; color: var(--muted); }
.item .time.new { color: var(--accent); font-weight: 700; }
.item .bottom { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.item .prev { flex: 1; font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .prev.bold { color: var(--ink); font-weight: 600; }
.item .prev.typing { color: var(--accent); font-style: italic; }
.section-title { font-size: 11.5px; letter-spacing: 1.1px; font-weight: 700; color: var(--muted); padding: 12px 14px 4px; }
.list-empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.tick { width: 16px; height: 16px; flex-shrink: 0; }
.tick.read { color: var(--read); }
.gicon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.gicon svg { width: 24px; height: 24px; }

/* ---------- Kosong ---------- */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px;
  background: radial-gradient(600px 300px at 50% 30%, var(--accent-soft), transparent 70%); }
.empty-art img { width: 110px; height: 110px; border-radius: 30px; box-shadow: 0 20px 40px var(--accent-soft); }
.empty h2 { margin: 18px 0 6px; font-size: 26px; }

/* ---------- Percakapan ---------- */
.conv { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--accent); }
.conv-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: #fff; }
.conv-head .icon-btn { color: #fff; }
.conv-head .icon-btn:hover { background: rgba(255,255,255,.18); color: #fff; }
.conv-head .back { display: none; }
.conv-title { flex: 1; min-width: 0; cursor: pointer; }
.conv-title .t { font-weight: 800; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-title .s { font-size: 12.5px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-title .s.typing { font-style: italic; opacity: 1; }
.phone-note { font-size: 12px; background: rgba(255,255,255,.16); padding: 6px 10px; border-radius: 14px; white-space: nowrap; }
.conv-head .gicon, .conv-head .avatar { box-shadow: 0 0 0 2px #fff; }
.conv-head .gicon { background: #fff; }

.msgs { flex: 1; overflow-y: auto; padding: 14px 18px 10px; display: flex; flex-direction: column; gap: 2px;
  background: linear-gradient(180deg, var(--accent) 0, color-mix(in srgb, var(--accent) 85%, #000) 100%); border-radius: 0 28px 0 0; }
.day { align-self: center; margin: 10px 0; padding: 4px 12px; border-radius: 12px; background: rgba(255,255,255,.2); color: #fff; font-size: 12px; font-weight: 700; }
.sys { align-self: center; margin: 6px 24px; padding: 6px 12px; border-radius: 12px; background: rgba(0,0,0,.16); color: #fff; font-size: 12.5px; text-align: center; }
.loading-more { align-self: center; color: #fff; opacity: .8; font-size: 12.5px; padding: 6px; }

.mrow { display: flex; align-items: center; gap: 6px; margin: 2px 0; position: relative; }
.mrow.mine { justify-content: flex-end; }
.bubble { max-width: min(560px, 72%); padding: 8px 12px 6px; border-radius: 18px; position: relative; word-wrap: break-word; overflow-wrap: anywhere;
  background: rgba(255,255,255,.17); color: #fff; border-bottom-left-radius: 6px; }
.mine .bubble { background: #fff; color: var(--ink); border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; }
.bubble.media { padding: 4px 4px 6px; }
.bubble .from { font-weight: 700; font-size: 12.5px; margin-bottom: 2px; }
.bubble .fwd { font-size: 12px; font-style: italic; opacity: .75; margin-bottom: 3px; }
.bubble .text { white-space: pre-wrap; line-height: 1.38; font-size: 15px; }
.bubble.media .text { padding: 4px 8px 0; }
.bubble a { color: inherit; text-decoration: underline; }
.mine .bubble a { color: var(--accent); }
.bubble code { background: rgba(0,0,0,.12); border-radius: 4px; padding: 0 4px; font-family: ui-monospace, monospace; }
.bubble .meta { display: flex; gap: 4px; align-items: center; justify-content: flex-end; font-size: 11px; opacity: .75; margin-top: 2px; padding: 0 4px; }
.bubble .deleted { font-style: italic; opacity: .8; }
.quote { border-left: 3px solid currentColor; background: rgba(255,255,255,.14); border-radius: 10px; padding: 5px 9px; margin-bottom: 5px; font-size: 13px; cursor: pointer; }
.mine .quote { background: var(--accent-soft); border-left-color: var(--accent); }
.quote b { display: block; font-size: 12.5px; }
.quote span { opacity: .8; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reacts { position: absolute; bottom: -12px; right: 10px; background: #fff; color: var(--ink); border-radius: 12px; padding: 1px 7px; font-size: 13px;
  box-shadow: 0 2px 6px rgba(0,0,0,.15); cursor: pointer; }
.mrow:not(.mine) .reacts { right: auto; left: 10px; }
.mrow.has-react { margin-bottom: 14px; }
.media-img { display: block; max-width: 340px; max-height: 360px; min-width: 120px; min-height: 80px; border-radius: 14px; cursor: zoom-in; object-fit: cover; background: rgba(0,0,0,.15); }
.media-ph { width: 260px; height: 160px; border-radius: 14px; display: grid; place-items: center; background: rgba(0,0,0,.15); color: inherit; font-size: 13px; cursor: pointer; }
.file-card { display: flex; gap: 10px; align-items: center; min-width: 240px; padding: 8px; border-radius: 12px; background: rgba(0,0,0,.08); cursor: pointer; text-decoration: none; }
.file-card .ext { width: 40px; height: 46px; border-radius: 8px; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 800; font-size: 11px; }
.mrow:not(.mine) .file-card .ext { background: #fff; color: var(--accent); }
.file-card .fn { font-weight: 600; font-size: 14px; }
.voice { display: flex; align-items: center; gap: 8px; min-width: 260px; }
.voice audio { height: 36px; flex: 1; }
.voice .spd { border: 0; border-radius: 10px; padding: 3px 7px; font-weight: 800; font-size: 12px; background: rgba(0,0,0,.1); color: inherit; }
.once { display: flex; gap: 10px; align-items: center; padding: 6px 4px; font-weight: 600; }
.once i { width: 28px; height: 28px; border-radius: 50%; border: 2px solid currentColor; display: grid; place-items: center; font-style: normal; font-weight: 800; font-size: 12px; }
.loc img { display: block; width: 280px; height: 150px; object-fit: cover; border-radius: 14px; }
.loc .ln { padding: 6px 6px 0; font-weight: 600; font-size: 14px; }

/* aksi saat bubble disorot */
.acts { display: none; gap: 2px; background: #fff; border-radius: 16px; padding: 2px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.mrow:hover .acts, .mrow.sel .acts { display: flex; }
.acts button { width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; color: var(--accent); display: grid; place-items: center; }
.acts button:hover { background: var(--accent-soft); }
.acts svg { width: 18px; height: 18px; }
.mine .acts { order: -1; }

.locked { background: #fff; padding: 18px 22px; color: var(--ink); display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.composer { background: #fff; padding: 10px 14px 12px; }
.composer .row { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea { flex: 1; resize: none; border: 0; outline: none; background: var(--bg); border-radius: 22px; padding: 12px 16px; max-height: 160px; line-height: 1.35; }
.composer .attach { cursor: pointer; color: var(--muted); }
.send { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 16px var(--accent-soft); flex-shrink: 0; }
.send:disabled { opacity: .4; }
.banner { display: flex; align-items: center; gap: 10px; background: var(--accent-soft); border-radius: 14px; padding: 6px 6px 6px 10px; margin-bottom: 8px; }
.banner .bar { width: 3px; align-self: stretch; background: var(--accent); border-radius: 2px; }
.banner .bt { flex: 1; min-width: 0; font-size: 13px; }
.banner .bt b { display: block; color: var(--accent); font-size: 12.5px; }
.banner .bt span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* ---------- Laci info ---------- */
.drawer { width: 340px; flex-shrink: 0; border-left: 1px solid var(--line); overflow-y: auto; background: #fff; padding: 18px; }
.drawer .center { text-align: center; }
.drawer h3 { margin: 12px 0 2px; font-size: 20px; }
.drawer .sec { font-size: 11.5px; letter-spacing: 1.1px; font-weight: 700; color: var(--muted); margin: 20px 0 8px; }
.drawer .card { background: var(--bg); border-radius: 14px; padding: 12px; }
.member { display: flex; gap: 10px; align-items: center; padding: 8px 4px; }
.member .nm { flex: 1; min-width: 0; }
.member .nm div:first-child { font-weight: 600; }
.member .nm div:last-child { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { font-size: 11px; font-weight: 800; color: var(--accent); background: var(--accent-soft); padding: 3px 8px; border-radius: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.grid3 img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; background: var(--bg); }

/* ---------- Modal, viewer, toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,15,40,.45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-card { background: #fff; border-radius: 22px; width: min(460px, 100%); max-height: 86vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-card h3 { margin: 0; padding: 18px 20px 6px; }
.modal-card .mb { padding: 6px 20px; overflow-y: auto; }
.modal-card .mf { padding: 12px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; }
.modal-card input[type=text], .modal-card textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; outline: none; margin: 4px 0 10px; }
.modal-card input[type=text]:focus, .modal-card textarea:focus { border-color: var(--accent); }
.pick { display: flex; gap: 10px; align-items: center; padding: 8px 4px; border-radius: 12px; cursor: pointer; }
.pick:hover { background: var(--bg); }
.pick input { width: 18px; height: 18px; accent-color: var(--accent); }
.emojis { display: flex; justify-content: space-around; padding: 6px 0 12px; }
.emojis button { font-size: 28px; border: 0; background: none; border-radius: 50%; width: 48px; height: 48px; }
.emojis button.on, .emojis button:hover { background: var(--accent-soft); }
.opt { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 12px; border-radius: 12px; }
.opt:hover { background: var(--bg); }
.opt.danger { color: var(--danger); }
.info-row { display: flex; gap: 10px; padding: 4px 0; font-size: 14px; }
.info-row span:first-child { width: 72px; color: var(--muted); }
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 60; display: flex; flex-direction: column; }
.viewer .vh { display: flex; justify-content: space-between; align-items: center; color: #fff; padding: 12px 16px; }
.viewer .vh button { color: #fff; }
.viewer .vb { flex: 1; display: grid; place-items: center; min-height: 0; padding: 10px; }
.viewer img, .viewer video { max-width: 100%; max-height: 100%; border-radius: 8px; }
.viewer .vc { color: #fff; text-align: center; padding: 10px 20px 20px; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 14px; z-index: 80; font-size: 14px; max-width: 90vw; }

/* ---------- Layar kecil ---------- */
@media (max-width: 860px) {
  .app { padding: 0; gap: 0; }
  .side, .main { border-radius: 0; }
  .side { width: 100%; }
  .main { display: none; }
  .app.open .side { display: none; }
  .app.open .main { display: flex; }
  .conv-head .back { display: grid; }
  .phone-note { display: none; }
  .drawer { position: absolute; inset: 0; width: auto; z-index: 20; }
  .login-card { flex-direction: column; padding: 26px; }
  .login-right { width: 100%; }
}
.member .tag { margin-left: auto; }
.gicon.lg { width: 84px; height: 84px; margin: 0 auto; }
.gicon.lg svg { width: 42px; height: 42px; }
.gicon.sm { width: 36px; height: 36px; }
.gicon.sm svg { width: 20px; height: 20px; }
.drawer .center .avatar { margin: 0 auto; }
#input::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer .sec { overflow: hidden; line-height: 26px; }