@font-face {
  font-family: 'Castoro';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/castoro/1q2EY5yMCld3-O4cLYp-wc4avEU.woff2") format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Instrument Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/instrumentserif/jizHRFtNs2ka5fXjeivQ4LroWlx-6zAjgn7MsNo.woff2") format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IRANSansX";
  src: url("../fonts/IRANSansX/Woff2/IRANSansXFaNum-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IRANSansX";
  src: url("../fonts/IRANSansX/Woff2/IRANSansXFaNum-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IRANSansX";
  src: url("../fonts/IRANSansX/Woff2/IRANSansXFaNum-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
:root{
  --bg1:#0b1220;
  --bg2:#0f1b33;
  --bg3:#091021;
  --muted:#9fb0d0;
  --text:#e9f0ff;
  --accent:#6d8cff;
  --accent-strong:#8ea8ff;
  --accent2:#38d9a9;
  --danger:#ff6b6b;
  --border: rgba(255,255,255,.08);
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --glass: rgba(15,26,43,.72);
  --glass2: rgba(15,26,43,.56);
}

*{ box-sizing:border-box; font-family:"IRANSansX",system-ui,-apple-system,"Segoe UI",Roboto,Arial; }
html,body{ height:100%; }
body{ margin:0; color:var(--text); background:var(--bg1); }
body.modal-open{ overflow:hidden; }
.hidden{ display:none !important; }

.bg{
  background: radial-gradient(1200px 800px at 20% 10%, #152a55, transparent 60%),
              radial-gradient(900px 700px at 90% 40%, #173b6d, transparent 55%),
              linear-gradient(180deg, var(--bg1), var(--bg2));
  display:flex;
}
.chat-bg{
  background: radial-gradient(1200px 700px at 16% 6%, #1c3263, transparent 58%),
              radial-gradient(1200px 800px at 94% 34%, #11426c, transparent 55%),
              linear-gradient(165deg, var(--bg1), var(--bg2) 54%, var(--bg3));
}

input, textarea, select{ font-size:16px; }
input, textarea, button{ -webkit-tap-highlight-color: transparent; }

/* Auth */
.auth-wrap{ width:100%; display:flex; align-items:center; justify-content:center; padding:24px; }
.card{
  background: rgba(15,26,43,.82);
  border:1px solid var(--border);
  border-radius:18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.auth-card{ width:min(520px,100%); padding:22px; }
.brand{ display:flex; align-items:center; gap:14px; margin-bottom:16px; }
.logo{
  width:44px; height:44px; border-radius:14px;
  display:flex; align-items:center; justify-content:center;
  background: rgba(109,140,255,.18);
  border:1px solid var(--border);
}
.title{ font-weight:800; }
.subtitle{ color:var(--muted); font-size:13px; margin-top:2px; }
.form{ display:flex; flex-direction:column; gap:10px; }
.label{ font-size:12px; color:var(--muted); margin-top:4px; }

.input{
  width:100%;
  padding:12px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(10,18,34,.55);
  color:var(--text);
  outline:none;
}
.input:focus{ border-color: rgba(109,140,255,.6); background: rgba(10,18,34,.75); }

.btn{
  border:1px solid var(--border);
  background: rgba(255,255,255,.06);
  color:var(--text);
  border-radius:12px;
  padding:11px 14px;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  text-decoration:none;
  user-select:none;
}
.btn:hover{ background: rgba(255,255,255,.09); }
.btn:active{ transform: translateY(1px); }
.btn.primary{
  background: linear-gradient(135deg, rgba(109,140,255,.95), rgba(56,217,169,.75));
  border-color: rgba(255,255,255,.14);
  font-weight:700;
}
.btn.ghost{ padding:9px 12px; }
.btn.icon{ width:44px; padding:0; font-size:18px;    margin-left: 5px;
}
.btn.small{ padding:7px 10px; border-radius:10px; font-size:12px; }
.btn.loading{ opacity:.85; pointer-events:none; }

.error{
  margin-top:8px;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,107,107,.3);
  background: rgba(255,107,107,.12);
  color:#ffd7d7;
  font-size:13px;
}
.hint{ margin-top:10px; color:var(--muted); font-size:12px; }

/* Spinner */
.spinner{
  width:18px; height:18px; border-radius:50%;
  border:2px solid rgba(255,255,255,.25);
  border-top-color: rgba(255,255,255,.85);
  animation: spin .8s linear infinite;
}
.spinner.small{ width:14px; height:14px; }
@keyframes spin{ to{ transform: rotate(360deg);} }

/* Admin */
.admin-head{
  display:flex; gap:10px; align-items:center; justify-content:space-between;
  margin-bottom: 12px;
}
.admin-actions{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.table-wrap{ width:100%; overflow:auto; border-radius:14px; border:1px solid var(--border); }
.user-table{ width:100%; min-width: 720px; border-collapse:collapse; }
.user-table th,.user-table td{
  padding:10px 10px; text-align:right; font-size:13px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.user-table th{ font-weight:800; background: rgba(255,255,255,.04); }
.user-table tr:hover td{ background: rgba(255,255,255,.03); }

/* Chat shell */
.chat-shell{
  height: 100vh;
  height: 100dvh;
  max-width: 1280px;
  margin: 0 auto;
  display:flex;
  flex-direction:column;
  padding: 16px;
  gap: 12px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.chat-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 12px 14px;
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(16,28,49,.9), rgba(12,21,38,.82));
  border:1px solid var(--border);
  box-shadow: var(--shadow);
}
.chat-header .left{
  display:flex;
  align-items:center;
  gap:12px;
  min-width: 0;
  flex: 1 1 auto;
}
.chat-header .right{
  display:flex;
  gap:8px;
  align-items:center;
  flex: 0 0 auto;
}

/* Back button should appear on far LEFT visually */
.back-btn{
  display:none;
  width:44px;
  margin-right: auto; /* ✅ pushes to the far left in RTL */
}

.avatar{
  width:40px; height:40px; border-radius:50%;
  background: rgba(109,140,255,.2);
  border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center;
  font-weight:800;
  overflow:hidden;
  flex: 0 0 auto;
}
.avatar img{ width:100%; height:100%; object-fit:cover; display:block; }

.header-meta{ min-width:0; }
.header-name{
  font-weight:800;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.header-status{
  color:var(--muted);
  font-size:13px;
  margin-top:2px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.e2ee-badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  margin-top:4px;
  padding:4px 8px;
  border-radius:999px;
  border:1px solid rgba(56,217,169,.35);
  background: rgba(56,217,169,.12);
  color:#9ff2d5;
  font-size:11px;
  font-weight:600;
}

/* Header menu (for mobile clean) */
.menu-wrap{ position:relative; }
.menu-panel{
  position:absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 180px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(15,26,43,.92);
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 50;
}
.menu-item{
  width:100%;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.03);
  color: var(--text);
  padding: 10px 10px;
  cursor: pointer;
  text-decoration: none;
  display:flex;
  align-items:center;
  justify-content:space-between;
}
.menu-item:hover{ background: rgba(255,255,255,.06); }

/* Chat main layout */
.chat-main{
  position:relative;
  flex:1;
  min-height:0;
  border-radius: 20px;
  background: linear-gradient(165deg, rgba(15,25,43,.88), rgba(9,17,31,.8));
  border:1px solid var(--border);
  overflow:hidden;
  display:flex;
  direction: rtl;
}

#sidebar{
  width: 320px;
  flex: 0 0 320px;
  border-left:1px solid rgba(255,255,255,.04);
  background: rgba(10,18,34,.50);
  padding:12px;
  overflow:auto;
}

.sidebar-top{ display:flex; gap:8px; align-items:center; margin-bottom:10px; }
.sidebar-top strong{ font-weight: 900; }
.sidebar-top .btn{ margin-right:auto; }

.userItem{
  padding:10px;
  border-radius:14px;
  margin-bottom:10px;
  background: linear-gradient(135deg, rgba(255,255,255,.03), rgba(109,140,255,.045));
  border: 1px solid rgba(255,255,255,.05);
  cursor:pointer;
}
.userItem:hover{
  background: linear-gradient(135deg, rgba(255,255,255,.07), rgba(109,140,255,.1));
  border-color: rgba(142,168,255,.3);
}
.userRow{ display:flex; gap:10px; align-items:center; }
.userMeta{ min-width:0; flex:1; }
.userName{ font-weight:800; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.userSub{ font-size:12px; color:var(--muted); margin-top:5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.userRight{ display:flex; gap:8px; align-items:center; flex:0 0 auto; }
.badge{
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(56,217,169,.22);
  border:1px solid rgba(56,217,169,.35);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 12px;
  font-weight: 900;
  padding: 0 7px;
}
.userDots{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  cursor:pointer;
}
.userDots:hover{ background: rgba(255,255,255,.07); }

.userMenu{
  position:absolute;
  margin-top: -66px;  left: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(15,26,43,.94);
  box-shadow: var(--shadow);
  padding: 8px;
  width: 210px;
  z-index: 40;
}
.userMenu .menu-item{ margin-bottom: 8px; }
.userMenu .menu-item:last-child{ margin-bottom: 0; }

#conversationArea{
  flex: 1 1 auto;
  min-width:0;
  height:100%;
  display:flex;
  flex-direction:column;
  position:relative;
}

.top-loader{
  position:absolute;
  top:10px; left:50%;
  transform: translateX(-50%);
  display:flex; gap:10px; align-items:center;
  padding:8px 12px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(10,18,34,.75);
  z-index: 20;
  color: var(--muted);
  font-size: 13px;
}

.day-toast{
  position:absolute;
  top: 12px;
  left:50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(10,18,34,.82);
  color: rgba(233,240,255,.85);
  font-size: 12px;
  pointer-events:none;
  opacity: 0;
  transition: opacity .18s ease;
}
.day-toast.show{ opacity: 1; }

.messages{
  flex: 1 1 auto;
  min-height:0;
  overflow:auto;
  padding: 16px;
  display:flex;
  flex-direction:column;
  gap: 10px;
  scroll-behavior:smooth;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Date separator like Telegram */
.day-sep{
  align-self:center;
  padding: 6px 12px;
  border-radius: 999px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
  color: rgba(233,240,255,.75);
  font-size: 12px;
  margin: 6px 0;
}

.bubble{
  max-width: min(78%, 680px);
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
}
.bubble.mine{
  align-self:flex-start;
  background: linear-gradient(155deg, rgba(109,140,255,.28), rgba(56,217,169,.13));
  border-color: rgba(109,140,255,.26);
}
.bubble.theirs{
  align-self:flex-end;
  background: rgba(255,255,255,.045);
}

.bubble .text{
  line-height:1.6;
  white-space: pre-wrap;
  word-break: break-word;
  direction: rtl;
  unicode-bidi: plaintext;
}

.bubble .meta{
  margin-top: 8px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  color: rgba(233,240,255,.55);
  font-size: 11px;
}

.reply-btn{
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-radius: 10px;
  padding: 5px 8px;
  cursor: pointer;
  font-size: 12px;
}

.reply{
  border-right: 3px solid rgba(109,140,255,.75);
  background: rgba(255,255,255,.04);
  padding: 8px 10px;
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
}
.reply__who{ color: rgba(233,240,255,.75); font-size: 11px; margin-bottom: 3px; }
.reply__text{ color: rgba(233,240,255,.9); font-size: 12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.media img{ max-width:100%; border-radius:12px; display:block; }
.media video{ width:100%; max-width:100%; border-radius:12px; display:block; background:#000; }
.media audio{ width:100%; display:block; }
.media-actions{ margin-top: 8px; display:flex; gap:8px; }
.file-card{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  border-radius:12px;
  background: rgba(255,255,255,.06);
  border:1px solid var(--border);
}
.file-meta{ display:flex; align-items:center; gap:8px; }
.file-icon{ font-size:18px; }
.file-name{ color: rgba(233,240,255,.9); font-size:13px; }

.bubble.flash{
  outline:2px solid rgba(56,217,169,.8);
  outline-offset:2px;
}

.bubble .meta .seen{ color: var(--accent2); font-weight:900; margin-right: 6px; }
.bubble .meta .pending{ color: var(--muted); margin-right: 6px; }

.chat-footer{
  padding: 12px;
  border-top:1px solid rgba(255,255,255,.06);
  background: rgba(15,26,43,.40);
}

.composer{ display:flex; gap:10px; align-items:flex-end; }
.input.msg{
  flex:1;
  resize:none;
  overflow:hidden;
  min-height:44px;
  max-height:160px;
  overflow-y:auto;
  padding:12px 12px;
}
.file{ display:none; }
.btn.recording{
  background: rgba(255,74,74,.15);
  border-color: rgba(255,74,74,.4);
  color: #ffcccc;
}

.send-btn-inner{
  display:inline-flex;
  align-items:center;
  gap:10px;
}

.replybar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.05);
  margin-bottom: 10px;
}
.replybar__title{ color: rgba(233,240,255,.65); font-size:12px; margin-bottom:4px; }
.replybar__preview{
  color: rgba(233,240,255,.95);
  font-size:13px;
  max-width: 70vw;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}

.upload{
  margin-top:10px;
  display:flex;
  align-items:center;
  gap:12px;
  color: var(--muted);
  font-size: 12px;
}
.upload .bar{
  flex:1; height:10px; border-radius:999px;
  background: rgba(255,255,255,.08);
  border:1px solid var(--border);
  overflow:hidden;
}
.upload .fill{
  width:0%;
  height:100%;
  background: linear-gradient(90deg, rgba(109,140,255,.95), rgba(56,217,169,.85));
  transition: width .15s ease;
}

/* ✅ scroll to bottom button - higher so it doesn't overlap send */
.scroll-bottom{
  position:absolute;
  left: 12px;
  bottom: 92px; /* ✅ moved up */
  z-index: 25;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(10,18,34,.75);
  color: var(--text);
  cursor:pointer;
  box-shadow: var(--shadow);
}

/* Modal */
.modal{ position: fixed; inset:0; z-index: 1000; }
.modal__backdrop{ position:absolute; inset:0; background: rgba(0,0,0,.55); backdrop-filter: blur(4px); }
.modal__panel{
  position:absolute; inset:0;
  display:flex; flex-direction:column;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)) 12px;
  padding-bottom: 0;

}
.modal__top{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding: 10px 12px;
  border-radius: 14px;
  border:1px solid var(--border);
  background: rgba(15,26,43,.82);
}
.modal__body{
  flex:1;
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  padding: 12px 0;
}
.stage{
  width: min(980px, 100%);
  height: 100%;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(10,18,34,.65);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:auto
  ;
}
.stage__img{ max-width:100%; max-height:100%; object-fit:contain; }
.stage__video{ width:100%; height:100%; object-fit:contain; background:#000; }
.navbtn{
  width:44px; height:44px; border-radius:999px;
  border:1px solid var(--border);
  background: rgba(15,26,43,.82);
  color: var(--text);
  cursor:pointer;
}
.navbtn:disabled{ opacity:.35; cursor: default; }

/* Settings modal (profile/password) */
.sheet{
  width: min(620px, 100%);
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(15,26,43,.92);
  box-shadow: var(--shadow);
  padding: 14px;
}
.sheet h3{ margin: 0 0 10px 0; }
.action-sheet{
  width: min(460px, 100%);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  animation: sheetUp .2s ease;
}
@keyframes sheetUp{
  from{ transform: translateY(12px); opacity:.7; }
  to{ transform: translateY(0); opacity:1; }
}
.sheet .row{ display:flex; gap:10px; flex-wrap:wrap; }
.sheet .row .col{ flex: 1 1 220px; }
.sheet .actions{ display:flex; gap:10px; margin-top:12px; }
.prefs-section{
  border:1px solid rgba(255,255,255,.06);
  border-radius:14px;
  padding:10px;
  margin-top:10px;
  background: rgba(10,18,34,.45);
}
.prefs-title{
  font-weight:700;
  margin-bottom:8px;
  font-size:13px;
}
.toggle{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:13px;
  margin:6px 0;
}
.toggle input{ accent-color: #6d8cff; }
.prefs-note{
  font-size:12px;
  color: var(--muted);
  margin-top:6px;
  line-height:1.6;
}
.prefs-inline{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
}
.prefs-inline .input{ flex: 1 1 200px; }
.chat-bg-preview{
  margin-top:10px;
  height:130px;
  border-radius:12px;
  border:1px solid var(--border);
  background-size: cover;
  background-position: center;
  overflow:hidden;
  position:relative;
}
.chat-bg-preview .overlay{ position:absolute; inset:0; background: rgba(11,18,32,.2); }

.pm-preview-wrap{
  width: 92px;
  min-width: 92px;
  height: 72px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(8,14,25,.75);
  overflow: hidden;
}
.pm-thumb{
  width: 100%;
  height: 100%;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  color: rgba(233,240,255,.85);
  font-size: 12px;
}
.pm-thumb--img,
.pm-thumb--video{
  object-fit: cover;
  display:block;
}
.pm-thumb--audio,
.pm-thumb--file{
  padding: 8px;
  text-align:center;
  flex-direction:column;
}

.toast-stack{
  position: fixed;
  bottom: 24px;
  right: 24px;
  display:flex;
  flex-direction:column;
  gap:10px;
  z-index: 1200;
  max-width: min(320px, 92vw);
}
.toast{
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(15,26,43,.92);
  box-shadow: var(--shadow);
  padding:10px 12px;
  display:flex;
  align-items:flex-start;
  gap:10px;
  cursor:pointer;
  animation: toastIn .25s ease;
}
.toast .title{ font-weight:700; font-size:13px; }
.toast .desc{ font-size:12px; color:var(--muted); margin-top:4px; }
.toast .dot{
  width:10px; height:10px; border-radius:50%;
  background: linear-gradient(135deg, rgba(109,140,255,.9), rgba(56,217,169,.8));
  margin-top:5px;
  flex:0 0 auto;
}
@keyframes toastIn{
  from{ transform: translateY(8px); opacity:0; }
  to{ transform: translateY(0); opacity:1; }
}

.text.encrypted{
  color: rgba(233,240,255,.75);
  font-style: italic;
}
.text.decrypt-failed{
  color: rgba(255,107,107,.9);
  font-style: normal;
}
.reply__text.encrypted{
  color: rgba(233,240,255,.75);
  font-style: italic;
}
.reply__text.decrypt-failed{
  color: rgba(255,107,107,.9);
  font-style: normal;
}

@media (max-width: 780px){
  .chat-shell{ padding: 10px; gap: 10px; }
  #sidebar{ width:100%; flex: 1 1 auto; border-left:0; }
  #conversationArea{ width:100%; flex:1 1 auto; }

  body:not(.mobile-chat-open) #conversationArea{ display:none; }
  body.mobile-chat-open #sidebar{ display:none; }
  body.mobile-chat-open #conversationArea{ display:flex; }

  body.mobile-chat-open .back-btn{ display:inline-flex; }
  body:not(.mobile-chat-open) .back-btn{ display:none; }

  .scroll-bottom{ left: 10px; bottom: 104px; width: 42px; height: 42px; } /* ✅ mobile higher */
  .messages{ padding: 12px; gap: 8px; }
.bubble{ max-width: 92%; }
  .pm-preview-wrap{ width: 76px; min-width: 76px; height: 62px; }
  .admin-head{ flex-direction: column; align-items: flex-start; gap: 10px; }
  .toast-stack{ right: 12px; left: 12px; bottom: 16px; }
}
@media (hover:hover){
  .messages::-webkit-scrollbar{ width: 10px; }
  .messages::-webkit-scrollbar-track{ background: rgba(255,255,255,.04); }
  .messages::-webkit-scrollbar-thumb{
    background: rgba(255,255,255,.12);
    border-radius: 999px;
    border: 2px solid rgba(0,0,0,0);
    background-clip: padding-box;
  }
  textarea::-webkit-scrollbar{ width: 10px; }
  .textarea::-webkit-scrollbar-track{ background: rgba(255,255,255,.04); }
  .textarea::-webkit-scrollbar-thumb{
    background: rgba(255,255,255,.12);
    border-radius: 999px;
    border: 2px solid rgba(0,0,0,0);
    background-clip: padding-box;
  }
}
/* ✅ آنلاین همیشه سبز */
.status-online{
  color:#22c55e;
  font-weight:800;
}

/* ✅ اجازه بده متن‌ها خط بعد برن و بریده نشن */
.userMeta,
.userName,
.userSub,
#headerName,
#headerStatus{
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: unset !important;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ✅ توی flex اگر min-width:0 نباشه متن درست wrap نمیشه */
.userRow .userMeta{
  min-width: 0;
}

/* اگر جایی nowrap گذاشتی (مثلا برای userSub) اینو هم کمک می‌کنه */
.userSub{
  line-height: 1.35;
}

.userItem,
.bubble,
.btn{
  transition: transform .15s ease, background-color .2s ease, border-color .2s ease;
}
.userItem:active,
.btn:active{
  transform: scale(.98);
}

@media (prefers-reduced-motion: reduce){
  *{
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ===== 2026 UI refresh + media grouping ===== */
:root{
  --bg1:#070b18;
  --bg2:#0a1330;
  --bg3:#050914;
  --accent:#4f7bff;
  --accent2:#35c7ff;
}
.chat-shell{ max-width: 1520px; gap: 14px; }
.chat-main{ gap: 14px; }
#sidebar,
#conversationArea,
.chat-header{
  background: linear-gradient(165deg, rgba(10,16,34,.88), rgba(7,13,28,.85));
  border-color: rgba(150,178,255,.16);
  box-shadow: 0 18px 44px rgba(2,8,24,.45);
}
.bubble{
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
}
.bubble.mine{
  background: linear-gradient(145deg, rgba(56,99,255,.44), rgba(36,70,178,.38));
  border-color: rgba(138,166,255,.35);
}
.bubble.theirs{
  background: linear-gradient(145deg, rgba(20,31,58,.94), rgba(14,24,45,.9));
}
.text--deleted{
  color:#c2cce6;
  font-style: italic;
  opacity:.92;
}
.media-group-start,.media-group-mid,.media-group-end{
  margin-top: 4px !important;
  margin-bottom: 4px !important;
}
.media-group-start .meta,
.media-group-mid .meta{
  opacity:.6;
}
.media-group-mid .reply-btn{
  display:none;
}
.media-group-start .media,
.media-group-mid .media,
.media-group-end .media{
  border-radius: 14px;
}
.messages{
  scroll-behavior: auto;
}
/* ================================
   FIX: MODALS SAFE AREA + CENTERING
================================== */
.modal{
  display: flex;
  align-items: flex-end;
  justify-content: center;
  /* padding: 16px;*/
}

.modal__panel{
position: relative !important;
inset: auto !important;
max-width: 100%;
max-height: 100%;
}

.modal__backdrop{
position: fixed;
inset: 0;
}

/* جلوگیری از بیرون زدن در موبایل */
.stage{
  max-width: 100%;
  max-height: 80vh;
}

/* ================================
   FIX: ICON BUTTON ALIGNMENT
================================== */
.btn.icon{
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 0;
  width: 44px;
  height: 44px;
  line-height: 1;
}

.btn.icon i{
  font-size: 18px;
  display:flex;
  align-items:center;
  justify-content:center;
}

/* مخصوص دکمه ارسال (خیلی مهم) */
#sendBtn{
  width: 46px;
  height: 44px;
  padding: 0;
}

#sendBtn .send-btn-inner{
  width:100%;
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
}

/* حذف هر فاصله اضافی آیکون ارسال */
#sendBtn i{
  font-size: 18px;
  margin: 0;
}

/* ================================
   FIX: COMPOSER STABILITY
================================== */
.composer{
  align-items: center;
}

.composer .btn{
  flex: 0 0 auto;
}

/* textarea بهتر داخل UI */
.input.msg{
  line-height: 1.6;
}

/* ================================
   FIX: MODAL OVERFLOW SAFE Z-INDEX
================================== */
.modal{
  z-index: 2000;
}

.modal__backdrop{
  z-index: 2000;
}

.modal__panel{
  z-index: 2001;
}

/* ================================
   FIX: prevent horizontal overflow bug
================================== */
.chat-shell,
.chat-main,
#conversationArea{
  overflow-x: hidden;
}

/* ================================
   FIX: mobile modal full fit
================================== */
@media (max-width: 780px){
  .modal{
    padding: 8px;
  }

  .modal__panel{
    width: 100%;
  }

  .stage{
    max-height: 70vh;
  }

  .btn.icon{
    width: 42px;
    height: 42px;
  }

  #sendBtn{
    width: 44px;
    height: 42px;
  }
}

/* ================================
   FIX: SETTINGS MODAL + SHEET UI
================================== */

/* جلوگیری از بیرون زدن کل مودال */
#settingsModal{
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 16px;
  overflow: hidden;
}

/* بک‌دراپ کامل */
#settingsModal .modal__backdrop{
  position: fixed;
  inset: 0;
  z-index: 2000;
}

/* پنل اصلی */
#settingsModal .modal__panel{
  position: relative !important;
  inset: auto !important;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  z-index: 2001;
  display:flex;
  align-items:center;
  justify-content:center;
}

/* خود sheet (اصلی مشکل اینجاست) */
.sheet{
  width: 100%;
  max-width: 720px;
  max-height: 80vh;
  overflow-y: auto;
  overflow-x: hidden;

  border-radius: 18px;
  border: 1px solid rgba(140,170,255,.18);
  background: linear-gradient(165deg, rgba(12,18,36,.96), rgba(8,14,28,.94));
  box-shadow: 0 18px 50px rgba(0,0,0,.45);

  padding: 14px;
  color: var(--text);
}

/* action sheet (پایینی‌ها) */
.action-sheet{
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  max-width: 520px;
  width: 1000px;

}

/* جلوگیری از بیرون زدن مدیا داخل sheet */
.sheet img,
.sheet video,
.sheet audio,
.sheet iframe{
  max-width: 100%;
  border-radius: 12px;
}

/* اسکرول تمیز داخل sheet */
.sheet::-webkit-scrollbar{
  width: 8px;
}
.sheet::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,.12);
  border-radius: 999px;
}

/* ================================
   FIX: MODAL GENERAL SAFETY (ALL MODALS)
================================== */
.modal{
  overflow: hidden;
}

.modal__body{
  max-width: 100%;
  overflow: hidden;
}

/* جلوگیری از بیرون زدگی stage */
.stage{
  max-width: 100%;
  max-height: 75vh;
}

/* ================================
   FIX: ICONS INSIDE SHEET (alignment)
================================== */
.sheet .btn{
  border-radius: 12px;
}

.sheet .btn.icon{
  width: 42px;
  height: 42px;
}

/* ================================
   MOBILE FIX
================================== */
@media (max-width: 780px){
  #settingsModal{
    padding: 8px;
  }

  .sheet{
    max-height: 85vh;
    border-radius: 14px;
  }

  .action-sheet{
    max-width: 100%;
  }
}


