:root{
  --bg:#f6f7fb;
  --card:#ffffff;
  --text:#111827;
  --muted:#6b7280;
  --line:rgba(0,0,0,.10);
  --line2:rgba(0,0,0,.14);
  --pri:#2563eb;
  --pri2:rgba(37,99,235,.10);
  --ok:#16a34a;
  --danger:#b42318;
  --dangerbg:#ffe7e7;
  --wave-voice:#b3e2b4;
  --wave-voice-progress:#5ebd66;
  --wave-audio:#b3e2b4;
  --wave-audio-progress:#5ebd66;
  --wave-bar:#b3e2b4;
  --wave-bar-progress:#5ebd66;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:yekan-bakh,ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial;
  font-weight:300;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}
a{color:inherit;text-decoration:none}
.hidden{display:none!important}

input,textarea,select{font-size:16px}

.page{padding:14px}
.title{font-size:18px;font-weight:600}
.muted{color:var(--muted);font-size:12px}

.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:18px;
}
.card.card-animate{padding:14px}
.card-animate{animation:fadeUp .16s ease both}
@keyframes fadeUp{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}

.alert{
  padding:10px 12px;
  border-radius:14px;
  border:1px solid var(--line);
  background:#fff;
  font-size:13px;
}
.alert.error{border-color:rgba(239,68,68,.25);background:var(--dangerbg);color:#7f1d1d}
.alert.ok{border-color:rgba(22,163,74,.25);background:rgba(22,163,74,.10);color:#14532d}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:10px 14px;
  border-radius:14px;
  border:none;
  background:#fff;
  cursor:pointer;
  transition:transform .14s ease,background-color .14s ease,border-color .14s ease;
  user-select:none;
}
.btn.outline{border:1px solid var(--line)}
.btn[disabled]{opacity:.55;cursor:not-allowed;transform:none}
.btn:active{transform:translateY(0)}
.btn.primary{background:var(--pri);border-color:rgba(37,99,235,.35);color:#fff}
.btn.icon{width:35px;height:40px;padding:0;border-radius:14px;font-size: 18px}

.icon-btn{
  width:25px;height:25px;font-size: 16px;
  border:none;
  border-radius: 8px;
  background:#fff;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition:transform .14s ease;
}
.icon-btn:active{transform:translateY(0)}

.form{display:flex;flex-direction:column;gap:10px}
.input{
  width:100%;
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--line);
  background:#fff;
  outline:none;
  transition:border-color .14s ease,background-color .14s ease;
}
.input:focus{border-color:rgba(37,99,235,.35);background:rgba(37,99,235,.03)}

.app-shell{
  height:100dvh;
  display:flex;
  overflow:hidden;
  flex-direction:row;
}

/* Sidebar moved to opposite side (RTL: right) */
.sidebar{
  flex:0 0 320px;
  width:320px;
  max-width:320px;
  background:#fff;
  border-left:1px solid var(--line);
  display:flex;
  flex-direction:column;
  transition:transform .22s ease,width .22s ease,flex-basis .22s ease,opacity .22s ease,max-width .22s ease,padding .22s ease;
  will-change:transform;
  order:2;
  border-right: 1px solid #e5e5e5;
}
.main{
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
  height:100dvh;
  order:1;
}

.sidebar-top{padding:14px 14px 10px}
.sidebar-title{font-size:16px;font-weight:600;cursor:pointer}
.sidebar-search{
  position:relative;
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius:16px;
  border:1px solid var(--line);
  background:#fff;
}
.sidebar-search i{color:var(--muted)}
.sidebar-search-input{
  width:100%;
  border:0;
  outline:none;
  background:transparent;
  padding:0;
  font-family:inherit;
  font-size: 12px;
}

.sidebar-search-results{
  margin-top:10px;
  border-radius:16px;
  border:1px solid var(--line);
  background:#fff;
  overflow:hidden;
}
.search-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border-bottom:1px solid var(--line);
  cursor:pointer;
  transition:background-color .12s ease;
}
.search-row:hover{background:rgba(0,0,0,.03)}
.search-row:last-child{border-bottom:0}
.search-avatar{
  width:38px;height:38px;border-radius:14px;
  background:rgba(37,99,235,.10);
  color:var(--pri);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:600;
}
.search-meta{min-width:0;flex:1}
.search-title{font-weight:500;font-size: 12px;}
.search-sub{color:var(--muted);font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.search-empty{padding:12px;color:var(--muted);font-size:13px}

.chat-list{flex:1;overflow:auto}
.chat-row{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 10px;
  cursor:pointer;
  transition:transform .14s ease,background-color .14s ease;
  position:relative;
}
.chat-row:hover{background:rgba(0,0,0,.03);}
.chat-row.selected{background:#f1f1f1}
.chat-avatar{
  width:44px;height:44px;border-radius:16px;
  background:rgba(37,99,235,.10);
  color:var(--pri);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:600;
  flex:0 0 44px;
  position:relative;
}
.chat-presence{
  position:absolute;
  right:-1px;
  bottom:-1px;
  width:12px;
  height:12px;
  border-radius:999px;
  border:2px solid #fff;
  background:#9ca3af;
  box-shadow:0 1px 2px rgba(0,0,0,.12);
}
.chat-presence.on{background:var(--ok)}
.chat-presence.off{background:#9ca3af}
.chat-meta{min-width:0;flex:1}
.chat-meta-top{display:flex;align-items:center;justify-content:space-between;gap:8px}
.chat-title{display:flex;align-items:center;gap:8px;font-weight:600;font-size:14px;min-width:0;flex:1}
.chat-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-time{color:var(--muted);font-size:11px;white-space:nowrap}
.chat-last{color:var(--muted);font-size:12px;display:flex;align-items:center;gap:6px;min-width:0}
.chat-last-text{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-last-status{font-size:12px;color:var(--muted);flex:0 0 auto}
.chat-badge{
  font-size:11px;
  padding:4px 8px;
  border-radius:999px;
  background:rgba(245,158,11,.12);
  color:#92400e;
  border:1px solid rgba(245,158,11,.22);
}
.chat-unread{
  min-width:22px;
  height:22px;
  padding:0 6px;
  border-radius:999px;
  background:var(--pri);
  color:#fff;
  font-size:11px;
  font-weight:600;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

.mini-btn{
  width:34px;height:34px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition:transform .14s ease,background-color .14s ease;
}
.mini-btn:active{transform:translateY(0)}
.mini-btn.ok{border-color:rgba(22,163,74,.25);background:rgba(22,163,74,.08);color:#14532d}
.mini-btn.danger{border-color:rgba(239,68,68,.25);background:rgba(239,68,68,.10);color:#7f1d1d}

html.sidebar-collapsed .sidebar{
  flex-basis:0;width:0;max-width:0;
  transform:translateX(105%);
  opacity:0;
  pointer-events:none;
  overflow:hidden;
  border-left:none;
  padding:0!important;
}

@media (max-width:820px){
  .sidebar{
    position:fixed;
    top:0;bottom:0;right:0;left:auto;
    width:320px;max-width:86vw;
    transform:translateX(105%);
    z-index:80;
    border-left:1px solid var(--line);
  }
  html:not(.sidebar-collapsed) .sidebar{transform:translateX(0)}
  html.sidebar-collapsed .sidebar{transform:translateX(105%)}
}

.main-topbar{
  position:sticky;
  top:0;
  z-index:40;
  background:#fff;
  border-bottom:none;
  padding:10px 12px;
  display:flex;
  flex-direction:row-reverse;
  align-items:center;
  gap:12px;
}
.main-spacer{flex:1;order:2}
.topbar-title{order:3}
#sidebar-toggle{order:1}
.main-title{font-weight:600;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#chat-title{font-weight:600}
.presence-pill{
  border-radius:999px;
  font-size:11px;
  border:none;
  background:#fff;
  color:var(--muted);
}
.presence-pill.on{color:#00cb4b}
.presence-pill.off{color:#374151}
.chat-status-pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  border-radius:999px;
  border:none;
  background:transparent;
  color:#92400e;
  font-size:11px;
  width:max-content;
}

.chat-main-body{display:flex;flex-direction:column;min-height:0;overflow:hidden}
.chat-box {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 12px 26px;
    background-image: url(/imgs/1-bg.jpg);
    background-size: cover;
    background-repeat: no-repeat;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,.18) transparent;
}
.chat-box::-webkit-scrollbar{width:6px;height:6px}
.chat-box::-webkit-scrollbar-track{background:transparent}
.chat-box::-webkit-scrollbar-thumb{
  background:rgba(0,0,0,.18);
  border-radius:999px;
}
.chat-box:hover::-webkit-scrollbar-thumb{background:rgba(0,0,0,.28)}

.msg-row{display:flex;margin:8px 0}
.msg-row.own{justify-content:flex-start}
.msg-row.other{justify-content:flex-end}
.msg-wrap{display:flex;gap:8px;align-items:flex-end;max-width:min(680px,92%)}
.message{
  border-radius:18px;
  padding:8px 10px 4px 8px;
  border:none;
  background:#fff;
  min-width:90px;
  position:relative;
  animation:fadeUp .14s ease both;
}
.message.own {
    background: #eef4dd;
    border-radius: 18px 18px 0px 18px;
}
.message.own:after {
    content: '';
    background-image: url(/imgs/corner-own.svg);
    background-repeat: no-repeat;
    background-size: contain;
    position: absolute;
    z-index: -1;
    right: -14px;
    bottom: 0px;
    display: block;
    width: 28px;
    height: 13px;
}
.message.other:after {
    content: "";
    background-image: url(/imgs/corner2.svg);
    background-repeat: no-repeat;
    background-size: contain;
    transform: rotateY(145deg);
    position: absolute;
    left: -26px;
    bottom: 0px;
    display: block;
    width: 41px;
    height: 13px;
}
.message.other {
    background: #fff;
    border-radius: 18px 18px 18px 0px;
}
.date-divider{
  position:sticky;
  top:8px;
  z-index:3;
  width:max-content;
  margin:10px auto;
  padding:6px 12px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(0,0,0,.06);
  color:var(--muted);
  font-size:12px;
  box-shadow:0 6px 16px rgba(0,0,0,.08);
  pointer-events:none;
}
.message-content{white-space:pre-wrap;word-break:break-word;line-height:normal;font-size:14px}
.sender-name{
  font-size:11px;
  color:var(--muted);
  margin-bottom:4px;
}
.linktext{color:var(--pri);text-decoration:underline;text-underline-offset:3px}
.code-block{
  margin:0;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(0,0,0,.10);
  background:rgba(0,0,0,.03);
  overflow:auto;
  direction:ltr;
  text-align:left;
  font-size:13px;
}
.message-info{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:4px;
  margin-top:4px;
  font-size:12px;
  color:#5fbe67;
}
.message.other .message-info {
    color: #8d8d8d;
}
.audio-time{
    white-space:nowrap;
    position: absolute;
    left: 10px;
    direction: ltr;
}
.status-fa{font-size:12px}
.edited-ico{font-size:12px;color:var(--muted)}

.group-ico{
  font-size:13px;
  color:var(--muted);
  margin-left:6px;
}

.group-popup-content{width:min(520px,92vw);padding:16px}
.group-popup-head{display:flex;align-items:center;justify-content:space-between}
.group-popup-title{font-weight:600;font-size:15px}
.group-form{display:flex;flex-direction:column;gap:12px}
.group-label{display:block;font-size:12px;color:var(--muted);margin-bottom:6px}
.group-chips{display:flex;flex-wrap:wrap;gap:6px}
.group-chip{
  display:inline-flex;align-items:center;gap:6px;
  padding:6px 10px;border:1px solid var(--line);border-radius:999px;background:#fff;font-size:12px;
}
.group-chip button{border:0;background:transparent;cursor:pointer}
.group-search-results{
  margin-top:8px;border-radius:14px;border:1px solid var(--line);background:#fff;overflow:auto;max-height:220px;
}
.group-actions{display:flex;gap:8px;justify-content:flex-end}
.group-member-list{display:flex;flex-direction:column;gap:8px}
.group-member-row{
  display:flex;align-items:center;justify-content:space-between;
  padding:8px 10px;border:1px solid var(--line);border-radius:12px;background:#fff;
}
.group-member-left{display:flex;align-items:center;gap:8px}
.group-member-avatar{
  width:32px;height:32px;border-radius:10px;
  background:rgba(37,99,235,.10);color:var(--pri);
  display:flex;align-items:center;justify-content:center;font-weight:600;
}
.group-member-info{min-width:0}
.group-member-name{font-size:13px;font-weight:500}
.group-member-sub{font-size:11px;color:var(--muted)}
.group-info-row{display:flex;align-items:center;justify-content:space-between}
.group-info-title{font-weight:600}

.reply-preview{
  border:1px solid var(--line);
  background:rgba(0,0,0,.03);
  border-radius:14px;
  padding:8px 10px;
  margin-bottom:8px;
  cursor:pointer;
  transition:background-color .12s ease,transform .12s ease;
}
.reply-preview:hover{background:rgba(0,0,0,.05);}
.rp-top{font-size:11px;color:var(--muted);display:flex;align-items:center;gap:6px}
.rp-body{font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

.reply-btn{
  width:20px;height:20px;
  border-radius:12px;
  border:none;
  background:transparent;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition:transform .14s ease,background-color .14s ease;
}
.reply-btn:active{transform:translateY(0)}

.file-message{display:flex}
.file-message.image img{
  width:260px;
  max-width:68vw;
  border-radius:14px;
  display:block;
  cursor:pointer;
}
.file-download{
  display:inline-flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(0,0,0,.10);
  background:#fff;
  transition:transform .14s ease;
}
.file-download:active{transform:translateY(0)}
.file-size{color:var(--muted);font-size:12px}

.chat-footer{
  position:sticky;
  bottom:0;
  z-index:35;
  background:#fff;
  border-top:none;
  transition:background-color .18s ease,border-color .18s ease;
}
.chat-footer.editing{background:var(--pri2)}
.chat-footer.replying{background:rgba(0,0,0,.02)}

.reply-bar{
  border:none;
  background:rgba(0,0,0,.03);
  padding:8px 10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  animation:fadeUp .14s ease both;
}
.reply-chip{min-width:0}
.reply-chip-title{font-size:12px;color:var(--muted);display:flex;align-items:center;gap:8px}
.reply-chip-body{font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.reply-cancel{
  width:34px;height:34px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  cursor:pointer;
  transition:transform .14s ease,background-color .14s ease;
}
.reply-cancel:active{transform:translateY(0)}

.message-input-wrap{
  position:relative;
  display:flex;
  align-items:center;
  gap:8px;
  padding:5px;
  border:none;
  background:#fff;
  transition:background-color .14s ease,border-color .14s ease;
}
.message-input-wrap .btn{align-self:flex-end}
.message-input-wrap:focus-within{border-color:rgba(37,99,235,.30)}
.message-input-wrap textarea{
  flex:1;
  min-height:42px;
  max-height:140px;
  resize:none;
  border:0;
  outline:none;
  background:transparent;
  padding:8px 10px;
  font-family:inherit;
  line-height:normal;
  font-weight:300;
  font-size:14px;
}
.voice-inline{
  display:none;
  align-items:center;
  gap:8px;
  flex:1;
  min-width:0;
  opacity:0;
  transform:translateY(6px);
  transition:opacity .18s ease,transform .18s ease;
}
.message-input-wrap.voice-inline-active .voice-inline{
  display:flex;
  opacity:1;
  transform:translateY(0);
}
.message-input-wrap.voice-inline-active textarea{
  flex:0;
  width:0;
  min-height:0;
  max-height:0;
  padding:0;
  margin:0;
  opacity:0;
  pointer-events:none;
}
.message-input-wrap.voice-inline-active #file-btn,
.message-input-wrap.voice-inline-active #edit-cancel-btn{
  display:none;
}
.message-input-wrap.voice-inline-recording #voice-play,
.message-input-wrap.voice-inline-recording #voice-cancel{
  display:none;
}
.message-input-wrap.voice-inline-preview #voice-play,
.message-input-wrap.voice-inline-preview #voice-cancel{
  display:inline-flex;
}
.voice-inline .voice-wave{
  flex:1;
  min-width:0;
  min-height:40px;
}
.voice-inline .voice-panel-btn{
  width:38px;
  height:38px;
  border-radius:12px;
}

.voice-panel{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px;
  margin-bottom:8px;
  border:none;
  background:#fff;
  animation:fadeUp .14s ease both;
}
.voice-panel.recording{
  border-color:rgb(68 105 239 / 35%);
  background:rgb(68 97 239 / 5%);
}
.voice-panel-btn{
  width:40px;height:40px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition:transform .14s ease,background-color .14s ease,border-color .14s ease;
}
.voice-panel-btn:active{transform:translateY(0)}
.voice-panel-btn[disabled]{opacity:.55;cursor:not-allowed;transform:none}
.voice-panel-btn.voice-cancel{
  color:var(--danger);
  border-color:rgba(239,68,68,.25);
  background:rgba(239,68,68,.06);
}
.voice-panel-btn.voice-send{
  color:#2563eb;
  border-color:rgba(37,99,235,.35);
}
.voice-wave{
  flex:1;
  min-width:0;
  min-height:auto;
}
@media (max-width:720px){
  .voice-panel{flex-wrap:wrap}
  .voice-wave{flex:1 1 100%}
}

.upload-menu{
  position:absolute;
  bottom:56px;
  left:10px;
  z-index:60;
  min-width:180px;
  background:#fff;
  border:1px solid var(--line2);
  border-radius:14px;
  padding:6px;
  transform:translateY(8px) scale(.98);
  opacity:0;
  pointer-events:none;
  transition:opacity .14s ease,transform .14s ease;
}
.upload-menu:not(.hidden){opacity:1;transform:translateY(0) scale(1);pointer-events:auto}
.upload-menu button{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:10px;
  padding:10px 12px;
  border:0;
  background:transparent;
  border-radius:12px;
  cursor:pointer;
  transition:background-color .12s ease,transform .12s ease;
}
.upload-menu button:hover{background:rgba(0,0,0,.04)}
.upload-menu button:active{transform:scale(.99)}

.uploading-wrap{min-width:240px}
.uploading-top{display:flex;align-items:center;justify-content:space-between;gap:10px}
.uploading-title{font-size:13px;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:240px}
.upload-cancel{
  border:0;background:transparent;
  width:34px;height:34px;
  border-radius:12px;
  cursor:pointer;
  color:var(--danger);
  display:flex;align-items:center;justify-content:center;
  transition:transform .12s ease,background-color .12s ease;
}
.upload-cancel:hover{background:rgba(239,68,68,.08)}
.upload-cancel:active{transform:scale(.98)}
.uploading-meta{font-size:12px;color:var(--muted);margin:6px 0}
.progress{height:8px;background:rgba(0,0,0,.08);border-radius:999px;overflow:hidden}
.progress-bar{height:100%;width:0;background:rgba(37,99,235,.85);transition:width .10s linear}

.scroll-down-btn {
    position: fixed;
    right: 14px;
    bottom: 65px;
    width: 35px;
    height: 35px;
    border-radius: 40px;
    border: 1px solid var(--line);
    background: #ffffff;
    color: #383838;
    z-index: 90;
    cursor: pointer;
    transition: transform .14s ease, opacity .14s ease;
}
.scroll-down-btn.hidden{opacity:0;pointer-events:none}

.flash{outline:2px solid rgba(37,99,235,.35);outline-offset:4px;border-radius:18px}

.file-message.audio{align-items:center}
.audio-wave{
  display:flex;
  align-items:center;
  gap:10px;
  width:100%;
  max-width:68vw;
  border:none;
  background:transparent;
  overflow:hidden;
  flex-direction: row-reverse;
}
.audio-wave-btn{
  width:45px;height:45px;
  border-radius:50px;
  font-size: 18px;
  border:1px solid var(--line);
  background:#5fbe67;
  color:#fff;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  transition:transform .14s ease,background-color .14s ease;
}
.audio-bar-inner .audio-wave-btn {
    width: 30px;
    height: 30px;
    font-size: 14px;
}
.audio-wave-btn:active{transform:translateY(0)}
.audio-waveform{
  flex:1;
  min-height:40px;
  overflow:hidden;
}
.audio-waveform ::part(canvases){
  width:200px;
}

@media (max-width:820px){
  .audio-waveform ::part(canvases) {
    width: 150px;
}}

/* Auth/Admin/Profile */
.auth-wrap{min-height:100dvh;display:flex;align-items:center;justify-content:center;padding:18px}
.auth-card{width:min(420px,92vw);padding:18px}
.auth-head{display:flex;flex-direction:column;align-items:center;gap:10px;margin-bottom:10px}
.auth-logo{width:48px;height:48px;border-radius:16px;border:1px solid var(--line);background:#fff;display:flex;align-items:center;justify-content:center}
.auth-title{font-size:18px;font-weight:600}
.auth-sub{font-size:12px;color:var(--muted)}

.admin-wrap{max-width:980px;margin:0 auto}
.profile-wrap{max-width:620px;margin:0 auto}

button,input,textarea,select{font-family:inherit}
body.no-scroll{overflow:hidden}

.sidebar-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}
.sidebar-top-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.icon-link{
  width:38px;height:38px;border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  transition:transform .14s ease,background-color .14s ease,border-color .14s ease;
  cursor:pointer;
}
.icon-link:hover{;background:rgba(0,0,0,.03)}
.icon-link:active{transform:translateY(0)}
.icon-link.danger{border-color:rgba(239,68,68,.25);background:rgba(239,68,68,.08);color:#7f1d1d}

.topbar-title{display:flex;flex-direction:column;gap:4px;min-width:0}
.topbar-name{display:flex;flex-direction: column;align-items:flex-start;gap:4px;min-width:0}
.main-body{flex:1;min-height:0;display:flex;flex-direction:column}

.empty-chat{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:10px;
  text-align:center;
  padding:24px;
  border:1px dashed var(--line);
  background:rgba(0,0,0,.02);
  color:var(--muted);
  margin: 10px;
}
.empty-chat-ico{
  width:64px;height:64px;border-radius:22px;
  display:flex;align-items:center;justify-content:center;
  background:rgba(37,99,235,.10);
  color:var(--pri);
  font-size:24px;
}
.empty-chat-title{font-weight:600;color:var(--text)}
.empty-chat-sub{font-size:12px;max-width:520px;line-height:1.7}

.sidebar-backdrop{
  position:fixed;
  inset:0;
  background:rgba(17,24,39,.24);
  backdrop-filter:blur(2px);
  z-index:70;
  opacity:1;
  transition:opacity .18s ease;
}
.sidebar-backdrop.hidden{opacity:0;pointer-events:none}

.menu-surface{
  position:fixed;
  z-index:120;
  min-width:180px;
  background:#fff;
  border:1px solid var(--line2);
  border-radius:14px;
  padding:6px;
  opacity:0;
  transform:translateY(8px) scale(.98);
  pointer-events:none;
  box-shadow:0 12px 30px rgba(15,23,42,.12);
  transition:opacity .14s ease,transform .14s ease;
}
.menu-surface.show{opacity:1;transform:translateY(0) scale(1);pointer-events:auto}
.menu-surface button{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:10px;
  padding:10px 12px;
  border:0;
  background:transparent;
  border-radius:12px;
  cursor:pointer;
  transition:background-color .12s ease,transform .12s ease;
}
.menu-surface button:hover{background:rgba(0,0,0,.04)}
.menu-surface button:active{transform:scale(.99)}
.menu-surface button.danger{color:#7f1d1d}

.popup{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,.65);
  display:flex;
  align-items:center;
  justify-content:center;
  opacity:0;
  transition:opacity .16s ease;
  z-index:140;
}
.popup.show{opacity:1}
.popup-content{
  background:#fff;
  border-radius:18px;
  padding:12px;
  max-width:92vw;
  max-height:86vh;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.popup-content img{max-width:86vw;max-height:70vh;border-radius:12px}
.popup .close{
  width:38px;height:38px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  cursor:pointer;
}

.card.auth-card{max-width:420px;margin:12vh auto 0;padding:18px}
.auth-head{display:flex;flex-direction:column;align-items:center;gap:10px;margin-bottom:12px}
.auth-logo-img{width:32px;height:32px;border-radius:10px}
.auth-alert{margin:10px 0}

.pw-wrap{position:relative;display:flex;align-items:center}
.pw-wrap .input{padding-left:44px}
.pw-eye{
  position:absolute;
  left:10px;
  top:50%;
  transform:translateY(-50%);
  width:34px;height:34px;
  border-radius:10px;
  border:1px solid var(--line);
  background:#fff;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
}

.btn.danger{border-color:rgba(239,68,68,.25);background:rgba(239,68,68,.10);color:#7f1d1d}

.admin-page{max-width:980px;margin:0 auto}
.card.admin-card{padding:14px;margin:12px 0}
.admin-header-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
.admin-actions{display:flex;gap:8px;flex-wrap:wrap}
.admin-section-title{font-size:16px;margin-bottom:10px}
.admin-alert{margin-bottom:10px}
.admin-user-head{
  margin-bottom:8px;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(0,0,0,.02);
}
.admin-user-row{
  padding:8px 10px;
  margin:8px 0;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  width:100%;
  max-width:100%;
}
.admin-grid.compact{
  display:grid;
  gap:8px;
  align-items:center;
  grid-template-columns:
    minmax(90px,1fr)
    minmax(90px,1fr)
    minmax(110px,1.1fr)
    minmax(90px,1fr)
    90px
    90px
    90px
    minmax(120px,1fr)
    70px;
}
.admin-col-title{font-size:11px;color:var(--muted)}
.admin-user-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px}
.admin-user-row .input,
.admin-user-row select{
  padding:8px 10px;
  font-size:13px;
  border-radius:12px;
  min-width:0;
}
.admin-user-row .btn{padding:8px 10px;border-radius:12px}
.admin-bulk-footer{display:flex;justify-content:flex-end;margin-top:12px}
.admin-bulk-form{width:100%}

.admin-pill-select{
  border-radius:999px;
  padding:6px 28px 6px 12px;
  font-size:12px;
  text-align:center;
  background:rgba(0,0,0,.03);
}
.admin-pill-select:focus{background:rgba(37,99,235,.06)}

.admin-pill-select{
  -webkit-appearance:none;
  appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa4b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:left 10px center;
  background-size:12px 12px;
  padding-left:30px;
}

.admin-select{
  min-width:0;
  -webkit-appearance:none;
  appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa4b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:left 10px center;
  background-size:12px 12px;
  padding-left:30px;
}

.admin-grid{display:flex;flex-wrap:wrap;gap:10px}
.admin-field{flex:1;min-width:140px}
.admin-field-wide{flex:2;min-width:220px}
.admin-footer{display:flex;justify-content:space-between;align-items:center;margin-top:10px;gap:10px;flex-wrap:wrap}

@media (max-width:1100px){
  .admin-grid.compact{
    grid-template-columns:repeat(2,minmax(140px,1fr));
  }
  .admin-user-head{display:none}
  .admin-user-row{gap:10px}
  .admin-user-actions{justify-content:flex-start}
}

.profile-page{max-width:620px;margin:0 auto}
.card.profile-card{padding:18px;margin:22px auto}
.profile-header{display:flex;align-items:center;justify-content:space-between;gap:10px}
.profile-alert{margin-top:10px}
.profile-form{margin-top:10px}

.switch{
  position:relative;
  display:flex;
  align-items:center;
  gap:10px;
  cursor:pointer;
  user-select:none;
  margin-top:6px;
}
.switch input{position:absolute;opacity:0;pointer-events:none}
.switch-ui{
  width:46px;height:26px;
  border-radius:999px;
  background:rgba(0,0,0,.12);
  position:relative;
  display:inline-flex;
  transition:background-color .14s ease;
}
.switch-ui::after{
  content:'';
  position:absolute;
  width:20px;height:20px;
  top:3px;right:3px;
  background:#fff;
  border-radius:999px;
  box-shadow:0 2px 6px rgba(0,0,0,.12);
  transition:transform .14s ease;
}
.switch input:checked + .switch-ui{background:rgba(239,68,68,.25)}
.switch input:checked + .switch-ui::after{transform:translateX(-20px)}
.switch-text{font-size:13px;color:var(--text)}
.profile-switch{justify-content:space-between;padding:10px 12px;border:1px solid var(--line);border-radius:14px;background:rgba(0,0,0,.02)}
.profile-switch-main{display:flex;flex-direction:column;gap:4px}
.profile-switch-title{font-weight:600;font-size:14px}
.profile-switch-sub{font-size:12px;color:var(--muted)}

.chat-main-body{position:relative}
.chat-actions{display:flex;gap:6px;align-items:center}

.error-display{position:absolute;left:12px;right:12px;bottom:100%;margin-bottom:10px}

.audio-bar{
  position:sticky;
  top:0;
  z-index:35;
  background:#fff;
  border-bottom:1px solid var(--line);
  padding:10px 12px;
}
.audio-bar.hidden{display:none}
.audio-bar-inner{display:flex;align-items:center;gap:10px;flex-direction: row-reverse}
.audio-title{font-weight:600;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.audio-bar-player{flex:1;min-width:180px}
.audio-bar-wave{flex:1;min-width:160px}
.audio-bar-time{font-size:12px;color:var(--muted);white-space:nowrap;width: 80px;text-align: center;direction:ltr}
.audio-bar-close{flex:0 0 auto}

.drop-overlay{
  position:absolute;
  inset:12px;
  border-radius:20px;
  background:rgba(37,99,235,.12);
  border:2px dashed rgba(37,99,235,.35);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:60;
}
.drop-card{
  background:#fff;
  border:1px solid var(--line);
  border-radius:16px;
  padding:12px 16px;
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:600;
  color:var(--pri);
}

.date-divider{
  position:sticky;
  top:8px;
  z-index:5;
  margin:14px auto;
  padding:6px 12px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.9);
  font-size:12px;
  color:var(--muted);
  width:max-content;
}

.audio-player{width:260px;max-width:68vw;border-radius:14px;display:block}

@media (max-width:820px){
  .audio-title{text-align:center}
}
