/* A328 — stable flat Pixel Chat composer and custom emoji. */
#chatfoot.pb-chat-composer{
  --pb-composer-bg:#182131;
  --pb-composer-line:rgba(143,159,184,.12);
  position:relative;
  display:flex!important;
  flex:0 0 auto!important;
  flex-direction:column!important;
  gap:0!important;
  width:100%!important;
  padding:0 0 env(safe-area-inset-bottom,0px)!important;
  border-top:1px solid var(--pb-composer-line)!important;
  background:var(--pb-composer-bg)!important;
  box-shadow:none!important;
  overflow:visible!important;
}
#chatcomposerrow{
  display:block!important;
  width:100%!important;
  min-height:60px!important;
  background:var(--pb-composer-bg)!important;
}
#chatcomposerrow #chatinputwrap{
  position:relative!important;
  display:flex!important;
  align-items:center!important;
  width:100%!important;
  min-width:0!important;
  min-height:60px!important;
  box-sizing:border-box!important;
  gap:6px!important;
  padding:8px 10px!important;
  border:0!important;
  border-radius:0!important;
  outline:0!important;
  background:var(--pb-composer-bg)!important;
  box-shadow:none!important;
}
#chatcomposerrow #chatinputwrap:focus-within{
  border:0!important;
  outline:0!important;
  box-shadow:none!important;
}
#chatcomposerrow #chatinput{
  flex:1 1 auto!important;
  align-self:center!important;
  width:auto!important;
  min-width:0!important;
  height:40px!important;
  min-height:40px!important;
  max-height:92px!important;
  box-sizing:border-box!important;
  margin:0!important;
  padding:9px 0!important;
  border:0!important;
  border-radius:0!important;
  outline:0!important;
  appearance:none!important;
  -webkit-appearance:none!important;
  resize:none!important;
  overflow-x:hidden!important;
  overflow-y:auto!important;
  background:transparent!important;
  color:#f1f5f9!important;
  box-shadow:none!important;
  font:600 15px/22px Inter,system-ui,sans-serif!important;
  caret-color:#6cff7a!important;
  scrollbar-width:none!important;
}
#chatcomposerrow #chatinput::-webkit-scrollbar{display:none!important}
#chatcomposerrow #chatinput:focus,
#chatcomposerrow #chatinput:active,
#chatcomposerrow #chatinput:focus-visible{
  border:0!important;
  outline:0!important;
  background:transparent!important;
  box-shadow:none!important;
}
#chatcomposerrow #chatinput::placeholder{
  color:#9ba8bc!important;
  opacity:1!important;
}
#chatcomposerrow.pb-chat-rich-active #chatinput{
  position:absolute!important;
  width:1px!important;
  min-width:1px!important;
  height:1px!important;
  min-height:1px!important;
  margin:0!important;
  padding:0!important;
  opacity:0!important;
  pointer-events:none!important;
  overflow:hidden!important;
}
.pb-chat-rich-editor{
  flex:1 1 auto;
  align-self:center;
  min-width:0;
  min-height:40px;
  max-height:92px;
  box-sizing:border-box;
  margin:0;
  padding:9px 0;
  overflow-x:hidden;
  overflow-y:auto;
  border:0;
  outline:0;
  background:transparent;
  color:#f1f5f9;
  box-shadow:none;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  font:600 15px/22px Inter,system-ui,sans-serif;
  caret-color:#6cff7a;
  scrollbar-width:none;
}
.pb-chat-rich-editor::-webkit-scrollbar{display:none}
.pb-chat-rich-editor:focus,.pb-chat-rich-editor:focus-visible{border:0;outline:0;box-shadow:none}
.pb-chat-rich-editor[data-empty="1"]::before{
  content:attr(data-placeholder);
  color:#9ba8bc;
  pointer-events:none;
}
.pb-chat-editor-emoji{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:30px;
  height:30px;
  margin:0 2px;
  vertical-align:-8px;
  user-select:none;
  -webkit-user-select:none;
}
.pb-chat-editor-emoji img{display:block;width:30px;height:30px;object-fit:contain;pointer-events:none}
#chatcomposerrow.pb-chat-rich-active #chatemojiinline{display:none!important}
#chatcomposerrow.has-inline-emoji #chatinput::placeholder{
  color:transparent!important;
  opacity:0!important;
}
#chatemojiinline{
  display:none;
  flex:0 1 auto;
  align-self:center;
  align-items:center;
  min-width:0;
  max-width:48%;
  height:40px;
  gap:3px;
  overflow-x:auto;
  overflow-y:hidden;
  scrollbar-width:none;
  overscroll-behavior-x:contain;
}
#chatemojiinline::-webkit-scrollbar{display:none}
#chatemojiinline.on{display:flex}
.pb-chat-inline-emoji{
  display:grid;
  place-items:center;
  flex:0 0 30px;
  width:30px;
  height:30px;
  margin:0;
  padding:0;
  border:0;
  border-radius:0;
  outline:0;
  background:transparent;
  box-shadow:none!important;
  appearance:none;
  -webkit-appearance:none;
}
.pb-chat-inline-emoji img{
  display:block;
  width:30px;
  height:30px;
  object-fit:contain;
  pointer-events:none;
}
#chatcomposerrow .chatcomposer-iconbtn,
#chatcomposerrow #chatimgbtn,
#chatcomposerrow #chatsend{
  display:grid!important;
  place-items:center!important;
  flex:0 0 40px!important;
  width:40px!important;
  min-width:40px!important;
  height:40px!important;
  min-height:40px!important;
  align-self:center!important;
  box-sizing:border-box!important;
  margin:0!important;
  padding:0!important;
  border:0!important;
  border-radius:0!important;
  outline:0!important;
  background:transparent!important;
  box-shadow:none!important;
  transform:none!important;
  appearance:none!important;
  -webkit-appearance:none!important;
  color:#d7e0eb!important;
  touch-action:manipulation;
}
#chatcomposerrow .chatcomposer-iconbtn:hover,
#chatcomposerrow .chatcomposer-iconbtn:focus-visible,
#chatcomposerrow #chatimgbtn:hover,
#chatcomposerrow #chatimgbtn:focus-visible,
#chatcomposerrow #chatsend:hover,
#chatcomposerrow #chatsend:focus-visible{
  border:0!important;
  outline:0!important;
  background:rgba(255,255,255,.035)!important;
  box-shadow:none!important;
}
#chatcomposerrow #chatsend{color:#47df73!important}
#chatcomposerrow #chatsend[data-composer-mode="disabled"]{
  opacity:.42!important;
  cursor:default!important;
}
#chatcomposerrow #chatsend.pb-chat-flood{
  flex-basis:auto!important;
  width:auto!important;
  min-width:68px!important;
  padding:0 9px!important;
  color:#e9f0ec!important;
  background:#27313e!important;
  font-size:11px!important;
}
#chatcomposerrow .pb-lucide{width:23px!important;height:23px!important}
#chatinputwrap #chatmentionbox{
  left:0!important;
  right:0!important;
  bottom:calc(100% + 1px)!important;
}