.love-banner{
  text-align:center;
  font-family:'Playfair Display', serif;
  font-size:16px;
  letter-spacing:1px;
  color:rgba(255,255,255,0.55);
  margin:10px 0 6px 0;
  pointer-events:none;
  user-select:none;
}

.love-banner::after{
  content:"";
  display:block;
  width:120px;
  height:1px;
  margin:8px auto 0;
  background:rgba(255,255,255,0.15);
}

/* =====================================================
   Telegram-like dark polish + UX refinement
   Added: WebSocket-ready chat refresh
===================================================== */
:root{
  --tg-bg:#0f172a;
  --tg-bg-deep:#070b14;
  --tg-sidebar:#101827;
  --tg-panel:#111c2d;
  --tg-panel-soft:#162235;
  --tg-incoming:#172033;
  --tg-outgoing:#256b5e;
  --tg-outgoing-2:#1f8a70;
  --tg-border:rgba(148,163,184,.16);
  --tg-text:#eef5ff;
  --tg-muted:#93a4bb;
  --tg-accent:#2ea6ff;
  --tg-green:#36d399;
}

body.chat-bg{
  background:
    radial-gradient(900px 520px at 20% 0%, rgba(46,166,255,.16), transparent 62%),
    radial-gradient(760px 560px at 90% 14%, rgba(54,211,153,.10), transparent 60%),
    linear-gradient(180deg, var(--tg-bg-deep), var(--tg-bg));
}

