:root{
  --bg-deep: #0a0612;
  --panel: #170f28;
  --panel-2: #1e1436;
  --line: #2c1f47;
  --pink: #ff5fa8;
  --cyan: #4eecec;
  --lilac: #cdc3ea;
  --lilac-dim: #8d80b0;
  --danger: #ff5f5f;
}

*::-webkit-scrollbar{
  display: none;              /* Chrome / Safari / Edge */
}

*{ box-sizing: border-box; }

body{
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 20% -10%, #22123f 0%, var(--bg-deep) 55%);
  color: var(--lilac);
  font-family: 'Inter', system-ui, sans-serif;
}
html, body {
  overflow-x: hidden;
  overscroll-behavior-x: none; /* also stops the edge-swipe back/forward gesture on mobile Chrome/Edge */
   touch-action: pan-y;
   max-width: 100%;
}html, body {
    max-width: 100%;
    overflow-x: hidden;
}
button.voice-play.playing {
    word-spacing: -2px !important;
    font-weight: bolder;
}
button#photoBtn {
    padding-bottom: 3px!important;
}
h1, h2, .brand{
  font-family: 'Press Start 2P', system-ui, sans-serif;
}


a{ color: var(--cyan); }

/* ---------- Auth pages ---------- */
.auth-wrap{
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#connStatus {
    opacity: 0;
}

@media (max-width: 640px) {
    .wallpaper-btn::before {
        content: "ï¸";
        font-size: 14px;
        margin-top: -17px;opacity:0!important;
    }
}

.auth-card{
  width: 100%;
  max-width: 380px;
  background-image: linear-gradient(rgba(10, 6, 18, 0.55), rgba(10, 6, 18, 0.55)), url(bg-dark.jpg);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 0 40px rgba(255, 95, 168, 0.08);
}

.auth-card .brand{
  font-size: 14px;
  color: var(--pink);
  text-align: center;
  margin: 0 0 8px;
  letter-spacing: 1px;
  text-shadow: 0 0 18px rgba(244, 114, 182, 0.55), 0 0 2px rgba(244, 114, 182, 0.8);
}

.auth-card h1{
  font-size: 11px;
  color: var(--cyan);
  text-align: center;
  margin: 0 0 28px;
  font-weight: 400;
     text-shadow: 0 0 18px rgba(244, 114, 182, 0.55), 0 0 2px rgb(114 146 244 / 80%);

}
span.lock-badge {
    font-size: 9px;
    opacity: 0.4;
    color: #4cff4c;
    
}

label{
  display: block;
  font-size: 12px;
  color: var(--lilac-dim);
  margin: 16px 0 6px;
}

input[type=text], input[type=password]{
    width: 100%;
    padding: 12px 14px;
    background: #28194600;
    border: 1px solid var(--line);
    border-radius: 18px;
    color: var(--lilac);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}
input[type=text]:focus, input[type=password]:focus{
  border-color: var(--pink);
}

.btn{
  width: 100%;
  margin-top: 24px;
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--pink), #c34e86);
  color: #170f28;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s;
}
.btn:hover{ box-shadow: 0 0 20px rgba(255, 95, 168, 0.35); }
.btn:active{ transform: scale(0.98); }

.btn.secondary{
  background: transparent;
  border: 1px solid var(--line);
  color: var(--cyan);
}

