:root {
  --wa-dark: #075E54; --wa-green: #128C7E; --wa-accent: #25D366; --wa-teal: #00A884;
  --wa-out: #D9FDD3; --wa-in: #fff; --wa-bg: #EFEAE2; --wa-side: #fff;
  --wa-header: #F0F2F5; --wa-text: #111b21; --wa-sec: #667781; --wa-border: #e9edef;
  --wa-hover: #f5f6f6; --wa-danger: #ea4335;
}
*{box-sizing:border-box;margin:0;padding:0}
body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;background:#d1d7db;color:var(--wa-text);line-height:1.4;min-height:100vh}
body.chat-app,html.chat-app{height:100%;height:100dvh;overflow:hidden}
body.chat-app .app-layout{height:100%;height:100dvh;overflow:hidden}
a{color:var(--wa-teal);text-decoration:none}
a:hover{text-decoration:underline}

/* Layout */
.chat-app{display:flex;flex:1 1 auto;min-height:0;height:auto;width:100%;max-width:1600px;margin:0 auto;background:#fff;box-shadow:0 0 20px rgba(0,0,0,.08);overflow:hidden}
.sidebar{width:380px;min-width:320px;flex-shrink:0;background:var(--wa-side);border-right:1px solid var(--wa-border);display:flex;flex-direction:column;height:100%;min-height:0;overflow:hidden}
.sidebar-header{background:var(--wa-header);padding:10px 16px;display:flex;align-items:center;justify-content:space-between;height:60px;border-bottom:1px solid var(--wa-border)}
.sidebar-header .user-info{display:flex;align-items:center;gap:12px;cursor:pointer}
.avatar{width:40px;height:40px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:#fff;font-weight:600;font-size:15px;flex-shrink:0;background:var(--wa-green);object-fit:cover}
.avatar img{width:100%;height:100%;border-radius:50%;object-fit:cover}
.avatar.sm{width:32px;height:32px;font-size:12px}
.avatar.lg{width:48px;height:48px;font-size:18px}
.user-info .name{font-weight:600;font-size:15px}
.user-info .role{font-size:12px;color:var(--wa-sec)}
.sidebar-actions{display:flex;align-items:center;gap:4px}
.sidebar-actions a,.sidebar-actions button{background:none;border:none;color:var(--wa-sec);cursor:pointer;padding:6px 8px;border-radius:6px;font-size:13px;display:flex;flex-direction:column;align-items:center;gap:2px;text-decoration:none}
.sidebar-actions a:hover,.sidebar-actions button:hover{background:var(--wa-hover);text-decoration:none}
.sidebar-actions .icon{font-size:18px}
.sidebar-actions .lbl{font-size:10px}
.search-box{padding:8px 12px;background:var(--wa-header);border-bottom:1px solid var(--wa-border)}
.search-wrap{position:relative}
.search-wrap::before{content:"🔍";position:absolute;left:12px;top:50%;transform:translateY(-50%);font-size:13px;opacity:.6}
.search-box input{width:100%;padding:9px 14px 9px 36px;border:none;border-radius:8px;background:#fff;font-size:14px;outline:none}
.chat-list{flex:1;overflow-y:auto}
.chat-item{display:flex;align-items:center;gap:12px;padding:12px 16px;cursor:pointer;border-bottom:1px solid var(--wa-border);transition:background .15s}
.chat-item:hover,.chat-item.active{background:var(--wa-hover)}
.chat-item .meta{flex:1;min-width:0}
.chat-item .title{font-weight:500;font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-item .preview{font-size:13px;color:var(--wa-sec);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px}
.avatar-wrap{position:relative;flex-shrink:0}
.status-dot{width:10px;height:10px;border-radius:50%;border:2px solid #fff;position:absolute;bottom:0;right:0}
.section-title{padding:10px 16px 6px;font-size:12px;font-weight:600;color:var(--wa-sec);text-transform:uppercase;letter-spacing:.5px;background:#f7f8fa}

/* Main chat */
.chat-main{flex:1 1 auto;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:hidden;background:var(--wa-bg);background-image:url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4cdc4' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");position:relative}
.chat-header{background:var(--wa-header);padding:10px 16px;display:flex;align-items:center;gap:12px;height:60px;border-bottom:1px solid var(--wa-border);z-index:2}
.chat-header .info .title{font-weight:600;font-size:16px}
.chat-header .info .subtitle{font-size:13px;color:var(--wa-sec)}
.messages-area,#messagesArea{flex:1 1 auto;min-height:0;overflow-x:hidden;overflow-y:auto;padding:20px 7% 24px;display:flex;flex-direction:column;gap:4px;-webkit-overflow-scrolling:touch}
.message{width:fit-content;min-width:0;max-width:min(65%,42rem);padding:8px 12px 6px;border-radius:8px;position:relative;font-size:14.2px;line-height:1.45;box-shadow:0 1px 1px rgba(0,0,0,.06);box-sizing:border-box;white-space:normal;overflow-wrap:anywhere;word-break:break-word;word-wrap:break-word}
.message.outgoing{align-self:flex-end;background:var(--wa-out);border-top-right-radius:0;margin-left:auto}
.message.incoming{align-self:flex-start;background:var(--wa-in);border-top-left-radius:0;margin-right:auto}
.message .sender-name{font-size:12.5px;font-weight:600;color:var(--wa-green);margin-bottom:2px}
.message .time{font-size:11px;color:var(--wa-sec);float:right;margin:4px 0 0 8px;display:inline-flex;align-items:center;gap:3px;white-space:nowrap;max-width:100%}
.message .ticks{font-size:14px;letter-spacing:-2px}
.message .ticks.read{color:#53bdeb}
/* msg-menu / msg-react-btn layout defined below (outside bubble) */
.message .reply-quote{background:rgba(0,0,0,.06);border-left:4px solid var(--wa-green);padding:6px 10px;border-radius:4px;margin-bottom:6px;font-size:13px;color:var(--wa-sec)}
.message .reply-quote .rn{font-weight:600;color:var(--wa-green);font-size:12px}
.message .fwd-label{font-size:11px;color:var(--wa-sec);font-style:italic;margin-bottom:4px}
.message .media-img{max-width:280px;max-height:320px;border-radius:6px;cursor:pointer;display:block;margin-bottom:4px}
.message .media-video{max-width:280px;border-radius:6px;display:block;margin-bottom:4px}
.message .media-audio{width:100%;max-width:280px;margin-bottom:4px}
.message .file-attach{display:flex;align-items:center;gap:8px;padding:8px;background:rgba(0,0,0,.04);border-radius:6px;margin-bottom:4px}

/* Input */
.chat-input-area{background:var(--wa-header);padding:10px 16px;display:flex;align-items:center;gap:10px;border-top:1px solid var(--wa-border);position:relative}
.chat-input-area input[type=text]{flex:1;padding:12px 16px;border:none;border-radius:8px;font-size:15px;outline:none;background:#fff}
.chat-input-area .btn-send{background:var(--wa-teal);color:#fff;border:none;width:46px;height:46px;border-radius:50%;cursor:pointer;font-size:18px;display:flex;align-items:center;justify-content:center}
.chat-input-area .btn-send:hover{background:var(--wa-green)}
.chat-input-area .btn-attach{background:none;border:none;font-size:22px;cursor:pointer;color:var(--wa-sec);padding:6px}
.attach-preview{position:absolute;bottom:100%;left:0;right:0;background:#fff;border-top:1px solid var(--wa-border);padding:12px 16px;display:none;align-items:center;gap:12px;box-shadow:0 -4px 12px rgba(0,0,0,.08)}
.attach-preview.show{display:flex}
.attach-preview img,.attach-preview video{max-height:120px;max-width:200px;border-radius:8px}
.attach-preview .ap-info{flex:1;font-size:13px}
.attach-preview .ap-actions{display:flex;gap:8px}
.empty-state{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;color:var(--wa-sec);text-align:center;padding:40px}
.empty-state .icon{font-size:64px;margin-bottom:16px;opacity:.5}
.empty-state h2{font-size:24px;font-weight:300;color:#41525d;margin-bottom:8px}

/* Context menu */
.ctx-menu{position:fixed;background:#fff;border-radius:8px;box-shadow:0 4px 20px rgba(0,0,0,.18);z-index:9999;min-width:160px;padding:6px 0;display:none}
.ctx-menu.show{display:block}
.ctx-menu button{display:block;width:100%;text-align:left;padding:10px 16px;border:none;background:none;cursor:pointer;font-size:14px}
.ctx-menu button:hover{background:var(--wa-hover)}

/* Reply bar */
.reply-bar{background:#fff;border-left:4px solid var(--wa-green);padding:8px 12px;margin:0 16px;border-radius:0 6px 6px 0;display:none;align-items:center;gap:10px;font-size:13px}
.reply-bar.show{display:flex}
.reply-bar .rb-close{background:none;border:none;cursor:pointer;font-size:16px;color:var(--wa-sec)}

/* Admin */
.admin-body{background:#f0f2f5;height:auto;overflow:auto;min-height:100vh}
.admin-nav{background:var(--wa-dark);color:#fff;padding:0 24px;height:56px;display:flex;align-items:center;justify-content:space-between;position:sticky;top:0;z-index:100}
.admin-nav .brand{font-weight:600;font-size:18px;display:flex;align-items:center;gap:10px}
.admin-nav .nav-links{display:flex;align-items:center;gap:4px}
.admin-nav .nav-links a,.admin-nav .nav-links .nav-drop{color:rgba(255,255,255,.9);font-size:14px;text-decoration:none;padding:6px 12px;border-radius:4px;cursor:pointer;position:relative}
.admin-nav .nav-links a:hover,.admin-nav .nav-links a.active,.admin-nav .nav-drop:hover{background:rgba(255,255,255,.15);text-decoration:none}
.nav-drop .drop-menu{display:none;position:absolute;top:100%;left:0;background:#fff;color:var(--wa-text);border-radius:8px;box-shadow:0 8px 24px rgba(0,0,0,.15);min-width:180px;padding:6px 0;z-index:200}
.nav-drop:hover .drop-menu,.nav-drop.open .drop-menu{display:block}
.nav-drop .drop-menu a{display:block;color:var(--wa-text);padding:10px 16px;font-size:13px}
.nav-drop .drop-menu a:hover{background:var(--wa-hover)}
.admin-container{max-width:1100px;margin:24px auto;padding:0 20px}
.admin-card{background:#fff;border-radius:10px;box-shadow:0 1px 3px rgba(0,0,0,.08);padding:24px;margin-bottom:24px}
.admin-card h2{font-size:18px;margin-bottom:18px;color:var(--wa-dark);display:flex;align-items:center;justify-content:space-between}
.stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:16px;margin-bottom:24px}
.stat-card{background:#fff;border-radius:10px;padding:20px;box-shadow:0 1px 3px rgba(0,0,0,.08);text-align:center}
.stat-card .number{font-size:28px;font-weight:700;color:var(--wa-dark)}
.stat-card .label{font-size:13px;color:var(--wa-sec);margin-top:4px}
table.data-table{width:100%;border-collapse:collapse;font-size:14px}
table.data-table th,table.data-table td{padding:11px 12px;text-align:left;border-bottom:1px solid var(--wa-border)}
table.data-table th{background:#f7f8fa;font-weight:600;color:var(--wa-sec);font-size:12px;text-transform:uppercase}
table.data-table tr:hover{background:#f9fafb}
.btn{display:inline-block;padding:8px 16px;border-radius:6px;font-size:13px;font-weight:600;cursor:pointer;border:none;text-decoration:none;transition:background .2s}
.btn-primary{background:var(--wa-accent);color:#fff}.btn-primary:hover{background:#1da851;color:#fff;text-decoration:none}
.btn-secondary{background:#e9edef;color:var(--wa-text)}.btn-secondary:hover{background:#d1d7db;text-decoration:none}
.btn-danger{background:#fee;color:var(--wa-danger)}.btn-danger:hover{background:#fdd}
.btn-sm{padding:5px 10px;font-size:12px}
.form-row{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:16px}
.form-group{margin-bottom:16px}
.form-group label{display:block;font-size:13px;font-weight:600;margin-bottom:6px;color:#333}
.form-group input,.form-group select,.form-group textarea{width:100%;padding:10px 12px;border:1px solid #ddd;border-radius:6px;font-size:14px}
.form-group input:focus,.form-group select:focus,.form-group textarea:focus{outline:none;border-color:var(--wa-accent);box-shadow:0 0 0 3px rgba(37,211,102,.15)}
.alert{padding:12px 16px;border-radius:8px;margin-bottom:16px;font-size:14px}
.alert-success{background:#e8f5e9;color:#2e7d32;border:1px solid #a5d6a7}
.alert-error{background:#ffebee;color:#c62828;border:1px solid #ef9a9a}
.badge{display:inline-block;padding:3px 8px;border-radius:10px;font-size:11px;font-weight:600}
.badge-super_admin{background:#fce4ec;color:#c2185b}
.badge-admin{background:#e3f2fd;color:#1565c0}
.badge-user{background:#e8f5e9;color:#2e7d32}
.badge-active{background:#e8f5e9;color:#2e7d32}
.badge-inactive{background:#fce4ec;color:#c62828}

/* Profile page */
.profile-page{background:#f0f2f5;min-height:100vh;overflow:auto}
.profile-card{max-width:520px;margin:30px auto;background:#fff;border-radius:12px;box-shadow:0 2px 12px rgba(0,0,0,.08);overflow:hidden}
.profile-header{background:var(--wa-dark);color:#fff;padding:30px;text-align:center}
.profile-header .av{width:96px;height:96px;border-radius:50%;margin:0 auto 12px;border:3px solid #25D366;object-fit:cover;display:flex;align-items:center;justify-content:center;font-size:36px;background:var(--wa-green)}
.profile-body{padding:24px}
.pass-wrap{position:relative}
.pass-wrap .eye-btn{position:absolute;right:10px;top:50%;transform:translateY(-50%);background:none;border:none;cursor:pointer;font-size:16px}

@media(max-width:768px){
  .chat-app{flex-direction:column}
  .sidebar{width:100%;height:40vh;min-width:0}
  .chat-main{height:60vh}
  .messages-area{padding:12px 16px}
  .message{max-width:85%}
  .form-row{grid-template-columns:1fr}
  .admin-nav .nav-links{flex-wrap:wrap}
}

.unread-badge, .badge-num {
  display: inline-block;
  background: #25D366;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}
.req-actions { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.req-item { background: #f0fff4; }
.stat-card { cursor: pointer; transition: transform .15s, box-shadow .15s; text-decoration: none; color: inherit; display: block; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.12); text-decoration: none; color: inherit; }

.chat-item.has-unread { background: #e8f5e9; }
.chat-item.has-unread .title { font-weight: 700; }
.chat-item.flash { animation: flashBg 1.2s ease; }
@keyframes flashBg {
  0%, 100% { background: transparent; }
  30% { background: #c8e6c9; }
  60% { background: #e8f5e9; }
}
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.45); display:flex; align-items:center; justify-content:center; z-index:1000; padding:20px; }
.modal { background:#fff; border-radius:12px; width:100%; max-width:480px; max-height:90vh; overflow-y:auto; box-shadow:0 20px 60px rgba(0,0,0,.3); }
.modal-header { padding:16px 18px; border-bottom:1px solid #e9edef; display:flex; align-items:center; justify-content:space-between; }
.modal-body { padding:18px; }
.gm-avatar { width:80px; height:80px; border-radius:50%; background:#128C7E; color:#fff; display:flex; align-items:center; justify-content:center; font-size:32px; margin:0 auto 12px; object-fit:cover; }
.gm-member { display:flex; align-items:center; gap:10px; padding:8px 0; border-bottom:1px solid #f0f0f0; }

/* Reactions */
.reactions-row{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}
.reaction-chip{background:rgba(0,0,0,.06);border-radius:12px;padding:2px 8px;font-size:13px;cursor:pointer;border:1px solid rgba(0,0,0,.08)}
.reaction-chip:hover{background:rgba(37,211,102,.2)}
.react-picker{position:fixed;z-index:10000;background:#fff;border-radius:24px;box-shadow:0 4px 20px rgba(0,0,0,.22);padding:6px 10px;display:flex;gap:4px;align-items:center}
.react-picker button{background:none;border:none;font-size:22px;cursor:pointer;padding:4px 6px;border-radius:50%}
.react-picker button:hover{background:#f0f0f0}

/* Mobile / responsive */
@media(max-width:768px){
  .app-layout{flex-direction:column;height:100vh;height:100dvh}
  .sidebar{width:100%;height:auto;max-height:42vh;min-width:0;border-right:none;border-bottom:1px solid var(--wa-border)}
  .chat-main{flex:1;min-height:0;height:58vh}
  .top-bar{flex-wrap:wrap;height:auto;padding:8px}
  .top-search{max-width:100%;order:3;width:100%;margin-top:6px}
  .chat-input-area{padding:8px}
  .chat-input-area input[type=text]{font-size:16px} /* prevent iOS zoom */
  .message{max-width:88%}
  .msg-menu,.msg-react-btn{opacity:.7}
  .admin-nav{flex-wrap:wrap;height:auto}
  .member-grid{grid-template-columns:1fr 1fr}
}
@media(max-width:480px){
  .sidebar{max-height:38vh}
  .stat-card .number{font-size:22px}
  .member-grid{grid-template-columns:1fr}
}

/* When chat open on mobile, hide sidebar optionally via class */
body.chat-open-mobile .sidebar{display:none}
body.chat-open-mobile .chat-main{height:100vh;height:100dvh}
.mobile-back{display:none;background:none;border:none;font-size:20px;cursor:pointer;margin-right:8px}
@media(max-width:768px){
  .mobile-back{display:inline-block}
}

/* Composer wrap - WhatsApp style attach above input */
.composer-wrap{position:relative;flex-shrink:0;background:var(--wa-header)}
.attach-preview{display:none;flex-direction:row;align-items:flex-end;gap:12px;padding:12px 16px;background:#f0f2f5;border-top:1px solid var(--wa-border);max-height:220px}
.attach-preview.show{display:flex}
.attach-preview .ap-media{flex-shrink:0}
.attach-preview .ap-media img,
.attach-preview .ap-media video{max-height:160px;max-width:min(280px,70vw);border-radius:8px;display:block;object-fit:contain;background:#000}
.attach-preview .ap-media audio{width:min(280px,70vw)}
.attach-preview .ap-side{flex:1;display:flex;flex-direction:column;gap:8px;min-width:0}
.attach-preview .ap-info{font-size:13px;color:var(--wa-sec);word-break:break-all}

/* Message actions outside bubble */
.message{position:relative}
.message .msg-menu,
.message .msg-react-btn{
  position:absolute;top:50%;transform:translateY(-50%);
  opacity:0;background:#fff;border:1px solid #e0e0e0;border-radius:50%;
  width:28px;height:28px;cursor:pointer;line-height:1;
  box-shadow:0 1px 4px rgba(0,0,0,.12);z-index:5;padding:0;
  display:flex!important;align-items:center;justify-content:center;
  visibility:visible;
}
.message .msg-menu{font-size:18px;font-weight:700;letter-spacing:1px;line-height:1}
.message .msg-react-btn{font-size:15px}
/* Menu arrow + emoji side by side outside bubble */
.message.outgoing .msg-menu{left:-34px}
.message.outgoing .msg-react-btn{left:-64px}
.message.incoming .msg-menu{right:-34px}
.message.incoming .msg-react-btn{right:-64px}
.message:hover .msg-menu,
.message:hover .msg-react-btn,
.message .msg-menu:focus,
.message .msg-react-btn:focus{opacity:1}
.reactions-row{display:flex;flex-wrap:wrap;gap:4px;margin-top:6px}
.media-img{max-width:min(280px,70vw);max-height:320px;border-radius:8px;cursor:pointer;display:block;object-fit:contain}
.media-video{max-width:min(280px,70vw);max-height:280px;border-radius:8px;display:block}
.media-audio{width:min(260px,70vw);margin-top:4px;display:block}

.img-lightbox{display:none;position:fixed;inset:0;background:rgba(0,0,0,.9);z-index:20000;align-items:center;justify-content:center;padding:20px}
.img-lightbox.show{display:flex}
.img-lightbox img{max-width:100vw;max-height:calc(100vh - 88px);object-fit:contain;border-radius:4px}

.ctx-menu{z-index:30000}
.mention-link{color:#027eb5;font-weight:600;cursor:pointer;text-decoration:none}
.mention-link:hover{text-decoration:underline}
.sys-message{text-align:center;margin:10px auto;max-width:90%}
.sys-message .sys-bubble{display:inline-block;background:#e1f2fb;color:#54656f;font-size:12.5px;padding:6px 12px;border-radius:8px}

@media(max-width:768px){
  .message .msg-menu,.message .msg-react-btn{opacity:1!important}
  .attach-preview{flex-direction:column;align-items:stretch;max-height:40vh}
  .attach-preview .ap-media img,.attach-preview .ap-media video{max-width:100%;max-height:140px}
}


/* WhatsApp-style attach sheet */
.chat-input-area{position:relative}
.attach-sheet{
  display:none;position:absolute;bottom:56px;left:8px;
  background:#fff;border-radius:16px;padding:12px 8px;
  box-shadow:0 4px 24px rgba(0,0,0,.18);z-index:40;
  grid-template-columns:repeat(3,1fr);gap:4px;min-width:240px
}
.attach-sheet.show{display:grid}
.attach-opt{
  display:flex;flex-direction:column;align-items:center;gap:6px;
  background:none;border:none;cursor:pointer;padding:10px 8px;border-radius:12px;
  font-size:12px;color:#54656f
}
.attach-opt:hover{background:#f0f2f5}
.ao-icon{
  width:48px;height:48px;border-radius:50%;display:flex;align-items:center;justify-content:center;
  font-size:22px;color:#fff
}
@media(max-width:480px){
  .attach-sheet{left:4px;right:4px;min-width:0;grid-template-columns:repeat(3,1fr)}
}

/* Forward multi-select rows */
.fwd-row{display:flex;align-items:center;gap:10px;padding:8px 4px;cursor:pointer;border-radius:8px}
.fwd-row:hover{background:#f5f6f6}
.fwd-row input{width:18px;height:18px;accent-color:#25D366}
.media-actions{display:flex;gap:10px;margin-top:6px;font-size:12px}
.media-actions a,.media-actions button{
  background:rgba(0,0,0,.06);border:none;border-radius:6px;padding:4px 8px;
  cursor:pointer;color:#027eb5;font-size:12px;text-decoration:none
}
.media-actions a:hover,.media-actions button:hover{background:rgba(0,0,0,.1)}

/* Lightbox toolbar */
.img-lightbox{display:none;position:fixed;inset:0;background:rgba(0,0,0,.92);z-index:20000;flex-direction:column}
.img-lightbox.show{display:flex}
.lb-toolbar{display:flex;justify-content:flex-end;gap:8px;padding:12px 16px;background:rgba(0,0,0,.4)}
.lb-toolbar button{background:rgba(255,255,255,.15);color:#fff;border:none;border-radius:8px;padding:8px 14px;cursor:pointer;font-size:14px}
.lb-toolbar button:hover{background:rgba(255,255,255,.28)}
.lb-body{flex:1;display:flex;align-items:center;justify-content:center;padding:12px;min-height:0}
.lb-body img{max-width:100vw;max-height:calc(100vh - 88px);object-fit:contain;border-radius:4px}

/* Attach sheet polish */
.attach-sheet{
  display:none;position:absolute;bottom:58px;left:8px;z-index:40;
  background:#fff;border-radius:16px;box-shadow:0 8px 28px rgba(0,0,0,.18);
  padding:14px;grid-template-columns:repeat(3,1fr);gap:10px;min-width:280px
}
.attach-sheet.show{display:grid}
.attach-opt{
  display:flex;flex-direction:column;align-items:center;gap:6px;
  background:none;border:none;cursor:pointer;font-size:12px;color:#3b4a54;padding:8px
}
.attach-opt:hover{background:#f0f2f5;border-radius:12px}
.ao-icon{
  width:52px;height:52px;border-radius:50%;display:flex;align-items:center;justify-content:center;
  font-size:22px;color:#fff
}
.chat-input-area{position:relative}

/* Custom voice / audio player */
.voice-player{
  display:flex;align-items:center;gap:10px;
  background:rgba(0,0,0,.04);border-radius:24px;padding:8px 12px;
  min-width:200px;max-width:280px;margin:4px 0
}
.voice-player audio{display:none}
.vp-play{
  width:36px;height:36px;border-radius:50%;border:none;
  background:#25D366;color:#fff;font-size:14px;cursor:pointer;
  flex-shrink:0;display:flex;align-items:center;justify-content:center
}
.vp-play:hover{background:#1da851}
.vp-wave{flex:1;height:6px;background:rgba(0,0,0,.12);border-radius:3px;overflow:hidden}
.vp-bar{height:100%;width:0;background:#128C7E;border-radius:3px;transition:width .1s linear}
.vp-time{font-size:11px;color:#667781;min-width:36px;text-align:right}
.edited-tag{font-size:11px;font-style:italic;color:#667781;margin-right:6px;font-weight:500}
.btn-voice{
  background:none;border:none;font-size:22px;cursor:pointer;padding:6px;color:var(--wa-sec)
}
.btn-voice.recording{color:#e53935;animation:pulseRec 1s infinite}
@keyframes pulseRec{50%{opacity:.5}}
.message.outgoing .voice-player{background:rgba(0,0,0,.06)}

/* Mobile-first chat layout improvements */
.video-thumb{position:relative;cursor:pointer;display:inline-block}
.video-thumb .media-video{max-width:min(260px,70vw);max-height:180px;border-radius:8px;display:block;background:#000}
.video-play-overlay{
  position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  background:rgba(0,0,0,.35);color:#fff;font-size:36px;border-radius:8px;pointer-events:none
}

@media(max-width:768px){
  body.chat-app,html:has(body.chat-app){height:100%;overflow:hidden}
  body.chat-app .app-layout{height:100dvh;height:100vh;flex-direction:column}
  .top-bar{flex-wrap:wrap;min-height:48px;height:auto;padding:6px 8px;gap:6px}
  .top-search{order:3;width:100%;max-width:none;margin:0}
  .sidebar{
    width:100%;max-height:none;flex:1;min-height:0;
    border-right:none;border-bottom:none
  }
  body.chat-open-mobile .sidebar{display:none !important}
  body.chat-open-mobile .chat-main{
    display:flex !important;flex-direction:column;
    height:100dvh;height:100vh;width:100%
  }
  .chat-main{display:none;flex:1;min-height:0}
  body:not(.chat-open-mobile) .chat-main{display:none}
  .chat-list{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch}
  .messages-area{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch}
  .composer-wrap{flex-shrink:0}
  .sidebar-actions{flex-wrap:wrap;gap:2px}
  .sidebar-actions .lbl{font-size:9px}
  .chat-header{padding:8px 10px}
  .mobile-back{display:inline-flex !important;align-items:center;justify-content:center;width:36px;height:36px}
  .message{max-width:85%}
  .attach-sheet{bottom:64px;left:4px;right:4px;min-width:0;grid-template-columns:repeat(3,1fr)}
}
@media(min-width:769px){
  body.chat-open-mobile .sidebar{display:flex !important}
  body:not(.chat-open-mobile) .chat-main{display:flex}
  .chat-main{display:flex}
}
.chat-header{display:flex;align-items:center;gap:10px}
.chat-header .info{flex:1;min-width:0}
.chat-header-actions{display:flex;align-items:center;gap:4px;margin-left:auto;flex-shrink:0}
.hdr-btn{
  background:none;border:none;font-size:20px;cursor:pointer;padding:6px 8px;
  border-radius:50%;line-height:1
}
.hdr-btn:hover{background:rgba(0,0,0,.06)}
.hdr-note{font-size:12px;color:#667781;padding:0 8px}




.hdr-video{color:#54656f;display:inline-flex;align-items:center}
.hdr-video svg{display:block}

/* Sidebar user header fix */
.sidebar-header,.user-info-bar,.user-info{
  display:flex;align-items:center;gap:10px;padding:10px 12px;
  min-height:56px;box-sizing:border-box
}
.user-info{cursor:pointer;flex:1;min-width:0}
.user-info .u-meta{flex:1;min-width:0;overflow:hidden}
.user-info .u-name{font-weight:600;font-size:15px;color:#111;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.25}
.user-info .u-role{font-size:12px;color:#667781;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sidebar-actions{display:flex;align-items:center;gap:2px;flex-shrink:0}
.sidebar-actions a,.sidebar-actions button{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  background:none;border:none;cursor:pointer;padding:4px 6px;min-width:40px;
  color:#54656f;text-decoration:none;font-size:11px
}
.sidebar-actions .icon{font-size:18px;line-height:1}
.sidebar-actions .lbl{font-size:9px;margin-top:2px}







/* Deleted message stays in chat flow as bubble */
.message.deleted-msg{opacity:.85}
.message.deleted-msg .deleted-text{font-style:italic;color:#667781;font-size:13.5px}

.chat-header-actions .hdr-btn{
  width:40px;height:40px;padding:0;display:inline-flex;align-items:center;justify-content:center;
  font-size:20px;color:#54656f;border-radius:50%
}
.chat-header-actions .hdr-btn svg{width:22px;height:22px;display:block}
.chat-header-actions .hdr-video{color:#54656f}


/* Composer */
.composer-main{flex:1;display:flex;flex-direction:column;min-width:0;background:#fff;border-radius:24px;padding:4px 12px;border:1px solid #e9edef}
.fmt-bar{display:flex;gap:2px;padding:2px 0 0}
.fmt-btn{background:none;border:none;cursor:pointer;font-size:13px;font-weight:700;color:#54656f;padding:2px 8px;border-radius:6px;line-height:1.2}
.fmt-btn:hover{background:#f0f2f5;color:#075E54}
.fmt-btn i{font-style:italic;font-weight:600}
.message-input,.chat-input-area textarea#messageInput{
  width:100%;border:none;outline:none;resize:none;font-size:15px;line-height:1.45;
  max-height:120px !important;
  min-height:28px !important;
  height:28px;
  padding:6px 0;background:transparent;font-family:inherit;
  overflow-y:hidden;
  box-sizing:border-box;
}
a.msg-url{color:#027eb5 !important;text-decoration:underline;word-break:break-all}

.chat-input-area{align-items:flex-end}
/* Reaction chips under bubble; emoji open via .msg-react-btn click */
.reactions-row{
  display:flex;flex-wrap:wrap;gap:4px;margin-top:4px;padding:0 2px;
}
.reaction-chip{
  background:rgba(0,0,0,.06);border:1px solid rgba(0,0,0,.08);
  border-radius:12px;padding:2px 7px;font-size:13px;cursor:pointer;
  line-height:1.3;user-select:none;
}
.message.outgoing .reaction-chip{background:rgba(255,255,255,.35)}
.reaction-chip:hover{filter:brightness(0.95)}
.react-picker{
  position:fixed;z-index:9999;background:#fff;border-radius:28px;
  box-shadow:0 4px 20px rgba(0,0,0,.18);padding:6px 8px;display:flex;gap:4px;
}
.react-picker button{
  background:none;border:none;font-size:22px;cursor:pointer;padding:4px 6px;
  border-radius:50%;line-height:1;transition:transform .12s;
}
.react-picker button:hover{transform:scale(1.25);background:#f0f2f5}
/* smoother message bubbles */
.message .bubble{transition:box-shadow .15s ease}
.message:hover .bubble{box-shadow:0 1px 3px rgba(0,0,0,.08)}
/* hover reaction bar removed — use .msg-react-btn click → .react-picker */

.msg-code{background:rgba(0,0,0,.06);padding:1px 5px;border-radius:4px;font-family:ui-monospace,monospace;font-size:13px}
.msg-code-block{display:block;background:rgba(0,0,0,.06);padding:8px;border-radius:8px;font-family:ui-monospace,monospace;font-size:12px;white-space:pre-wrap;margin:4px 0}

.chat-item.pinned-notes{background:rgba(18,140,126,.08);border-left:3px solid #128C7E}
.chat-item.pinned-notes .title{color:#075E54;font-weight:600}

.create-group-bar{
  display:flex;gap:8px;padding:10px 12px;border-bottom:1px solid var(--wa-border);
  background:#f0f2f5;flex-wrap:wrap;
}
.btn-create-group{
  flex:1;min-width:120px;padding:10px 12px;border-radius:10px;cursor:pointer;
  font-size:13px;font-weight:600;border:none;
  background:#25D366;color:#fff;
  box-shadow:0 1px 3px rgba(0,0,0,.12);
}
.btn-create-group.secondary{
  background:#fff;color:#075E54;border:1px solid #25D366;box-shadow:none;
}
.btn-create-group:hover{filter:brightness(1.05)}
.btn-create-group.secondary:hover{background:#e7f8ee}

.chat-list{display:flex;flex-direction:column;overflow:hidden!important;min-height:0}
.chat-section-scroll{
  min-height:0;
}
.chat-section-scroll.groups-scroll{
  max-height:min(28vh, 220px);
  overflow-y:auto;
  overflow-x:hidden;
  flex-shrink:0;
  border-bottom:1px solid var(--wa-border);
  -webkit-overflow-scrolling:touch;
}
.chat-section-scroll.contacts-scroll{
  flex:1 1 auto;
  overflow-y:auto;
  overflow-x:hidden;
  min-height:120px;
  -webkit-overflow-scrolling:touch;
}
.sec-count{font-weight:500;color:#8696a0;font-size:12px}
.sticky-sec{position:sticky;top:0;z-index:2;background:#fff}
.chat-section-scroll.groups-scroll::-webkit-scrollbar{width:6px}
.chat-section-scroll.groups-scroll::-webkit-scrollbar-thumb{background:#ccc;border-radius:3px}
.pin-btn{
  background:none;border:none;cursor:pointer;font-size:14px;padding:4px 8px;
  opacity:.45;flex-shrink:0;align-self:center;
}
.pin-btn:hover,.chat-item.pinned-item .pin-btn{opacity:1}
.chat-item{display:flex;align-items:center}
.chat-item .meta{flex:1;min-width:0}
.chat-item.pinned-item{background:rgba(18,140,126,.06)}

.notify-box{margin-top:18px;padding:16px;background:#f0f2f5;border-radius:12px}
.notify-title{font-weight:600;display:block;margin-bottom:4px;color:#075E54}
.notify-hint{font-size:12px;color:#667781;margin:0 0 12px}
.notify-row{display:flex;flex-wrap:wrap;gap:8px}
.notify-chip{
  display:inline-flex;align-items:center;gap:6px;padding:8px 12px;
  background:#fff;border:1px solid #d1d7db;border-radius:20px;cursor:pointer;
  font-size:13px;font-weight:500;user-select:none;
}
.notify-chip input{accent-color:#25D366}
.notify-chip:has(input:checked){border-color:#25D366;background:#e7f8ee;color:#075E54}
@media(max-width:480px){.notify-row{flex-direction:column}.notify-chip{width:100%}}

.req-btn-wrap{position:relative}
.req-badge{
  position:absolute;top:0;right:2px;min-width:16px;height:16px;padding:0 4px;
  background:#25D366;color:#fff;font-size:10px;font-weight:700;line-height:16px;
  border-radius:8px;text-align:center;box-shadow:0 0 0 2px #fff;
}
.block-composer-note{
  display:none;padding:14px 16px;text-align:center;background:#f0f2f5;
  color:#667781;font-size:14px;border-top:1px solid #e9edef;
}

.pinned-msg-bar{
  display:none;align-items:center;gap:10px;padding:8px 14px;
  background:#f0faf7;border-bottom:1px solid #d1e7e0;cursor:default;flex-shrink:0;
}
.pinned-msg-bar .pm-icon{font-size:16px}
.pinned-msg-bar .pm-body{flex:1;min-width:0}
.pinned-msg-bar .pm-title{font-size:11px;font-weight:600;color:#075E54}
.pinned-msg-bar .pm-text{font-size:13px;color:#54656f;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pinned-msg-bar .pm-close{background:none;border:none;cursor:pointer;color:#667781;font-size:14px;padding:4px}
.chat-item.muted-chat .title::after{content:" 🔇";font-size:12px;opacity:.8}
.chat-item.muted-chat .preview{opacity:.75}

.load-more-chats{text-align:center;padding:10px;font-size:13px;color:#128C7E;cursor:pointer;font-weight:600}
.load-more-chats:hover{background:#f0f2f5}




/* ===== Admin + mobile layout (v54) ===== */
body.admin-body{
  background:#f0f2f5;
  height:auto !important;
  min-height:100%;
  overflow-x:hidden !important;
  overflow-y:auto !important;
  -webkit-overflow-scrolling:touch;
}
html:has(body.admin-body){
  height:auto !important;
  overflow-y:auto !important;
}
.admin-nav{
  flex-wrap:wrap;
  height:auto;
  min-height:56px;
  gap:8px;
  padding:10px 12px;
}
.admin-nav .nav-links{
  display:flex;
  flex-wrap:wrap;
  gap:4px;
  align-items:center;
}
.admin-nav .nav-drop .drop-menu{
  right:0;
  left:auto;
  max-height:70vh;
  overflow-y:auto;
}

@media (max-width:768px){
  body.admin-body,
  body.login-body,
  .profile-page{
    height:auto !important;
    min-height:100dvh;
    overflow-x:hidden !important;
    overflow-y:auto !important;
    -webkit-overflow-scrolling:touch !important;
    position:relative;
  }
  .admin-nav{
    flex-direction:column;
    align-items:stretch;
    height:auto !important;
    padding:10px 12px;
    position:sticky;
    top:0;
    z-index:100;
  }
  .admin-nav .brand{
    font-size:16px;
    margin-bottom:4px;
  }
  .admin-nav .nav-links{
    width:100%;
    display:flex;
    flex-wrap:wrap;
    gap:4px;
  }
  .admin-nav .nav-links a,
  .admin-nav .nav-links .nav-drop{
    font-size:13px;
    padding:8px 10px;
    flex:1 1 auto;
    text-align:center;
  }
  .admin-nav .nav-drop .drop-menu{
    position:static;
    display:none;
    box-shadow:none;
    background:rgba(0,0,0,.15);
    margin-top:4px;
    border-radius:8px;
    width:100%;
  }
  .admin-nav .nav-drop.open .drop-menu,
  .admin-nav .nav-drop:focus-within .drop-menu{
    display:block;
  }
  .admin-nav .nav-drop span{
    display:block;
    padding:8px 10px;
    text-align:center;
  }
  .admin-container{
    margin:12px auto 40px !important;
    padding:0 10px 48px !important;
    max-width:100%;
    width:100%;
    box-sizing:border-box;
  }
  .admin-card,
  .admin-container .box{
    padding:14px !important;
    margin-bottom:14px !important;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
  }
  .admin-card h2{
    flex-wrap:wrap;
    gap:8px;
    font-size:16px;
  }
  .stats-grid{
    grid-template-columns:1fr 1fr !important;
    gap:10px !important;
  }
  table.data-table,
  .admin-container table{
    display:block;
    width:100%;
    max-width:100%;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    font-size:12px;
  }
  table.data-table th,
  table.data-table td,
  .admin-container th,
  .admin-container td{
    white-space:nowrap;
    padding:8px 6px;
  }
  .form-group input,
  .form-group select,
  .form-group textarea,
  .admin-card input,
  .admin-card select,
  .admin-card textarea{
    font-size:16px !important; /* prevent iOS zoom */
    max-width:100%;
    box-sizing:border-box;
  }
  .btn, .btn-sm{
    min-height:40px;
  }
  .member-grid{
    grid-template-columns:1fr !important;
  }
  .pick-toolbar{
    flex-wrap:wrap;
  }
  .pick-toolbar button{
    flex:1 1 auto;
  }
}

@media (max-width:480px){
  .stats-grid{grid-template-columns:1fr 1fr !important}
  .admin-nav .nav-links a{font-size:12px;padding:6px 8px}
}




/* ===== v54.4: shell fit + bubble wrap (classic size) ===== */
html, body {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
*, *::before, *::after { box-sizing: border-box; }

body.chat-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #d1d7db;
}
body.chat-page > .top-bar {
  flex-shrink: 0;
  width: 100%;
}
body.chat-page > .chat-app {
  flex: 1 1 auto;
  min-height: 0;
  height: auto !important;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}

/* Long pasted text stays inside the bubble — never stretches the window */
.message,
.message.incoming,
.message.outgoing {
  width: fit-content;
  min-width: 0 !important;
  max-width: min(65%, 42rem) !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  white-space: pre-wrap !important;
}
.message a {
  overflow-wrap: anywhere;
  word-break: break-all;
  color: #027eb5;
}
.message .media-img,
.message .media-video {
  max-width: 100%;
  height: auto;
}
.sys-message {
  align-self: center;
  max-width: 85%;
  width: fit-content;
  min-width: 0;
}
.chat-header .info {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.chat-header .info .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .sidebar { width: 320px; min-width: 280px; }
  .message, .message.incoming, .message.outgoing {
    max-width: min(75%, 36rem) !important;
  }
}
@media (max-width: 768px) {
  .sidebar { width: 100%; min-width: 0; max-width: none; }
  .message, .message.incoming, .message.outgoing {
    max-width: 88% !important;
  }
}


/* Profile DND + email notify layout */
.notify-box{margin-top:18px;padding:16px;background:#f0f2f5;border-radius:12px}
.notify-title{font-weight:600;display:block;margin-bottom:6px;color:#075E54;font-size:15px}
.notify-hint{font-size:12px;color:#667781;margin:0 0 12px}
.dnd-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px 16px;
  align-items:end;
  margin-bottom:4px;
}
.dnd-check{
  grid-column:1 / -1;
  display:flex;align-items:center;gap:10px;
  font-size:14px;font-weight:500;cursor:pointer;
}
.dnd-check input{width:18px;height:18px;accent-color:#25D366}
.dnd-time{
  display:flex;flex-direction:column;gap:6px;
  font-size:13px;color:#54656f;
}
.dnd-time input[type=time]{
  padding:10px 12px;border:1px solid #d1d7db;border-radius:8px;
  font-size:15px;background:#fff;width:100%;
}
.notify-row{display:flex;flex-wrap:wrap;gap:8px}
@media(max-width:480px){
  .dnd-grid{grid-template-columns:1fr}
}


/* File attachment card + download for all types */
.file-attach{
  display:flex;align-items:center;gap:10px;
  padding:10px 12px;background:rgba(0,0,0,.04);
  border-radius:10px;max-width:100%;min-width:0;
}
.file-attach-icon{font-size:28px;flex-shrink:0}
.file-attach-meta{flex:1;min-width:0}
.file-attach-name{
  font-weight:500;font-size:13px;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.file-attach-ext{font-size:11px;color:#667781;margin-top:2px}
.file-dl-btn,.media-actions a{
  flex-shrink:0;font-size:12px;font-weight:600;
  color:#027eb5;text-decoration:none;padding:6px 10px;
  border-radius:8px;background:rgba(2,126,181,.08);
  white-space:nowrap;
}
.file-dl-btn:hover,.media-actions a:hover{background:rgba(2,126,181,.16);text-decoration:none}
.mention-everyone{
  background:#dcf8c6 !important;color:#075E54 !important;
  font-weight:600;padding:1px 6px;border-radius:4px;
}
.th-sort{color:inherit;text-decoration:none;display:inline-flex;align-items:center;gap:4px}
.th-sort:hover{color:#075E54;text-decoration:none}
.unread-filter-btn{
  flex-shrink:0;border:1px solid #d1d7db;background:#fff;
  border-radius:8px;padding:6px 10px;font-size:12px;cursor:pointer;
  color:#667781;margin-left:6px;
}
.unread-filter-btn.active{
  background:#25D366;color:#fff;border-color:#25D366;font-weight:600;
}
.search-box-with-unread .search-wrap,
.search-box .search-wrap{display:flex;align-items:center;gap:4px;width:100%}
.search-box .search-wrap input{flex:1;min-width:0}

/* Online presence dots (WhatsApp-style) */
.status-dot{
  width:12px;height:12px;border-radius:50%;
  border:2px solid #fff;position:absolute;bottom:0;right:0;
  box-shadow:0 0 0 1px rgba(0,0,0,.08);
}
.avatar-wrap{position:relative;flex-shrink:0}


/* ===== v56.1 mobile + Safari fixes ===== */
html {
  height: -webkit-fill-available;
}
body.chat-page {
  min-height: 100vh;
  min-height: -webkit-fill-available;
  min-height: 100dvh;
}

@supports (-webkit-touch-callout: none) {
  /* iOS Safari */
  body.chat-page {
    height: -webkit-fill-available;
  }
  .messages-area, #messagesArea {
    -webkit-overflow-scrolling: touch;
  }
  .chat-section-scroll, .groups-scroll, .contacts-scroll, .chat-list {
    -webkit-overflow-scrolling: touch;
  }
  input, select, textarea {
    font-size: 16px !important; /* prevent iOS zoom on focus */
  }
}

@media (max-width: 768px) {
  body.chat-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    height: -webkit-fill-available;
    overflow: hidden;
  }
  body.chat-page > .top-bar {
    flex-shrink: 0;
    flex-wrap: wrap;
    height: auto !important;
    min-height: 48px;
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
    gap: 8px;
  }
  body.chat-page > .top-bar .logo {
    font-size: 16px;
  }
  body.chat-page > .top-bar .top-search {
    order: 3;
    flex: 1 1 100%;
    max-width: 100%;
    margin: 0;
    width: 100%;
  }
  body.chat-page > .top-bar .top-search select {
    flex-shrink: 0;
    max-width: 72px;
    font-size: 12px;
    padding: 8px 4px;
  }
  body.chat-page > .top-bar .top-search input {
    min-width: 0;
    font-size: 16px !important;
  }
  /* hide top-bar Profile/Logout text links on very small — sidebar has them */
  body.chat-page > .top-bar > div:last-child {
    font-size: 12px;
    gap: 8px;
  }

  body.chat-page > .chat-app {
    flex: 1 1 auto;
    min-height: 0;
    height: auto !important;
    max-width: 100%;
    flex-direction: column;
    overflow: hidden;
  }

  .sidebar {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 100%;
    min-height: 0;
    border-right: none;
    display: flex;
    flex-direction: column;
  }
  .sidebar-header {
    flex-shrink: 0;
    height: auto;
    min-height: 56px;
    padding: 8px 10px;
    flex-wrap: wrap;
  }
  .sidebar-actions {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .sidebar-actions .lbl { display: none; } /* icons only on narrow */
  .sidebar-actions a, .sidebar-actions button {
    padding: 8px;
    min-width: 40px;
  }

  .search-box {
    flex-shrink: 0;
    padding: 8px 10px;
  }
  .search-box .search-wrap {
    display: flex;
    gap: 6px;
    align-items: center;
  }
  .search-box input {
    font-size: 16px !important;
    min-width: 0;
  }
  .unread-filter-btn {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .chat-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .create-group-bar {
    flex-direction: row !important;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 8px 10px;
  }
  .btn-create-group {
    flex: 1 1 50%;
    width: auto;
    min-width: 0;
    padding: 10px 8px;
    font-size: 12px;
    justify-content: center;
    white-space: nowrap;
  }

  /* chat main when open */
  body.chat-open-mobile .sidebar { display: none !important; }
  body.chat-open-mobile .chat-main {
    display: flex !important;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
  }
  body:not(.chat-open-mobile) .chat-main { display: none !important; }

  .chat-header {
    flex-shrink: 0;
    padding: 8px 10px;
    height: auto;
    min-height: 56px;
  }
  .mobile-back {
    display: inline-flex !important;
  }
  .messages-area, #messagesArea {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 10px 16px;
  }
  .message, .message.incoming, .message.outgoing {
    max-width: 88% !important;
  }
  .chat-input-area, .composer-wrap {
    flex-shrink: 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .chat-input-area input,
  .chat-input-area textarea,
  #messageInput {
    font-size: 16px !important;
  }

  /* modals full-ish on mobile */
  .modal, .profile-preview-modal, #profilePreviewModal {
    align-items: flex-end;
  }
}

@media (max-width: 480px) {
  body.chat-page > .top-bar > div:last-child a:not(:last-child) {
    /* keep logout visible */
  }
  .sidebar-actions .lbl { display: none !important; }
}

/* Admin mobile */
@media (max-width: 768px) {
  .admin-container {
    padding: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .admin-nav {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    padding: 8px 12px;
  }
  .admin-nav .nav-links {
    flex-wrap: wrap;
  }
  .data-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .form-row {
    flex-direction: column;
  }
  .form-row .form-group {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .chat-section-scroll.groups-scroll {
    max-height: min(22vh, 160px) !important;
  }
  .deleted-text {
    font-style: italic;
    opacity: 0.85;
    font-size: 13px;
  }
}

.side-ico, .nav-ico {
  width: 18px; height: 18px; display: block;
  filter: none;
}
.sidebar-actions .side-ico {
  width: 20px; height: 20px;
  /* dark icons on light sidebar */
  filter: invert(35%) sepia(10%) saturate(500%) hue-rotate(120deg);
}
.top-bar .nav-ico {
  width: 16px; height: 16px;
  filter: brightness(0) invert(1);
}
.sys-name {
  color: #027eb5;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.sys-name:hover { text-decoration: underline; }
.pending-msg { opacity: 0.75; }
.pending-msg .ticks { opacity: 0.6; }
.send-failed { border: 1px solid #e53935; }
.deleted-text { font-style: italic; opacity: 0.9; font-size: 13px; }

/* Link preview (composer + bubbles) */
.link-preview-bar{
  display:none;align-items:stretch;gap:10px;margin:0 12px 6px;padding:8px 10px;
  background:#fff;border-radius:10px;border-left:4px solid #25D366;
  box-shadow:0 1px 3px rgba(0,0,0,.08);position:relative;
}
.link-preview-bar.show{display:flex}
.link-preview-bar img{
  width:72px;height:72px;object-fit:cover;border-radius:8px;flex-shrink:0;background:#eee;
}
.link-preview-bar .lp-meta{flex:1;min-width:0}
.link-preview-bar .lp-title{font-weight:600;font-size:13px;color:#111;margin-bottom:2px;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.3}
.link-preview-bar .lp-desc{font-size:12px;color:#667781;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.link-preview-bar .lp-site{font-size:11px;color:#25D366;margin-top:2px}
.link-preview-bar .lp-close{
  position:absolute;top:4px;right:6px;border:none;background:none;cursor:pointer;
  font-size:16px;color:#667781;line-height:1;padding:4px;
}
.msg-link-card{
  display:flex;flex-direction:column;gap:0;margin:4px 0 6px;padding:0;border-radius:10px;
  background:rgba(0,0,0,.06);text-decoration:none;color:inherit;overflow:hidden;max-width:280px;
}
.message.outgoing .msg-link-card{background:rgba(255,255,255,.35)}
.msg-link-card img{width:100%;height:140px;object-fit:cover;border-radius:0;flex-shrink:0;display:block;background:#ddd}
.msg-link-card .lp-meta{padding:8px 10px}
.msg-link-card .lp-title{font-weight:600;font-size:14px;margin-bottom:2px;color:#111}
.msg-link-card .lp-desc{font-size:12px;opacity:.85;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.msg-link-card .lp-site{font-size:11px;color:#075E54;margin-top:3px;text-transform:lowercase}
.message.outgoing .msg-link-card{background:rgba(255,255,255,.45)}
.msg-link-card .lp-title{font-weight:600;font-size:13px;margin-bottom:2px}
.msg-link-card .lp-desc{font-size:12px;opacity:.85;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.msg-link-card .lp-site{font-size:11px;color:#075E54;margin-top:2px}
.msg-location-card{
  display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:10px;
  background:rgba(0,0,0,.05);text-decoration:none;color:inherit;margin-top:4px;
}
.message.outgoing .msg-location-card{background:rgba(255,255,255,.35)}
.msg-location-card .loc-ico{font-size:28px;line-height:1}
.msg-location-card .loc-label{font-weight:600;font-size:14px}
.msg-location-card .loc-sub{font-size:12px;color:#667781}


/* WhatsApp-style day separators */
.day-separator{
  display:flex;
  justify-content:center;
  align-items:center;
  margin:14px 0 10px;
  clear:both;
}
.day-separator-label{
  background:#e1f2fb;
  color:#54656f;
  font-size:12.5px;
  font-weight:500;
  padding:6px 12px;
  border-radius:8px;
  box-shadow:0 1px 1px rgba(0,0,0,.06);
  user-select:none;
}


/* Sticky day chip (WhatsApp-style freeze on scroll) */
.messages-wrap{
  position:relative;
  flex:1;
  min-height:0;
  display:flex;
  flex-direction:column;
}
.messages-wrap .messages-area{
  flex:1;
  min-height:0;
}
.sticky-day-chip{
  position:absolute;
  top:8px;
  left:50%;
  transform:translateX(-50%);
  z-index:5;
  display:none;
  align-items:center;
  justify-content:center;
  background:#e1f2fb;
  color:#54656f;
  font-size:12.5px;
  font-weight:600;
  padding:6px 14px;
  border-radius:8px;
  box-shadow:0 1px 3px rgba(0,0,0,.12);
  pointer-events:none;
  max-width:80%;
  white-space:nowrap;
}


/* Unread separator */
.unread-separator{text-align:center;margin:12px 0;clear:both}
.unread-separator span{background:#ffeaa7;color:#5d4e37;font-size:12px;font-weight:600;padding:5px 12px;border-radius:8px}

/* Jump to latest */
.jump-latest-btn{
  position:absolute;right:16px;bottom:16px;z-index:6;
  width:40px;height:40px;border-radius:50%;border:none;
  background:#fff;color:#075E54;font-size:20px;cursor:pointer;
  box-shadow:0 2px 8px rgba(0,0,0,.18);align-items:center;justify-content:center;
  display:none;
}
.jump-latest-btn:hover{background:#e7f5f0}

/* Flash when jumping to reply */
.msg-flash{animation:ttFlash 1.4s ease}
@keyframes ttFlash{
  0%,100%{box-shadow:none}
  30%{box-shadow:0 0 0 3px rgba(7,94,84,.45)}
}
.reply-quote{cursor:pointer}
.reply-quote:hover{filter:brightness(0.97)}


/* Clearer muted chats */
.chat-item.muted-chat{opacity:.78}

/* =========================================================
   TeamTalk Dark Theme — cohesive (inspired by WA Web, unique)
   ========================================================= */
html[data-theme="dark"] {
  color-scheme: dark;
  --tt-card: #141414;
  --wa-sec: #a3a3a3;
}
html[data-theme="dark"] body.chat-page,
body.theme-dark.chat-page {
  --wa-bg: #000000;
  --wa-panel: #0a0a0a;
  --wa-header: #111111;
  --wa-chat: #000000;
  --wa-in: #1a1a1a;
  --wa-out: #0d3d36;
  --wa-text: #f5f5f5;
  --wa-sec: #a3a3a3;
  --wa-border: #222222;
  --wa-teal: #1ec997;
  --wa-hover: #222222;
  background: #000000 !important;
  color: #f5f5f5 !important;
}

/* Top bar */
html[data-theme="dark"] .top-bar,
html[data-theme="dark"] body.chat-page > .top-bar {
  background: #141414 !important;
  border-color: #222222 !important;
  color: #f5f5f5 !important;
}
html[data-theme="dark"] .top-bar a,
html[data-theme="dark"] .top-bar .logo { color: #f5f5f5 !important; }
html[data-theme="dark"] .top-search input,
html[data-theme="dark"] .top-search select {
  background: #222222 !important;
  color: #f5f5f5 !important;
  border: 1px solid #2e2e2e !important;
}
html[data-theme="dark"] #themeToggleBtn {
  background: #222222 !important;
  color: #f5f5f5 !important;
}

/* Sidebar shell */
html[data-theme="dark"] .sidebar {
  background: #0a0a0a !important;
  border-color: #222222 !important;
  color: #f5f5f5 !important;
}
html[data-theme="dark"] .sidebar-header,
html[data-theme="dark"] .user-info-bar {
  background: #111111 !important;
  border-bottom: 1px solid #222222 !important;
}
html[data-theme="dark"] .u-name,
html[data-theme="dark"] .sidebar-header .u-name { color: #f5f5f5 !important; }
html[data-theme="dark"] .u-role { color: #a3a3a3 !important; }
html[data-theme="dark"] .sidebar-actions a,
html[data-theme="dark"] .sidebar-actions button {
  color: #f5f5f5 !important;
  background: transparent !important;
}
html[data-theme="dark"] .sidebar-actions a:hover,
html[data-theme="dark"] .sidebar-actions button:hover {
  background: #222222 !important;
}

/* Search + section titles (CHAT GROUPS / CONTACTS) */
html[data-theme="dark"] .search-box {
  background: #0a0a0a !important;
  border-bottom-color: #222222 !important;
}
html[data-theme="dark"] .search-box input,
html[data-theme="dark"] #searchChats {
  background: #111111 !important;
  color: #f5f5f5 !important;
  border: none !important;
}
html[data-theme="dark"] .search-box input::placeholder { color: #a3a3a3 !important; }
html[data-theme="dark"] .unread-filter-btn {
  background: #111111 !important;
  color: #1ec997 !important;
  border-color: #222222 !important;
}
html[data-theme="dark"] .section-title {
  background: #0a0a0a !important;
  color: #1ec997 !important;
  border: none !important;
}
html[data-theme="dark"] .chat-list,
html[data-theme="dark"] .chat-section-scroll,
html[data-theme="dark"] .groups-scroll,
html[data-theme="dark"] .contacts-scroll {
  background: #0a0a0a !important;
}
html[data-theme="dark"] .chat-item {
  background: transparent !important;
  border-bottom: 1px solid #222d34 !important;
  color: #f5f5f5 !important;
}
html[data-theme="dark"] .chat-item:hover,
html[data-theme="dark"] .chat-item.active {
  background: #222222 !important;
}
html[data-theme="dark"] .chat-item .title { color: #f5f5f5 !important; }
html[data-theme="dark"] .chat-item .preview,
html[data-theme="dark"] .chat-item .meta .preview { color: #a3a3a3 !important; }
html[data-theme="dark"] .btn-primary { background: #1ec997 !important; border-color: #1ec997 !important; color: #111 !important; }
html[data-theme="dark"] .btn-secondary {
  background: #222222 !important;
  color: #f5f5f5 !important;
  border: 1px solid #2e2e2e !important;
}

/* Main chat pane */
html[data-theme="dark"] .chat-main,
html[data-theme="dark"] .messages-wrap,
html[data-theme="dark"] .messages-area,
html[data-theme="dark"] #messagesArea {
  background: #000000 !important;
}
html[data-theme="dark"] .chat-header,
html[data-theme="dark"] #chatHeaderBar {
  background: #111111 !important;
  border-bottom: 1px solid #222222 !important;
  color: #f5f5f5 !important;
}
html[data-theme="dark"] .chat-header .title,
html[data-theme="dark"] #chatTitle { color: #f5f5f5 !important; }
html[data-theme="dark"] .chat-header .subtitle,
html[data-theme="dark"] #chatSubtitle { color: #a3a3a3 !important; }
html[data-theme="dark"] .empty-state { color: #a3a3a3 !important; }
html[data-theme="dark"] .empty-state h2 { color: #f5f5f5 !important; }

/* Bubbles */
html[data-theme="dark"] .message.incoming {
  background: #111111 !important;
  color: #f5f5f5 !important;
}
html[data-theme="dark"] .message.outgoing {
  background: #0d3d36 !important;
  color: #f5f5f5 !important;
}
html[data-theme="dark"] .message .time,
html[data-theme="dark"] .message .ticks { color: #ffffff99 !important; }
html[data-theme="dark"] .message strong { color: inherit; font-weight: 700; }
html[data-theme="dark"] .day-separator-label,
html[data-theme="dark"] .sticky-day-chip {
  background: #161616 !important;
  color: #a3a3a3 !important;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
html[data-theme="dark"] .sys-message .sys-bubble {
  background: #161616 !important;
  color: #a3a3a3 !important;
}

/* Composer — was still white */
html[data-theme="dark"] .composer-wrap {
  background: #111111 !important;
  border-top: 1px solid #222222 !important;
}
html[data-theme="dark"] .composer-main {
  background: #222222 !important;
  border: 1px solid #2e2e2e !important;
  color: #f5f5f5 !important;
}
html[data-theme="dark"] #messageInput,
html[data-theme="dark"] .composer-main textarea {
  background: transparent !important;
  color: #f5f5f5 !important;
  border: none !important;
}
html[data-theme="dark"] #messageInput::placeholder { color: #a3a3a3 !important; }
html[data-theme="dark"] .fmt-bar { border-color: #2e2e2e !important; }
html[data-theme="dark"] .fmt-btn {
  background: #141414 !important;
  color: #f5f5f5 !important;
  border: 1px solid #2e2e2e !important;
}
html[data-theme="dark"] .fmt-btn:hover { background: #1ec99733 !important; }
html[data-theme="dark"] .btn-send {
  background: #1ec997 !important;
  color: #111 !important;
}
html[data-theme="dark"] .reply-bar {
  background: #141414 !important;
  border-left: 4px solid #1ec997 !important;
  color: #f5f5f5 !important;
}
html[data-theme="dark"] .link-preview-bar {
  background: #141414 !important;
  border-color: #222222 !important;
  color: #f5f5f5 !important;
}
html[data-theme="dark"] .attach-sheet {
  background: #1a1a1a !important;
  color: #f5f5f5 !important;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
html[data-theme="dark"] .attach-opt { color: #f5f5f5 !important; }
html[data-theme="dark"] .attach-opt:hover { background: #222222 !important; }
html[data-theme="dark"] #attachPreview,
html[data-theme="dark"] .attach-preview {
  background: #141414 !important;
  color: #f5f5f5 !important;
}

/* Modals */
html[data-theme="dark"] .modal-overlay { background: rgba(11,20,26,.75) !important; }
html[data-theme="dark"] .modal,
html[data-theme="dark"] .modal-body,
html[data-theme="dark"] #profilePreviewModal,
html[data-theme="dark"] .profile-preview-modal {
  background: #1a1a1a !important;
  color: #f5f5f5 !important;
}
html[data-theme="dark"] .modal-header {
  background: #141414 !important;
  border-bottom: 1px solid #222222 !important;
  color: #f5f5f5 !important;
}
html[data-theme="dark"] .modal input:not([type="file"]):not([type="checkbox"]),
html[data-theme="dark"] .modal textarea,
html[data-theme="dark"] .modal select {
  background: #0a0a0a !important;
  color: #f5f5f5 !important;
  border: 1px solid #2e2e2e !important;
}
html[data-theme="dark"] .gm-member,
html[data-theme="dark"] .member-row {
  border-bottom-color: #222222 !important;
  color: #f5f5f5 !important;
}
html[data-theme="dark"] .gm-member *,
html[data-theme="dark"] .member-row * { color: #f5f5f5 !important; }
html[data-theme="dark"] .ctx-menu {
  background: #1a1a1a !important;
  color: #f5f5f5 !important;
  border: 1px solid #222222 !important;
}
html[data-theme="dark"] .ctx-menu button {
  color: #f5f5f5 !important;
  background: transparent !important;
}
html[data-theme="dark"] .ctx-menu button:hover { background: #222222 !important; }
html[data-theme="dark"] .search-results {
  background: #1a1a1a !important;
  color: #f5f5f5 !important;
  border-color: #222222 !important;
}
html[data-theme="dark"] .sr-item { color: #f5f5f5 !important; }
html[data-theme="dark"] .sr-item:hover { background: #222222 !important; }
html[data-theme="dark"] .file-attach {
  background: #141414 !important;
  color: #f5f5f5 !important;
}
html[data-theme="dark"] .jump-latest-btn {
  background: #141414 !important;
  color: #1ec997 !important;
  box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
html[data-theme="dark"] .hdr-btn {
  color: #f5f5f5 !important;
  background: transparent !important;
}

/* ===== Dark theme v2 — remaining light patches ===== */

/* Create / Join row under search */
html[data-theme="dark"] .create-group-bar {
  background: #0a0a0a !important;
  border-bottom: 1px solid #222222 !important;
  padding: 8px 12px !important;
  gap: 8px !important;
}
html[data-theme="dark"] .btn-create-group {
  background: #1ec997 !important;
  color: #000000 !important;
  border: none !important;
  font-weight: 600 !important;
}
html[data-theme="dark"] .btn-create-group.secondary {
  background: #111111 !important;
  color: #f5f5f5 !important;
  border: 1px solid #2e2e2e !important;
}
html[data-theme="dark"] .btn-create-group.secondary:hover {
  background: #222222 !important;
  filter: none !important;
}

/* All generic buttons in dark */
html[data-theme="dark"] .btn {
  border-radius: 8px;
}
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn.btn-primary {
  background: #1ec997 !important;
  color: #000000 !important;
  border: none !important;
}
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn.btn-secondary {
  background: #222222 !important;
  color: #f5f5f5 !important;
  border: 1px solid #2e2e2e !important;
}
html[data-theme="dark"] .btn-danger,
html[data-theme="dark"] .btn.btn-danger {
  background: #ea4335 !important;
  color: #fff !important;
  border: none !important;
  opacity: 1 !important;
}
html[data-theme="dark"] .btn-danger:hover {
  background: #c5221f !important;
  color: #fff !important;
}
html[data-theme="dark"] .btn-sm {
  opacity: 1 !important;
}

/* Group info modal — permissions card was hard-coded white */
html[data-theme="dark"] .modal div[style*="background:#f0f2f5"],
html[data-theme="dark"] .modal div[style*="background: #f0f2f5"],
html[data-theme="dark"] .modal div[style*="background:#fff"],
html[data-theme="dark"] .modal div[style*="background: #fff"],
html[data-theme="dark"] .modal div[style*="background:#ffffff"],
html[data-theme="dark"] .modal div[style*="background:#f7f8fa"],
html[data-theme="dark"] .modal div[style*="background:#fafafa"] {
  background: #141414 !important;
  color: #f5f5f5 !important;
  border-color: #222222 !important;
}
html[data-theme="dark"] .modal label {
  color: #f5f5f5 !important;
}
html[data-theme="dark"] .modal code {
  background: #0a0a0a !important;
  color: #1ec997 !important;
  padding: 2px 6px;
  border-radius: 4px;
}
html[data-theme="dark"] .modal input[type="checkbox"] {
  accent-color: #1ec997;
}

/* Member rows: Make admin / Remove always visible */
html[data-theme="dark"] .gm-member .btn-secondary,
html[data-theme="dark"] .gm-member button.btn-secondary {
  background: #222222 !important;
  color: #f5f5f5 !important;
  border: 1px solid #2e2e2e !important;
}
html[data-theme="dark"] .gm-member .btn-danger,
html[data-theme="dark"] .gm-member button.btn-danger {
  background: #ea4335 !important;
  color: #ffffff !important;
  border: none !important;
  min-width: 64px;
}

/* File input browse */
html[data-theme="dark"] .modal input[type="file"] {
  color: #a3a3a3 !important;
}
html[data-theme="dark"] .modal input[type="file"]::file-selector-button {
  background: #222222 !important;
  color: #f5f5f5 !important;
  border: 1px solid #2e2e2e !important;
  border-radius: 6px;
  padding: 6px 12px;
  margin-right: 10px;
  cursor: pointer;
}

/* Inline light greys used in JS templates */
html[data-theme="dark"] [style*="background:#f0f2f5"],
html[data-theme="dark"] [style*="background: #f0f2f5"],
html[data-theme="dark"] [style*="background:#eee"],
html[data-theme="dark"] [style*="background:#f5f5f5"] {
  background: #141414 !important;
  color: #f5f5f5 !important;
}

/* Scrollbars */
html[data-theme="dark"] *::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
html[data-theme="dark"] *::-webkit-scrollbar-thumb {
  background: #2e2e2e;
  border-radius: 4px;
}
html[data-theme="dark"] *::-webkit-scrollbar-track {
  background: #0a0a0a;
}


/* Mobile/tablet: hide menu + react until message is selected */
@media (max-width: 900px) {
  .message .msg-menu,
  .message .msg-react-btn {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden;
  }
  .message.msg-selected .msg-menu,
  .message.msg-selected .msg-react-btn {
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible;
  }
  .message.msg-selected {
    outline: 2px solid rgba(30, 201, 151, 0.45);
    outline-offset: 2px;
  }
}


/* Zoomable lightbox */
.img-lightbox{
  display:none;position:fixed;inset:0;z-index:20000;
  background:rgba(0,0,0,.94);flex-direction:column;
  touch-action:none;
}
.img-lightbox.show{display:flex}
.img-lightbox .lb-toolbar{
  flex-shrink:0;display:flex;gap:8px;justify-content:center;align-items:center;
  padding:10px;background:rgba(0,0,0,.55);z-index:2;
}
.img-lightbox .lb-toolbar button{
  background:#222;color:#fff;border:1px solid #444;border-radius:8px;
  padding:8px 14px;font-size:16px;cursor:pointer;min-width:44px;
}
.img-lightbox .lb-toolbar button:hover{background:#333}
.img-lightbox .lb-body{
  flex:1;min-height:0;overflow:hidden;position:relative;
  display:flex;align-items:center;justify-content:center;
  cursor:grab;touch-action:none;
}
.img-lightbox .lb-body:active{cursor:grabbing}
.img-lightbox .lb-stage{
  transform-origin:center center;
  transition:transform .05s linear;
  will-change:transform;
  display:block;
  width:fit-content;
  height:fit-content;
  max-width:none;
  max-height:none;
  line-height:0;
}
.img-lightbox .lb-stage img,
.img-lightbox .lb-stage video{
  max-width:100vw;
  max-height:calc(100vh - 88px);
  width:auto;
  height:auto;
  object-fit:contain;
  border-radius:2px;
  user-select:none;
  -webkit-user-drag:none;
  pointer-events:auto;
  display:block;
}
.img-lightbox .lb-body{
  background:transparent;
  /* fill remaining viewport so black area is easy to click */
  width:100%;
}
.img-lightbox .lb-hint{
  flex-shrink:0;text-align:center;color:#aaa;font-size:12px;padding:6px 10px 12px;
}

/* Group permissions card — light + dark */
.gm-perms-card{
  margin-top:12px;padding:12px;border-radius:10px;font-size:13px;text-align:left;
  background:#f0f2f5;color:#111;border:1px solid #e9edef;
}
.gm-perms-title{font-weight:600;margin-bottom:8px;color:#075E54}
html[data-theme="dark"] .gm-perms-card{
  background:#1a1a1a !important;color:#f5f5f5 !important;border-color:#222 !important;
}
html[data-theme="dark"] .gm-perms-title{color:#1ec997 !important}
html[data-theme="dark"] .gm-perms-card label{color:#f5f5f5 !important}
html[data-theme="dark"] .gm-perms-card code{background:#0a0a0a;color:#1ec997}

/* Light theme modal defaults (override any dark bleed) */
html:not([data-theme="dark"]) .modal,
html:not([data-theme="dark"]) .modal-body {
  background:#fff !important;color:#111 !important;
}
html:not([data-theme="dark"]) .modal-header {
  background:#fff !important;color:#111 !important;border-bottom:1px solid #e9edef !important;
}
html:not([data-theme="dark"]) .modal label,
html:not([data-theme="dark"]) .modal strong,
html:not([data-theme="dark"]) .modal h3 { color:#111 !important; }
html:not([data-theme="dark"]) .modal input:not([type="file"]):not([type="checkbox"]),
html:not([data-theme="dark"]) .modal textarea {
  background:#fff !important;color:#111 !important;border:1px solid #ddd !important;
}

/* Multi-select messages */
.msg-select-bar{
  position:absolute;top:60px;left:50%;transform:translateX(-50%);z-index:40;
  display:flex;gap:10px;align-items:center;background:#202c33;color:#fff;
  padding:10px 16px;border-radius:12px;box-shadow:0 4px 20px rgba(0,0,0,.25);
}
html:not([data-theme="dark"]) .msg-select-bar{background:#fff;color:#111;border:1px solid #ddd}
.message.msg-checked{outline:2px solid #1ec997;outline-offset:2px}
body.msg-select-mode .message{cursor:pointer}

.message .fwd-label{font-size:11px;color:var(--wa-sec);font-style:italic;margin-bottom:2px;line-height:1.3}
.message .fwd-orig{font-size:11px;color:var(--wa-sec);margin-bottom:4px;line-height:1.3;opacity:.95}
.message .msg-footer{display:flex;justify-content:flex-end;align-items:center;gap:4px;margin-top:2px;clear:both}
.message .msg-footer .time{float:none;margin:0;white-space:nowrap}
.msg-select-bar{
  position:sticky;top:0;left:0;right:0;z-index:50;
  transform:none;width:100%;max-width:100%;
  border-radius:0;justify-content:flex-start;
}
#forwardModal .modal{display:flex;flex-direction:column;max-height:90vh}
#forwardModal .modal-header{flex-shrink:0;position:sticky;top:0;z-index:2;background:inherit}
#forwardModal .modal-body{flex:1;overflow-y:auto;min-height:0}
#forwardModal .fwd-footer{
  flex-shrink:0;position:sticky;bottom:0;z-index:2;
  padding:12px 16px;border-top:1px solid #eee;
  display:flex;gap:8px;justify-content:flex-end;
  background:#fff;
}
html[data-theme="dark"] #forwardModal .fwd-footer{background:#1a1a1a;border-color:#222}
#forwardModal .fwd-top-actions{
  display:flex;gap:8px;align-items:center;margin-left:auto;
}

/* @mention picker — theme aware */
#mentionBox{
  background:var(--tt-card,#ffffff) !important;
  color:var(--tt-text,#111) !important;
  border:1px solid var(--wa-border,#e9edef) !important;
  box-shadow:0 8px 24px rgba(0,0,0,.12);
  border-radius:12px;
  max-height:240px;
  overflow-y:auto;
  z-index:80;
}
#mentionBox .mention-item{
  padding:8px 12px;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:8px;
  color:inherit;
  background:transparent;
}
#mentionBox .mention-item:hover{background:var(--wa-hover,#f0f2f5)}
#mentionBox .mention-all{background:rgba(37,211,102,.12) !important}
html[data-theme="dark"] #mentionBox{
  background:#1a1a1a !important;
  color:#f5f5f5 !important;
  border-color:#333 !important;
}
html[data-theme="dark"] #mentionBox .mention-item:hover{background:#222 !important}
html[data-theme="dark"] #mentionBox .mention-all{background:rgba(30,201,151,.15) !important}

/* ===== WhatsApp-style voice note UI ===== */
.vn-bar{
  display:flex;align-items:center;gap:10px;
  padding:10px 12px;margin:0 8px 8px;
  border-radius:16px;
  background:var(--tt-card,#fff);
  border:1px solid var(--wa-border,#e9edef);
  box-shadow:0 2px 12px rgba(0,0,0,.06);
}
html[data-theme="dark"] .vn-bar, body.theme-dark .vn-bar{
  background:#1a1a1a;border-color:#333;
}
.vn-icon-btn{
  width:40px;height:40px;border-radius:50%;border:none;
  background:transparent;cursor:pointer;font-size:18px;
  display:flex;align-items:center;justify-content:center;
  color:var(--wa-sec,#667781);flex-shrink:0;
}
.vn-icon-btn:hover{background:rgba(0,0,0,.06)}
.vn-trash{color:#e53935 !important}
.vn-rec-mid{flex:1;display:flex;align-items:center;gap:10px;min-width:0}
.vn-dot{
  width:10px;height:10px;border-radius:50%;background:#e53935;
  box-shadow:0 0 0 0 rgba(229,57,53,.5);
  animation:vnPulse 1.2s ease-out infinite;flex-shrink:0;
}
@keyframes vnPulse{
  0%{box-shadow:0 0 0 0 rgba(229,57,53,.45)}
  70%{box-shadow:0 0 0 10px rgba(229,57,53,0)}
  100%{box-shadow:0 0 0 0 rgba(229,57,53,0)}
}
.vn-timer{font-size:15px;font-weight:600;color:var(--tt-text,#111);min-width:42px;font-variant-numeric:tabular-nums}
html[data-theme="dark"] .vn-timer{color:#f5f5f5}
.vn-wave-live{
  flex:1;height:28px;display:flex;align-items:center;gap:2px;
  overflow:hidden;min-width:60px;
}
.vn-wave-live span{
  width:3px;border-radius:2px;background:#25D366;
  animation:vnBar 1s ease-in-out infinite;
  height:8px;
}
.vn-wave-live span:nth-child(odd){animation-duration:.8s}
.vn-wave-live span:nth-child(3n){animation-duration:1.2s;background:#128C7E}
@keyframes vnBar{
  0%,100%{height:6px;opacity:.55}
  50%{height:22px;opacity:1}
}
.vn-send-btn{
  width:44px;height:44px;border-radius:50%;border:none;
  background:#25D366;color:#fff;font-size:18px;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  flex-shrink:0;box-shadow:0 2px 8px rgba(37,211,102,.35);
}
.vn-send-btn:hover{background:#1da851}
.vn-stop{
  background:rgba(229,57,53,.12) !important;color:#e53935 !important;
}
.vn-play-btn{
  width:40px;height:40px;border-radius:50%;border:none;
  background:#25D366;color:#fff;font-size:14px;cursor:pointer;
  flex-shrink:0;display:flex;align-items:center;justify-content:center;
}
.vn-preview-mid{flex:1;min-width:0}
.vn-wave-static{
  height:28px;display:flex;align-items:center;gap:2px;
  margin-bottom:2px;
}
.vn-wave-static span{
  width:3px;border-radius:2px;background:#25D366;opacity:.75;
}
.vn-preview-meta{font-size:12px;color:var(--wa-sec,#8696a0)}
/* In-bubble player polish */
.voice-player{
  display:flex;align-items:center;gap:10px;
  background:rgba(0,0,0,.05);border-radius:20px;padding:8px 12px 8px 8px;
  min-width:220px;max-width:300px;margin:2px 0;
}
.voice-player .vp-play{
  width:38px;height:38px;border-radius:50%;border:none;
  background:#25D366;color:#fff;font-size:13px;cursor:pointer;
  flex-shrink:0;display:flex;align-items:center;justify-content:center;
  box-shadow:0 1px 4px rgba(0,0,0,.12);
}
.message.outgoing .voice-player{background:rgba(0,0,0,.08)}
.message.incoming .voice-player{background:rgba(0,0,0,.04)}
html[data-theme="dark"] .voice-player{background:rgba(255,255,255,.08)}
.vp-wave{
  flex:1;height:28px;display:flex;align-items:center;gap:2px;
  position:relative;background:transparent;
}
.vp-wave .vp-bar{
  position:absolute;left:0;top:0;bottom:0;width:0;
  background:linear-gradient(90deg,rgba(18,140,126,.35),rgba(37,211,102,.55));
  border-radius:4px;transition:width .08s linear;pointer-events:none;
}
.vp-wave-bars{display:flex;align-items:center;gap:2px;width:100%;height:100%}
.vp-wave-bars i{
  display:block;width:3px;border-radius:2px;background:#128C7E;opacity:.55;
  height:10px;
}
.message.outgoing .vp-wave-bars i{background:#075E54}
.vp-time{font-size:11px;color:#667781;min-width:34px;text-align:right;font-variant-numeric:tabular-nums}
.btn-voice.recording{color:#e53935;animation:pulseRec 1s infinite}

.reply-bar.edit-bar{background:#fff8e6;border-left:4px solid #f0b429}
html[data-theme="dark"] .reply-bar.edit-bar, body.theme-dark .reply-bar.edit-bar{background:#2a2410;border-left-color:#f0b429}
.fmt-btn.active{background:rgba(37,211,102,.2);color:#075E54;font-weight:700}
.call-spk-btn{margin:8px 0;width:100%}

/* Clear (✕) on chat filter */
.chat-filter-clear{
  flex-shrink:0;width:28px;height:28px;border:none;border-radius:50%;
  background:rgba(0,0,0,.08);color:#667781;font-size:14px;line-height:1;
  cursor:pointer;display:flex;align-items:center;justify-content:center;
  padding:0;margin:0 2px;
}
.chat-filter-clear:hover{background:rgba(0,0,0,.14);color:#111}
html[data-theme="dark"] .chat-filter-clear,
body.theme-dark .chat-filter-clear{
  background:rgba(255,255,255,.12);color:#ccc;
}
html[data-theme="dark"] .chat-filter-clear:hover{background:rgba(255,255,255,.2);color:#fff}
.search-box .search-wrap input{padding-right:8px}

/* Call history table */
.call-history-modal{border-radius:16px;overflow:hidden}
.ch-table-wrap{overflow-x:auto}
.ch-table{width:100%;border-collapse:collapse;font-size:13px}
.ch-table thead th{
  text-align:left;padding:12px 14px;font-size:12px;font-weight:600;
  color:#667781;background:#f7f8fa;border-bottom:1px solid #e9edef;
  white-space:nowrap;position:sticky;top:0;z-index:1
}
.ch-table tbody td{padding:12px 14px;border-bottom:1px solid #f0f2f5;vertical-align:middle;color:#111b21}
.ch-table tbody tr:hover{background:#fafbfc}
.ch-dir{font-size:16px;font-weight:700}
.ch-dir.out{color:#25D366}
.ch-dir.in{color:#128C7E}
.ch-badge{
  display:inline-flex;align-items:center;gap:4px;padding:3px 10px;border-radius:999px;
  font-size:12px;font-weight:600;white-space:nowrap
}
.ch-c-dur,.ch-c-when{color:#667781;white-space:nowrap}
.ch-c-user{font-weight:600}
html[data-theme="dark"] .ch-table thead th{background:#1a1a1a;color:#a3a3a3;border-color:#333}
html[data-theme="dark"] .ch-table tbody td{border-color:#2a2a2a;color:#f5f5f5}
html[data-theme="dark"] .ch-table tbody tr:hover{background:#222}
html[data-theme="dark"] .ch-c-dur,html[data-theme="dark"] .ch-c-when{color:#a3a3a3}
@media(max-width:640px){
  .ch-table thead th:nth-child(5),.ch-table tbody td:nth-child(5){font-size:11px}
  .ch-table thead th,.ch-table tbody td{padding:10px 8px}
}

/* sticky day fix v39 */
.sticky-day-chip{
  position: sticky;
  top: 8px;
  z-index: 5;
  pointer-events: none;
  width: max-content;
  max-width: 80%;
  margin: 0 auto 8px;
  text-align: center;
  padding: 4px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  font-size: 12px;
  color: #667781;
}
.day-separator{
  display: flex;
  justify-content: center;
  margin: 12px 0;
  pointer-events: none;
  clear: both;
  position: relative;
  z-index: 1;
}
.day-separator-label{
  background: rgba(255,255,255,.95);
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 12px;
  color: #667781;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
html[data-theme="dark"] .sticky-day-chip,
html[data-theme="dark"] .day-separator-label{
  background: rgba(30,30,30,.95);
  color: #a3a3a3;
}
#messagesArea{ position: relative; }
.message{ position: relative; z-index: 2; clear: both; }

#ttOfflineBanner{letter-spacing:.2px}
html[data-theme="dark"] #ttOfflineBanner{background:#b45309;color:#fff}

/* Drag & drop attach (WhatsApp-style) */
.composer-wrap.tt-drag-over,
.composer-main.tt-drag-over,
#messagesArea.tt-drag-over,
#chatMain.tt-drag-over-main {
  outline: 2px dashed #25D366;
  outline-offset: -4px;
  background: rgba(37, 211, 102, 0.08) !important;
  border-radius: 12px;
}
.composer-main.tt-drag-over::after {
  content: "Drop files to attach";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #075E54;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 20px;
  pointer-events: none;
  z-index: 20;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.composer-main { position: relative; }
html[data-theme="dark"] .composer-wrap.tt-drag-over,
html[data-theme="dark"] .composer-main.tt-drag-over,
html[data-theme="dark"] #messagesArea.tt-drag-over,
html[data-theme="dark"] #chatMain.tt-drag-over-main {
  outline-color: #25D366;
  background: rgba(37, 211, 102, 0.12) !important;
}

/* mention-box fix v42 */
#mentionBox.mention-box,
.mention-box {
  background: #fff !important;
  color: #111b21;
  border: 1px solid #e9edef !important;
  border-radius: 12px !important;
  z-index: 80 !important;
}
#mentionBox .mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
}
#mentionBox .mention-item:last-child { border-bottom: none; }
#mentionBox .mention-item:hover { background: #f0f2f5; }
html[data-theme="dark"] #mentionBox.mention-box,
html[data-theme="dark"] .mention-box {
  background: #1f2c34 !important;
  color: #e9edef !important;
  border-color: #2a3942 !important;
}
html[data-theme="dark"] #mentionBox .mention-item { border-color: #2a3942; }
html[data-theme="dark"] #mentionBox .mention-item:hover { background: #2a3942; }

.reaction-chip.mine {
  outline: 1px solid #25D366;
  background: rgba(37,211,102,.15);
}

/* Teams-style more button (⋯) — clear on hover */
.message .msg-menu {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 27, 33, 0.06);
  border: none;
  color: #54656f;
  opacity: 0;
  transition: opacity .15s ease, background .15s ease, color .15s ease;
  cursor: pointer;
  padding: 0;
  z-index: 3;
}
.message .msg-react-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 27, 33, 0.06);
  border: none;
  opacity: 0;
  transition: opacity .15s ease, background .15s ease;
  cursor: pointer;
  padding: 0;
  z-index: 3;
}
.message:hover .msg-menu,
.message:hover .msg-react-btn,
.message:focus-within .msg-menu,
.message:focus-within .msg-react-btn,
.message .msg-menu:focus,
.message .msg-react-btn:focus {
  opacity: 1 !important;
}
.message .msg-menu:hover {
  background: #fff;
  color: #111b21;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.message .msg-react-btn:hover {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
html[data-theme="dark"] .message .msg-menu,
html[data-theme="dark"] .message .msg-react-btn {
  background: rgba(255,255,255,0.08);
  color: #e9edef;
}
html[data-theme="dark"] .message .msg-menu:hover,
html[data-theme="dark"] .message .msg-react-btn:hover {
  background: #2a3942;
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
/* Mobile / touch: always visible when selected */
@media (hover: none), (max-width: 768px) {
  .message.msg-selected .msg-menu,
  .message.msg-selected .msg-react-btn,
  .message:active .msg-menu {
    opacity: 1 !important;
  }
}


/* Readable message spacing — CSS only (do not alter URLs) */
.message {
  line-height: 1.6 !important;
  font-size: 14.5px !important;
  letter-spacing: 0.01em;
}
.message a.msg-url,
a.msg-url {
  color: #027eb5 !important;
  text-decoration: underline;
  word-break: break-all;
  overflow-wrap: anywhere;
}
html[data-theme="dark"] .message a.msg-url,
html[data-theme="dark"] a.msg-url {
  color: #6bc9f0 !important;
}

/* In-chat search (current DM / group) */
.chat-search-bar{
  background:var(--wa-panel,#f0f2f5);
  border-bottom:1px solid rgba(0,0,0,.08);
  padding:8px 12px;
  flex-shrink:0;
  z-index:5;
}
.chat-search-row{display:flex;gap:8px;align-items:center}
.chat-search-row input{
  flex:1;border:none;border-radius:8px;padding:10px 12px;
  font-size:14px;outline:none;background:#fff;color:#111;
}
.chat-search-close{
  border:none;background:transparent;font-size:18px;cursor:pointer;
  color:#667781;padding:6px 10px;border-radius:8px;
}
.chat-search-close:hover{background:rgba(0,0,0,.06)}
.chat-search-results{
  max-height:220px;overflow-y:auto;margin-top:8px;
}
.csr-item{
  padding:10px 12px;border-radius:8px;cursor:pointer;
  background:#fff;margin-bottom:6px;border:1px solid #e9edef;
}
.csr-item:hover{background:#eef7f4}
.csr-top{display:flex;justify-content:space-between;gap:8px;margin-bottom:4px}
.csr-who{font-weight:600;font-size:13px;color:#111}
.csr-when{font-size:11px;color:#667781;white-space:nowrap}
.csr-prev{font-size:13px;color:#54656f;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.csr-empty{text-align:center;color:#667781;font-size:13px;padding:12px}
html[data-theme="dark"] .chat-search-bar{background:#1f2c34;border-color:#2a3942}
html[data-theme="dark"] .chat-search-row input{background:#111b21;color:#e9edef}
html[data-theme="dark"] .csr-item{background:#111b21;border-color:#2a3942}
html[data-theme="dark"] .csr-item:hover{background:#1a282f}
html[data-theme="dark"] .csr-who{color:#e9edef}
html[data-theme="dark"] .csr-prev{color:#aebac1}

/* Audio: one download + file name */
.voice-wrap{display:flex;flex-direction:column;gap:6px;min-width:0;max-width:min(300px,85vw)}
.voice-meta{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 2px}
.voice-fname{
  font-size:12px;color:var(--wa-sec,#667781);overflow:hidden;text-overflow:ellipsis;
  white-space:nowrap;flex:1;min-width:0;
}
.voice-dl{
  flex-shrink:0;font-size:12px;color:#027eb5;text-decoration:none;
  background:rgba(2,126,181,.1);padding:4px 10px;border-radius:12px;font-weight:600;
}
.voice-dl:hover{background:rgba(2,126,181,.18);text-decoration:none}
html[data-theme="dark"] .voice-fname{color:#aebac1}
html[data-theme="dark"] .voice-dl{color:#6bc9f0;background:rgba(107,201,240,.12)}

/* Attach preview bar polish */
.attach-preview{
  position:absolute;bottom:100%;left:0;right:0;
  background:#fff;border-top:1px solid var(--wa-border,#e9edef);
  padding:12px 14px;display:none;flex-direction:column;gap:10px;
  box-shadow:0 -6px 18px rgba(0,0,0,.1);z-index:20;max-height:42vh;overflow:auto;
}
.attach-preview.show{display:flex}
.attach-preview .ap-media{
  display:flex;flex-wrap:wrap;gap:8px;align-items:stretch;
}
.attach-preview .ap-side{
  display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;
}
.attach-preview .ap-info{font-size:13px;color:#54656f;flex:1;min-width:140px}
.attach-preview .ap-actions{display:flex;gap:8px;flex-shrink:0}
.attach-preview .ap-actions .btn{min-width:88px;padding:8px 16px;border-radius:20px;font-weight:600}
.ap-chip{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  width:76px;min-height:72px;padding:6px;border-radius:10px;
  background:#f0f2f5;border:1px solid #e9edef;overflow:hidden;
}
.ap-chip img{width:56px;height:56px;object-fit:cover;border-radius:8px}
.ap-chip-ico{font-size:22px;line-height:1.2}
.ap-chip-name{
  font-size:10px;color:#667781;max-width:68px;overflow:hidden;text-overflow:ellipsis;
  white-space:nowrap;margin-top:4px;text-align:center;
}
.ap-chip.ap-more{
  font-size:14px;font-weight:700;color:#075E54;justify-content:center;
}
html[data-theme="dark"] .attach-preview{background:#1f2c34;border-color:#2a3942}
html[data-theme="dark"] .ap-chip{background:#111b21;border-color:#2a3942}
html[data-theme="dark"] .attach-preview .ap-info{color:#aebac1}

/* Who reacted popup */
.react-people-popup{
  position:fixed;z-index:10050;min-width:200px;max-width:280px;
  background:#fff;border-radius:12px;box-shadow:0 8px 28px rgba(0,0,0,.2);
  border:1px solid rgba(0,0,0,.08);overflow:hidden;font-size:14px;
}
.react-people-popup .rpp-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:10px 12px;font-weight:600;background:#f0f2f5;color:#111;
}
.react-people-popup .rpp-x{
  border:none;background:transparent;cursor:pointer;font-size:16px;color:#667781;padding:2px 6px;
}
.react-people-popup .rpp-list{max-height:200px;overflow-y:auto}
.react-people-popup .rpp-row{
  display:flex;align-items:center;justify-content:space-between;gap:8px;
  padding:10px 12px;border-bottom:1px solid #f0f2f5;
}
.react-people-popup .rpp-name{color:#111}
.react-people-popup .rpp-name em{font-style:normal;color:#667781;font-size:12px}
.react-people-popup .rpp-remove{
  border:none;background:rgba(234,67,53,.1);color:#c62828;
  border-radius:8px;padding:4px 10px;font-size:12px;font-weight:600;cursor:pointer;
}
.react-people-popup .rpp-add{
  display:block;width:100%;border:none;background:#e7f8f0;color:#075E54;
  padding:12px;font-weight:600;cursor:pointer;font-size:13px;
}
.react-people-popup .rpp-add:hover{background:#d1f0e3}
.reaction-chip.mine{outline:1px solid rgba(18,140,126,.45);background:rgba(18,140,126,.12)}
html[data-theme="dark"] .react-people-popup{background:#1f2c34;border-color:#2a3942}
html[data-theme="dark"] .react-people-popup .rpp-head{background:#111b21;color:#e9edef}
html[data-theme="dark"] .react-people-popup .rpp-name{color:#e9edef}
html[data-theme="dark"] .react-people-popup .rpp-row{border-color:#2a3942}
html[data-theme="dark"] .react-people-popup .rpp-add{background:#0b3d32;color:#25d366}

.mention-item.active, .mention-item:hover{background:#e7f8f0}
html[data-theme="dark"] .mention-item.active,
html[data-theme="dark"] .mention-item:hover{background:#0b3d32}
