/* ============================================================
   Live Chat UI v16 — Secure Live Chat (gelap, terenkripsi, status kirim)
   Status pesan: jam (mengirim) · ✓ terkirim · ✓✓ diterima · ✓✓ biru dibaca
   Layout dikunci: tidak bisa digeser / ditarik / zoom, anti crash.
   Aksen: --ac (bisa diganti ?ac=RRGGBB).
   ============================================================ */
:root{color-scheme:dark;--ac:#2f7df6;--ac2:#1f63d1;--acsoft:rgba(47,125,246,.16);--bg:#0b0c0f;--surf:#14161b;--surf2:#1b1e24;--bub:#1f2229;--txt:#eceef2;--mut:#9aa1ad;--soft:#6c7380;--line:#252932;--line2:#323744;--inp:#0f1115;--grn:#2ecc71;--red:#ef4444;--tick:#7d8695;--read:#4fc3ff;--sh:rgba(0,0,0,.45)}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{height:100%;margin:0;padding:0;overflow:hidden;overscroll-behavior:none;touch-action:manipulation;-webkit-text-size-adjust:100%;-webkit-touch-callout:none}
body{position:fixed;inset:0;width:100%;font-family:Inter,'Segoe UI',system-ui,-apple-system,sans-serif;font-size:14px;color:var(--txt);background:var(--bg);-webkit-font-smoothing:antialiased;user-select:none;-webkit-user-select:none}
.m,.intro,textarea,input{user-select:text;-webkit-user-select:text}
img{-webkit-user-drag:none;user-drag:none}
.app{width:100%;max-width:520px;height:100%;height:var(--vh,100dvh);display:flex;flex-direction:column;background:var(--bg);overflow:hidden;position:relative;contain:layout paint;margin:0 auto}
body.embed .app{max-width:none}
[hidden]{display:none!important}
button{font:inherit}
*{scrollbar-width:thin;scrollbar-color:#3a3f4b transparent}
.pre,.list,.ibox,.emoji{overscroll-behavior:contain;touch-action:pan-y;-webkit-overflow-scrolling:touch}

/* ===== Header ===== */
.top{flex:none;position:relative;display:flex;align-items:center;gap:10px;min-height:62px;padding:max(10px,env(safe-area-inset-top)) 12px 10px;background:var(--surf);border-bottom:1px solid var(--line)}
.pill{display:flex;align-items:center;gap:11px;min-width:0;flex:1}
.ava{position:relative;width:40px;height:40px;border-radius:50%;background:var(--acsoft);color:var(--ac);display:grid;place-items:center;font-weight:700;font-size:.82rem;flex:none}
.ava img{width:100%;height:100%;border-radius:50%;object-fit:cover;display:block}
.dot{position:absolute;right:-1px;bottom:-1px;width:12px;height:12px;border-radius:50%;background:var(--soft);border:2px solid var(--surf)}
body.on .dot{background:var(--grn)}
.who{min-width:0;line-height:1.25}
.who b{display:block;font-size:.95rem;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.who small{display:flex;align-items:center;gap:6px;color:var(--mut);font-size:.74rem;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.who .on{flex:none;width:7px;height:7px;border-radius:50%;background:var(--soft)}
body.on .who .on{background:var(--grn)}
.sec{flex:none;display:flex;align-items:center;gap:5px;padding:5px 9px;border-radius:999px;background:rgba(46,204,113,.12);color:var(--grn);font-size:.68rem;font-weight:700;letter-spacing:.2px}
.sec svg{width:12px;height:12px}
.circ{flex:none;width:36px;height:36px;border-radius:50%;border:1px solid var(--line2);background:var(--surf2);color:var(--mut);cursor:pointer;font-size:1rem;display:grid;place-items:center;padding:0}
.circ:hover{color:var(--txt);background:var(--line)}
.circ.l{order:-1}

/* ===== Pita keamanan ===== */
.enc{flex:none;display:flex;align-items:center;justify-content:center;gap:6px;padding:7px 14px;background:#10131a;border-bottom:1px solid var(--line);color:var(--mut);font-size:.7rem;text-align:center}
.enc svg{width:12px;height:12px;flex:none;color:var(--grn)}
.net{flex:none;padding:5px;text-align:center;font-size:.72rem;font-weight:600;background:#3a2a0c;color:#ffcc66}
.net.bad{background:#3b1414;color:#ff9a9a}

/* ===== Kartu sambutan + form ===== */
.pre{flex:1;overflow-y:auto;overflow-x:hidden;padding:14px 14px 16px;display:flex;flex-direction:column;min-height:0}
.bub{background:var(--surf);border:1px solid var(--line);border-radius:16px;padding:18px 16px}
.bub.big{display:flex;flex-direction:column;min-height:0;max-height:100%;margin:auto 0;width:100%}
.ibox{overflow-y:auto;overflow-x:hidden;min-height:0;flex:0 1 auto;margin-bottom:14px;max-height:34dvh}
.intro{font-size:.88rem;line-height:1.6;text-align:left;margin:0;overflow-wrap:anywhere;color:var(--txt)}
.intro b,.intro strong{font-weight:700}
.intro a,.m a{color:var(--read);text-decoration:underline;word-break:break-all}
.ban{display:block;width:auto;max-width:100%;max-height:110px;object-fit:contain;border-radius:10px;margin:0 auto 12px}
label{display:block;font-size:.78rem;font-weight:600;color:var(--mut);margin-bottom:12px}
label i{color:var(--red);font-style:normal;margin-left:2px}
input,select,textarea{width:100%;margin-top:6px;font:inherit;font-size:16px;padding:12px 13px;border:1px solid var(--line2);border-radius:10px;background:var(--inp);color:var(--txt);outline:none;transition:border-color .15s,box-shadow .15s}
input::placeholder,textarea::placeholder{color:var(--soft)}
input:focus,select:focus,textarea:focus{border-color:var(--ac);box-shadow:0 0 0 3px var(--acsoft)}
input[readonly]{color:var(--mut)}
select{appearance:none;-webkit-appearance:none;background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%239aa1ad' stroke-width='1.8' stroke-linecap='round'/></svg>");background-repeat:no-repeat;background-position:right 13px center;padding-right:34px}
select option{color:#111;background:#fff}
.go{width:100%;border:0;border-radius:10px;padding:13px;font:inherit;font-weight:700;font-size:.92rem;color:#fff;background:var(--ac);cursor:pointer;transition:background .15s,transform .1s}
.go:hover{background:var(--ac2)}.go:active{transform:translateY(1px)}.go:disabled{opacity:.6}
.safe{display:block;text-align:center;color:var(--soft);font-size:.72rem;margin-top:12px}
.err{color:#ff8a8a;font-size:.8rem;min-height:1em;margin-bottom:10px}.err:empty{display:none}

/* ===== Pesan ===== */
.room{flex:1;display:flex;flex-direction:column;min-height:0;position:relative}
.list{flex:1;overflow-y:auto;overflow-x:hidden;padding:10px 12px;display:flex;flex-direction:column;gap:3px;background:radial-gradient(120% 60% at 50% 0,#12151c 0,var(--bg) 70%)}
.day{align-self:center;margin:10px 0 6px;padding:4px 12px;border-radius:999px;background:var(--surf2);color:var(--mut);font-size:.68rem;font-weight:600}
.sys{align-self:center;max-width:90%;margin:6px 0;padding:6px 12px;border-radius:10px;background:rgba(46,204,113,.09);color:#8fdcae;font-size:.7rem;text-align:center;line-height:1.45}
.m{position:relative;max-width:82%;padding:8px 11px 6px;border-radius:14px;font-size:.9rem;line-height:1.5;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;animation:in .16s ease-out both}
@keyframes in{from{opacity:0;transform:translateY(5px)}to{opacity:1;transform:none}}
.m.agent,.m.bot{align-self:flex-start;background:var(--bub);color:var(--txt);border-bottom-left-radius:4px}
.m.visitor{align-self:flex-end;background:var(--ac);color:#fff;border-bottom-right-radius:4px}
.m.visitor a{color:#fff}
.m .mt{display:flex;align-items:center;justify-content:flex-end;gap:4px;margin-top:2px;font-size:.62rem;line-height:1;opacity:.75;white-space:nowrap}
.m.agent .mt,.m.bot .mt{opacity:.55}
.m .mt time{display:inline}
.tk{display:inline-flex;align-items:center;width:17px;height:11px;color:rgba(255,255,255,.7)}
.tk svg{width:100%;height:100%;display:block;overflow:visible}
.tk .c2{opacity:0}
.m.st-deliv .tk .c2,.m.st-read .tk .c2{opacity:1}
.m.st-read .tk{color:#9be3ff}
.m.st-pending .tk{width:11px}
.m.st-pending{opacity:.78}
.m.st-failed{background:#5b1d1d}
.m.st-failed .mt{opacity:1;color:#ffb4b4}
.m.st-failed .mt::after{content:'Gagal terkirim — ketuk untuk kirim ulang';margin-left:2px}
.m img.ph{display:block;max-width:210px;max-height:240px;width:auto;height:auto;border-radius:10px}
.m.pic{padding:4px}
.m.pic .mt{position:absolute;right:9px;bottom:8px;margin:0;padding:3px 7px;border-radius:999px;background:rgba(0,0,0,.55);color:#fff;opacity:1}
.row{display:flex;gap:8px;align-items:flex-end;align-self:flex-start;max-width:94%;margin-top:4px}.row .m{max-width:none}
.mav{width:28px;height:28px;border-radius:50%;object-fit:cover;flex:none;background:var(--acsoft)}
.tp{align-self:flex-start;display:flex;gap:4px;padding:11px 14px;background:var(--bub);border-radius:14px;border-bottom-left-radius:4px;margin-top:4px}
.tp i{width:6px;height:6px;border-radius:50%;background:var(--mut);animation:bn 1.2s infinite ease-in-out}
.tp i:nth-child(2){animation-delay:.15s}.tp i:nth-child(3){animation-delay:.3s}
@keyframes bn{0%,60%,100%{transform:translateY(0);opacity:.4}30%{transform:translateY(-4px);opacity:1}}
.closed{flex:none;padding:14px;text-align:center;color:var(--mut);border-top:1px solid var(--line);background:var(--surf);font-size:.85rem}.closed .go{margin-top:10px;width:auto;padding:11px 22px}

/* ===== Kotak ketik ===== */
.box{flex:none;display:flex;gap:6px;align-items:flex-end;margin:8px 10px calc(4px + env(safe-area-inset-bottom));padding:6px;background:var(--surf);border:1px solid var(--line2);border-radius:26px}
.box:focus-within{border-color:var(--ac);box-shadow:0 0 0 3px var(--acsoft)}
.box textarea{margin:0;resize:none;max-height:110px;border:0;background:transparent;border-radius:18px;padding:10px 6px;box-shadow:none!important}
.emo,.att,.send{flex:none;width:38px;height:38px;border-radius:50%;border:0;display:grid;place-items:center;cursor:pointer;margin:0;padding:0}
.emo{background:transparent;color:var(--mut)}
.emo:hover,.emo.open{color:var(--ac);background:var(--acsoft)}
.att{background:transparent;color:var(--mut);font-size:1.6rem;line-height:1;font-weight:300}
.att:hover{color:var(--ac);background:var(--acsoft)}
.send{background:var(--ac);color:#fff}.send:hover{background:var(--ac2)}
.emoji{position:absolute;left:10px;right:10px;bottom:64px;max-height:216px;overflow-y:auto;background:var(--surf2);border:1px solid var(--line2);border-radius:14px;box-shadow:0 -8px 30px var(--sh);display:grid;grid-template-columns:repeat(8,1fr);gap:2px;padding:8px;z-index:20;animation:emup .15s ease-out}
@keyframes emup{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
.emoji button{background:none;border:0;border-radius:8px;font-size:20px;line-height:1.5;padding:4px 0;cursor:pointer}
.emoji button:hover{background:var(--line)}

/* ===== Dialog tutup obrolan ===== */
.modal{position:absolute;inset:0;background:rgba(0,0,0,.6);display:grid;place-items:center;padding:20px;z-index:50;animation:fd .15s ease-out}
.dlg{position:relative;width:100%;max-width:330px;background:var(--surf2);color:var(--txt);border:1px solid var(--line2);border-radius:16px;padding:26px 20px 20px;text-align:center;box-shadow:0 20px 50px var(--sh);animation:pop .2s ease-out}
.dlg .x{position:absolute;top:8px;right:10px;border:0;background:none;font-size:1.2rem;color:var(--soft);cursor:pointer}
.dlg .ic{width:54px;height:54px;margin:0 auto 14px;border-radius:50%;background:var(--line);color:var(--mut);display:grid;place-items:center;font-weight:700;font-size:1.3rem}
.dlg h3{margin:0 0 16px;font-size:1rem;font-weight:600;line-height:1.4}.dlg p{display:none}
.dlg .acts{display:flex;flex-direction:column-reverse;gap:8px}
.b2{border:1px solid var(--line2);background:var(--surf);color:var(--txt);border-radius:10px;padding:12px;font:inherit;font-weight:600;cursor:pointer}
.b2:hover{background:var(--line)}
.b2.red{background:#d93a22;border-color:#d93a22;color:#fff}.b2.red:hover{background:#bf2f19}
@keyframes fd{from{opacity:0}to{opacity:1}}@keyframes pop{from{opacity:0;transform:scale(.94)}to{opacity:1;transform:none}}
.pw{display:flex;align-items:center;justify-content:center;gap:5px;text-align:center;color:var(--soft);font-size:.66rem;padding:2px 0 max(8px,env(safe-area-inset-bottom))}
.pw svg{width:10px;height:10px}

/* ===== Standalone (komputer) & responsif ===== */
body:not(.embed){display:flex;justify-content:center;align-items:center;background:#05060a}
body:not(.embed) .app{height:min(100% - 48px,740px);max-width:430px;border-radius:18px;border:1px solid var(--line);box-shadow:0 24px 60px rgba(0,0,0,.6)}
@media(max-width:600px){body:not(.embed) .app{height:100%;max-width:none;border-radius:0;border:0;box-shadow:none}.m{max-width:88%}}
@media(prefers-reduced-motion:reduce){.m,.emoji,.dlg,.modal,.go,.tp i{animation:none!important;transition:none!important}}
