/* ================================================================
   PRIYO STORY — MESSAGES
   Desktop: a panel docked to the bottom-right.
   Phone:   full screen, so typing has room.
   ================================================================ */

.ch-panel{
  position:fixed;
  right:22px; bottom:0;
  width:360px;
  height:min(560px, calc(100vh - 90px));
  background:#fff;
  border-radius:14px 14px 0 0;
  box-shadow:0 -2px 40px rgba(0,0,0,.22);
  z-index:9200;
  display:none;
  flex-direction:column;
  overflow:hidden;
  font-family:'Hind Siliguri', sans-serif;
  color:var(--text, #1f2a24);
}
.ch-panel.open{ display:flex; }

/* ---------------- header ---------------- */
.ch-head{
  display:flex; align-items:center; gap:10px;
  padding:11px 12px;
  background:var(--green-dark, #0f5132);
  color:#fff;
  flex-shrink:0;
}
.ch-back, .ch-close{
  width:32px; height:32px;
  border:none; border-radius:50%;
  background:rgba(255,255,255,.16);
  color:#fff;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; flex-shrink:0;
}
.ch-back{ display:none; }
.ch-back svg, .ch-close svg{ width:17px; height:17px; }
.ch-head-pic{ position:relative; width:36px; height:36px; flex-shrink:0; }
.ch-head-pic img{ width:100%; height:100%; border-radius:50%; object-fit:cover; display:block; }
.ch-head-main{ flex:1; min-width:0; }
.ch-title{
  font-size:18px; font-weight:700;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.ch-sub{ font-size:14.5px; opacity:.85; }

/* green dot */
.ch-dot{
  position:absolute;
  right:-1px; bottom:-1px;
  width:12px; height:12px;
  border-radius:50%;
  background:#9aa8a1;
  border:2px solid #fff;
}
.ch-dot.on{ background:#22c55e; }
.ch-head-pic .ch-dot{ border-color:var(--green-dark, #0f5132); }

/* ---------------- conversation list ---------------- */
.ch-list{ flex:1; overflow-y:auto; display:block; }
.ch-panel.in-thread .ch-list{ display:none; }
.ch-panel.in-thread .ch-back{ display:flex; }

.ch-row{
  width:100%;
  display:flex; align-items:center; gap:11px;
  padding:11px 13px;
  border:none; background:transparent;
  border-bottom:1px solid var(--border, #e2e8e4);
  cursor:pointer;
  text-align:left;
  font-family:inherit;
}
.ch-row:hover{ background:var(--bg, #f0f2f0); }
.ch-row.unread{ background:var(--green-light, #e8f5ee); }
.ch-row-pic{ position:relative; width:46px; height:46px; flex-shrink:0; }
.ch-row-pic img{ width:100%; height:100%; border-radius:50%; object-fit:cover; display:block; }
.ch-row-main{ flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
.ch-row-name{
  font-size:17px; font-weight:700;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.ch-row-last{
  font-size:15.5px; color:var(--muted, #6b7a72);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.ch-row.unread .ch-row-last{ color:var(--text, #1f2a24); font-weight:600; }
.ch-row-side{ display:flex; flex-direction:column; align-items:flex-end; gap:4px; flex-shrink:0; }
.ch-row-time{ font-size:14px; color:var(--muted, #6b7a72); }
.ch-row-badge{
  min-width:20px; height:20px;
  border-radius:20px;
  background:var(--red, #e2231a);
  color:#fff;
  font-size:14px; font-weight:700;
  display:flex; align-items:center; justify-content:center;
  padding:0 6px;
}
.ch-sep{
  padding:9px 13px 5px;
  font-size:14.5px; font-weight:700;
  color:var(--muted, #6b7a72);
  text-transform:uppercase; letter-spacing:.3px;
  background:var(--bg, #f0f2f0);
}
.ch-empty{ padding:34px 20px; text-align:center; color:var(--muted, #6b7a72); font-size:16.5px; line-height:1.7; }

/* ---------------- thread ---------------- */
.ch-thread{ flex:1; min-height:0; display:none; flex-direction:column; }
.ch-panel.in-thread .ch-thread{ display:flex; }

.ch-msgs{
  flex:1;
  overflow-y:auto;
  padding:14px 12px;
  background:#f6f8f7;
  display:flex; flex-direction:column; gap:8px;
  scroll-behavior:smooth;
}
.ch-b{ display:flex; max-width:82%; }
.ch-b.me{ align-self:flex-end; justify-content:flex-end; }
.ch-b.them{ align-self:flex-start; }
.ch-bubble{
  background:#fff;
  border-radius:16px 16px 16px 5px;
  padding:8px 12px;
  box-shadow:0 1px 2px rgba(0,0,0,.07);
  min-width:0;
  max-width:100%;
}
.ch-b.me .ch-bubble{
  background:var(--green-dark, #0f5132);
  color:#fff;
  border-radius:16px 16px 5px 16px;
}
.ch-text{ font-size:17px; line-height:1.5; white-space:pre-wrap; word-break:break-word; }
.ch-time{ font-size:13.5px; opacity:.65; margin-top:3px; text-align:right; }

.ch-img{
  border-radius:11px;
  overflow:hidden;
  max-width:230px;
  cursor:pointer;
  background:#0e1512;
  min-height:60px;
}
.ch-img img{ width:100%; display:block; }

.ch-file{
  display:flex; align-items:center; gap:8px;
  text-decoration:none;
  color:inherit;
  font-size:16.5px; font-weight:600;
  padding:3px 0;
  max-width:230px;
}
.ch-file svg{ width:20px; height:20px; flex-shrink:0; }
.ch-file span{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.ch-voice{ display:flex; align-items:center; gap:9px; min-width:170px; padding:2px 0; }
.ch-vplay{
  width:32px; height:32px; border-radius:50%;
  border:none;
  background:var(--green-light, #e8f5ee);
  color:var(--green-dark, #0f5132);
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; flex-shrink:0;
}
.ch-b.me .ch-vplay{ background:rgba(255,255,255,.22); color:#fff; }
.ch-vplay svg{ width:14px; height:14px; }
.ch-vwave{ flex:1; height:24px; display:flex; align-items:center; gap:2px; min-width:60px; }
.ch-vwave i{
  flex:1; min-width:2px; border-radius:2px;
  background:var(--green, #1a7a4c);
  opacity:.32;
}
.ch-b.me .ch-vwave i{ background:#fff; }
.ch-vwave i.on{ opacity:1; }
.ch-vtime{ font-size:14px; font-weight:600; opacity:.75; flex-shrink:0; }

/* ---------------- composer ---------------- */
.ch-attach{
  display:none;
  align-items:center; gap:9px;
  padding:9px 12px;
  border-top:1px solid var(--border, #e2e8e4);
  background:var(--bg, #f0f2f0);
  font-size:16px;
}
.ch-attach.show{ display:flex; }
.ch-attach img{ width:52px; height:52px; border-radius:8px; object-fit:cover; }
.ch-attach svg{ width:20px; height:20px; color:var(--muted, #6b7a72); }
.ch-attach span{ flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.ch-emoji{
  display:none;
  grid-template-columns:repeat(auto-fill, minmax(36px, 1fr));
  gap:2px;
  max-height:150px;
  overflow-y:auto;
  padding:8px;
  border-top:1px solid var(--border, #e2e8e4);
  background:#fbfdfc;
}
.ch-emoji.open{ display:grid; }
.ch-emoji button{
  border:none; background:transparent;
  font-size:22px; padding:5px 0;
  border-radius:7px; cursor:pointer;
}
.ch-emoji button:hover{ background:var(--green-light, #e8f5ee); }

.ch-recbar{
  display:none;
  align-items:center; gap:9px;
  padding:9px 12px;
  background:#fdecea;
  border-top:1px solid #f7c9c5;
  font-size:15.5px; font-weight:700;
  color:var(--red, #e2231a);
}
.ch-recbar.show{ display:flex; }
.ch-rectext{ flex:1; }
.ch-recdot{
  width:9px; height:9px; border-radius:50%;
  background:var(--red, #e2231a);
  animation:chdot 1s ease-in-out infinite;
}
@keyframes chdot{ 50%{ opacity:.25; } }

.ch-compose{
  display:flex; align-items:flex-end; gap:4px;
  padding:8px 9px;
  padding-bottom:calc(8px + env(safe-area-inset-bottom, 0px));
  border-top:1px solid var(--border, #e2e8e4);
  background:#fff;
  flex-shrink:0;
}
.ch-icon{
  width:36px; height:36px;
  border:none; background:transparent;
  border-radius:50%;
  color:var(--muted, #6b7a72);
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; flex-shrink:0;
}
.ch-icon:hover{ background:var(--bg, #f0f2f0); color:var(--green-dark, #0f5132); }
.ch-icon svg{ width:19px; height:19px; }
.ch-icon.mic.rec{ background:var(--red, #e2231a); color:#fff; }
.ch-input{
  flex:1; min-width:0;
  border:1px solid var(--border, #e2e8e4);
  background:#f4f7f5;
  border-radius:20px;
  padding:9px 14px;
  font-family:inherit; font-size:17px;
  line-height:1.45;
  resize:none;
  outline:none;
  max-height:110px;
  color:var(--text, #1f2a24);
}
.ch-input:focus{ border-color:var(--green, #1a7a4c); background:#fff; }
.ch-send{
  width:38px; height:38px;
  border:none; border-radius:50%;
  background:var(--green-dark, #0f5132);
  color:#fff;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; flex-shrink:0;
}
.ch-send svg{ width:18px; height:18px; }

/* ================================================================
   ONLINE FRIENDS (right sidebar)
   ================================================================ */
.ch-friend{
  width:100%;
  display:flex; align-items:center; gap:10px;
  padding:8px 4px;
  border:none; background:transparent;
  cursor:pointer;
  font-family:inherit;
  text-align:left;
  border-radius:9px;
}
.ch-friend:hover{ background:var(--bg, #f0f2f0); }
.ch-friend-pic{ position:relative; width:38px; height:38px; flex-shrink:0; }
.ch-friend-pic img{ width:100%; height:100%; border-radius:50%; object-fit:cover; display:block; }
.ch-friend-name{
  flex:1; min-width:0;
  font-size:16.5px; font-weight:600;
  color:var(--text, #1f2a24);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}

/* ================================================================
   RESPONSIVE — full screen on phones
   ================================================================ */
@media (max-width:760px){
  .ch-panel{
    right:0; left:0; bottom:0; top:0;
    width:100%;
    height:100vh;
    height:100dvh;
    border-radius:0;
  }
  body.ch-open{ overflow:hidden; }
  .ch-head{ padding-top:calc(11px + env(safe-area-inset-top, 0px)); }
  .ch-msgs{ padding:12px 10px; }
  .ch-b{ max-width:88%; }
  .ch-img{ max-width:min(230px, 62vw); }
  .ch-emoji{ max-height:38vh; }
}
@media (max-width:380px){
  .ch-icon{ width:32px; height:32px; }
  .ch-icon svg{ width:17px; height:17px; }
  .ch-input{ font-size:16.5px; padding:8px 12px; }
  .ch-send{ width:34px; height:34px; }
  .ch-row{ padding:10px; gap:9px; }
  .ch-row-pic{ width:42px; height:42px; }
}
@media (prefers-reduced-motion:reduce){
  .ch-msgs{ scroll-behavior:auto; }
  .ch-recdot{ animation:none; }
}