.chat-shell{
  max-width:1560px;
  padding:14px;
  gap:12px;
}

.chat-header{
  min-height:68px;
  border-radius:22px;
  background:rgba(15,23,42,.82);
  border-color:var(--tg-border);
  box-shadow:0 18px 55px rgba(0,0,0,.34);
  backdrop-filter:blur(18px);
}

.chat-main{
  border-radius:24px;
  background:rgba(10,17,30,.82);
  border-color:var(--tg-border);
  box-shadow:0 24px 70px rgba(0,0,0,.38);
}

#sidebar{
  background:linear-gradient(180deg, rgba(16,24,39,.96), rgba(11,18,32,.96));
  border-left:1px solid rgba(148,163,184,.12);
  padding:14px;
}

.sidebar-top{
  position:sticky;
  top:0;
  z-index:5;
  padding:4px 2px 12px;
  background:linear-gradient(180deg, rgba(16,24,39,.98), rgba(16,24,39,.72), transparent);
}

#userIdSearch{
  height:44px;
  border-radius:999px;
  background:rgba(2,6,23,.48);
  border-color:rgba(148,163,184,.14);
  padding-inline:16px;
}

#userIdSearch:focus{
  border-color:rgba(46,166,255,.55);
  box-shadow:0 0 0 4px rgba(46,166,255,.10);
}

.userItem{
  border-radius:18px;
  padding:11px;
  border-color:transparent;
  background:transparent;
  transition:background .18s ease, border-color .18s ease, transform .12s ease;
}

.userItem:hover{
  background:rgba(148,163,184,.09);
  border-color:rgba(148,163,184,.10);
}

.userItem.active,
.userItem[aria-selected="true"]{
  background:linear-gradient(135deg, rgba(46,166,255,.20), rgba(54,211,153,.11));
  border-color:rgba(46,166,255,.22);
}

.userItem .avatar,
.chat-header .avatar{
  box-shadow:0 8px 18px rgba(0,0,0,.28);
  border-color:rgba(255,255,255,.10);
}

.userName{
  color:var(--tg-text);
  letter-spacing:-.01em;
}

.userSub,
.header-status{
  color:var(--tg-muted);
}

.badge{
  background:linear-gradient(135deg, var(--tg-green), #21b8f3);
  color:#04111d;
  border:0;
  box-shadow:0 8px 18px rgba(54,211,153,.22);
}

#conversationArea{
  background:
    radial-gradient(circle at 20% 20%, rgba(46,166,255,.08), transparent 28%),
    radial-gradient(circle at 84% 68%, rgba(54,211,153,.06), transparent 30%),
    linear-gradient(180deg, rgba(9,14,25,.76), rgba(7,11,20,.92));
}

#conversationArea::before{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  opacity:.18;
  background-image:
    linear-gradient(30deg, rgba(255,255,255,.055) 12%, transparent 12.5%, transparent 87%, rgba(255,255,255,.055) 87.5%, rgba(255,255,255,.055)),
    linear-gradient(150deg, rgba(255,255,255,.045) 12%, transparent 12.5%, transparent 87%, rgba(255,255,255,.045) 87.5%, rgba(255,255,255,.045));
  background-size:36px 62px;
}

.messages{
  position:relative;
  z-index:1;
  padding:22px 22px 18px;
  gap:8px;
}

.day-sep,
.day-toast,
.top-loader{
  backdrop-filter:blur(16px);
  background:rgba(15,23,42,.72);
  border-color:rgba(148,163,184,.14);
  color:#c7d2e5;
}

.bubble{
  position:relative;
  max-width:min(72%, 720px);
  padding:9px 12px 8px;
  border:0;
  box-shadow:0 10px 22px rgba(0,0,0,.18);
}

.bubble.mine{
  align-self:flex-start;
  color:#f8fffd;
  background:linear-gradient(145deg, var(--tg-outgoing), var(--tg-outgoing-2));
  border-radius:18px 18px 6px 18px;
}

.bubble.theirs{
  align-self:flex-end;
  color:var(--tg-text);
  background:linear-gradient(145deg, rgba(23,32,51,.98), rgba(18,27,44,.98));
  border-radius:18px 18px 18px 6px;
}

.bubble.mine::after,
.bubble.theirs::after{
  content:"";
  position:absolute;
  bottom:0;
  width:12px;
  height:16px;
}

.bubble.mine::after{
  left:-6px;
  background:linear-gradient(145deg, var(--tg-outgoing), var(--tg-outgoing-2));
  clip-path:polygon(100% 0, 0 100%, 100% 100%);
}

.bubble.theirs::after{
  right:-6px;
  background:rgba(18,27,44,.98);
  clip-path:polygon(0 0, 0 100%, 100% 100%);
}

.bubble .text{
  font-size:14px;
  line-height:1.75;
}

.bubble .meta{
  margin-top:5px;
  justify-content:flex-end;
  color:rgba(226,232,240,.64);
}

.bubble .meta .seen{
  color:#b6fff0;
}

.reply,
.file-card{
  background:rgba(2,6,23,.22);
  border-color:rgba(255,255,255,.09);
}

.media img,
.media video{
  border-radius:15px;
  box-shadow:0 12px 28px rgba(0,0,0,.26);
}

.chat-footer{
  position:relative;
  z-index:2;
  padding:12px 14px 14px;
  background:rgba(15,23,42,.82);
  border-top:1px solid rgba(148,163,184,.12);
  backdrop-filter:blur(18px);
}

.composer{
  gap:9px;
  padding:3px;
  border-radius:22px;
  background:rgba(2,6,23,.30);
  border:1px solid rgba(148,163,184,.12);
}

.composer .btn,
#sendBtn,
label[for="fileInput"],
#recordBtn{
  border-radius:50%;
}

.input.msg{
  min-height:44px;
  border:0;
  background:transparent;
  box-shadow:none;
  padding:10px 12px;
}

.input.msg:focus{
  border-color:transparent;
  background:transparent;
}

#sendBtn{
  background:linear-gradient(135deg, #2ea6ff, #36d399);
  border:0;
  color:#03111f;
  box-shadow:0 10px 22px rgba(46,166,255,.20);
}

.scroll-bottom{
  background:rgba(15,23,42,.82);
  border:1px solid rgba(148,163,184,.18);
  backdrop-filter:blur(14px);
}

.menu-panel,
.userMenu,
.sheet,
.modal__panel{
  background:rgba(15,23,42,.94);
  border-color:rgba(148,163,184,.16);
  backdrop-filter:blur(18px);
}

@media (max-width: 820px){
  .chat-shell{ padding:0; gap:0; }
  .chat-header{ border-radius:0; min-height:64px; }
  .chat-main{ border-radius:0; border-inline:0; }
  #sidebar{ width:100%; flex-basis:100%; }
  .messages{ padding:16px 12px 12px; }
  .bubble{ max-width:88%; }
  .chat-footer{ padding:10px; }
  .composer{ border-radius:20px; }
}

/* =========================================================
   Shared-host realtime redesign patch: cleaner bubbles, safer media,
   Telegram-like message actions, mobile fixes and auth redesign.
   ========================================================= */
:root{
  --tg-page:#07111f;
  --tg-panel:#0e1728;
  --tg-panel-2:#111d31;
  --tg-line:rgba(148,163,184,.14);
  --tg-text:#edf4ff;
  --tg-muted:#8fa2bd;
  --tg-blue:#2ea6ff;
  --tg-green:#35d09b;
  --tg-danger:#ef4444;
  --tg-outgoing:rgba(46,166,255,.22);
  --tg-incoming:rgba(15,23,42,.94);
}

