:root {
  --g: #0A140E; --g2: #16A34A; --g3: #15803D; --neon: #39E75F; --bg: #E6ECE7; --me: #DCFCE7; --other: #fff;
  --t: #111B21; --s: #667781; --line: #E9EDEF; --panel: #fff; --red: #D93025;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font-family: -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", Arial, sans-serif;
  color: var(--t); background: #DADBD3; font-size: 15px; overscroll-behavior: none; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; }

/* ---------- login ---------- */
#login { background: radial-gradient(ellipse at 50% 20%, #0f2a17 0%, #050A07 60%); color: #fff; display: flex; align-items: center; justify-content: center; padding: 24px; }
.logo-img { width: 120px; height: 120px; border-radius: 28px; display: block; margin: 0 auto 14px; box-shadow: 0 0 40px rgba(57,231,95,.25); }
.logo-img.big { width: 130px; height: 130px; opacity: .9; }
.brand-sub { margin: 2px 0 0; letter-spacing: 6px; font-size: 13px; font-weight: 600; color: #B9F5C8; }
#login .sub { color: #A7B7AC; }
#login #loginForm input { background: #121D16; color: #fff; }
#login #loginForm input::placeholder { color: #7D8F83; }
#login .link { color: var(--neon); }
#login .msg.ok { color: #8BF0A4; }
#login .msg { color: #FF8A80; }
.login-box { width: 100%; max-width: 360px; text-align: center; }
.logo { width: 76px; height: 76px; border-radius: 50%; background: var(--g2); margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center; font-size: 38px; }
.logo.big { width: 110px; height: 110px; font-size: 54px; background: #d9dbd5; }
h1 { color: #fff; font-size: 30px; margin: 0; letter-spacing: .5px; }
.sub { color: var(--s); margin: 6px 0 22px; }
#loginForm input, .dlg-box input { display: block; width: 100%; height: 50px; border: 0; border-radius: 10px; background: #F0F2F5;
  padding: 0 14px; font-size: 16px; margin-bottom: 12px; outline: none; }
#loginForm input:focus, .dlg-box input:focus { box-shadow: 0 0 0 2px var(--g2) inset; }
.btn-main { width: 100%; height: 50px; border: 0; border-radius: 25px; background: var(--g2); color: #fff; font-size: 16px; font-weight: 700; cursor: pointer; }
.btn-main.sm { width: auto; height: 40px; padding: 0 18px; border-radius: 20px; font-size: 15px; }
.btn-main:disabled { opacity: .6; }
.btn-text { background: none; border: 0; color: var(--g3); font-size: 15px; padding: 0 14px; height: 40px; cursor: pointer; }
.link { display: inline-block; margin-top: 18px; color: var(--g); text-decoration: none; padding: 8px; }
.msg { min-height: 20px; color: var(--red); font-size: 14px; margin: 10px 0 0; }
.msg.ok { color: #0B6B2E; }

/* ---------- layout ---------- */
#main { display: flex; background: var(--panel); }
#listPane { width: 380px; max-width: 100%; border-right: 1px solid var(--line); display: flex; flex-direction: column; position: relative; background: #fff; }
#chatPane { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.no-chat { margin: auto; text-align: center; color: var(--s); }
#chat { display: flex; flex-direction: column; height: 100%; }

.bar { height: calc(56px + var(--safe-top)); padding: var(--safe-top) 8px 0 14px; background: var(--g); color: #fff; border-bottom: 1px solid rgba(57,231,95,.25);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0; position: relative; }
.bar .title { font-size: 18px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .who { flex: 1; min-width: 0; }
.bar .who .title { font-size: 16px; }
.subtitle { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { background: none; border: 0; color: inherit; font-size: 22px; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; }
.back { display: none; }
.menu { position: absolute; right: 8px; top: calc(52px + var(--safe-top)); background: #fff; border-radius: 8px; box-shadow: 0 4px 18px rgba(0,0,0,.18); z-index: 10; min-width: 200px; overflow: hidden; }
.menu a { display: block; padding: 14px 16px; color: var(--t); text-decoration: none; }
.menu a:active, .menu a:hover { background: #F5F6F6; }
.tip { background: #FFF8E1; color: #5d4600; font-size: 13px; padding: 10px 14px; border-bottom: 1px solid var(--line); line-height: 1.45; }

/* ---------- chat list ---------- */
.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; padding-bottom: 90px; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: pointer; }
.list li:hover { background: #F5F6F6; }
.list li.on { background: #F0F2F5; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: #DCE7DF; color: #14532D; font-weight: 700; font-size: 20px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar.sm { width: 38px; height: 38px; font-size: 16px; }
.avatar.bot { background: #DCFCE7; }
.li-main { flex: 1; min-width: 0; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.li-top, .li-bot { display: flex; align-items: center; gap: 8px; }
.li-name { flex: 1; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-time { color: var(--s); font-size: 12px; }
.li-time.unread { color: var(--g3); font-weight: 600; }
.li-last { flex: 1; color: var(--s); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.badge { background: var(--g3); color: #fff; border-radius: 11px; min-width: 21px; height: 21px; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }
.empty { color: var(--s); text-align: center; padding: 30px; line-height: 1.6; }
.fab { position: absolute; right: 18px; bottom: calc(18px + var(--safe-bottom)); width: 58px; height: 58px; border-radius: 16px; border: 0;
  background: var(--g2); color: #fff; font-size: 30px; box-shadow: 0 3px 10px rgba(0,0,0,.25); cursor: pointer; }

/* ---------- messages ---------- */
.msgs { flex: 1; overflow-y: auto; padding: 10px 0 6px; -webkit-overflow-scrolling: touch;
  background-color: var(--bg); background-image: radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px); background-size: 18px 18px; }
.day { text-align: center; margin: 10px 0; }
.day span { background: #fff; color: var(--s); font-size: 12px; padding: 5px 12px; border-radius: 8px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.m { display: flex; padding: 2px 12px; }
.m.me { justify-content: flex-end; }
.b { max-width: min(78%, 520px); background: var(--other); border-radius: 0 10px 10px 10px; padding: 6px 9px 4px;
  box-shadow: 0 1px 1px rgba(0,0,0,.1); word-wrap: break-word; overflow-wrap: anywhere; }
.m.me .b { background: var(--me); border-radius: 10px 0 10px 10px; }
.b .txt { white-space: pre-wrap; line-height: 1.38; }
.b .meta { text-align: right; font-size: 11px; color: var(--s); margin-top: 2px; white-space: nowrap; }
.b .meta .tick.read { color: #53BDEB; }
.file { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.045); border-radius: 8px; padding: 9px 10px; margin: 2px 0 4px;
  text-decoration: none; color: var(--t); min-width: 210px; }
.file .fi { font-size: 26px; }
.file .fn { font-weight: 600; font-size: 14px; word-break: break-all; }
.file .fs { color: var(--s); font-size: 12px; }
.status { text-align: center; font-size: 13px; color: var(--s); padding: 4px; background: var(--bg); }

.composer { display: flex; align-items: flex-end; gap: 6px; padding: 6px 8px calc(6px + var(--safe-bottom)); background: var(--bg); flex-shrink: 0; }
.composer textarea { flex: 1; resize: none; border: 0; border-radius: 22px; padding: 12px 16px; font: inherit; font-size: 16px;
  max-height: 140px; outline: none; background: #fff; line-height: 1.3; }
.attach { background: #fff; color: var(--s); width: 46px; height: 46px; flex-shrink: 0; cursor: pointer; }
.send { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--g3); color: #fff; font-size: 19px; flex-shrink: 0; cursor: pointer; }

/* ---------- dialog ---------- */
.dlg { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
.dlg-box { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 360px; }
.dlg-box h3 { margin: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }

/* ---------- mobile: ek waqt mein ek screen ---------- */
@media (max-width: 760px) {
  #listPane { width: 100%; border: 0; }
  #chatPane { position: fixed; inset: 0; transform: translateX(100%); transition: transform .2s ease; z-index: 5; }
  #main.in-chat #chatPane { transform: none; }
  .back { display: inline-flex; margin-left: -6px; }
  .bar { padding-left: 8px; }
}

/* ---------- photo / call messages ---------- */
.photo { display: block; margin: 2px 0 4px; }
.photo img { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; background: #ddd; }
.b.calllog .txt { font-weight: 600; }
.b.calllog { cursor: pointer; }

/* ---------- call screen ---------- */
.call { position: fixed; inset: 0; z-index: 50; background: #0b141a; color: #fff; display: flex; flex-direction: column;
  justify-content: space-between; overflow: hidden; }
.call .remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #0b141a; }
.call .remote.off { display: none; }
.call .local { position: absolute; right: 14px; top: calc(14px + var(--safe-top)); width: 104px; height: 150px; object-fit: cover;
  border-radius: 12px; z-index: 3; background: #222; box-shadow: 0 2px 10px rgba(0,0,0,.5); transform: scaleX(-1); }
.call-top { position: relative; z-index: 2; text-align: center; padding: calc(60px + var(--safe-top)) 20px 0; }
.call.video-on .call-top { padding-top: calc(20px + var(--safe-top)); text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.call.video-on .call-top .avatar { display: none; }
.avatar.xl { width: 120px; height: 120px; font-size: 50px; margin: 0 auto 18px; background: #2a3942; color: #fff; }
.call-name { font-size: 26px; font-weight: 600; }
.call-state { font-size: 15px; opacity: .85; margin-top: 8px; font-variant-numeric: tabular-nums; }
.call-bottom { position: relative; z-index: 2; padding: 0 20px calc(40px + var(--safe-bottom)); }
.call-row { display: flex; justify-content: space-evenly; align-items: flex-start; }
.cbtn-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; opacity: .95; min-width: 70px; }
.cbtn { width: 62px; height: 62px; border-radius: 50%; border: 0; font-size: 26px; color: #fff; cursor: pointer; }
.cbtn.red { background: #E53935; } .cbtn.green { background: #1DA851; } .cbtn.dark { background: rgba(255,255,255,.16); }
.cbtn.dark.on { background: #fff; color: #111; }
.cbtn.pulse { animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(29,168,81,.7); } 70% { box-shadow: 0 0 0 18px rgba(29,168,81,0); } 100% { box-shadow: 0 0 0 0 rgba(29,168,81,0); } }