/* A370: attachment and special previews stay inside the composer flow.
   The footer grows and the message list shrinks, so the latest message is never covered. */
#chatimgpreviewbar.pbu-queue,
#chatemojipreviewbar{
  position:relative!important;
  left:auto!important;
  right:auto!important;
  bottom:auto!important;
  z-index:2!important;
  order:-1!important;
  flex:0 0 auto!important;
  width:100%!important;
  max-height:92px!important;
  box-sizing:border-box!important;
  margin:0!important;
  padding:8px 10px!important;
  overflow:hidden!important;
  border:0!important;
  border-bottom:1px solid var(--pb-composer-line)!important;
  border-radius:0!important;
  background:#121a27!important;
  box-shadow:none!important;
}
#chatimgpreviewbar.pbu-queue{display:none!important}
#chatimgpreviewbar.pbu-queue.on{display:flex!important}
#chatimgpreviewbar.pbu-queue .pbu-item{
  width:100%!important;
  min-height:52px!important;
  box-sizing:border-box!important;
  border:0!important;
  border-radius:12px!important;
  background:#182131!important;
  box-shadow:none!important;
}
#chatimgpreviewbar.pbu-queue .pbu-preview{
  width:42px!important;
  min-width:42px!important;
  height:42px!important;
  border-radius:10px!important;
}
#chatemojipreviewbar{display:none!important}
#chatemojipreviewbar.on{display:flex!important;align-items:center!important;gap:8px!important}
.pb-chat-special-preview img{width:34px;height:34px;object-fit:contain;flex:0 0 auto}
.pb-chat-special-preview-copy{display:flex;flex:1;min-width:0;flex-direction:column;gap:2px}
.pb-chat-special-preview-copy b{font-size:12px;color:#f2f6f4;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pb-chat-special-preview-copy span{font-size:10px;color:#8f9b95}
.pb-chat-special-preview button{width:30px;height:30px;display:grid;place-items:center;border:0;border-radius:9px;background:transparent;color:#cfd6d2;box-shadow:none}
.pb-chat-special-preview .pb-lucide{width:17px;height:17px}

#chatmediapicker{
  left:auto!important;
  right:0!important;
  bottom:100%!important;
  z-index:47!important;
  border:1px solid var(--pb-composer-line)!important;
  border-radius:0!important;
  background:#182131!important;
  box-shadow:none!important;
}
#chatmediapicker .chatmediachoice,
#chatmediapicker #chatgifbtn{
  border-radius:0!important;
  background:transparent!important;
  box-shadow:none!important;
}