.chat-header{ position:relative; z-index:1200; }
.chat-main{ z-index:1; }
.menu-panel{
  z-index:3000 !important;
  min-width:240px;
  box-shadow:0 24px 70px rgba(0,0,0,.45);
}
.menu-item + .menu-item{ margin-top:6px; }
.btn.danger{ color:#fecaca; border-color:rgba(239,68,68,.30); background:rgba(239,68,68,.10); }
.btn.danger:hover{ background:rgba(239,68,68,.18); }

.messages{
  background-image:
    radial-gradient(circle at 20% 8%, rgba(46,166,255,.055), transparent 28%),
    radial-gradient(circle at 92% 90%, rgba(53,208,155,.045), transparent 30%);
}

.bubble{
  position:relative;
  max-width:min(70%, 690px);
  padding:8px 10px 7px;
  border:1px solid rgba(148,163,184,.10);
  box-shadow:none;
  transform:none;
}
.bubble.mine,
.bubble.theirs{
  border-radius:16px;
}
.bubble.mine::after,
.bubble.theirs::after{ display:none !important; }
.bubble.mine{
  background:linear-gradient(145deg, rgba(46,166,255,.20), rgba(53,208,155,.10));
  border-color:rgba(46,166,255,.22);
}
.bubble.theirs{
  background:rgba(15,23,42,.92);
  border-color:rgba(148,163,184,.12);
}
.bubble .text{
  font-size:14px;
  line-height:1.8;
}
.msg-link{
  color:#8fd4ff;
  text-decoration:none;
  border-bottom:1px solid rgba(143,212,255,.45);
  overflow-wrap:anywhere;
}
.msg-link:hover{ color:#c6ecff; border-bottom-color:#c6ecff; }
.bubble .meta{
  justify-content:flex-end;
  gap:7px;
  color:rgba(226,232,240,.62);
  user-select:none;
}
.meta-left{ display:flex; align-items:center; gap:6px; }
.edited{ font-size:10px; color:rgba(226,232,240,.48); }
.reply-btn{
  opacity:0;
  width:26px;
  height:26px;
  padding:0;
  border-radius:999px;
  transition:.16s ease;
}
.bubble:hover .reply-btn{ opacity:1; }
@media (hover:none){ .reply-btn{ opacity:1; } }

.message-action-popover{
  position:fixed;
  z-index:5000;
  direction:rtl;
  padding:8px;
  border-radius:16px;
  border:1px solid rgba(148,163,184,.18);
  background:rgba(15,23,42,.96);
  box-shadow:0 24px 70px rgba(0,0,0,.55);
  backdrop-filter:blur(18px);
  animation:popoverIn .14s ease;
}
@keyframes popoverIn{ from{ opacity:.55; transform:scale(.96); } to{ opacity:1; transform:scale(1); } }
.msg-pop-item{
  width:100%;
  min-height:42px;
  border:0;
  border-radius:12px;
  padding:9px 11px;
  color:var(--tg-text);
  background:transparent;
  display:flex;
  align-items:center;
  gap:10px;
  cursor:pointer;
  font-size:13px;
  text-align:right;
}
.msg-pop-item:hover{ background:rgba(255,255,255,.07); }
.msg-pop-item i{ width:20px; text-align:center; color:#9cc4ff; }
.msg-pop-item.danger{ color:#fecaca; }
.msg-pop-item.danger i{ color:#fb7185; }
.edit-message-input{ min-height:140px; resize:vertical; overflow:auto; }

.media{
  cursor:pointer;
  border-radius:16px;
  overflow:hidden;
}
.media:focus-visible{ outline:2px solid rgba(46,166,255,.65); outline-offset:3px; }
.media img{
  max-height:380px;
  object-fit:cover;
  width:100%;
  background:#020617;
}
.media--video .video-card{
  width:min(330px, 72vw);
  min-height:185px;
  border-radius:16px;
  border:1px solid rgba(148,163,184,.12);
  background:
    linear-gradient(135deg, rgba(46,166,255,.18), rgba(53,208,155,.10)),
    radial-gradient(circle at center, rgba(255,255,255,.08), transparent 48%),
    #020617;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  gap:12px;
}
.video-play{
  width:58px;
  height:58px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(255,255,255,.16);
  border:1px solid rgba(255,255,255,.24);
  box-shadow:0 14px 34px rgba(0,0,0,.35);
}
.video-play i{ margin-right:-3px; }
.video-meta{ display:flex; flex-direction:column; align-items:center; gap:3px; color:#eaf3ff; }
.video-meta small{ color:rgba(226,232,240,.58); font-size:11px; }
.media-actions{ justify-content:flex-end; }

.media-viewer{ z-index:4200; }
.media-viewer .modal__backdrop{ background:rgba(2,6,23,.82); backdrop-filter:blur(12px); }
.media-viewer .modal__panel{ padding:12px; gap:10px; }
.media-viewer__top{
  position:relative;
  z-index:2;
  border-radius:18px;
  background:rgba(15,23,42,.86);
  box-shadow:0 18px 48px rgba(0,0,0,.35);
}
.media-viewer__body{ padding:0; min-height:0; }
.stage{
  position:relative;
  border-radius:20px;
  border-color:rgba(148,163,184,.14);
  background:rgba(2,6,23,.64);
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.03), 0 22px 70px rgba(0,0,0,.34);
}
.stage__img{ max-width:100%; max-height:100%; object-fit:contain; }
.stage__video{ width:100%; height:100%; max-height:calc(100dvh - 126px); object-fit:contain; background:#000; }
.video-hint{
  position:absolute;
  bottom:12px;
  right:50%;
  transform:translateX(50%);
  display:flex;
  align-items:center;
  gap:8px;
  padding:7px 12px;
  border-radius:999px;
  background:rgba(15,23,42,.72);
  border:1px solid rgba(148,163,184,.18);
  color:rgba(226,232,240,.78);
  font-size:12px;
  pointer-events:none;
}
.media-confirm{
  position:absolute;
  inset:0;
  z-index:5;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  background:rgba(2,6,23,.35);
}
.media-confirm.hidden{ display:none; }
.media-confirm__box{
  width:min(360px, 100%);
  border-radius:18px;
  border:1px solid rgba(148,163,184,.18);
  background:rgba(15,23,42,.96);
  box-shadow:0 24px 70px rgba(0,0,0,.50);
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:9px;
}
.media-confirm__box span{ color:var(--tg-muted); font-size:13px; }
.media-confirm__actions{ display:flex; gap:8px; justify-content:flex-end; margin-top:8px; }

/* Login redesign without product-specific wording */
.auth-page{
  min-height:100dvh;
  margin:0;
  color:var(--tg-text);
  background:
    radial-gradient(circle at 12% 15%, rgba(46,166,255,.22), transparent 34%),
    radial-gradient(circle at 88% 82%, rgba(53,208,155,.14), transparent 34%),
    linear-gradient(150deg, #050b16, #0a1528 58%, #06101d);
}
.auth-screen{
  min-height:100dvh;
  display:grid;
  place-items:center;
  padding:24px;
}
.auth-card--modern{
  width:min(440px, 100%);
  padding:24px;
  border-radius:28px;
  background:rgba(15,23,42,.78);
  border:1px solid rgba(148,163,184,.16);
  box-shadow:0 30px 90px rgba(0,0,0,.48);
  backdrop-filter:blur(22px);
}
.auth-brandline{
  display:flex;
  gap:14px;
  align-items:center;
  margin-bottom:22px;
}
.auth-logo{
  width:54px;
  height:54px;
  border-radius:18px;
  display:grid;
  place-items:center;
  background:linear-gradient(135deg, rgba(46,166,255,.30), rgba(53,208,155,.18));
  border:1px solid rgba(148,163,184,.18);
  color:#dff7ff;
  font-size:22px;
}
.auth-brandline h1{ margin:0; font-size:22px; }
.auth-brandline p{ margin:5px 0 0; color:var(--tg-muted); font-size:13px; }
.auth-form{ display:flex; flex-direction:column; gap:14px; }
.auth-field{ display:flex; flex-direction:column; gap:8px; color:#cbd5e1; font-size:13px; }
.auth-input-wrap{ position:relative; display:flex; align-items:center; }
.auth-input-wrap > i{
  position:absolute;
  right:13px;
  color:#86a4c6;
  z-index:2;
}
.auth-input-wrap .input{
  height:50px;
  padding-right:42px;
  padding-left:44px;
  border-radius:16px;
  background:rgba(2,6,23,.36);
  border-color:rgba(148,163,184,.16);
}
.auth-input-wrap .input:focus{
  border-color:rgba(46,166,255,.55);
  box-shadow:0 0 0 4px rgba(46,166,255,.10);
}
.auth-eye{
  position:absolute;
  left:8px;
  width:36px;
  height:36px;
  border:0;
  border-radius:12px;
  background:transparent;
  color:#93a9c7;
  cursor:pointer;
}
.auth-eye:hover{ background:rgba(255,255,255,.06); }
.auth-submit{
  height:50px;
  border-radius:16px;
  margin-top:6px;
}
.auth-form .error{ margin-top:0; }

@media (max-width:820px){
  .chat-shell{ height:100dvh; padding:0; }
  .chat-header{ min-height:60px; padding:9px 10px; border-radius:0; border-right:0; border-left:0; }
  .chat-main{ border-radius:0; border:0; }
  #sidebar{ padding:10px; }
  .sidebar-top{ position:sticky; top:0; z-index:3; padding:2px 0 8px; background:rgba(7,17,31,.92); backdrop-filter:blur(12px); }
  .messages{ padding:12px 9px 10px; gap:7px; }
  .bubble{ max-width:88%; padding:8px 10px 7px; border-radius:15px !important; }
  .bubble .text{ font-size:13.5px; line-height:1.75; }
  .reply-btn{ width:28px; height:28px; opacity:1; }
  .chat-footer{ padding:8px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .composer{ gap:6px; border-radius:18px; }
  .composer .btn.icon, #sendBtn{ width:42px; min-width:42px; height:42px; padding:0; }
  .input.msg{ min-height:42px; max-height:120px; font-size:16px; }
  .message-action-popover{ width:min(248px, calc(100vw - 22px)) !important; left:11px !important; right:11px; top:auto !important; bottom:max(84px, env(safe-area-inset-bottom) + 72px); }
  .media--video .video-card{ width:min(315px, 80vw); min-height:168px; }
  .media-viewer .modal__panel{ padding:8px; }
  .media-viewer__top{ flex-direction:column; align-items:stretch; gap:8px; }
  .modal__actions{ display:flex; gap:7px; flex-wrap:wrap; }
  .modal__actions .btn{ flex:1; min-height:38px; }
  .stage{ border-radius:16px; }
  .navbtn{ width:38px; height:38px; min-width:38px; }
  .video-hint{ display:none; }
  .auth-screen{ padding:16px; align-items:center; }
  .auth-card--modern{ padding:20px; border-radius:24px; }
}

/* EliLink branding patch */
.logo-text{
  font-weight:900;
  letter-spacing:.04em;
  color:#dff7ff;
  background:linear-gradient(135deg, rgba(46,166,255,.26), rgba(54,211,153,.18));
}
.elilink-brand{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:3px;
  line-height:1.35;
}
.elilink-brand strong{
  font-size:19px;
  font-weight:900;
  letter-spacing:.01em;
  color:#f8fbff;
}
.elilink-brand span{
  font-size:11.5px;
  font-weight:600;
  color:#95b5d6;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.auth-brandline h1{
  font-weight:900;
  letter-spacing:.01em;
}
.auth-brandline p{
  color:#a9c5df;
}
@media (max-width: 560px){
  .elilink-brand strong{ font-size:17px; }
  .elilink-brand span{ max-width:210px; }
}

/* =========================================================
   EliLink hotfix UI polish: stable chat, premium media, notes
   ========================================================= */

.brand-en,
.brand-title-en,
.elilink-brand.brand-en,
.auth-brandline h1,
.auth-brandline p{
  font-family:"Space Grotesk", "Inter", system-ui, sans-serif !important;
  direction:ltr;
  text-align:left;
  letter-spacing:.01em;
}
.elilink-brand.brand-en{
  padding:12px 14px;
  border:1px solid rgba(148,163,184,.16);
  background:linear-gradient(135deg, rgba(109,140,255,.16), rgba(56,217,169,.08));
  border-radius:18px;
  box-shadow:0 16px 36px rgba(0,0,0,.16);
}
.elilink-brand.brand-en strong{
  font-size:20px;
  line-height:1;
  background:linear-gradient(90deg,#f8fbff,#a8baff 55%,#7cf6d5);
  -webkit-background-clip:text;
  background-clip:text;
  color:transparent;
}
.elilink-brand.brand-en span{
  font-size:11.5px;
  color:#b9c6e6;
  white-space:normal;
  max-width:260px;
}
.auth-brandline p{
  color:#b9c6e6 !important;
  font-weight:500;
}
.auth-logo,
.logo.logo-text{
  font-family:"Space Grotesk", system-ui, sans-serif !important;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.18), 0 18px 40px rgba(109,140,255,.18);
}

/* cleaner, no-tail message surfaces */
.bubble,
.bubble.mine,
.bubble.theirs{
  border-radius:18px !important;
  border:1px solid rgba(148,163,184,.12) !important;
  box-shadow:0 12px 34px rgba(0,0,0,.18) !important;
}
.bubble.mine::after,
.bubble.theirs::after{ display:none !important; }
.bubble.mine{
  background:linear-gradient(135deg, rgba(85,116,255,.34), rgba(42,66,132,.72)) !important;
}
.bubble.theirs{
  background:linear-gradient(135deg, rgba(22,34,55,.96), rgba(12,21,38,.96)) !important;
}
.bubble .text{ overflow-wrap:anywhere; }
.msg-link{
  color:#9fc1ff;
  text-decoration:none;
  border-bottom:1px dashed rgba(159,193,255,.55);
}
.msg-link:hover{ color:#cfe0ff; border-bottom-style:solid; }
.message-action-popover{
  z-index:7000 !important;
  backdrop-filter:blur(18px);
  background:rgba(12,20,36,.96) !important;
  border:1px solid rgba(148,163,184,.18) !important;
  box-shadow:0 26px 80px rgba(0,0,0,.42) !important;
}
.msg-pop-item{
  min-height:42px;
  border-radius:13px;
}
.msg-pop-item:hover{ background:rgba(109,140,255,.13); }

/* premium media viewer */
.media-viewer .modal__panel{
  max-width:min(1180px, calc(100vw - 24px)) !important;
  width:min(1180px, calc(100vw - 24px)) !important;
  height:min(820px, calc(100dvh - 24px)) !important;
  border-radius:28px !important;
  overflow:hidden;
  background:linear-gradient(145deg, rgba(11,18,32,.98), rgba(6,12,24,.96)) !important;
  border:1px solid rgba(148,163,184,.18) !important;
}
.media-viewer__top{
  background:rgba(15,23,42,.72);
  border-bottom:1px solid rgba(148,163,184,.12);
  padding:12px 14px !important;
}
.media-viewer__body{
  flex:1;
  background:radial-gradient(900px 500px at 50% 15%, rgba(109,140,255,.12), transparent 55%), #040814;
}
.stage{
  border:0 !important;
  background:transparent !important;
}
.stage__img,
.stage__video{
  max-width:100%;
  max-height:calc(100dvh - 150px);
  border-radius:20px;
  box-shadow:0 24px 90px rgba(0,0,0,.45);
}
.stage__video{
  background:#000;
  outline:none;
}
.media-confirm{
  z-index:3;
  background:rgba(2,6,23,.42);
  backdrop-filter:blur(8px);
}
.media-confirm__box{
  border-radius:22px !important;
  border:1px solid rgba(255,255,255,.16) !important;
  background:rgba(15,23,42,.96) !important;
  box-shadow:0 24px 80px rgba(0,0,0,.42) !important;
}
.media--video .video-card{
  min-height:132px;
  border-radius:20px;
  background:linear-gradient(135deg, rgba(15,23,42,.95), rgba(30,41,59,.9));
}
.media--video-note{
  width:170px;
  min-height:196px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:10px;
  border-radius:26px;
  padding:14px;
  background:linear-gradient(145deg, rgba(15,23,42,.86), rgba(30,41,59,.62));
  border:1px solid rgba(148,163,184,.16);
}
.video-note-ring{
  width:118px;
  height:118px;
  border-radius:50%;
  display:grid;
  place-items:center;
  background:radial-gradient(circle at 35% 30%, rgba(255,255,255,.26), transparent 28%), linear-gradient(135deg, rgba(109,140,255,.62), rgba(56,217,169,.32));
  box-shadow:0 16px 48px rgba(109,140,255,.22);
}
.video-note-meta{
  direction:ltr;
  font-family:"Space Grotesk", system-ui, sans-serif;
  text-align:center;
  color:#dbeafe;
}
.video-note-meta small{ display:block; color:#94a3b8; font-size:11px; margin-top:3px; }
.voice-shell{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:min(280px, 72vw);
  padding:8px 10px;
  border-radius:18px;
  background:rgba(15,23,42,.44);
  border:1px solid rgba(148,163,184,.12);
}
.voice-shell > i{ color:#8ea8ff; }
.voice-shell audio{ width:100%; height:34px; }

/* recording overlay */
.record-overlay{
  position:fixed;
  inset:auto 16px max(18px, env(safe-area-inset-bottom)) 16px;
  z-index:7200;
  display:flex;
  justify-content:center;
  pointer-events:none;
}
.record-overlay.hidden{ display:none !important; }
.record-card{
  pointer-events:auto;
  width:min(560px, 100%);
  min-height:94px;
  display:flex;
  align-items:center;
  gap:14px;
  padding:12px;
  border-radius:28px;
  border:1px solid rgba(148,163,184,.20);
  background:linear-gradient(145deg, rgba(15,23,42,.96), rgba(8,13,26,.96));
  box-shadow:0 28px 90px rgba(0,0,0,.5);
  backdrop-filter:blur(18px);
}
.record-preview{
  width:74px;
  height:74px;
  border-radius:50%;
  overflow:hidden;
  display:grid;
  place-items:center;
  flex:0 0 auto;
  background:linear-gradient(135deg, rgba(109,140,255,.26), rgba(56,217,169,.16));
  border:1px solid rgba(255,255,255,.12);
}
.record-preview video{ width:100%; height:100%; object-fit:cover; transform:scaleX(-1); }
.record-wave{ font-size:26px; color:#9fb6ff; }
.record-info{ min-width:0; flex:1; display:flex; flex-direction:column; gap:3px; }
.record-info strong{ font-family:"Space Grotesk", system-ui, sans-serif; direction:ltr; font-size:16px; }
.record-info span{ font-family:"Space Grotesk", monospace; color:#e0e7ff; }
.record-info small{ color:#94a3b8; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.record-actions{ display:flex; gap:7px; }
.record-overlay.locked .record-card{ border-color:rgba(56,217,169,.32); }
.record-toggle.video-mode{ background:rgba(109,140,255,.16) !important; color:#c7d2fe; }
.record-toggle.recording{ color:#ffb4b4; }

/* profile modal redesign */
.profile-hero{
  display:flex;
  align-items:center;
  gap:14px;
  padding:14px;
  border-radius:24px;
  background:linear-gradient(135deg, rgba(109,140,255,.16), rgba(56,217,169,.08));
}
.profile-hero-avatar,
.profile-hero-avatar-img,
.profile-hero-avatar-fallback{
  width:100%;
  height:100%;
  border-radius:100%;
  flex:0 0 auto;
}
.profile-hero-avatar-img{ object-fit:cover; display:block; }
.profile-hero-avatar-fallback{
  display:grid;
  place-items:center;
  font-size:24px;
  font-weight:900;
  background:rgba(109,140,255,.18);
}
.profile-hero-meta h3{ margin:0; font-size:19px; }
.profile-hero-meta span{ color:#9fb0d0; direction:ltr; display:inline-block; margin-top:4px; }
.profile-media-section{ margin-top:12px; }
.profile-media-list{
  max-height:min(390px, 50dvh);
  overflow:auto;
  display:grid;
  grid-template-columns:1fr;
  gap:8px;
  padding-left:3px;
}
.profile-media-list .file-card{
  border-radius:18px;
  background:rgba(15,23,42,.48);
  border:1px solid rgba(148,163,184,.13);
}
.pm-preview-wrap{
  border-radius:14px !important;
  overflow:hidden;
  background:rgba(15,23,42,.72);
}

/* admin/register/auth polish */
.auth-wrap .card,
.auth-card--modern{
  border-color:rgba(148,163,184,.16) !important;
  background:linear-gradient(145deg, rgba(15,23,42,.88), rgba(8,13,26,.88)) !important;
}
.user-table th,
.user-table td{ border-color:rgba(148,163,184,.12) !important; }

@media (max-width:780px){
  .chat-shell{ padding:0; gap:0; }
  .chat-header{ border-radius:0; border-left:0; border-right:0; }
  .chat-main{ border-radius:0 !important; min-height:0; }
  .composer{ gap:6px; padding:8px; }
  .bubble{ max-width:88% !important; }
  .media-viewer .modal__panel{ width:100vw !important; height:100dvh !important; max-width:100vw !important; border-radius:0 !important; }
  .stage__img,.stage__video{ max-height:calc(100dvh - 170px); border-radius:14px; }
  .record-overlay{ inset:auto 8px max(10px, env(safe-area-inset-bottom)) 8px; }
  .record-card{ border-radius:22px; gap:10px; padding:10px; }
  .record-preview{ width:58px; height:58px; }
  .record-info small{ max-width:145px; }
  .record-actions .btn{ width:38px; min-width:38px; padding:0; }
  .elilink-brand.brand-en span{ max-width:200px; font-size:10.5px; }
}
.menu-panel,
.userMenu{ z-index:8000 !important; }

/* =========================================================
   EliLink shared-host polish patch: dialogs, media, profile,
   responsive layout, brand typography, recorder UX.
   ========================================================= */
:root{
  --bg1:#050914;
  --bg2:#081527;
  --bg3:#020612;
  --accent:#7c9bff;
  --accent-strong:#b6c8ff;
  --accent2:#52e0c4;
  --panel:#0a1222;
  --panel2:#111c32;
  --line:rgba(166,190,255,.16);
  --soft:rgba(124,155,255,.13);
  --romance:#dbe7ff;
}
.chat-bg{
  background:
    radial-gradient(900px 620px at 18% 8%, rgba(88,128,255,.22), transparent 62%),
    radial-gradient(800px 680px at 92% 30%, rgba(82,224,196,.13), transparent 62%),
    radial-gradient(1200px 780px at 50% 110%, rgba(57,86,170,.12), transparent 64%),
    linear-gradient(150deg, var(--bg1), var(--bg2) 54%, var(--bg3));
}
.chat-header,.chat-main,#sidebar,#conversationArea,.card,.sheet,.modal__panel{
  border-color:var(--line) !important;
  box-shadow:0 28px 90px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.04);
}
#refreshUsers{ display:none !important; }
.sidebar-top{ align-items:flex-start; }
.elilink-brand.brand-en{
  width:100%;
  position:relative;
  padding:18px 18px 16px 18px;
  border-radius:24px;
  background:
    linear-gradient(135deg, rgba(125,154,255,.18), rgba(82,224,196,.10)),
    rgba(8,18,34,.82);
  border:1px solid rgba(182,200,255,.18);
  overflow:hidden;
}
.elilink-brand.brand-en::after{
  content:"";
  position:absolute;
  inset:auto -18% -42% 12%;
  height:96px;
  pointer-events:none;
}
.elilink-brand.brand-en strong,
.brand-en .title,
.logo + div .title{
  font-family: Instrument Serif, Georgia, serif!important;
  letter-spacing:.7px;
  color:#f4f7ff;
  text-shadow:0 0 18px rgba(124,155,255,.28);
}
.elilink-brand.brand-en strong{ font-size:30px; line-height:1; }
.elilink-brand.brand-en span{
  font-family: Instrument Serif, Georgia, serif!important;
  direction:ltr;
  display:block;
  margin-top:8px;
  max-width:260px;
  color:var(--romance);
  font-size:13px;
  line-height:1.65;
  letter-spacing:.25px;
}
.userItem{
  border-radius:22px !important;
  padding:14px !important;
  background:rgba(12,24,43,.45);
  border:1px solid transparent;
}
.userItem:hover{ background:rgba(124,155,255,.09); border-color:rgba(124,155,255,.14); }
.userItem.active{
  background:linear-gradient(135deg, rgba(30,92,139,.72), rgba(21,58,83,.78)) !important;
  border-color:rgba(82,224,196,.25) !important;
}

/* Modal/Dialog system */
.modal{ z-index:5000 !important; display:grid; place-items:center; padding:18px; }
.modal.hidden{ display:none !important; }
.modal__backdrop{
  background:rgba(1,5,14,.78) !important;
  backdrop-filter:blur(18px) saturate(130%) !important;
}
.modal__panel{
  width:min(920px, calc(100vw - 30px)) !important;
  max-height:calc(100dvh - 36px) !important;
  border-radius:30px !important;
  background:
    radial-gradient(700px 260px at 16% 0%, rgba(124,155,255,.12), transparent 65%),
    radial-gradient(540px 360px at 100% 18%, rgba(82,224,196,.08), transparent 62%),
    rgba(8,15,30,.96) !important;
  border:1px solid rgba(182,200,255,.18) !important;
  overflow:hidden !important;
}
#settingsModal .modal__panel{
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  padding:16px !important;
}
.sheet{
  width:min(860px, 100%) !important;
  max-height:calc(100dvh - 64px) !important;
  padding:22px !important;
  border-radius:28px !important;
  background:linear-gradient(180deg, rgba(17,28,50,.98), rgba(8,15,29,.98)) !important;
  border:1px solid rgba(182,200,255,.16) !important;
  overflow:auto !important;
}
.sheet h3{
  font-size:24px !important;
  color:#f8fbff;
  margin-bottom:18px !important;
}
.sheet .row{ gap:14px !important; }
.sheet .actions{ justify-content:flex-end; gap:10px !important; }
.sheet .input{
  min-height:58px;
  border-radius:18px !important;
  background:rgba(4,10,21,.58) !important;
  border-color:rgba(182,200,255,.13) !important;
}
.prefs-section{
  border-radius:22px;
  border:1px solid rgba(182,200,255,.12);
  background:rgba(255,255,255,.035);
  padding:16px;
}
.prefs-title{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  font-weight:800;
}
.prefs-title small{ color:#8ea2c8; font-weight:600; }

/* Media viewer */
.media-viewer{ padding:12px !important; }
.media-viewer .modal__panel{
  width:min(1120px, calc(100vw - 24px)) !important;
  height:min(760px, calc(100dvh - 24px)) !important;
  max-height:calc(100dvh - 24px) !important;
  padding:0 !important;
  display:grid !important;
  grid-template-rows:auto 1fr;
}
.media-viewer__top{
  min-height:72px;
  padding:14px 16px !important;
  background:rgba(9,17,32,.82);
  border-bottom:1px solid rgba(182,200,255,.13);
}
.media-viewer .modal__title{
  direction:ltr;
  text-align:left;
  max-width:min(560px, 58vw);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  font-family:"Space Grotesk","IRANSansX",sans-serif;
  font-weight:800;
}
.media-viewer__body{
  position:relative;
  min-height:0;
  background:
    linear-gradient(45deg, rgba(255,255,255,.025) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.025) 75%),
    rgba(0,0,0,.18);
  background-size:32px 32px;
}
.stage{
  width:100%; height:100%;
  display:grid; place-items:center;
  padding:18px 72px;
}
.stage__img,
.stage__video{
  max-width:100%; max-height:100%;
  border-radius:22px !important;
  background:#000;
  box-shadow:0 24px 90px rgba(0,0,0,.45);
}
.stage__video-note{
  aspect-ratio:1/1;
  width:min(520px, 80vw) !important;
  height:auto !important;
  border-radius:50% !important;
  object-fit:cover !important;
}
.navbtn{
  width:48px !important;
  height:48px !important;
  border-radius:18px !important;
  background:rgba(16,28,49,.76) !important;
  border:1px solid rgba(182,200,255,.16) !important;
  backdrop-filter:blur(10px);
}
.media-confirm{
  position:absolute !important;
  inset:0 !important;
  display:grid !important;
  place-items:center !important;
  background:rgba(1,5,14,.34);
  z-index:10;
}
.media-confirm.hidden{ display:none !important; }
.media-confirm__box{
  width:min(360px, calc(100vw - 44px));
  border-radius:24px !important;
  border:1px solid rgba(255,107,107,.24) !important;
  background:linear-gradient(180deg, rgba(38,18,27,.98), rgba(11,16,29,.98)) !important;
  box-shadow:0 22px 70px rgba(0,0,0,.44);
}
.media-caption{
  position:absolute;
  left:10px; right:10px; bottom:10px;
  display:flex; justify-content:space-between; gap:10px;
  padding:8px 10px;
  border-radius:14px;
  background:linear-gradient(180deg, transparent, rgba(0,0,0,.54));
  font-size:11px;
  color:#e9f0ff;
  pointer-events:none;
}
.media-caption span{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; direction:ltr; }
.media-caption small{ color:#c1ceeb; }
.file-sub{ color:#8ea2c8; font-size:11px; margin-top:3px; direction:ltr; }

/* Voice / video message */
.voice-shell{
  display:grid !important;
  grid-template-columns:auto minmax(120px, 1fr);
  align-items:center;
  gap:10px;
  min-width:min(320px, 72vw);
  padding:10px;
  border-radius:18px;
  background:linear-gradient(135deg, rgba(124,155,255,.12), rgba(82,224,196,.06));
}
.voice-shell audio{ grid-column:1 / -1; width:100%; height:32px; }
.voice-play-proxy{
  width:42px; height:42px; border-radius:50%; border:0;
  color:#06101f; background:linear-gradient(135deg, #b6c8ff, #52e0c4);
  display:grid; place-items:center; cursor:pointer;
}
.voice-meta{ min-width:0; direction:ltr; text-align:left; }
.voice-meta strong{ display:block; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.voice-meta span{ display:block; color:#9fb0d0; font-size:11px; margin-top:2px; }
.media--video-note{
  width:178px !important; height:178px !important;
  border-radius:50% !important;
  background:radial-gradient(circle at 35% 20%, rgba(182,200,255,.34), rgba(20,32,57,.88) 54%, rgba(7,14,27,.96)) !important;
  box-shadow:0 18px 42px rgba(0,0,0,.34), inset 0 0 0 1px rgba(182,200,255,.16);
}
.video-note-ring{ border-radius:50%; }
.video-note-meta{ font-family:"Space Grotesk","IRANSansX",sans-serif; }
.record-overlay{ z-index:5600 !important; pointer-events:none; }
.record-card{ pointer-events:auto; border-radius:28px !important; background:rgba(8,15,30,.96) !important; }
.record-overlay.locked .record-card{ box-shadow:0 0 0 1px rgba(82,224,196,.28), 0 24px 80px rgba(0,0,0,.42); }
.record-overlay.locked #recordLock{ background:linear-gradient(135deg, rgba(82,224,196,.28), rgba(124,155,255,.16)); }
.record-preview video{ border-radius:22px; object-fit:cover; }

/* Profile redesign */
.profile-hero--polished{
  position:relative;
  display:grid !important;
  grid-template-columns:auto 1fr !important;
  gap:18px !important;
  align-items:end !important;
  min-height:178px;
  padding:22px !important;
  border-radius:28px !important;
  overflow:hidden;
  background:linear-gradient(135deg, rgba(27,46,82,.96), rgba(12,25,45,.96)) !important;
}
.profile-hero-cover{
  position:absolute; inset:0;
  background:
    radial-gradient(440px 160px at 22% 0%, rgba(124,155,255,.34), transparent 65%),
    linear-gradient(90deg, rgba(124,155,255,.16), rgba(82,224,196,.09));
  opacity:.96;
}
.profile-hero-avatar,
.profile-hero-meta{ position:relative; z-index:1; }
.profile-hero-avatar{ width:98px !important; height:98px !important; border-radius:30px !important; }
.profile-hero-meta h3{ font-size:26px !important; font-family:"Space Grotesk","IRANSansX",sans-serif; }
.profile-hero-meta small{ display:block; color:#8ea2c8; margin-top:7px; direction:ltr; }
.profile-media-list{
  display:grid !important;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:12px;
  max-height:min(440px, 52dvh) !important;
  padding:4px 2px 10px !important;
}
.profile-media-card{
  position:relative;
  border-radius:22px;
  overflow:hidden;
  background:rgba(6,13,26,.72);
  border:1px solid rgba(182,200,255,.12);
  min-height:210px;
  display:flex;
  flex-direction:column;
}
.profile-media-preview{ padding:0; border:0; background:transparent; cursor:pointer; height:128px; overflow:hidden; }
.pm-thumb{ width:100%; height:100%; display:grid; place-items:center; object-fit:cover; }
.pm-thumb--placeholder,.pm-thumb--audio,.pm-thumb--file{
  background:linear-gradient(135deg, rgba(124,155,255,.15), rgba(82,224,196,.07));
  color:#dbe7ff; font-weight:800; gap:8px;
}
.pm-thumb i{ font-size:26px; }
.profile-media-info{ padding:10px 12px 0; min-width:0; direction:ltr; text-align:left; }
.profile-media-info strong{ display:block; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.profile-media-info span{ display:block; color:#8ea2c8; font-size:11px; margin-top:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.profile-media-actions{ display:flex; gap:8px; padding:10px 12px 12px; margin-top:auto; }
.profile-media-actions .btn{ flex:1; }
.profile-media-empty{ grid-column:1 / -1; display:grid; place-items:center; gap:10px; min-height:160px; color:#8ea2c8; border:1px dashed rgba(182,200,255,.16); border-radius:22px; }
.profile-delete-confirm{
  position:absolute; inset:auto 10px 10px 10px; z-index:4;
  display:flex; align-items:center; gap:8px; flex-wrap:wrap;
  padding:10px; border-radius:16px;
  background:rgba(14,18,32,.96); border:1px solid rgba(255,107,107,.28);
  box-shadow:0 18px 44px rgba(0,0,0,.36);
}
.profile-delete-confirm span{ flex:1 1 100%; color:#ffd7d7; font-size:12px; }

@media (max-width: 780px){
  .chat-shell{ padding:0 !important; gap:0 !important; }
  .chat-header{ border-radius:0 !important; }
  .chat-main{ border-radius:0 !important; }
  #sidebar{ width:100% !important; }
  .elilink-brand.brand-en strong{ font-size:25px; }
  .elilink-brand.brand-en span{ max-width:100%; font-size:11.5px; }
  .modal{ padding:0 !important; }
  #settingsModal .modal__panel,.modal__panel{
    width:100vw !important; height:100dvh !important; max-height:100dvh !important;
    border-radius:0 !important;
    padding:10px !important;
  }
  .sheet{ width:100% !important; max-height:calc(100dvh - 20px) !important; border-radius:24px !important; padding:16px !important; }
  .media-viewer .modal__panel{ width:100vw !important; height:100dvh !important; border-radius:0 !important; }
  .media-viewer__top{ min-height:auto; flex-direction:column; align-items:stretch !important; }
  .media-viewer .modal__title{ max-width:100%; }
  .stage{ padding:12px 10px 72px; }
  .navbtn{ position:absolute; bottom:16px; top:auto !important; transform:none !important; }
  #mediaPrev{ right:72px; }
  #mediaNext{ left:72px; }
  .profile-hero--polished{ grid-template-columns:1fr !important; min-height:210px; text-align:center; justify-items:center; }
  .profile-media-list{ grid-template-columns:1fr !important; max-height:calc(100dvh - 360px) !important; }
  .profile-media-card{ min-height:auto; }
  .profile-media-preview{ height:180px; }
  .voice-shell{ min-width:0; width:min(320px, calc(100vw - 82px)); }
  .media--video-note{ width:148px !important; height:148px !important; }
}
.auth-brandline h1{
  font-family: Instrument Serif, Georgia, serif!important;
  font-size:42px !important;
  letter-spacing:.8px;
  line-height:1;
  margin-bottom:8px !important;
}
.auth-brandline p{
  font-family: Instrument Serif, Georgia, serif!important;
  direction:ltr;
  color:#dbe7ff !important;
  letter-spacing:.25px;
}

/* Extra modal polish for account/password sheets */
.modal-card{
  position:relative;
  width:100%;
  border-radius:28px;
  padding:2px;
}
.modal-card::before{
  content:"";
  position:absolute;
  inset:-1px;
  border-radius:inherit;
  background:linear-gradient(135deg, rgba(124,155,255,.34), rgba(82,224,196,.24), transparent 72%);
  pointer-events:none;
  opacity:.68;
}
.modal-card > *{ position:relative; z-index:1; }
.modal-card__eyebrow{
  display:inline-flex;
  align-items:center;
  margin-bottom:10px;
  padding:6px 10px;
  border-radius:999px;
  background:rgba(124,155,255,.12);
  color:#b6c8ff;
  font-family:"Space Grotesk","IRANSansX",sans-serif;
  font-size:11px;
  font-weight:800;
  letter-spacing:.12em;
  text-transform:uppercase;
  direction:ltr;
}
.modal-card__subtitle{
  margin:-6px 0 18px;
  color:#8ea2c8;
  line-height:1.9;
}
.modal-form-grid{
  display:grid;
  grid-template-columns:1fr;
  gap:12px;
  margin-top:8px;
}
.modal-form-grid--two{ grid-template-columns:1.2fr .8fr; }
.field-card{
  display:grid;
  gap:8px;
  padding:12px;
  border-radius:20px;
  background:rgba(5,12,24,.46);
  border:1px solid rgba(182,200,255,.12);
}
.field-card .label{ margin:0; color:#b9c8e8; }
.field-card .hint{ display:block; color:#7f92b8; font-size:12px; }
.field-card--upload .input{ padding:14px; cursor:pointer; }
#settingsModal .sheet > .modal-card{ padding:0; }
#settingsModal .sheet > .modal-card::before{ display:none; }

@media (max-width:780px){
  .modal-form-grid--two{ grid-template-columns:1fr; }
  .modal-card__subtitle{ font-size:13px; }
  .field-card{ padding:10px; }
}

/* Header/menu layering safety */
.chat-header{ position:relative; z-index:800; }
.menu-wrap{ position:relative; z-index:1200; }
.menu-panel{ z-index:1300 !important; }
.modal{ z-index:5000 !important; }
.message-action-popover{ z-index:4200 !important; }

/* =========================================================
   EliLink v10 patch: iOS-safe downloads, drag/drop upload,
   cleaner recorder, camera switch, encrypted text actions
   ========================================================= */
.btn.js-download-file,
#mediaDownload{
  cursor:pointer;
}
.drop-zone{
  position:fixed;
  inset:0;
  z-index:9000;
  display:grid;
  place-items:center;
  background:rgba(2,6,23,.62);
  backdrop-filter:blur(14px);
  pointer-events:auto;
}
.drop-zone.hidden{ display:none !important; }
.drop-zone > div{
  width:min(380px, calc(100vw - 36px));
  min-height:180px;
  display:grid;
  place-items:center;
  gap:8px;
  padding:28px;
  border-radius:32px;
  border:1px dashed rgba(182,200,255,.42);
  background:linear-gradient(145deg, rgba(12,22,42,.94), rgba(5,12,24,.94));
  box-shadow:0 28px 100px rgba(0,0,0,.48), inset 0 1px 0 rgba(255,255,255,.09);
  color:#eaf1ff;
  text-align:center;
}
.drop-zone i{
  width:70px;
  height:70px;
  display:grid;
  place-items:center;
  border-radius:24px;
  background:linear-gradient(135deg, rgba(124,155,255,.28), rgba(82,224,196,.16));
  color:#c7d2fe;
  font-size:30px;
}
.drop-zone strong{
  font-size:18px;
  font-weight:900;
}
.drop-zone span{
  color:#9fb0d0;
  font-size:13px;
}
.record-card{
  position:relative;
  overflow:hidden;
}
.record-card::before{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background:linear-gradient(90deg, rgba(124,155,255,.08), transparent 38%, rgba(82,224,196,.08));
}
.record-preview video{ transform:none !important; }
.record-preview video.is-front-camera{ transform:scaleX(-1) !important; }
#recordSwitch:not(.hidden){ display:grid !important; }
.record-actions .btn{
  width:42px;
  min-width:42px;
  height:42px;
  border-radius:16px;
}
.record-overlay.recording-video .record-preview{
  width:86px;
  height:86px;
  box-shadow:0 0 0 5px rgba(124,155,255,.09), 0 18px 44px rgba(0,0,0,.34);
}
.record-overlay.locked .record-info small{ color:#9ff3dd; }
.video-note-ring{
  position:relative;
  overflow:hidden;
}
.video-note-preview{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
  opacity:.72;
  pointer-events:none;
}
.video-note-ring .video-play{
  position:relative;
  z-index:2;
  width:44px;
  height:44px;
  border-radius:50%;
  display:grid;
  place-items:center;
  color:#06101f;
  background:linear-gradient(135deg, rgba(234,241,255,.96), rgba(82,224,196,.92));
  box-shadow:0 14px 34px rgba(0,0,0,.34);
}
.media--video-note .video-note-meta{
  position:relative;
  z-index:2;
  padding:0 10px;
}
.stage__video-note{
  width:min(560px, 82vw) !important;
  max-height:min(560px, calc(100dvh - 176px)) !important;
  aspect-ratio:1/1;
  border-radius:50% !important;
  object-fit:cover !important;
  background:#000;
}
.media-viewer .modal__actions{
  flex-wrap:wrap;
}
.msg-pop-item[data-msg-act="edit"]{
  color:#dfe7ff;
}
.text[data-encrypted="0"] .msg-link,
.text .msg-link{
  user-select:text;
}
@media (max-width: 780px){
  .record-overlay{
    left:8px !important;
    right:8px !important;
    bottom:max(8px, env(safe-area-inset-bottom)) !important;
  }
  .record-card{
    width:100%;
    min-height:82px;
    gap:8px !important;
    padding:9px !important;
    border-radius:22px !important;
  }
  .record-overlay.recording-video .record-preview,
  .record-preview{
    width:54px !important;
    height:54px !important;
  }
  .record-info strong{ font-size:13px !important; }
  .record-info span{ font-size:12px !important; }
  .record-info small{
    white-space:normal !important;
    line-height:1.55;
    max-width:unset !important;
    font-size:10.5px;
  }
  .record-actions{
    gap:5px !important;
    flex-wrap:nowrap;
  }
  .record-actions .btn{
    width:34px !important;
    min-width:34px !important;
    height:34px !important;
    border-radius:13px !important;
    font-size:12px;
  }
  .media--video-note{
    width:138px !important;
    height:138px !important;
    min-height:138px !important;
  }
  .video-note-meta span{ font-size:12px; }
  .video-note-meta small{ display:none; }
  .stage__video-note{
    width:min(88vw, 430px) !important;
    max-height:min(88vw, calc(100dvh - 190px)) !important;
  }
  .drop-zone > div{
    min-height:150px;
    border-radius:26px;
    padding:22px;
  }
}

/* =========================
   EliLink advanced chat patch
   ========================= */
.pinned-bar{
  position:sticky;
  top:8px;
  z-index:30;
  display:flex;
  align-items:center;
  gap:10px;
  margin:8px auto 0;
  width:min(92%, 680px);
  padding:10px 12px;
  border:1px solid rgba(116,174,255,.22);
  border-radius:16px;
  background:linear-gradient(135deg, rgba(28,43,67,.92), rgba(18,29,46,.92));
  box-shadow:0 14px 40px rgba(0,0,0,.25);
  cursor:pointer;
  backdrop-filter:blur(14px);
}
.pinned-bar.hidden{display:none!important}
.pinned-bar__icon{width:34px;height:34px;border-radius:12px;display:grid;place-items:center;color:#77bfff;background:rgba(92,163,255,.14)}
.pinned-bar__text{min-width:0;display:grid;gap:2px;flex:1}
.pinned-bar__text strong{font-size:12px;color:#9ecfff}
.pinned-bar__text span{font-size:13px;color:#eef6ff;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pinned-bar__arrow{color:#8fa8c8;font-size:12px}

.editbar{border-color:rgba(91,173,255,.28)!important;background:linear-gradient(135deg, rgba(30,58,88,.78), rgba(18,30,49,.76))!important}
#sendBtn.is-editing{background:linear-gradient(135deg,#4e9cff,#7cc7ff)!important}
#sendBtn.is-editing .fa-paper-plane:before{content:"\f00c";font-family:"Font Awesome 6 Free";font-weight:900}

.emoji-panel{position:absolute;right:16px;bottom:86px;width:min(360px,calc(100vw - 24px));max-height:360px;overflow:auto;padding:12px;border:1px solid rgba(139,171,223,.18);border-radius:22px;background:rgba(13,24,39,.98);box-shadow:0 24px 80px rgba(0,0,0,.42);z-index:1500;backdrop-filter:blur(18px)}
.emoji-panel.hidden{display:none!important}
.emoji-panel__head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px;color:#eef6ff}
.emoji-panel__head span{font-size:11px;color:#8ea2c8;text-align:left;direction:rtl}
.emoji-panel__grid{display:grid;grid-template-columns:repeat(7,1fr);gap:8px}
.emoji-item{height:42px;border:1px solid rgba(255,255,255,.08);border-radius:14px;background:rgba(255,255,255,.04);font-size:23px;cursor:pointer;color:#fff;display:grid;place-items:center;transition:.16s ease}
.emoji-item:hover{background:rgba(112,174,255,.16);transform:translateY(-1px)}
.emoji-item--custom img{width:28px;height:28px;object-fit:contain}
.emoji-empty{grid-column:1/-1;color:#8ea2c8;text-align:center;padding:14px;border:1px dashed rgba(255,255,255,.1);border-radius:14px;font-size:12px}
.custom-emoji{width:28px;height:28px;object-fit:contain;vertical-align:middle;margin:0 2px;border-radius:6px}
.mention-link{border:0;background:transparent;color:#67b7ff;font:inherit;font-weight:700;padding:0 1px;cursor:pointer;direction:ltr;display:inline}
.mention-link:hover{text-decoration:underline}

.userItem{transition:transform .16s ease, border-color .16s ease, background .16s ease!important}
.userItem:hover{transform:translateY(-1px)}
.userItem--pinned{border-color:rgba(117,190,255,.26)!important;background:linear-gradient(135deg,rgba(56,91,136,.18),rgba(255,255,255,.035))!important}
.userPin{width:26px;height:26px;border:0;border-radius:10px;background:rgba(255,255,255,.05);color:#7891b6;display:grid;place-items:center;cursor:pointer;transition:.16s ease}
.userPin:hover,.userPin.active{color:#79c1ff;background:rgba(105,180,255,.16);transform:rotate(-18deg)}
.userRight{display:flex;align-items:center;gap:6px}

.media--video-note{border-radius:999px!important;overflow:visible!important;background:radial-gradient(circle at 35% 25%,rgba(101,176,255,.18),rgba(12,22,37,.92))!important;border:1px solid rgba(121,193,255,.22)!important;box-shadow:0 18px 46px rgba(0,0,0,.28)!important}
.video-note-ring{box-shadow:0 0 0 3px rgba(102,184,255,.18),0 0 0 7px rgba(102,184,255,.08)!important}
.custom-player-hint{border:1px solid rgba(121,193,255,.16);border-radius:14px;padding:8px 10px;background:rgba(0,0,0,.18)}
#recordTorch.active{background:linear-gradient(135deg,rgba(255,203,80,.34),rgba(255,255,255,.08));color:#ffd76b;box-shadow:0 0 0 1px rgba(255,215,107,.22)}

.avatar-cropper{margin-top:14px;display:grid;gap:10px;justify-items:center;padding:14px;border:1px solid rgba(255,255,255,.09);border-radius:22px;background:rgba(255,255,255,.035)}
.avatar-cropper.hidden{display:none!important}
.avatar-cropper__stage{position:relative;width:260px;height:260px;border-radius:50%;overflow:hidden;box-shadow:0 18px 50px rgba(0,0,0,.35),0 0 0 1px rgba(255,255,255,.14)}
#avatarCropCanvas{width:260px;height:260px;display:block;touch-action:none;cursor:grab;background:#0d1727}
#avatarCropCanvas:active{cursor:grabbing}
.avatar-cropper__mask{position:absolute;inset:0;border-radius:50%;box-shadow:inset 0 0 0 2px rgba(122,194,255,.75), inset 0 0 0 999px rgba(255,255,255,.015);pointer-events:none}
#avatarCropZoom{width:min(280px,100%)}
.modal-card--profile-advanced .field-card{margin-top:10px}
.profile-hero--telegram{border-radius:30px!important;overflow:hidden}
.mention-profile .actions{margin-top:12px}

@media (max-width:780px){
  .emoji-panel{right:8px;left:8px;width:auto;bottom:82px;max-height:300px}
  .emoji-panel__grid{grid-template-columns:repeat(6,1fr)}
  .pinned-bar{width:calc(100% - 20px);top:6px}
}

/* EliLink v12 - custom emoji/GIF picker */
.emoji-panel__head--tabs{align-items:flex-start;flex-direction:column}
.emoji-tabs{width:100%;display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:4px;border:1px solid rgba(139,171,223,.14);border-radius:16px;background:rgba(255,255,255,.035)}
.emoji-tab{border:0;border-radius:12px;padding:9px 10px;background:transparent;color:#8ea2c8;font-weight:800;cursor:pointer;transition:.16s ease}
.emoji-tab.active{background:rgba(112,174,255,.18);color:#eef6ff;box-shadow:0 8px 22px rgba(0,0,0,.18)}
.emoji-panel__body.hidden{display:none!important}
.emoji-panel__grid--gif{grid-template-columns:repeat(3,1fr)}
.gif-item{height:86px;padding:0;overflow:hidden;background:rgba(0,0,0,.22)}
.gif-item img{width:100%;height:100%;object-fit:cover;display:block}
.gif-item:hover img{transform:scale(1.04)}
.gif-item img{transition:.18s ease}
@media (max-width:780px){.emoji-panel__grid--gif{grid-template-columns:repeat(2,1fr)}.gif-item{height:92px}}

/* v16: Telegram-like emoji/GIF packs, video note, profile polish */
.text--emoji-large{font-size:42px!important;line-height:1.28!important;letter-spacing:2px;word-spacing:4px;background:transparent!important;padding:4px 2px!important}
.text--emoji-large .custom-emoji{width:54px;height:54px;border-radius:14px;margin:0 3px}

.emoji-panel{width:min(470px,calc(100vw - 18px))!important;max-height:min(78vh,560px)!important;padding:0!important;overflow:hidden!important;border-radius:0 0 18px 18px!important;background:#101d36!important;border:1px solid rgba(123,167,236,.16)!important;box-shadow:0 28px 85px rgba(0,0,0,.48)!important;display:flex;flex-direction:column;direction:ltr}
.emoji-panel__head--telegram{padding:13px 14px 7px!important;margin:0!important;display:flex!important;align-items:center!important;gap:10px!important;flex-direction:row!important}
.emoji-panel__search{height:42px;flex:1;display:flex;align-items:center;gap:10px;padding:0 12px;border-radius:16px;background:rgba(8,16,31,.7);border:1px solid rgba(143,176,232,.13);color:#9db6e4}
.emoji-panel__search input{width:100%;height:100%;border:0;background:transparent;color:#dbe8ff;outline:0;font:inherit;font-size:14px;direction:ltr}
.emoji-panel__search input::placeholder{color:#91a9d3}
.emoji-panel__close{width:34px;height:34px;border:0;background:transparent;color:#a9bce1;border-radius:12px;display:grid;place-items:center;cursor:pointer}
.emoji-panel__close:hover{background:rgba(255,255,255,.07);color:#fff}
.emoji-content{min-height:0;display:flex;flex-direction:column;flex:1;overflow:hidden}
.emoji-content.hidden{display:none!important}
.emoji-pack-rail{display:flex;gap:10px;overflow-x:auto;overflow-y:hidden;padding:6px 14px 12px;scrollbar-width:thin;flex:0 0 auto}
.emoji-pack{width:40px;height:40px;border:0;border-radius:13px;background:transparent;color:#91a9d3;display:grid;place-items:center;cursor:pointer;position:relative;flex:0 0 auto;transition:.16s ease}
.emoji-pack img{width:31px;height:31px;object-fit:contain;border-radius:8px;display:block}
.emoji-pack.active::after{content:"";position:absolute;left:8px;right:8px;bottom:-7px;height:3px;border-radius:9px;background:#4c9dff}
.emoji-pack:hover{background:rgba(255,255,255,.06)}
.emoji-scroll{overflow:auto;padding:6px 14px 12px;min-height:190px;scrollbar-width:thin;direction:ltr}
.emoji-pack-section{margin-bottom:18px}.emoji-pack-title{font-size:12px;text-transform:uppercase;font-weight:800;color:#8fb2e8;margin:6px 0 10px;letter-spacing:.03em;text-align:left}
.emoji-panel__grid{grid-template-columns:repeat(8,1fr)!important;gap:9px!important;direction:ltr}
.emoji-item{border:0!important;background:transparent!important;border-radius:12px!important;height:40px!important;padding:2px!important}.emoji-item:hover{background:rgba(255,255,255,.07)!important;transform:none!important}
.emoji-item--custom img{width:36px!important;height:36px!important;object-fit:contain!important;border-radius:9px}
.emoji-tabs--bottom{display:grid!important;grid-template-columns:1fr 1fr;border-top:1px solid rgba(143,176,232,.11);background:#0d1a31;margin-top:auto;flex:0 0 auto}
.emoji-tabs--bottom .emoji-tab{height:48px;border:0;background:transparent;color:#9bb7e8;font-weight:800;cursor:pointer}.emoji-tabs--bottom .emoji-tab.active{color:#63a9ff;background:rgba(76,157,255,.08)}
.emoji-panel__grid--gif{grid-template-columns:repeat(3,1fr)!important;gap:10px!important}.gif-tile-wrap{position:relative;min-width:0}.gif-item{width:100%;height:104px!important;overflow:hidden!important;background:rgba(0,0,0,.22)!important;border-radius:15px!important}.gif-item img{width:100%!important;height:100%!important;object-fit:cover!important;display:block}.gif-delete{position:absolute;top:6px;right:6px;width:26px;height:26px;border:0;border-radius:999px;background:rgba(3,9,20,.72);color:#fff;display:grid;place-items:center;cursor:pointer;opacity:0;transition:.16s ease}.gif-tile-wrap:hover .gif-delete{opacity:1}.gif-delete:hover{background:rgba(239,68,68,.92)}

.media--video-note{max-width:230px!important;border-radius:26px!important;padding:10px!important;background:linear-gradient(135deg,rgba(31,55,91,.95),rgba(6,15,30,.92))!important;border:1px solid rgba(112,174,255,.22)!important}.media--video-note .video-note-ring{width:142px!important;height:142px!important;margin:auto;border-radius:50%;overflow:hidden;background:#050b15;position:relative;box-shadow:0 0 0 4px rgba(80,159,255,.20),0 0 0 8px rgba(80,159,255,.08),0 18px 45px rgba(0,0,0,.35)!important}.video-note-preview{width:100%;height:100%;object-fit:cover}.video-note-preview.is-front-camera{transform:scaleX(-1)}.video-note-meta{text-align:center;margin-top:9px!important}.video-note-meta span{font-weight:800;color:#eaf3ff}.video-note-meta small{color:#91a9d3}.record-overlay.recording-video .record-preview video.is-front-camera{transform:scaleX(-1)}
#recordSwitch,#recordTorch{min-width:38px}.record-actions #recordTorch.active{background:linear-gradient(135deg,rgba(255,205,75,.35),rgba(255,255,255,.08))!important;color:#ffd85b!important;border-color:rgba(255,216,91,.24)!important}

.profile-hero--telegram{background:radial-gradient(circle at 20% 15%,rgba(109,162,255,.28),transparent 45%),linear-gradient(135deg,#243b69,#10283a)!important;border:1px solid rgba(161,194,255,.14)!important;box-shadow:0 20px 60px rgba(0,0,0,.32);min-height:220px!important;padding:34px!important;grid-template-columns:120px 1fr!important;gap:22px!important;align-items:center!important}.profile-hero--telegram .profile-hero-avatar{width:112px!important;height:112px!important;border-radius:100%!important;box-shadow:0 18px 45px rgba(0,0,0,.32),0 0 0 4px rgba(255,255,255,.08)}.profile-hero--telegram .profile-hero-meta h3{font-size:31px!important;margin:0;color:#fff}.profile-hero--telegram .profile-hero-meta span{font-size:16px;color:#b7c9eb}.profile-hero--telegram .profile-hero-meta small{margin-top:10px;color:#8fb2e8}.mention-profile .profile-hero{margin-bottom:14px}.modal-card--profile-advanced{border-radius:28px!important;background:linear-gradient(180deg,rgba(16,29,54,.98),rgba(8,16,31,.98))!important;border:1px solid rgba(143,176,232,.13)!important}.modal-card--profile-advanced .modal-card__eyebrow{color:#6db3ff!important}.modal-card--profile-advanced textarea.input{resize:vertical;min-height:88px}

@media (max-width:780px){.emoji-panel{right:0!important;left:0!important;bottom:0!important;width:100%!important;max-height:74vh!important;border-radius:18px 18px 0 0!important}.emoji-panel__grid{grid-template-columns:repeat(7,1fr)!important}.emoji-panel__grid--gif{grid-template-columns:repeat(2,1fr)!important}.gif-item{height:112px!important}.gif-delete{opacity:1}.profile-hero--telegram{grid-template-columns:1fr!important;text-align:center!important;justify-items:center!important;padding:28px 18px!important}.text--emoji-large{font-size:38px!important}.text--emoji-large .custom-emoji{width:48px;height:48px}}

/* =========================
   EliLink v17 stability / UX polish
   ========================= */
.avatar,
.header-avatar,
.userItem .avatar,
.profile-hero-avatar,
.profile-hero-avatar-img,
.profile-hero-avatar-fallback,
.admin-user-avatar{
  border-radius:50% !important;
  overflow:hidden !important;
}
.avatar img,
.userItem .avatar img,
.profile-hero-avatar img,
.profile-hero-avatar-img{
  width:100% !important;
  height:100% !important;
  object-fit:cover !important;
  border-radius:50% !important;
  display:block !important;
}
.profile-hero--telegram{
  position:relative;
  min-height:260px !important;
  padding:38px 34px !important;
  background:
    radial-gradient(circle at 82% 10%, rgba(105, 180, 255, .30), transparent 38%),
    linear-gradient(145deg, rgba(29,55,93,.98), rgba(11,24,42,.98)) !important;
}
.profile-hero--telegram::after{
  content:"";
  position:absolute;
  inset:auto 0 0 0;
  height:52px;
  background:linear-gradient(180deg, transparent, rgba(4,10,20,.25));
  pointer-events:none;
}
.profile-hero--telegram .profile-hero-avatar{
  width:118px !important;
  height:118px !important;
  aspect-ratio:1/1;
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.16);
}
.profile-hero--telegram .profile-hero-meta{
  position:relative;
  z-index:2;
  display:grid;
  gap:7px;
}
.profile-hero-bio{
  color:#dbe9ff;
  line-height:1.9;
  white-space:pre-wrap;
  margin-top:6px;
  opacity:.92;
}
.modal-card--profile-advanced{
  max-width:860px;
  margin:auto;
  padding:28px !important;
  background:
    radial-gradient(circle at 0 0, rgba(84,154,255,.12), transparent 34%),
    linear-gradient(180deg, rgba(14,27,51,.98), rgba(7,15,29,.98)) !important;
}
.modal-card--profile-advanced .modal-form-grid--two{
  align-items:stretch;
}
.modal-card--profile-advanced .field-card{
  border-radius:24px !important;
  background:rgba(4,12,25,.46) !important;
  border-color:rgba(137,174,235,.15) !important;
}
.modal-card--profile-advanced .input{
  border-radius:18px !important;
  background:rgba(1,8,18,.66) !important;
  border-color:rgba(136,177,242,.14) !important;
}
.avatar-cropper{
  background:linear-gradient(180deg,rgba(16,32,57,.84),rgba(7,16,31,.84)) !important;
  border-color:rgba(124,190,255,.18) !important;
}
.avatar-cropper__stage{
  outline:4px solid rgba(76,157,255,.08);
}

/* cleaner video messages, closer to Telegram's compact round cards */
.media--video-note{
  width:178px !important;
  min-height:218px !important;
  display:grid !important;
  place-items:center !important;
  gap:8px !important;
  border-radius:28px !important;
  background:linear-gradient(145deg,rgba(27,55,94,.96),rgba(8,17,32,.98)) !important;
}
.media--video-note .video-note-ring{
  width:136px !important;
  height:136px !important;
  border-radius:50% !important;
  background:#020816 !important;
  isolation:isolate;
}
.media--video-note .video-note-ring::before{
  content:"";
  position:absolute;
  inset:-7px;
  border-radius:50%;
  background:conic-gradient(from 150deg, rgba(85,172,255,.72), rgba(128,236,213,.36), rgba(85,172,255,.72));
  z-index:-1;
  opacity:.42;
}
.media--video-note .video-play{
  inset:50% auto auto 50%;
  transform:translate(-50%,-50%);
}
.video-note-meta span{
  font-size:14px !important;
}
.video-note-meta small{
  font-size:12px !important;
}

/* emoji/gif panel: smoother scrolling and less layout shift */
.emoji-panel{
  will-change:transform, opacity;
  contain:layout paint;
}
.emoji-scroll{
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
}
.emoji-panel__grid img,
.gif-item img{
  content-visibility:auto;
}
.emoji-loading{
  padding:24px;
  color:#9bb7e8;
  text-align:center;
}
.text--emoji-large{
  max-width:min(340px, 80vw);
}

/* pin scope modal */
#pinConfirm,
#pinCancel{
  min-width:96px;
}

/* admin polish */
.admin-page{min-height:100dvh;padding:28px 16px;background:radial-gradient(circle at top right,rgba(55,116,205,.22),transparent 36%),#06101e;color:#eaf3ff}
.admin-shell{width:min(1180px,100%);margin:0 auto;display:grid;gap:18px}
.admin-card{border:1px solid rgba(139,171,223,.16);border-radius:30px;background:linear-gradient(180deg,rgba(15,27,49,.96),rgba(8,16,31,.96));box-shadow:0 28px 90px rgba(0,0,0,.35);padding:22px;overflow:scroll}
.admin-card--hero{background:radial-gradient(circle at 18% 0,rgba(87,171,255,.22),transparent 34%),linear-gradient(145deg,rgba(19,37,67,.98),rgba(8,16,31,.98))}
.admin-brand-row,.admin-head--polished{display:flex;align-items:center;justify-content:space-between;gap:18px;flex-wrap:wrap}
.admin-actions--top,.admin-row-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.admin-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin-top:20px}
.admin-stat{border:1px solid rgba(139,171,223,.13);border-radius:22px;padding:16px;background:rgba(255,255,255,.035)}
.admin-stat span{display:block;color:#92abd4;font-size:12px;font-weight:800}.admin-stat strong{display:block;margin-top:7px;font-size:28px;color:#fff}
.admin-head--polished h2{margin:0;font-size:24px}.admin-head--polished p{margin:6px 0 0;color:#94aad2;font-size:13px}
.admin-filter{display:flex;align-items:center;gap:10px;border:1px solid rgba(139,171,223,.14);border-radius:18px;padding:0 12px;background:rgba(3,10,22,.55);min-width:min(360px,100%)}
.admin-filter i{color:#78b8ff}.admin-filter .input{border:0!important;background:transparent!important;box-shadow:none!important;padding:12px 4px!important}
.admin-user-cell{display:flex;align-items:center;gap:12px}.admin-user-cell strong{display:block}.admin-user-cell span{display:block;color:#90a8cd;font-size:12px;margin-top:3px}
.admin-user-avatar{width:42px;height:42px;display:grid;place-items:center;background:linear-gradient(135deg,rgba(95,165,255,.24),rgba(91,229,196,.15));font-weight:900;color:#eaf6ff}
.ltr-cell{direction:ltr;text-align:right}.admin-badge{display:inline-flex;align-items:center;padding:5px 9px;border-radius:999px;background:rgba(255,255,255,.06);color:#a9bad8;font-size:12px;font-weight:800;margin:2px}.admin-badge.is-active{background:rgba(45,212,191,.12);color:#8ef5df}.admin-badge.is-muted{background:rgba(239,68,68,.12);color:#ffaaa9}.admin-badge.is-admin{background:rgba(96,165,250,.14);color:#91c5ff}
.admin-table-wrap{border-radius:24px;overflow:auto;border:1px solid rgba(139,171,223,.12)}
.admin-user-table tr{transition:.15s ease}.admin-user-table tbody tr:hover{background:rgba(94,156,255,.055)}
@media (max-width:780px){.admin-stats{grid-template-columns:repeat(2,1fr)}.admin-card{border-radius:22px;padding:16px}.admin-filter{min-width:100%}.admin-row-actions .btn{width:100%;justify-content:center}}


/* =========================
   EliLink v18 hotfix: recorder, scrollbars, profile/admin polish
   ========================= */
*{
  scrollbar-width:thin;
  scrollbar-color:rgba(118,178,255,.55) rgba(9,17,30,.55);
}
*::-webkit-scrollbar{width:9px;height:9px}
*::-webkit-scrollbar-track{background:rgba(8,16,29,.58);border-radius:999px}
*::-webkit-scrollbar-thumb{background:linear-gradient(180deg,rgba(112,176,255,.75),rgba(54,94,148,.72));border-radius:999px;border:2px solid rgba(8,16,29,.58)}
*::-webkit-scrollbar-thumb:hover{background:linear-gradient(180deg,rgba(145,201,255,.92),rgba(75,125,188,.88))}

.record-screen-flash{position:fixed;inset:0;z-index:2147483600;background:#fff;opacity:0;pointer-events:none;transition:opacity .16s ease}.record-screen-flash.on{opacity:1}.record-screen-flash.hidden{display:none!important}
.record-overlay.recording-video{inset:0!important;background:linear-gradient(180deg,rgba(3,8,15,.18),rgba(3,8,15,.72))!important;align-items:stretch!important;justify-content:flex-end!important;pointer-events:none!important}.record-overlay.recording-video .record-card{pointer-events:auto!important;width:100%!important;max-width:none!important;min-height:100dvh!important;border-radius:0!important;border:0!important;background:transparent!important;box-shadow:none!important;display:grid!important;grid-template-rows:1fr auto!important;align-items:end!important;padding:0!important}.record-overlay.recording-video .record-preview{position:absolute!important;inset:0!important;width:100%!important;height:100%!important;border-radius:0!important;background:#000!important;box-shadow:none!important;overflow:hidden!important}.record-overlay.recording-video #recordPreview{width:100%!important;height:100%!important;object-fit:cover!important}.record-overlay.recording-video .record-info{position:relative!important;z-index:3!important;grid-row:2!important;width:100%!important;padding:12px 82px 22px 22px!important;display:flex!important;align-items:center!important;gap:10px!important;justify-content:flex-start!important;background:linear-gradient(0deg,rgba(4,10,18,.82),rgba(4,10,18,.10))!important}.record-overlay.recording-video .record-info strong{display:none!important}.record-overlay.recording-video .record-info span{font-size:16px!important;color:#fff!important;font-weight:800!important;direction:ltr}.record-overlay.recording-video .record-info span:before{content:'';display:inline-block;width:8px;height:8px;border-radius:50%;background:#c62845;margin-inline-end:10px;box-shadow:0 0 12px rgba(255,50,80,.7)}.record-overlay.recording-video .record-info small{display:none!important}.record-overlay.recording-video .record-actions{position:relative!important;z-index:4!important;grid-row:2!important;justify-self:end!important;align-self:end!important;margin:0 16px 14px 0!important;display:flex!important;align-items:center!important;gap:10px!important}.record-overlay.recording-video .record-actions .btn{width:50px!important;height:50px!important;min-width:50px!important;border-radius:50%!important;background:rgba(12,22,38,.58)!important;border:1px solid rgba(255,255,255,.16)!important;color:#eaf5ff!important;backdrop-filter:blur(14px)}.record-overlay.recording-video #recordSend{width:62px!important;height:62px!important;min-width:62px!important;background:linear-gradient(135deg,#67b7ff,#8df4df)!important;color:#07111f!important;font-size:22px!important}.record-overlay.recording-video #recordCancel{position:fixed!important;top:calc(env(safe-area-inset-top) + 14px)!important;left:14px!important}.record-overlay.recording-video #recordSwitch,.record-overlay.recording-video #recordTorch{position:fixed!important;top:calc(env(safe-area-inset-top) + 14px)!important}.record-overlay.recording-video #recordSwitch{right:14px!important}.record-overlay.recording-video #recordTorch{right:78px!important}.record-overlay.recording-video #recordLock{position:fixed!important;right:18px!important;bottom:118px!important}.record-overlay.recording-video #recordTorch.active{background:rgba(255,255,255,.86)!important;color:#111827!important;box-shadow:0 0 0 5px rgba(255,255,255,.22)!important}.record-lock-target{position:fixed;right:16px;bottom:180px;z-index:5;padding:10px 12px;border-radius:18px;color:#dff6ff;background:rgba(8,18,34,.58);border:1px solid rgba(255,255,255,.15);display:flex;gap:8px;align-items:center;backdrop-filter:blur(14px);font-size:12px;pointer-events:none}.record-lock-target.hidden{display:none!important}.record-overlay.recording-video .record-lock-target{display:flex!important}.record-overlay.locked .record-lock-target{background:rgba(117,240,210,.22);color:#fff}.record-overlay.locked #recordLock{background:rgba(117,240,210,.26)!important;color:#96ffe9!important}

.media--video-note{width:158px!important;min-height:186px!important;height:auto!important;border-radius:28px!important;overflow:hidden!important;padding:12px!important;background:linear-gradient(180deg,rgba(24,53,94,.92),rgba(11,23,42,.96))!important;border:1px solid rgba(117,180,255,.24)!important;box-shadow:0 16px 44px rgba(0,0,0,.32)!important}.media--video-note .video-note-ring{position:relative;width:134px!important;height:134px!important;margin:0 auto 8px;border-radius:50%!important;background:#020915!important;overflow:hidden!important;box-shadow:0 0 0 4px rgba(83,151,235,.18), inset 0 0 0 4px rgba(78,143,226,.34)!important}.media--video-note .video-note-preview{width:100%!important;height:100%!important;object-fit:cover!important;border-radius:50%!important}.media--video-note .video-play{right:5px!important;bottom:5px!important;left:auto!important;top:auto!important;transform:none!important;width:42px!important;height:42px!important;border-radius:50%!important;background:linear-gradient(135deg,#9ffbea,#60b8ff)!important;color:#07111f!important}.media--video-note .video-note-meta{text-align:center!important;display:grid!important;gap:2px}.media--video-note .video-note-meta span{font-size:14px!important;font-weight:900!important;color:#fff}.media--video-note .video-note-meta small{display:block!important;font-size:12px!important;color:#9fc2eb!important}.media--video-note:before{content:none!important}

.emoji-panel{contain:layout paint style!important}.emoji-scroll{content-visibility:auto;contain-intrinsic-size:520px}.emoji-panel__grid{align-items:start}.emoji-item img,.gif-item img{image-rendering:auto}.emoji-pack-section{content-visibility:auto;contain-intrinsic-size:280px}.emoji-recent-title{font-size:11px;color:#8fb7f0;font-weight:900;text-transform:uppercase;margin:10px 4px 8px}.emoji-panel__grid--recent{margin-bottom:10px}

.profile-hero--telegram{display:grid!important;grid-template-columns:108px 1fr!important;direction:rtl!important;text-align:right!important}.profile-hero--telegram .profile-hero-avatar,.profile-hero-avatar,.profile-hero-avatar-img,.profile-hero-avatar-fallback{border-radius:50%!important;overflow:hidden!important}.profile-hero-avatar-img,.profile-hero-avatar img{width:100%!important;height:100%!important;object-fit:cover!important}.profile-hero-bio{margin-top:12px;padding:10px 12px;border-radius:16px;background:rgba(255,255,255,.07);color:#eaf4ff;font-size:13px;line-height:1.8}.profile-media-section{border-radius:26px!important;background:rgba(8,18,33,.72)!important}.profile-media-list{max-height:min(46vh,390px)!important;padding-inline-end:4px}.modal-card--profile-advanced{width:min(780px,92vw)!important;padding:0!important;overflow:hidden!important;background:linear-gradient(180deg,#11213d,#07111f)!important}.profile-edit-hero{padding:30px;background:radial-gradient(circle at 20% 0,rgba(108,180,255,.32),transparent 42%),linear-gradient(135deg,#19305a,#10283a);border-bottom:1px solid rgba(255,255,255,.08)}.profile-edit-hero h3{font-size:30px!important;margin:6px 0 8px!important}.profile-edit-body{padding:22px}.profile-edit-avatar-row{display:flex;align-items:center;gap:16px;flex-wrap:wrap}.profile-edit-avatar-preview{width:94px;height:94px;border-radius:50%;overflow:hidden;background:rgba(255,255,255,.08);display:grid;place-items:center;border:1px solid rgba(255,255,255,.14);box-shadow:0 16px 42px rgba(0,0,0,.32)}.profile-edit-avatar-preview img{width:100%;height:100%;object-fit:cover}.profile-edit-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:16px}.pf-file-btn{position:relative;overflow:hidden}.pf-file-btn input{position:absolute;inset:0;opacity:0;cursor:pointer}.self-preview-badge{display:inline-flex;gap:8px;align-items:center;border-radius:999px;padding:8px 12px;background:rgba(109,179,255,.14);color:#93c9ff;font-weight:900;font-size:12px;letter-spacing:.08em;text-transform:uppercase}

.admin-toast{position:fixed;left:22px;bottom:22px;z-index:9999;min-width:240px;max-width:min(420px,calc(100vw - 44px));padding:13px 15px;border-radius:18px;background:linear-gradient(135deg,rgba(20,36,63,.96),rgba(9,20,36,.96));border:1px solid rgba(137,184,255,.18);box-shadow:0 20px 60px rgba(0,0,0,.35);color:#eaf4ff;display:none}.admin-toast.show{display:block;animation:toastIn .18s ease}.admin-toast.success{border-color:rgba(87,232,185,.28)}.admin-toast.error{border-color:rgba(255,111,132,.36)}.admin-modal{position:fixed;inset:0;z-index:9998;display:none;align-items:center;justify-content:center;padding:18px;background:rgba(1,6,14,.58);backdrop-filter:blur(10px)}.admin-modal.show{display:flex}.admin-modal__box{width:min(520px,96vw);border-radius:26px;background:linear-gradient(180deg,#10213c,#07111f);border:1px solid rgba(143,176,232,.16);box-shadow:0 28px 90px rgba(0,0,0,.46);padding:20px}.admin-loadmore{display:flex;justify-content:center;padding:16px}.admin-skeleton-row td{opacity:.65}.admin-actionbar{display:flex;gap:10px;flex-wrap:wrap;align-items:center;justify-content:space-between}.admin-stat small{display:block;margin-top:4px;color:#8fa8c8;font-size:12px}
@media (max-width:780px){.record-overlay.recording-video .record-info{padding-left:14px!important;padding-bottom:18px!important}.record-overlay.recording-video #recordSend{width:58px!important;height:58px!important;min-width:58px!important}.profile-hero--telegram{grid-template-columns:1fr!important;justify-items:center!important;text-align:center!important}.modal-card--profile-advanced{width:96vw!important}.profile-edit-hero{padding:22px}.profile-edit-body{padding:16px}}
.record-toggle,#recordBtn{touch-action:none;-webkit-user-select:none;user-select:none}
.record-overlay.recording-video *{touch-action:none}