.switch-link{
  text-align: center;
  margin-top: 18px;
  font-size: 13px;
  color: var(--lilac-dim);
}
div#messages {
    background-image: linear-gradient(rgb(0 0 0 / 13%), rgb(54 18 64 / 0%)), url(bg-dark.jpg);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.error{
  background: rgba(255, 95, 95, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-top: 16px;
}

/* ---------- Chat page ---------- */
.chat-shell{
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar (conversation list) ---------- */
.sidebar{
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.sidebar-header{
  padding: 16px 20px;
}

.sidebar-header .brand{
  font-size: 13px;
  color: var(--pink);
  margin: 0 0 10px;
}

.sidebar-header .who{
  font-size: 12px;
  color: var(--cyan);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.my-profile{
  display: flex;
  align-items: center;
  gap: 10px;
}

.my-avatar{
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: linear-gradient(135deg, var(--pink), var(--cyan));
  color: #170f28;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.my-avatar:hover{ border-color: var(--pink); }
.my-avatar img{
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.my-username-link{
  background: none;
    border: none;
    text-shadow: 0 0 15px #ffffff33;
    padding: 0;
    margin: 0;
    font-size: 16px !important;
    font: icon;
    /* font-family: fantasy; */
    color: inherit;
    cursor: pointer;
}
.my-username-link:hover{ color: var(--pink);text-shadow: 1px 1px 10px #aaaaaa; }

.avatar-error{
  color: var(--danger);
  font-size: 11px;
  margin-top: 8px;
  
}

.new-chat{
  padding: 0 20px 14px;
  border-bottom: 1px solid var(--line);
}

.new-chat-toggle{
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-deep);
  color: var(--cyan);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.new-chat-toggle:hover{ border-color: var(--cyan); }

.new-chat-form{
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.new-chat-form input[type=text]{
  flex: 1;
  padding: 9px 12px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--lilac);
  font-size: 16px;
  font-family: inherit;
  outline: none;
}
.new-chat-form input[type=text]:focus{ border-color: var(--pink); }

.btn-small{
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  background: linear-gradient(135deg, var(--pink), #c34e86);
  color: #170f28;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.new-chat-error{
  color: var(--danger);
  font-size: 11px;
  margin-top: 8px;
}

.conv-list{
  flex: 1;
  overflow-y: auto;
}

.conv-empty{
  padding: 24px 20px;
  color: var(--lilac-dim);
  font-size: 13px;
  text-align: center;
}

.conv-item{
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: padding-right .15s, background .15s;
}
.conv-item:hover{ background: var(--panel-2); }
.conv-item.active{ background: var(--panel-2); border-left: 3px solid var(--pink); padding-left: 17px; }
.conv-item.selected{ background: rgba(78,236,236,0.09); }
.conv-list.selecting .conv-item{ padding-right: 46px; }

.conv-check{
  position: absolute;
  right: 25px;
  top: 65%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 2px solid var(--line);
  background: var(--bg-deep);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s, border-color .15s;
  padding: 0;
  flex-shrink: 0;
}
.conv-item:hover .conv-check,
.conv-list.selecting .conv-check{ opacity: 1; }
.conv-item.selected .conv-check{
  opacity: 1;
  background: #2bcf85;
  border-color: #2bcf85;
  
}
.conv-item.selected .conv-check::after{
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #0a0612;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.conv-selection-bar{
  border-top: none;
  border-bottom: 1px solid var(--line);
}

.conv-item.unread .conv-username{
  color: #fff;
  font-weight: 800;
}
.conv-item.unread .conv-preview{
  color: var(--lilac);
  font-weight: 600;
}
.conv-item.unread .conv-time{
  color: var(--cyan);
}
.conv-unread-dot{
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 8px rgba(255, 95, 168, 0.7);
  flex-shrink: 0;
}

.conv-avatar{
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--cyan));
  color: #170f28;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.conv-avatar img{
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.conv-body{
  flex: 1;
  min-width: 0;
}

.conv-top{
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.conv-name-wrap{
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.conv-username{
  color: var(--lilac);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-time{
  font-size: 11px;
  color: var(--lilac-dim);
  flex-shrink: 0;
}

.conv-preview{
  font-size: 12px;
  color: var(--lilac-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* ---------- Chat panel ---------- */
.chat-panel{
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-placeholder{
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: var(--lilac-dim);
  font-size: 14px;
}

.chat-active{
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: -17px;
}

.back-btn{
  display: none;
  border: none;
  background: transparent;
  color: var(--cyan);
  font-size: 18px;
  cursor: pointer;
  margin-right: 4px;
}

.peer-name{ color: var(--cyan); }

.peer-info{
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}
.peer-info .peer-name {
    margin: 0;
    cursor: pointer;
    top: 23px;
    position: absolute;
}

.peer-presence-text {
    margin: 13px 1px -11px;
    font-size: 12px;
    color: #888;
}
.peer-presence-text.is-online{ color: #3ddc84; }

.peer-typing{
  margin: 0;
    font-size: 12px;
    color: #777;
    /* display: flex; */
    align-items: center;
    position: fixed;
    top: 39px!important;
    margin-left:4px;
}
.peer-typing .dots span{
  animation: peer-typing-blink 1.4s infinite both;
}
.peer-typing .dots span:nth-child(2){ animation-delay: .2s; }
.peer-typing .dots span:nth-child(3){ animation-delay: .4s; }
@keyframes peer-typing-blink{
  0%, 80%, 100% { opacity: .2; }
  40% { opacity: 1; }
}
button#myUsernameBtn {
    font-weight: bold;
    font-size: 20px !important;
}
.peer-avatar-inner{
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--cyan));
  color: #170f28;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.peer-avatar-inner img{
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-header{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 19px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position:relative;
}

.wallpaper-controls{
  margin-left: auto;
  display: flex;
 
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.wallpaper-btn{
  background: transparent;
  color: var(--lilac-dim);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.wallpaper-btn:hover{ border-color: var(--pink); color: var(--pink); }

.wallpaper-reset {
    background: transparent;
    color: var(--lilac-dim);
    border: 1px solid var(--line);
    width: 26px;
    height: 26px;
    padding-top: 5px;
    border-radius: 8px;
    padding-left: 7px;
    font-size: 12px;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}
.wallpaper-reset:hover{ border-color: var(--pink); color: var(--pink); }

@media (min-width: 758px) {
.conn-status {
   
}
    .status-pc {
        left: 97px !important;
        top: 35px !important;
    }
     .status-phone {
       
    }

}


@media (max-width: 758px) {
.conn-status {
   
}
    .status-pc {
        left: 97px !important;
        top: 35px !important;
    }
     .status-phone {
        
    }

}


@media (max-width: 640px) {
  .wallpaper-btn{        display: grid;
        width: 80px;
        height: 25px;
        justify-content: center;
        justify-items: center;
        align-content: center;
        grid-auto-flow: row;}
  .wallpaper-btn::before{
    content: "ï¸";
    font-size: 14px;
    margin-top: -17px;
  }
  .status-pc {
        
    }
    .wallpaper-reset {
               padding-left: 8px!Important;
        padding-bottom: 19px !important;
        padding-top: 2px!Important;
        font-size: 15px!Important;
    }
  .conn-status{    background: none!important;backdrop-filter:blur(0px)!important;}
  button#photoBtn {
    padding-bottom: 4px!important;
}
button#myUsernameBtn {
    font-weight: bold;
    font-size: 20px !important;
}
.my-username-link{
  background: none;
    border: none;
    text-shadow: 0 0 15px #ffffff33;
    padding: 0;
    margin: 0;
    font-size: 25px !important;
    font: icon;
    /* font-family: fantasy; */
    color: inherit;
    cursor: pointer;
}

}

.logout-link{
  color: var(--lilac-dim);
  text-decoration: none;
  font-size: 12px;
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 8px;
}
.logout-link:hover{ border-color: var(--pink); color: var(--pink); }

.messages{
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;

  /* Wallpaper: drop your image at assets/wallpaper.jpg (or change the
     filename below). The dark gradient on top just dims it a bit so
     it doesn't fight with the message bubbles â€” tweak the 0.55 opacity
     or delete that layer entirely if you want it at full brightness. */
  background-image: linear-gradient(rgba(10,6,18,0.55), rgba(10,6,18,0.55)), url('wallpaper.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Wraps #messages so the scroll-to-bottom arrow can be pinned to the
   visible viewport of the (scrolling) message list, instead of scrolling
   away with the content. */
.messages-wrap{
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
}
.messages-wrap .messages{
  flex: 1;
}

.scroll-bottom-btn{
  position: absolute;
  right: 20px;
  bottom: 16px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--cyan);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  z-index: 5;
  transition: border-color .15s, transform .15s;
}
.scroll-bottom-btn:hover{
  border-color: var(--pink);
  transform: translateY(-2px);
}
.scroll-bottom-arrow{
  font-size: 18px;
  line-height: 1;
}
.scroll-bottom-badge{
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--pink);
  color: #170f28;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 2px!important;
}

.msg-outer{
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 4px 34px 4px 6px;
  margin: -4px -6px;
  border-radius: 10px;
  transition: background .15s;
}
.msg-outer.mine{ align-items: flex-end; }
.msg-outer.theirs{ align-items: flex-start; }
.msg-outer:hover{ background: rgba(255,255,255,0.035); }
.msg-outer.selected{ background: rgba(78,236,236,0.09); }

@keyframes flashHighlight {
  0% { background: rgba(255,95,168,0.35); }
  100% { background: transparent; }
}
.msg-outer.flash{ animation: flashHighlight 1.2s ease; }

.msg-check {
    position: absolute;
    right: 16px;
    top: 36%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border-radius: 6px;
    border: 2px solid var(--line);
    background: var(--bg-deep);
    cursor: pointer;
    opacity: 0.1;
    transition: opacity .15s, background .15s, border-color .15s;
    padding: 0;
    margin-right: -5px;
}
.msg-outer:hover .msg-check{ opacity: 1; }
.messages.selecting .msg-check{ opacity: 1; }
.msg-outer.selected .msg-check{
  opacity: 1;
  background: #2bcf85;
  border-color: #2bcf85;
}
.msg-outer.selected .msg-check::after {
    content: '';
    position: absolute;
    /* font-size: 1px; */
    left: 4px;
    top: 1px;
    width: 3px;
    height: 6px;
    border: solid #0a0612;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.msg-row{
  display: flex;
  flex-direction: column-reverse;
  max-width: 70%;
}
.msg-outer.mine .msg-row{ align-items: flex-end; }
.msg-outer.theirs .msg-row{ align-items: flex-start; }
.msg-outer{margin-right:  0px;right: -12px;}
.msg-meta{
  font-size: 11px;
  color: var(--lilac-dim);
  margin-bottom: 4px;
}
.msg-meta .uname{ color: var(--cyan); }
.msg-row.mine .msg-meta .uname{ color: var(--pink); }

.msg-status{
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  vertical-align: -1px;
  color: var(--lilac-dim);
}
.msg-status.read{ color: var(--cyan); }

.bubble{
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.msg-row.mine .bubble{
              background: linear-gradient(156deg, rgb(232 24 157 / 59%), rgb(246 133 252 / 62%));
    border-color: rgb(87 37 84);
}

.bubble-text{ white-space: pre-wrap;color:white; }

/* Photos and videos ship as bare media, not inside a chat bubble â€” only
   text (and file/voice) messages keep the bubble treatment. */
.bubble.bubble-media{
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 10px;
}
.msg-row.mine .bubble.bubble-media{
  background: transparent;
  border: none;
}
span.mention-link {
    color: #ffd146;
    font-weight: bold;
    cursor: pointer;
}

.reply-quote{
  border-left: 3px solid var(--cyan);
  background: rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 5px 9px;
  margin-bottom: 6px;
  cursor: pointer;
}
.reply-quote-user{ color: var(--cyan); font-weight: 600; font-size: 12px; margin-bottom: 1px; }
.msg-outer.mine .reply-quote{ border-left-color: var(--pink); }
.msg-outer.mine .reply-quote .reply-quote-user{ color: var(--pink); }
.reply-quote-text{
  color: var(--lilac-dim);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.bubble img.chat-photo{
  max-width: 260px;
  max-height: 260px;
  border-radius: 10px;
  display: block;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}

.bubble video.chat-video{
  max-width: 260px;
  max-height: 320px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
  border-radius: 10px;
  display: block;
}

.file-chip{
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--lilac);
  font-size: 13px;
}
.file-chip .ext{
  background: var(--cyan);
  color: #0a0612;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 6px;
}
.file-chip .fname{ text-decoration: underline; }
.file-chip .fsize{ color: var(--lilac-dim); font-size: 11px; }

.voice-bubble{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}
.voice-play{
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: var(--cyan);
  color: #0a0612;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 6px; /* optically center the â–¶ glyph */
}
.voice-play.playing{ padding-left: 0; background: var(--pink); }
.msg-outer.mine .voice-play{ background: var(--pink); }
.msg-outer.mine .voice-play.playing{ background: var(--cyan);
padding-left: 6px;}

.voice-play.playing {
    padding-left: 6px;
    font-size: 17px;
    background: var(--pink);
}
.voice-track{
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.voice-progress{
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  background: var(--cyan);
  border-radius: 999px;
}
.msg-outer.mine .voice-progress{ background: var(--pink); }

.voice-time{
  font-size: 11px;
  color: var(--lilac-dim);
  flex-shrink: 0;
  min-width: 32px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.reply-preview{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--panel-2);
  border-top: 1px solid var(--line);
}
.reply-preview-bar{
  width: 3px;
  align-self: stretch;
  background: var(--cyan);
  border-radius: 2px;
  flex-shrink: 0;
}
.reply-preview-body{
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.reply-preview-label{
  font-size: 12px;
  color: var(--cyan);
  font-weight: 600;
}
.reply-preview-text{
  font-size: 12px;
  color: var(--lilac-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-preview-cancel{
  border: none;
  background: transparent;
  color: var(--lilac-dim);
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
}
.reply-preview-cancel:hover{ color: var(--pink); }

.selection-bar{
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.sel-cancel{
  border: none;
  background: transparent;
  color: var(--lilac);
  font-size: 16px;
  cursor: pointer;
}
.sel-count{
  color: var(--lilac);
  font-weight: 600;
  font-size: 14px;
}
.sel-actions{
  margin-left: auto;
  display: flex;
  gap: 20px;
}
.sel-action{
  border: none;
  background: transparent;
  font-size: 19px;
  cursor: pointer;
  color: var(--lilac);
  padding: 0;
}
.sel-action:hover{ transform: scale(1.12); }
.sel-action:disabled{ opacity: 0.3; cursor: not-allowed; transform: none; }

.composer{
  padding: 14px 16px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  display:block!important;
  margin-bottom: 16px;
}

.composer-normal,
.composer-recording{
  display: flex;
  align-items: center;
  gap: 10px;
}

.composer input[type=text]{
  flex: 1;
  margin: 0;padding: 9px;
      padding-left: 18px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 10px;
    border: 0px solid var(--line);
    background: #26164500;
    color: var(--cyan);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:hover{ border-color: var(--cyan); }

.attach-wrap{
  position: relative;
  flex-shrink: 0;
}

.attach-menu{
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  z-index: 20;
}

.attach-menu-item{
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: var(--lilac);
  font-size: 14px;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
}
.attach-menu-item:hover{ background: var(--panel); }
.attach-menu-icon{ font-size: 17px; }

.send-btn{
  border: none;
  border-radius: 10px;
  padding: 0 10px;
  height: 40px;
  background: linear-gradient(135deg, var(--pink), #c34e86);
  color: #170f28;
  font-weight: 600;
  cursor: pointer;
}

.composer-recording{
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
  height: 40px;
}

.rec-cancel,
.rec-send{
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--lilac-dim);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rec-cancel:hover{ color: var(--danger); }
.rec-send{
  margin-left: auto;
  background: linear-gradient(135deg, var(--pink), #c34e86);
  color: #170f28;
}

.rec-dot{
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
  animation: rec-pulse 1.2s infinite;
}
@keyframes rec-pulse{
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.rec-timer{
  font-variant-numeric: tabular-nums;
  color: var(--lilac);
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.rec-hint{
  color: var(--lilac-dim);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-progress{
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--lilac-dim);
  padding: 0 16px 8px;
}

.upload-ring{
  flex-shrink: 0;
  transform: rotate(-90deg);
}

.upload-ring-bg{
  fill: none;
  stroke: rgba(255,255,255,0.15);
  stroke-width: 3;
}

.upload-ring-fg{
  fill: none;
  stroke: var(--pink);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.15s ease;
}

.upload-progress-text{
  font-size: 12px;
}

.hint{
  font-size: 10px;
  color: var(--lilac-dim);
  padding: 0 16px 10px;
  display:none!important;
}

/* ---------- Mobile: list <-> chat toggle ---------- */
@media (max-width: 760px){
  .sidebar{
    width: 100%;
    border-right: none;
  }
  .chat-panel{
    position: fixed;
    inset: 0;
    transform: translateX(100%);
    transition: transform .2s ease;
    background: var(--bg-deep);
  }
  .chat-shell.show-chat .sidebar{
    display: none;
  }
  .chat-shell.show-chat .chat-panel{
    transform: translateX(0);
  }
  .back-btn{
    display: block;
  }
}

/* ---------- Profile popup ---------- */
.clickable-avatar{ cursor: pointer; }
.clickable-avatar:hover{ filter: brightness(1.15); }

.profile-overlay{
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 6, 18, 0.72);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.profile-card {
    position: relative;
    width: 100%;
    max-width: 400px;
    max-height: 88vh;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 29px;
    padding: 32px 24px 14px 24px;
    box-shadow: 0 0 40px rgba(255, 95, 168, 0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.profile-close{
  position: absolute;
  top: 15px;
  right: 18px;
  border: none;
  background: transparent;
  color: var(--lilac-dim);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.profile-close:hover{ color: var(--pink); }

.profile-avatar-wrap{
  position: relative;
  width: 88px;
  height: 88px;
  margin-bottom: 16px;
}

.profile-avatar{
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: linear-gradient(135deg, var(--pink), var(--cyan));
  color: #170f28;
  font-weight: 700;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}
.profile-avatar:hover{ filter: brightness(1.1); }
.profile-avatar-inner{
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-avatar-inner img{
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-edit{
     position: absolute;
    bottom: -2px;
    right: -2px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--panel);
    background: linear-gradient(135deg, #000000, #5c595a);
    color: #170f28;
    font-size: 13px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.profile-avatar-edit:hover{ filter: brightness(1.1); }

.profile-username{
  font-size: 13px;
  color: var(--cyan);
  margin: 0 0 4px;
}

.profile-member-since{
  font-size: 11px;
  color: var(--lilac-dim);
  margin: 0 0 6px;
}

.profile-presence-text{
  
  color: #888;
  margin: 0 0 6px;
      font-size: 14px;
}
.profile-presence-text.is-online{ color: #3ddc84; }

/* ---------- Profile info list (mobile / username / date of birth / bio) ---------- */
/* Shared "row" system — one rounded card containing each field, divided
   by thin lines, matching a Telegram-style profile: label on the left,
   value on the right, an Edit link that swaps the row for an inline form. */

.profile-info-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    background: #553f81;
    border: 0px solid var(--line);
    border-radius: 19px;
    margin-top: 1px;
}
button#profileMessageBtn {
    border-color: pink;
    margin-top: 8px;
    border-radius: 21px;
    border: 0px solid #ff17ed;
    font-weight: bold;
    cursor: pointer;
    font-size: 15px;
    color: #ff61cb;
    background-color: #171128;
}
button#profileMessageBtn:hover {
   color: #ffb7e7;
}
.profile-row{
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  
}
.profile-info-list .profile-row:last-child{ border-bottom: none; }

.profile-row-bio{ align-items: flex-start; }

.profile-row-label{
  font-size: 11px;
  color: var(--lilac-dim);
  text-align: left;
  flex-shrink: 0;
}

.profile-row-value{
  font-size: 13px;
  color: var(--lilac);
  flex: 1;
  text-align: right;
  word-break: break-word;
}

.profile-bio-value{
  text-align: right;
  white-space: pre-wrap;
}

.profile-row-edit-btn{
  border: none;
  background: transparent;
  color: var(--cyan);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.profile-row-edit-btn:hover{ color: var(--pink); }

.profile-row-edit{
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
}
.profile-info-list .profile-row-edit:last-child{ border-bottom: none; }

.profile-row-edit label{
  margin: 0;
  text-align: left;
  font-size: 11px;
  color: var(--lilac-dim);
}

.profile-row-edit input,
.profile-row-edit textarea{
  width: 100%;
  padding: 9px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--lilac);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  color-scheme: dark;
  resize: vertical;
}
.profile-row-edit input:focus,
.profile-row-edit textarea:focus{ border-color: var(--pink); }

.profile-row-edit-actions{
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.profile-row-cancel{
  border: 1px solid var(--line);
  background: transparent;
  color: var(--lilac-dim);
  border-radius: 8px;
  padding: 0 14px;
  font-size: 13px;
  cursor: pointer;
}
.profile-row-cancel:hover{ border-color: var(--pink); color: var(--lilac); }

.profile-error{
  color: var(--danger);
  font-size: 11px;
  margin-top: 10px;
  min-height: 0;
}

/* ---------- Search this conversation ---------- */
span.profile-message-icon {
    margin-right: 6px;
}
.profile-search-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0 14px;
    padding: 7px 13px;
    border-radius: 999px;
    border: 0px solid #171128;
    background: var(--panel);
    font-size: 15px;
    font-weight: bold;
    color: cyan;
    cursor: pointer;
}

.profile-search-toggle:hover{     color: #008484; }
.profile-search-icon{ font-size: 15px; 
    margin-right: 6px;
}

.profile-search-panel{
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.profile-search-panel input{
  width: 100%;
  padding: 9px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--lilac);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.profile-search-panel input:focus{ border-color: var(--pink); }

.profile-search-results{
  width: 100%;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-search-result{
  display: flex;
  align-items: baseline;
  gap: 6px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--bg-deep);
  border-radius: 8px;
  cursor: pointer;
  color: var(--lilac);
}
.profile-search-result:hover{ border-color: var(--cyan); }

.profile-search-result-who{
  font-size: 11px;
  color: var(--cyan);
  flex-shrink: 0;
}
.profile-search-result-text{
  font-size: 12px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-search-result-time{
  font-size: 10px;
  color: var(--lilac-dim);
  flex-shrink: 0;
}

.profile-search-empty{
  font-size: 11px;
  color: var(--lilac-dim);
  padding: 6px 2px;
}

/* Briefly highlights a message bubble that was jumped to from search. */
.msg-outer.msg-highlight .bubble{
  box-shadow: 0 0 0 2px var(--pink);
  transition: box-shadow 0.3s ease;
}

/* ---------- Shared media / files ---------- */

.profile-media-section{
  width: 100%;
  margin-top: 18px;
}

.profile-media-tabs{
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.profile-media-tab{
  flex: 1;
  padding: 8px 0;
  border: none;
  background: transparent;
  color: var(--lilac-dim);
  font-size: 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.profile-media-tab.active{
  color: var(--cyan);
  border-bottom-color: var(--cyan);
}

.profile-media-grid{
  width: 100%;
  min-height: 40px;
}

.profile-media-grid-thumbs{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.profile-media-thumb{
  position: relative;
  aspect-ratio: 1 / 1;
  border: none;
  padding: 0;
  overflow: hidden;
  background: var(--bg-deep);
  cursor: pointer;
  border-radius: 6px;
}
.profile-media-thumb img,
.profile-media-thumb video{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.profile-media-video-badge{
  position: absolute;
  bottom: 4px;
  right: 6px;
  color: #fff;
  font-size: 12px;
  text-shadow: 0 0 4px rgba(0,0,0,0.8);
}

.profile-media-grid-list{
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-media-file{
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  color: var(--lilac);
}
.profile-media-file:hover{ border-color: var(--cyan); }

.profile-media-file-icon{ font-size: 16px; flex-shrink: 0; }

.profile-media-file-info{
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  text-align: left;
}
.profile-media-file-name{
  font-size: 12px;
  color: var(--lilac);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-media-file-meta{
  font-size: 10px;
  color: var(--lilac-dim);
}

.profile-media-loading,
.profile-media-empty{
  font-size: 11px;
  color: var(--lilac-dim);
  padding: 10px 2px;
}

/* ---------- Online/offline presence dots ---------- */
.peer-avatar{
  position: relative;
  flex-shrink: 0;
}

.avatar-wrap{
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
}

.presence-dot{
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--bg-deep);
  background: #6b6f80;
  box-sizing: content-box;
}
.presence-dot.online{
  background: #3ddc84;
  box-shadow: 0 0 6px rgba(61, 220, 132, 0.65);
}
.presence-dot.offline{
  background: #6b6f80;
}

.header-presence-dot{
  border-color: var(--panel);
  width: 10px;
  height: 10px;
}

/* ---------- Photo viewer (Telegram-style full-screen gallery) ---------- */
.photo-viewer-overlay{
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(6, 4, 12, 0.94);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.photo-viewer-top{
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
}

.photo-viewer-username{
  color: var(--cyan);
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-viewer-counter{
  color: var(--lilac-dim);
  font-size: 12px;
  flex-shrink: 0;
}

.photo-viewer-close{
  border: none;
  background: transparent;
  color: var(--lilac-dim);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 6px;
  flex-shrink: 0;
}
.photo-viewer-close:hover{ color: var(--pink); }

.photo-viewer-stage{
  position: relative;
  width: 100%;
  max-width: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-viewer-img{
  max-width: 100%;
  max-height: 70vh;
  border-radius: 12px;
  object-fit: contain;
  background: var(--panel);
  box-shadow: 0 0 40px rgba(255, 95, 168, 0.15);
}

.photo-viewer-nav{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(23, 15, 40, 0.7);
  color: var(--lilac);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.photo-viewer-nav:hover{ color: var(--pink); border-color: var(--pink); }
.photo-viewer-prev{ left: 6px; }
.photo-viewer-next{ right: 6px; }

.photo-viewer-dots{
  display: flex;
  gap: 6px;
  margin-top: 16px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 320px;
}

.photo-viewer-dot{
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line);
  cursor: pointer;
  border: none;
  padding: 0;
}
.photo-viewer-dot.active{ background: var(--pink); }

.photo-viewer-actions{
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.photo-viewer-action-btn{
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--lilac);
  font-size: 12px;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
}
.photo-viewer-action-btn:hover{ border-color: var(--cyan); color: var(--cyan); }
.photo-viewer-delete-btn:hover{ border-color: var(--pink); color: var(--pink); }

.photo-viewer-error{
  margin-top: 10px;
  color: var(--pink);
  font-size: 12px;
  min-height: 1em;
}

/* ---------- "Recording a voice messageâ€¦" peer status ---------- */
.peer-typing .mic-wave{
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-right: 2px;
}


.peer-typing {
    margin: 0;
    font-size: 12px;
    color: #777;
    /* display: flex; */
    align-items: center;
    position: fixed;
    top: 50px;
    margin-left: 2px;
}
.peer-typing .mic-wave span{
  display: inline-block;
  width: 2px;
  height: 6px;
  background: #c70000;
  border-radius: 1px;
  animation: mic-wave-bounce 0.9s infinite ease-in-out both;
}
.peer-typing .mic-wave span:nth-child(2){ animation-delay: .15s; }
.peer-typing .mic-wave span:nth-child(3){ animation-delay: .3s; }
.peer-typing .mic-wave span:nth-child(4){ animation-delay: .45s; }
@keyframes mic-wave-bounce{
  0%, 100% { height: 4px; }
  50% { height: 11px; }
}

/* ---------- Connection status pill ---------- */
.conn-status{
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(23, 15, 40, 0.85);
  
  color: var(--lilac);
  backdrop-filter: blur(6px);
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.conn-status .conn-dot{
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lilac-dim);
  flex-shrink: 0;
}

.conn-status.is-connecting .conn-dot{
  background: #f5c86a;
  box-shadow: 0 0 6px rgba(245, 200, 106, 0.7);
  animation: conn-dot-pulse 1s infinite ease-in-out;
}
.conn-status.is-connecting{margin-top: 32px; opacity: 0.3; color: #ff8d69; border-color: #ff8d69; }

.conn-status.is-connected .conn-dot{
  background: #4be07f;
 
}
.conn-status.is-connected{margin-top: 32px;
    opacity: 0.5;
    backdrop-filter: none;
    background: none;
    color: #4be07f;}

.conn-status.is-offline .conn-dot {
    
    margin-top: -1px;
    
    opacity: 1;
    margin-right: 3px;
    margin-left: -3px;
    color: #b7b7b7;
    
}
.conn-status.is-offline{ margin-top: 32px; opacity: 0.3; color: #b7b7b7; }

@keyframes conn-dot-pulse{
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------- Peer-header connection indicator ---------- */
.peer-conn-status { 
    margin: 2px 4px 0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #bbbbbb;
    opacity: 0;
    transition: opacity 0.25s ease, color 0.25s ease;
    pointer-events: none;
}
  pointer-events: none;
}
.peer-conn-status.is-visible{ opacity: 1; }
.peer-conn-status.is-online{ color: #4be07f; }


element.style {
    display: inline-flex;
    text-decoration: none;
    align-items: center;
    gap: 4px;
    padding: 1px 2px;
    margin-bottom: -8px;
    border-radius: 20px;
    /* background: rgb(35, 39, 51); */
    color: rgb(226 121 19);
    font-size: 13px;
    font-weight: 600;
}
a#profileE2eBtn:hover {
        color: #ffc170 !important;
}