/* Three visible emoji rows; the rest scrolls inside the flat panel. */
#chatemojipanel{
  --pb-emoji-row:60px;
  position:absolute;
  left:0;
  right:0;
  bottom:100%;
  z-index:48;
  display:none;
  height:260px;
  max-height:260px;
  overflow:hidden;
  box-sizing:border-box;
  border:1px solid var(--pb-composer-line);
  border-radius:0;
  background:#1a222a;
  box-shadow:none;
}
#chatemojipanel.on{display:flex;flex-direction:column}
.pb-chat-emoji-head{
  display:grid;
  grid-template-columns:minmax(0,1fr) 40px;
  align-items:center;
  flex:0 0 56px;
  height:56px;
  min-height:56px;
  box-sizing:border-box;
  gap:6px;
  padding:8px 10px;
  overflow:hidden;
  border-bottom:1px solid var(--pb-composer-line);
  background:#1a222a;
}
.pb-chat-emoji-tabs{
  display:flex;
  align-items:center;
  min-width:0;
  height:40px;
  gap:4px;
  overflow-x:auto;
  overflow-y:hidden;
  scrollbar-width:none;
}
.pb-chat-emoji-tabs::-webkit-scrollbar{display:none}
.pb-chat-emoji-tab,
.pb-chat-emoji-tool{
  display:grid;
  place-items:center;
  width:40px;
  min-width:40px;
  height:40px;
  min-height:40px;
  margin:0;
  padding:4px;
  border:0;
  border-radius:0;
  outline:0;
  background:transparent;
  color:#cdd6df;
  box-shadow:none;
  appearance:none;
  -webkit-appearance:none;
}
.pb-chat-emoji-tab{flex:0 0 40px}
.pb-chat-emoji-tab.active{background:#26313a;box-shadow:none}
.pb-chat-emoji-tab img{width:30px;height:30px;object-fit:contain}
.pb-chat-emoji-tool .pb-lucide{width:20px;height:20px}
.pb-chat-emoji-tab:hover,
.pb-chat-emoji-tool:hover,
.pb-chat-emoji-tab:focus-visible,
.pb-chat-emoji-tool:focus-visible{
  outline:0;
  background:#26313a;
  box-shadow:none;
}
.pb-chat-emoji-grid{
  display:grid;
  grid-template-columns:repeat(6,minmax(0,1fr));
  grid-auto-rows:var(--pb-emoji-row);
  align-content:start;
  flex:0 0 204px;
  height:204px;
  min-height:204px;
  max-height:204px;
  box-sizing:border-box;
  gap:4px;
  padding:8px;
  overflow-x:hidden;
  overflow-y:auto;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
  background:#1a222a;
}
.pb-chat-emoji-pick{
  display:grid;
  place-items:center;
  width:100%;
  height:var(--pb-emoji-row);
  min-width:0;
  min-height:var(--pb-emoji-row);
  box-sizing:border-box;
  margin:0;
  padding:4px;
  border:0;
  border-radius:0;
  outline:0;
  background:transparent;
  box-shadow:none;
  appearance:none;
  -webkit-appearance:none;
}
.pb-chat-emoji-pick:hover,
.pb-chat-emoji-pick:focus-visible{background:#242e36;outline:0;box-shadow:none}
.pb-chat-emoji-pick img{display:block;width:100%;height:100%;max-width:50px;max-height:50px;object-fit:contain}
.pb-chat-emoji-empty{grid-column:1/-1;display:grid;place-items:center;min-height:92px;color:#88938e;font-size:12px;text-align:center;padding:14px}
.pb-chat-emoji-manager{display:none;flex:1 1 auto;min-height:0;overflow:auto;padding:10px;border-top:0;background:#1a222a}
.pb-chat-emoji-manager.on{display:block}
#chatemojipanel:has(.pb-chat-emoji-manager.on) .pb-chat-emoji-grid{display:none}
.pb-chat-emoji-formrow{display:grid;grid-template-columns:minmax(0,1fr) 90px;gap:7px;margin-bottom:8px}
.pb-chat-emoji-manager input[type="text"],
.pb-chat-emoji-manager input[type="number"]{width:100%;min-width:0;height:36px;border:1px solid var(--pb-composer-line);border-radius:0;background:#222c35;color:#f0f4f2;padding:0 10px;outline:none;box-shadow:none}
.pb-chat-emoji-active{display:flex;align-items:center;gap:8px;color:#d9dfdc;font-size:12px;margin:4px 0 9px}
.pb-chat-emoji-active input{accent-color:#31c675}
.pb-chat-emoji-adminitems{display:flex;flex-direction:column;gap:1px}
.pb-chat-emoji-adminitem{display:grid;grid-template-columns:36px minmax(0,1fr) auto;align-items:center;gap:7px;padding:6px 4px;border-radius:0;background:#222c35}
.pb-chat-emoji-adminitem.preview{outline:1px solid rgba(52,211,125,.45);outline-offset:-1px}
.pb-chat-emoji-adminitem img{width:32px;height:32px;object-fit:contain;cursor:pointer}
.pb-chat-emoji-adminitem button{width:31px;height:31px;display:grid;place-items:center;border:0;border-radius:0;background:transparent;color:#d5dcda;box-shadow:none}
.pb-chat-emoji-adminmeta{font-size:12px;color:#cfd7d3;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pb-chat-emoji-actions{display:flex;gap:1px;flex-wrap:wrap;margin-top:9px}
.pb-chat-emoji-actions button,.pb-chat-emoji-upload-label{height:36px;display:inline-flex;align-items:center;justify-content:center;gap:6px;border:0;border-radius:0;background:#27313a;color:#e2e8e5;padding:0 11px;font-size:12px;cursor:pointer;box-shadow:none}
.pb-chat-emoji-actions .primary{background:#2dbb69;color:#08180f;font-weight:800}
.pb-chat-emoji-actions .danger{background:rgba(225,73,85,.14);color:#ff9da5}
.pb-chat-emoji-status{min-height:18px;margin-top:7px;color:#9aa59f;font-size:11px}

.pb-chat-custom-emoji{display:inline-flex;align-items:center;justify-content:center;border:0;background:transparent;padding:0 1px;vertical-align:-7px;line-height:1}
.pb-chat-custom-emoji img{display:block;width:min(28px,7.2vw);height:min(28px,7.2vw);object-fit:contain}
.chatreply .pb-chat-custom-emoji img{width:20px;height:20px;display:inline-block;vertical-align:middle}

/* GIFs stay compact and fully visible. */
.chatimg-wrap.is-gif,.chatimg-wrap.is-giphy{width:min(68%,260px)!important;max-width:260px!important}
.chatimg-wrap.is-gif img,.chatimg-wrap.is-giphy img{display:block!important;width:auto!important;max-width:100%!important;height:auto!important;max-height:230px!important;object-fit:contain!important}

@media(max-width:600px){
  #chatfoot.pb-chat-composer{padding-bottom:env(safe-area-inset-bottom,0px)!important}
  #chatcomposerrow,#chatcomposerrow #chatinputwrap{min-height:58px!important}
  #chatcomposerrow #chatinputwrap{gap:4px!important;padding:8px!important}
  #chatcomposerrow #chatinput{height:40px!important;min-height:40px!important;padding:9px 0!important;font-size:14px!important;line-height:22px!important}
  .pb-chat-rich-editor{min-height:40px;max-height:92px;padding:9px 0;font-size:14px;line-height:22px}
  #chatemojiinline{max-width:42%;height:40px;gap:2px}
  .pb-chat-inline-emoji{flex-basis:30px;width:30px;height:30px}
  #chatcomposerrow .chatcomposer-iconbtn,
  #chatcomposerrow #chatimgbtn,
  #chatcomposerrow #chatsend{flex-basis:38px!important;width:38px!important;min-width:38px!important;height:38px!important;min-height:38px!important}
  #chatemojipanel{--pb-emoji-row:60px;height:260px;max-height:260px}
  .pb-chat-emoji-head{grid-template-columns:minmax(0,1fr) 38px;gap:4px;padding:8px}
  .pb-chat-emoji-tab,.pb-chat-emoji-tool{width:38px;min-width:38px;height:38px;min-height:38px}
  .pb-chat-emoji-tab{flex-basis:38px}
  .pb-chat-emoji-grid{grid-template-columns:repeat(5,minmax(0,1fr));height:204px;min-height:204px;max-height:204px;flex-basis:204px;gap:4px;padding:8px}
  .pb-chat-emoji-pick img{max-width:52px;max-height:52px}
  .chatimg-wrap.is-gif,.chatimg-wrap.is-giphy{width:min(68vw,238px)!important;max-width:min(68vw,238px)!important}
  .chatimg-wrap.is-gif img,.chatimg-wrap.is-giphy img{max-height:215px!important}
}
@media(max-width:390px){
  #chatcomposerrow #chatinputwrap{padding:7px 6px!important}
  #chatemojiinline{max-width:38%}
  #chatcomposerrow .chatcomposer-iconbtn,
  #chatcomposerrow #chatimgbtn,
  #chatcomposerrow #chatsend{flex-basis:36px!important;width:36px!important;min-width:36px!important;height:36px!important;min-height:36px!important}
  #chatemojipanel{--pb-emoji-row:62px}
  .pb-chat-emoji-grid{gap:3px;padding:7px}
}

.pb-chat-emoji-head.is-admin{grid-template-columns:minmax(0,1fr) repeat(3,40px)}
@media(max-width:600px){
  .pb-chat-emoji-head.is-admin{grid-template-columns:minmax(0,1fr) repeat(3,38px)!important}
  body.pb-chat-emoji-open #chatpanel,body.pb-chat-emoji-open.tg-mode #chatpanel{transition:none!important}
}

/* A370 — reliable contenteditable focus on iPhone/Safari. */
.pb-chat-rich-editor{
  -webkit-user-select:text!important;
  user-select:text!important;
  -webkit-touch-callout:default!important;
  touch-action:manipulation!important;
}
@supports (-webkit-touch-callout:none){
  .pb-chat-rich-editor{cursor:text!important}
}


/* A373 — iPhone/Safari: reply focus must keep the composer above the keyboard. */
@supports (-webkit-touch-callout:none){
  body.pb-chat-ios-keyboard #chatpanel,
  body.pb-chat-ios-keyboard.tg-mode #chatpanel{
    height:var(--pb-chat-kb-height,520px)!important;
    max-height:var(--pb-chat-kb-height,520px)!important;
    transform:translate3d(0,calc(-1 * var(--pb-chat-kb-shift,0px)),0)!important;
    transition:none!important;
    will-change:transform,height;
  }
  body.pb-chat-ios-keyboard #chatmsgs{
    min-height:0!important;
    overscroll-behavior:contain!important;
    -webkit-overflow-scrolling:touch;
  }
  body.pb-chat-ios-keyboard #chatfoot.pb-chat-composer{
    flex:0 0 auto!important;
    padding-bottom:max(2px,env(safe-area-inset-bottom,0px))!important;
  }
  body.pb-chat-ios-keyboard .pb-chat-rich-editor{
    font-size:16px!important;
    line-height:22px!important;
  }
}
