*{box-sizing:border-box}
body{margin:0;font-family:Arial,sans-serif;background:#0f172a;color:#e5e7eb}
a{text-decoration:none;color:#93c5fd}
input,button,select{padding:10px;border-radius:10px;border:1px solid #334155;background:#111827;color:#fff}
button{cursor:pointer}
.login-body{display:flex;align-items:center;justify-content:center;min-height:100vh}
.login-card{width:360px;background:#111827;padding:30px;border-radius:20px;box-shadow:0 10px 30px rgba(0,0,0,.3)}
.login-card form{display:flex;flex-direction:column;gap:12px}
.alert{padding:12px;border-radius:10px;margin:12px 0}
.alert.error{background:#7f1d1d}.alert.success{background:#14532d}
.app-shell{display:flex;height:100vh}
.sidebar{width:300px;background:#111827;padding:20px;overflow:auto;border-right:1px solid #1f2937}
.brand{font-size:24px;font-weight:700;margin-bottom:20px}
.user-box,.card{background:#0b1220;padding:16px;border-radius:16px;margin-bottom:16px}
.nav-link{display:block;margin:10px 0}
.danger-btn{background:#b91c1c;border:none}
.user-list{display:flex;flex-direction:column;gap:8px}
.user-item{display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;padding:12px;background:#0b1220;border-radius:12px;border:1px solid #1f2937;color:#fff}
.user-item-main{display:flex;align-items:center;gap:10px;min-width:0}
.user-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.dot{width:10px;height:10px;border-radius:50%}.online{background:#22c55e}.offline{background:#ef4444}
.chat-panel{position:relative;flex:1;display:flex;flex-direction:column}
.chat-header{padding:20px;border-bottom:1px solid #1f2937;font-size:20px;font-weight:700}
.badge{min-width:24px;height:24px;padding:0 8px;border-radius:999px;background:#ef4444;color:#fff;display:inline-flex;align-items:center;justify-content:center;font-size:12px;font-weight:700}
.hidden{display:none !important}
.blink{animation:blinkPulse .95s linear infinite;border-color:#ef4444}
@keyframes blinkPulse{0%{box-shadow:0 0 0 0 rgba(239,68,68,.78)}50%{box-shadow:0 0 0 8px rgba(239,68,68,.12)}100%{box-shadow:0 0 0 0 rgba(239,68,68,.78)}}
.messages{flex:1;overflow:auto;padding:20px}
.message{display:flex;flex-direction:column;align-items:flex-start;max-width:72%;margin-bottom:16px}.message.mine{margin-left:auto;align-items:flex-end}
.bubble{background:#1e293b;padding:12px 14px;border-radius:16px;white-space:pre-wrap;word-break:break-word}
.message.mine .bubble{background:#2563eb}
.file-card{background:#1e293b;padding:12px 14px;border-radius:16px}
.message.mine .file-card{background:#2563eb}
.file-name{font-weight:700}
.file-note{margin-top:6px;white-space:pre-wrap;word-break:break-word}
.file-actions{display:flex;gap:12px;margin-top:8px;align-items:flex-start;flex-wrap:wrap}
.message-footer{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:6px}
.time{font-size:11px;color:#94a3b8}
.icon-btn{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:999px;border:none;color:#fff;font-size:16px;cursor:pointer;list-style:none}
.icon-btn::-webkit-details-marker{display:none}
.trash-icon{background:#b91c1c}
.blue-icon{background:#2563eb}
.delete-menu,.share-menu{position:relative}
.delete-popover,.inline-menu-form{position:absolute;right:0;top:38px;z-index:40;min-width:160px;background:#0b1220;border:1px solid #334155;border-radius:12px;padding:8px;box-shadow:0 8px 24px rgba(0,0,0,.35)}
.inline-menu-form{min-width:220px;display:flex;flex-direction:column;gap:8px}
.menu-delete-btn,.inline-menu-form button{width:100%;background:#111827;border:1px solid #334155}
.menu-delete-btn{margin:0 0 6px 0}.menu-delete-btn:last-child{margin-bottom:0}
.send-form{padding:16px 20px;border-top:1px solid #1f2937}
.input-row{display:flex;gap:10px;align-items:center}.message-input{flex:1;min-height:52px;font-size:15px}
.emoji-btn{font-size:22px;line-height:1}
.file-picker{display:inline-flex;align-items:center;justify-content:center;padding:10px 14px;border-radius:10px;border:1px solid #334155;background:#111827;color:#fff;cursor:pointer}
.file-picker input{display:none}
.file-selected{padding-top:8px;color:#94a3b8;font-size:13px}.emoji-panel{display:flex;gap:8px;flex-wrap:wrap;padding-top:10px}
.simple-page{padding:30px}.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:20px}table{width:100%;border-collapse:collapse}th,td{padding:10px;border-bottom:1px solid #334155;text-align:left;vertical-align:top}.check-list{display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:10px 0}.empty-state{padding:30px;color:#94a3b8}
.drop-zone{position:absolute;inset:76px 20px 90px 20px;border:2px dashed #60a5fa;border-radius:18px;background:rgba(15,23,42,.92);display:flex;align-items:center;justify-content:center;font-size:24px;font-weight:700;color:#bfdbfe;z-index:20}
.drop-send-row{padding-top:8px}.drop-send-btn{background:#2563eb;border:none}
.admin-trash-form{display:inline-block}.admin-trash-btn{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:999px;border:none;background:#b91c1c;color:#fff;font-size:16px}

.text-action-btn{display:inline-flex;align-items:center;justify-content:center;min-width:64px;height:32px;padding:0 12px;border-radius:999px;border:none;color:#fff;font-size:13px;font-weight:700;cursor:pointer;list-style:none}
.text-action-btn::-webkit-details-marker{display:none}
.share-text-btn{background:#2563eb}
.file-preview-shell{width:240px;max-width:100%;height:150px;border-radius:12px;overflow:hidden;background:rgba(255,255,255,.08);display:flex;align-items:center;justify-content:center;margin-bottom:10px}
.file-preview-image{width:100%;height:100%;object-fit:cover;display:block}
.file-preview-frame{width:100%;height:100%;border:0;background:#fff}
.file-preview-generic{font-size:42px;opacity:.95}
.file-card{max-width:320px}

.file-preview-media{width:100%;height:100%;display:block;background:#0f172a}
.message.mine .file-card{align-self:flex-end}
.message:not(.mine) .file-card{align-self:flex-start}
.file-preview-generic{padding:12px;text-align:center;font-weight:700;line-height:1.2}

.ghost-input{position:absolute !important;left:-9999px !important;top:auto !important;width:1px !important;height:1px !important;opacity:0 !important;pointer-events:none !important}
.emoji-btn{
  width:42px;
  height:42px;
  padding:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:30px;
  line-height:1;
  font-family:"Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif;
  text-rendering:optimizeLegibility;
  image-rendering:auto;
}
.emoji-panel button{
  width:42px;
  height:42px;
  padding:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:28px;
  line-height:1;
  font-family:"Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif;
  border-radius:10px;
}
.trash-icon{
  background:transparent !important;
  color:#ff4d4f;
  width:34px;
  height:34px;
  padding:0;
}
.trash-icon svg{
  width:22px;
  height:22px;
  display:block;
  fill:currentColor;
  filter:drop-shadow(0 1px 0 rgba(0,0,0,.25));
}
.trash-icon:hover{
  color:#ff6b6b;
  background:rgba(255,77,79,.08) !important;
}

.admin-user-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.admin-user-actions form{margin:0}
.admin-user-actions input{min-width:140px}


.user-texts{display:flex;flex-direction:column;min-width:0}
.user-presence{font-size:11px;line-height:1.2;margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.presence-online{color:#22c55e}
.presence-offline{color:#94a3b8}
.chat-header{padding:16px 20px;border-bottom:1px solid #1f2937;font-size:20px;font-weight:700;display:flex;align-items:center}
.chat-header-main{display:flex;align-items:center;gap:10px}
.chat-header-texts{display:flex;flex-direction:column}
.chat-header-title{font-size:22px;font-weight:700;line-height:1.1}
.chat-header-status{font-size:12px;font-weight:500;margin-top:4px}
.dot{width:10px;height:10px;border-radius:50%;flex:0 0 10px}


.message-actions-inline{display:flex;align-items:center;gap:8px}
.react-icon{background:transparent;color:#fbbf24;width:32px;height:32px;padding:0;font-size:18px}
.react-popover{position:absolute;right:40px;top:0;z-index:45;display:flex;gap:6px;flex-wrap:wrap;min-width:180px;background:#0b1220;border:1px solid #334155;border-radius:12px;padding:8px;box-shadow:0 8px 24px rgba(0,0,0,.35)}
.react-btn{width:34px;height:34px;padding:0;border-radius:10px;font-size:22px;line-height:1;transition:transform .12s ease, background .12s ease}
.react-btn:hover{transform:translateY(-2px) scale(1.12);background:#1e293b}
.reactions-row{display:flex;gap:6px;flex-wrap:wrap;margin-top:8px}
.reaction-chip{display:inline-flex;align-items:center;gap:4px;padding:4px 8px;border-radius:999px;background:rgba(255,255,255,.10);font-size:12px}
.bubble.emoji-only{font-size:34px;line-height:1.3;padding:10px 12px;background:transparent !important;box-shadow:none}
.message.mine .bubble.emoji-only{background:transparent !important}
.emoji-panel{position:absolute;bottom:92px;left:20px;right:20px;max-width:420px;background:#0b1220;border:1px solid #334155;border-radius:16px;padding:10px;box-shadow:0 18px 46px rgba(0,0,0,.45);z-index:30}
.emoji-tabs{display:flex;gap:6px;margin-bottom:8px}
.emoji-tab{width:40px;height:40px;padding:0;border-radius:12px;font-size:20px;background:#111827}
.emoji-tab.active{background:#2563eb}
.emoji-search-wrap input{width:100%;margin-bottom:10px}
.emoji-grid{display:grid;grid-template-columns:repeat(6, minmax(0,1fr));gap:8px;max-height:220px;overflow:auto}
.emoji-choice{width:100%;aspect-ratio:1/1;display:flex;align-items:center;justify-content:center;font-size:28px;border-radius:12px;transition:transform .12s ease, background .12s ease}
.emoji-choice:hover{transform:translateY(-2px) scale(1.12);background:#1e293b}
.mobile-menu-btn{display:none;margin-right:12px;width:38px;height:38px;padding:0;border-radius:10px;background:#111827}
@media (max-width: 900px){
  .sidebar{position:fixed;left:0;top:0;bottom:0;z-index:60;transform:translateX(-105%);transition:transform .2s ease;width:280px}
  .sidebar.sidebar-open{transform:translateX(0)}
  .mobile-menu-btn{display:inline-flex;align-items:center;justify-content:center}
  .chat-panel{width:100%}
  .message{max-width:88%}
  .emoji-panel{left:10px;right:10px;max-width:none;bottom:84px}
  .input-row{gap:8px}
  .file-picker{padding:10px}
}


.group-dot{width:18px;height:18px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;background:#1e293b;color:#cbd5e1;font-size:11px;font-weight:700}
.brand{display:flex;align-items:center;gap:10px;justify-content:space-between}
.mobile-close-btn{display:none;width:34px;height:34px;padding:0;border-radius:10px;background:#0b1220;border:1px solid #1f2937}
.mobile-sidebar-overlay{display:none}
.soft-react-icon{background:transparent !important;color:rgba(251,191,36,.48) !important;width:20px;height:20px;font-size:14px;padding:0;line-height:1;box-shadow:none}
.soft-react-icon:hover{color:rgba(251,191,36,.82) !important;background:transparent !important}
.message{position:relative}
.message-actions-inline{position:relative;gap:10px}
.message-react-launcher{order:2}
.below-bubble-popover{top:auto;bottom:calc(100% + 8px);right:-8px;left:auto;min-width:auto;padding:6px 8px;display:flex;gap:6px;flex-wrap:nowrap}
.react-popover form{margin:0}
.seen-state{font-size:14px;line-height:1;color:rgba(248,113,113,.72);letter-spacing:-1px;min-width:22px;text-align:center}
.seen-state.seen{color:rgba(248,113,113,.94)}
.seen-state.delivered{color:rgba(248,113,113,.62)}
@media (max-width: 900px){
  body.mobile-nav-open{overflow:hidden}
  .app-shell{height:100dvh;overflow:hidden}
  .sidebar{position:fixed;left:0;top:0;bottom:0;width:82vw;max-width:320px;transform:translateX(-105%);transition:transform .22s ease;z-index:70;padding:14px}
  .sidebar.sidebar-open{transform:translateX(0)}
  .mobile-sidebar-overlay{position:fixed;inset:0;background:rgba(2,6,23,.55);z-index:65;display:none}
  .mobile-sidebar-overlay.show{display:block}
  .mobile-close-btn{display:inline-flex;align-items:center;justify-content:center}
  .chat-panel{width:100%;min-width:0}
  .chat-header{position:sticky;top:0;z-index:30;padding:12px 14px;background:#0f172a}
  .mobile-menu-btn{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;padding:0;border-radius:10px;background:#111827;border:1px solid #334155}
  .messages{padding:12px 10px 88px;overflow:auto}
  .message{max-width:92%}
  .send-form{position:sticky;bottom:0;background:#0f172a;padding:10px;border-top:1px solid #1f2937;z-index:30}
  .input-row{gap:8px;align-items:center}
  .emoji-btn{width:40px;height:40px;font-size:24px;flex:0 0 40px}
  .message-input{min-height:46px;font-size:16px;flex:1}
  .file-picker{padding:0 10px;height:40px;white-space:nowrap;font-size:13px}
  .send-form button[type='submit']{height:40px;padding:0 14px}
  .emoji-panel{left:10px;right:10px;bottom:72px;max-width:none}
  .below-bubble-popover{bottom:calc(100% + 6px);right:-4px;max-width:78vw;overflow:auto}
}



/* v8_16 targeted fix */
.message-footer{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:nowrap}
.message-actions-inline{display:inline-flex;align-items:center;gap:8px;position:relative;justify-content:flex-end}
.message-react-launcher{position:relative;display:inline-flex;align-items:center}
.soft-react-icon{display:inline-flex !important;align-items:center;justify-content:center;color:rgba(251,191,36,.44) !important}
.soft-react-icon:hover{color:rgba(251,191,36,.78) !important}
.below-bubble-popover{position:absolute !important;bottom:calc(100% + 6px) !important;right:0 !important;left:auto !important;top:auto !important;transform:none !important;z-index:120;white-space:nowrap;max-width:none}
.message.mine .message-actions-inline{justify-content:flex-end}
.message:not(.mine) .message-actions-inline{justify-content:flex-start}
.mobile-menu-btn{display:none}
@media (max-width: 900px){
  html,body{height:100%;overflow:hidden}
  .app-shell{height:100dvh;display:flex;overflow:hidden}
  .sidebar{position:fixed;left:0;top:0;bottom:0;width:84vw;max-width:320px;background:#111827;transform:translateX(-105%);transition:transform .24s ease;z-index:110;padding:14px 12px 18px;box-shadow:12px 0 30px rgba(0,0,0,.35)}
  .sidebar.sidebar-open{transform:translateX(0)}
  .mobile-sidebar-overlay{position:fixed;inset:0;background:rgba(2,6,23,.58);z-index:100;display:none}
  .mobile-sidebar-overlay.show{display:block}
  .chat-panel{flex:1;min-width:0;display:flex;flex-direction:column}
  .chat-header{position:sticky;top:0;z-index:90;padding:12px 14px;background:#0f172a;border-bottom:1px solid #1f2937;display:flex;align-items:center;gap:10px}
  .mobile-menu-btn{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;padding:0;border-radius:12px;background:#111827;border:1px solid #334155;color:#e5e7eb;font-size:18px}
  .messages{flex:1;padding:12px 10px 96px;overflow:auto}
  .message{max-width:94%}
  .send-form{position:sticky;bottom:0;z-index:95;background:#0f172a;padding:10px 10px calc(10px + env(safe-area-inset-bottom));border-top:1px solid #1f2937}
  .input-row{align-items:center;gap:8px}
  .message-input{min-height:46px;font-size:16px;flex:1}
  .emoji-btn{width:42px;height:42px;flex:0 0 42px;font-size:23px}
  .file-picker{height:42px;padding:0 10px;font-size:13px}
  .send-form button[type='submit']{height:42px;padding:0 14px}
  .emoji-panel{left:10px;right:10px;bottom:74px;max-width:none}
  .below-bubble-popover{bottom:calc(100% + 8px) !important;right:0 !important;left:auto !important;max-width:78vw;overflow:auto}
}


/* v8_17 mobile + reaction + vienna */
.message-react-launcher{position:relative;display:inline-flex;align-items:center}
.below-bubble-popover{bottom:calc(100% + 4px) !important;right:0 !important;left:auto !important;top:auto !important}
.message-actions-inline{align-items:flex-end}

@media (max-width: 900px){
  .send-form button[type='submit']{
    width:42px;min-width:42px;height:42px;padding:0 !important;
    border-radius:999px;display:inline-flex;align-items:center;justify-content:center;
    background:#229ED9;border-color:#229ED9;font-size:0;flex:0 0 42px;
  }
  .send-form button[type='submit']::before{
    content:'➤';font-size:18px;line-height:1;color:#fff;transform:translateX(1px);
  }
  .file-picker{
    width:42px;min-width:42px;height:42px;padding:0 !important;
    font-size:0;display:inline-flex;align-items:center;justify-content:center;
    border-radius:10px;flex:0 0 42px;
  }
  .file-picker::before{content:'📎';font-size:18px;line-height:1}
  .input-row{display:grid;grid-template-columns:40px 1fr 42px 42px;gap:8px;align-items:center}
  .message-input{min-width:0;width:100%}
  .chat-header{padding-left:10px;padding-right:10px}
  .messages{padding-left:10px;padding-right:10px}
  .sidebar{width:84vw;max-width:320px}
}


/* === v8_17_1 patch === */
.sidebar [id^="user-presence-"],
.sidebar .user-presence,
.sidebar .presence-text,
.sidebar .user-status,
.sidebar .last-seen,
.sidebar .last-seen-text,
.sidebar .presence-line,
.sidebar .user-meta-status,
.sidebar .user-subtitle,
.sidebar .user-substatus {
  display: none !important;
}

/* mobile button icon fix */
.send-submit-btn .send-icon,
.icon-file-picker .file-picker-icon {
  display: none;
}

@media (max-width: 768px) {
  .input-row {
    gap: 8px;
    align-items: center;
  }

  .message-input {
    flex: 1;
    min-width: 0;
  }

  .icon-file-picker {
    width: 42px;
    height: 42px;
    min-width: 42px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
  }

  .icon-file-picker .file-picker-text {
    display: none !important;
  }

  .icon-file-picker .file-picker-icon {
    display: inline-block;
  }

  .send-submit-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
  }

  .send-submit-btn .send-text {
    display: none !important;
  }

  .send-submit-btn .send-icon {
    display: inline-block;
    transform: translateX(1px);
  }
}
