/* NEAR Chat (VK-like) */
.nearChatFab{
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px dashed rgba(150,150,150,0.35);
  background: rgba(255,255,255,0.7);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  cursor: pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 9999;
  transition: transform .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  color: #111;
}
.nearChatFab:hover{
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.nearChatFab:active{
  transform: scale(0.95);
}

.nearChatBadge{
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #e63946;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border: 2px solid var(--bg);
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

.nearChatPanel{
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: min(560px, calc(100vw - 44px));
  height: min(720px, 85vh);
  border: 2px dashed rgba(150,150,150,0.35);
  background: rgba(255,255,255,0.7);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-radius: 16px;
  overflow: hidden;
  z-index: 9999;
  display:none;
  box-shadow: 0 10px 25px rgba(0,0,0,.12);
  box-sizing: border-box;
}

.nearChatHead{
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 52px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 2px dashed rgba(150,150,150,0.35);
  font-weight: 900;
  background:rgba(255,255,255,0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-sizing:border-box;
  position: relative;
  z-index: 2;
}

.nearChatPinned{
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  min-height: 48px;
  display: none;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
  background: rgba(255,250,230,0.9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 2px dashed rgba(150,150,150,0.35);
  box-sizing: border-box;
  z-index: 1;
}

.nearChatPinnedNav{
  border: 2px dashed rgba(150,150,150,0.35);
  background: rgba(255,255,255,0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all .2s ease;
  flex-shrink: 0;
}

.nearChatPinnedNav:hover{
  background: rgba(255,255,255,0.95);
  transform: scale(1.1);
}

.nearChatPinnedUnpinAll{
  border: 2px dashed rgba(150,150,150,0.35);
  background: rgba(255,200,200,0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all .2s ease;
  flex-shrink: 0;
}

.nearChatPinnedUnpinAll:hover{
  background: rgba(255,150,150,0.9);
  transform: scale(1.1);
}

.nearChatPinnedContent{
  flex: 1;
  min-width: 0;
  cursor: pointer;
  transition: opacity .2s ease;
}

.nearChatPinnedContent:hover{
  opacity: 0.8;
}

.nearChatPinnedClose{
  border: 2px dashed rgba(150,150,150,0.35);
  background: rgba(255,255,255,0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 10px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
  transition: transform .15s ease;
  flex-shrink: 0;
}

.nearChatPinnedClose:hover{
  transform: scale(1.1);
}

.nearChatHeadAva{
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px dashed rgba(150,150,150,0.35);
  flex-shrink: 0;
}

.nearChatHeadAvaEmpty{
  background: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nearChatHeadAvaEmpty svg{
  width: 14px;
  height: 14px;
  color: #999;
}

.nearChatHeadInfo{
  display: flex;
  align-items: center;
  gap: 8px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.nearChatBack{
  position: absolute;
  left: 12px;
}

.nearChatClose{
  position: absolute;
  right: 12px;
}

.nearChatBack{
  display:none;
  border:2px dashed rgba(150,150,150,0.35);
  background:rgba(255,255,255,0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 7px 12px;
  cursor:pointer;
  transition: transform .15s ease;
}
.nearChatBack:hover{ transform: translateY(-1px); }

.nearChatClose{
  border:2px dashed rgba(150,150,150,0.35);
  background:rgba(255,255,255,0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 7px 12px;
  cursor:pointer;
  transition: transform .15s ease;
}
.nearChatClose:hover{ transform: translateY(-1px); }

.nearChatBody{
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  background: rgba(248,248,250,0.4);
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(150,150,150,0.3) transparent;
}

.nearChatPanel:has(.nearChatFoot[style*="display: flex"]) .nearChatBody,
.nearChatPanel:has(.nearChatFoot[style*="display:flex"]) .nearChatBody{
  bottom: 82px;
}

.nearChatPanel:has(.nearChatPinned[style*="display: flex"]) .nearChatBody,
.nearChatPanel:has(.nearChatPinned[style*="display:flex"]) .nearChatBody{
  top: 100px;
}

.nearChatBody::-webkit-scrollbar{
  width: 6px;
}

.nearChatBody::-webkit-scrollbar-track{
  background: transparent;
}

.nearChatBody::-webkit-scrollbar-thumb{
  background: rgba(150,150,150,0.3);
  border-radius: 3px;
}

.nearChatBody::-webkit-scrollbar-thumb:hover{
  background: rgba(150,150,150,0.5);
}

.nearChatFoot{
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 2px dashed rgba(150,150,150,0.35);
  background:rgba(255,255,255,0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-sizing:border-box;
  display:none;
  flex-direction:column;
  padding-bottom: 20px;
}

.nearChatFoot[style*="display: flex"],
.nearChatFoot[style*="display:flex"]{
  display:flex;
}

.nearReplyBoxTop{
  order:-1 !important;
}

.nearChatInputRow{
  order:0 !important;
}

#nearChatPreview{
  order:1 !important;
}

.nearChatInput{
  width: 100%;
  border:2px dashed rgba(150,150,150,0.35);
  border-radius: 14px;
  padding: 10px 12px;
  outline:none;
  height: 42px;
  box-sizing:border-box;
  background:rgba(255,255,255,0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #111;
  font-size: 14px;
}
.nearChatInput:focus{
  border-color:rgba(150,150,150,0.5);
  background:rgba(255,255,255,0.9);
}
.nearChatInput::placeholder{
  color: #999;
}

.nearChatBtn{
  border:2px dashed rgba(150,150,150,0.35);
  background:rgba(255,255,255,0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  cursor:pointer;
  min-width: 46px;
  height: 42px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 0 12px;
  box-sizing:border-box;
  transition: transform .15s ease;
  flex-shrink: 0;
}
.nearChatBtn:hover{ transform: translateY(-2px); }

.nearChatListItem{
  background:rgba(255,255,255,0.7);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border:2px dashed rgba(150,150,150,0.35);
  border-radius: 14px;
  padding: 10px 12px;
  cursor:pointer;
  margin-bottom: 8px;
  transition: transform .15s ease, border-color .15s ease;
}
.nearChatListItem:last-child{
  margin-bottom: 0;
}
.nearChatListItem:hover{
  transform: translateY(-2px);
  border-color:rgba(150,150,150,0.5);
}

.nearChatListAva{
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px dashed rgba(150,150,150,0.35);
}

.nearChatListAvaEmpty{
  background: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nearChatListAvaEmpty svg{
  color: #999;
}

.nearChatItemBadge{
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e63946;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* messages */
.nearMsgRow{
  display:flex;
  flex-direction: column;
  margin: 7px 0;
}
.nearMsgMe{
  align-items: flex-end;
}
.nearMsgOther{
  align-items: flex-start;
  position:relative;
}

.nearMsgBubble{
  max-width: 82%;
  background:rgba(255,255,255,0.85);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border:2px dashed rgba(150,150,150,0.35);
  border-radius: 16px;
  padding: 10px 13px;
  overflow-wrap:anywhere;
  word-break:break-word;
  position:relative;
  line-height:1.5;
  font-size:14px;
}

.nearMsgMe .nearMsgBubble{
  border:2px dashed rgba(150,150,150,0.35);
  background:rgba(255,255,255,0.95);
}

.nearMsgStatus{
  font-size: 10px;
  color: #999;
  margin-top: 3px;
  padding: 0 4px;
}

/* image msg */
.nearMsgImg{
  width: 100%;
  max-width: 360px;
  border-radius: 16px;
  border:2px dashed rgba(150,150,150,0.35);
  display:block;
  cursor: zoom-in;
  transition: transform .2s ease;
}

.nearMsgImg:hover{
  transform: scale(1.02);
}

.nearChatModalBg{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.45);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display:none;
  align-items:center;
  justify-content:center;
  z-index: 5;
}
.nearChatModal{
  width: min(420px, calc(100% - 24px));
  background:rgba(255,255,255,0.9);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border:1px solid rgba(255,255,255,0.3);
  border-radius: 16px;
  padding: 14px;
  box-sizing:border-box;
}
.nearChatModalTop{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom: 10px;
  font-weight: 900;
}
.nearChatModalX{
  border:1px solid #111;
  background:rgba(255,255,255,0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 6px 10px;
  cursor:pointer;
  transition: transform .15s ease;
}
.nearChatModalX:hover{ transform: translateY(-1px); }

.nearDrop{
  border:2px dashed rgba(150,150,150,0.3);
  border-radius: 14px;
  padding: 14px;
  background:rgba(250,250,250,0.5);
}
.nearHint{
  font-size:12px;
  color:#777;
  margin-top:8px;
}
.nearUploadBtn{
  margin-top: 10px;
  width: 100%;
  height: 44px;
  border-radius: 14px;
  border:1px solid #111;
  background:rgba(255,255,255,0.8);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor:pointer;
  font-weight: 800;
  transition: transform .15s ease;
}
.nearUploadBtn:hover{ transform: translateY(-2px); }

/* fullscreen image viewer */
.nearImgViewer{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.75);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display:none;
  align-items:center;
  justify-content:center;
  z-index: 10000;
  animation: fadeIn .2s ease;
}

@keyframes fadeIn{
  from{ opacity:0; }
  to{ opacity:1; }
}

.nearImgViewerBox{
  width: min(94vw, 1100px);
  height: min(90vh, 850px);
  background:#0000;
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
}

.nearImgViewerImg{
  max-width:100%;
  max-height:100%;
  border-radius: 16px;
  border: 2px solid rgba(255,255,255,.3);
  display:block;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  transition: transform .3s ease;
}

.nearImgViewerImg:hover{
  transform: scale(1.02);
}

.nearImgViewerClose{
  position:absolute;
  top: -8px;
  right: -8px;
  border:2px dashed rgba(255,255,255,0.5);
  color:#fff;
  background: rgba(0,0,0,.6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 10px 14px;
  cursor:pointer;
  font-weight:900;
  transition: all .2s ease;
}

.nearImgViewerClose:hover{
  background: rgba(0,0,0,.8);
  border-color:rgba(255,255,255,0.8);
  transform: scale(1.1);
}

.nearMsgReply{
  background:rgba(220,220,220,0.4);
  border-left:4px solid rgba(100,100,100,0.6);
  padding:8px 12px;
  margin-bottom:8px;
  border-radius:10px;
  font-size:12px;
  color:#444;
  cursor:pointer;
  max-width:85%;
  overflow:hidden;
  text-overflow:ellipsis;
  transition: all .2s ease;
}

.nearMsgReply:hover{
  background:rgba(220,220,220,0.6);
  border-left-color:rgba(100,100,100,0.8);
  transform: translateX(2px);
}

.nearMsgActions{
  position:absolute;
  top:50%;
  transform:translateY(-50%);
  display:flex;
  gap:6px;
  opacity:0;
  transition:opacity .2s ease;
}

.nearMsgRow:hover .nearMsgActions{
  opacity:1;
}

.nearMsgActionsLeft{
  left:-105px;
}

.nearMsgActionsRight{
  right:-105px;
}

.nearMsgActionBtn{
  width:28px;
  height:28px;
  border-radius:8px;
  border:2px dashed rgba(150,150,150,0.35);
  background:rgba(255,255,255,0.95);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0;
  transition:all .2s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}

.nearMsgActionBtn:hover{
  background:#fff;
  border-color:rgba(150,150,150,0.5);
  transform:translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
}

.nearMsgActionBtn svg{
  stroke:#333;
  stroke-width:2.2;
}

@media (max-width: 768px) {
  .nearChatPanel{
    width: 100vw;
    height: 100dvh;
    right: 0;
    bottom: 0;
    top: 0;
    left: 0;
    border-radius: 0;
    border: none;
  }

  .nearChatFab{
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .nearChatFoot{
    bottom: 0;
    padding-bottom: 20px;
  }

  .nearChatBody{
    bottom: 82px;
    min-height: auto;
  }

  .nearChatPanel:has(.nearChatFoot[style*="display: flex"]) .nearChatBody,
  .nearChatPanel:has(.nearChatFoot[style*="display:flex"]) .nearChatBody{
    bottom: 82px;
  }

  .nearMsgActions{
    position:static;
    transform:none;
    opacity:1;
    margin-top:8px;
    justify-content:flex-start;
  }

  .nearMsgImg{
    max-width: 90%;
  }
}

.nearUnpinModalBg{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.5);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display:none;
  align-items:center;
  justify-content:center;
  z-index: 10;
  animation: fadeIn .2s ease;
}

.nearUnpinModal{
  width: min(360px, calc(100% - 32px));
  background:rgba(255,255,255,0.95);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border:2px dashed rgba(150,150,150,0.35);
  border-radius: 16px;
  padding: 20px;
  box-sizing:border-box;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
}

.nearUnpinModalTitle{
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 16px;
  text-align: center;
  color: #222;
}

.nearUnpinModalButtons{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nearUnpinModalBtn{
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border:2px dashed rgba(150,150,150,0.35);
  background:rgba(255,255,255,0.9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor:pointer;
  font-weight: 700;
  font-size: 14px;
  transition: all .2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
}

.nearUnpinModalBtn:hover{
  background:#fff;
  border-color:rgba(150,150,150,0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}

.nearUnpinModalBtn.danger{
  background:rgba(255,240,240,0.9);
  border-color:rgba(230,57,70,0.4);
  color:#e63946;
}

.nearUnpinModalBtn.danger:hover{
  background:rgba(255,230,230,0.95);
  border-color:rgba(230,57,70,0.6);
}

.nearUnpinModalBtn.cancel{
  background:rgba(245,245,245,0.9);
  color:#666;
}

.nearUnpinModalBtn.cancel:hover{
  background:rgba(240,240,240,0.95);
}
