:root {
  --bg: #0e1621;
  --text: #e6e6e6;
  --muted: rgba(255, 255, 255, 0.65);
  --border: rgba(255, 255, 255, 0.1);
  --contentMax: 980px;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Arial;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* AUTH */
#authBox {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(900px 600px at 70% 10%, rgba(46, 166, 255, 0.13), transparent 60%),
    radial-gradient(900px 700px at 20% 70%, rgba(59, 214, 113, 0.08), transparent 60%),
    linear-gradient(180deg, #0a111c, #070b12);
  overflow: auto;
}
#authBox .card {
  width: 420px;
  max-width: 92vw;
  background: rgba(23, 33, 43, 0.92);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}
.card h2 {
  margin: 0 0 12px;
  font-size: 24px;
}
.card input {
  width: 100%;
  padding: 12px 14px;
  margin: 10px 0;
  border-radius: 14px;
  background: rgba(16, 25, 34, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  outline: none;
}
.card input:focus {
  border-color: rgba(46, 166, 255, 0.35);
  box-shadow: 0 0 0 4px rgba(46, 166, 255, 0.08);
}
.row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
button {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(31, 51, 71, 0.95);
  color: #fff;
  cursor: pointer;
}
button:hover {
  border-color: rgba(255, 255, 255, 0.24);
}
button.secondary {
  background: transparent;
}
.hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
}

.authLinks {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}
.linkBtn {
  background: transparent;
  border: none;
  padding: 0;
  color: rgba(120, 180, 255, 0.95);
  cursor: pointer;
  font-size: 13px;
}
.linkBtn:hover {
  text-decoration: underline;
}

/* CHAT */
.tg {
  height: 100dvh;
  display: flex;
  min-height: 0;
  background:
    radial-gradient(1200px 800px at 80% 20%, rgba(46, 166, 255, 0.12), transparent 60%),
    radial-gradient(900px 700px at 20% 70%, rgba(59, 214, 113, 0.08), transparent 60%),
    linear-gradient(180deg, #0a111c, #070b12);
}

/* LEFT */
.tgLeft {
  width: 430px;
  flex: 0 0 430px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 12px;
  min-height: 0;
}
.tgLeftTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tgBrand {
  font-weight: 900;
  opacity: 0.95;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tgLogout {
  padding: 10px 12px;
}
.tgMe {
  opacity: 0.8;
  font-size: 13px;
  margin-top: -6px;
  padding: 0 2px 6px 2px;
}

.tgDm,
.tgGroup {
  display: flex;
  gap: 8px;
  align-items: center;
}
.tgDm input,
.tgGroup input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 10px 12px;
  border-radius: 12px;
  outline: none;
}
.tgChats {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 6px;
  min-height: 0;
}
.chatCard {
  width: 100%;
  padding: 12px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: center;
}
.chatCard:hover {
  background: rgba(255, 255, 255, 0.08);
}
.chatCard.active {
  background: rgba(46, 166, 255, 0.16);
  border-color: rgba(46, 166, 255, 0.35);
}
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 900;
  flex: 0 0 auto;
}

.avatarImg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}
.chatMain {
  flex: 1;
  min-width: 0;
}
.chatTopRow {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.chatTitle {
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
.chatTime {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  white-space: nowrap;
}
.chatBottomRow {
  margin-top: 4px;
}
.chatLast {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* RIGHT */
.tgRight {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 0 24px;
}
.tgTop {
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}
.tgTitle {
  font-weight: 900;
  opacity: 0.95;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* group tools */
.groupTools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(6px);
}
.groupTools input {
  width: 320px;
  max-width: 38vw;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 10px 12px;
  border-radius: 12px;
  outline: none;
}

/* center */
.tgCenter {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.emptyState {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.55);
  font-size: 18px;
  padding: 16px;
}
.chatArea {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* колонка сообщений слева */
.tgMsgs {
  flex: 1;
  overflow: auto;
  min-height: 0;

  display: flex;
  justify-content: flex-start;
}

.tgMsgsInner {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dateSep {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0 12px;
  pointer-events: none;
}

.dateSep::before,
.dateSep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0 12px;
}

.dateSep span {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.75);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

/* сообщения собеседника слева, мои справа */
.msgRow {
  display: flex;
  width: 100%;
  justify-content: flex-start;
  align-items: flex-end;
  gap: 8px;
}

.msgRow.me {
  justify-content: flex-end;
  padding-right: 48px;
}

.msgRow.me .msgAvatar {
  display: none;
}

.msgAvatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  flex: 0 0 32px;
}

.msgAvatarImg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bubble {
  max-width: 58%;
  min-width: 80px;
  padding: 10px 10px 6px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
}

/* мои сообщения справа */
.msgRow.me .bubble {
  background: rgba(43, 82, 120, 0.95);
  border-color: rgba(46, 166, 255, 0.25);
}

/* собеседник */
.msgRow.other .bubble {
  background: rgba(24, 37, 51, 0.95);
  border-color: rgba(255, 255, 255, 0.1);
}

.msgName {
  font-size: 12px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.78);
  margin-bottom: 4px;
}
.bubble .text {
  white-space: pre-wrap;
  word-break: break-word;
  color: rgba(255, 255, 255, 0.94);
}

.meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.65);
}

.msgBtn {
  padding: 4px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.15);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  opacity: 0.9;
}
.msgBtn:hover {
  border-color: rgba(255, 255, 255, 0.28);
  opacity: 1;
}

/* ✅ СИСТЕМНЫЕ сообщения (вступил/кик/роль/owner) */
.sysRow {
  display: flex;
  justify-content: center;
  margin: 2px 0 8px;
}
.sysBubble {
  max-width: 86%;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  text-align: center;
}

/* input */
.tgInput {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.tgInputInner {
  width: 100%;
  max-width: calc(100% - 72px);
  padding: 12px 0;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.tgInput textarea {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 12px 14px;
  border-radius: 14px;
  outline: none;
  resize: none;
  min-height: 44px;
  max-height: 140px;
  overflow: auto;
}
.kbdHint {
  width: calc(100% - 72px);
  margin: 0;
  padding: 0 0 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
}

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 50;
}
.modalCard {
  width: 560px;
  max-width: 92vw;
  max-height: 80vh;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(23, 33, 43, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
}
.modalTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.modalTitle {
  font-weight: 900;
}
.membersList {
  padding: 12px 14px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.memberItem {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.memberAvatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 900;
}
.memberMain {
  flex: 1;
  min-width: 0;
}
.memberName {
  font-weight: 800;
}
.memberMeta {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 2px;
}
.memberActions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.memberActions .msgBtn {
  padding: 6px 10px;
}

/* scrollbars */
.tgChats::-webkit-scrollbar,
.tgMsgs::-webkit-scrollbar,
.tgInput textarea::-webkit-scrollbar,
.membersList::-webkit-scrollbar {
  width: 10px;
}
.tgChats::-webkit-scrollbar-thumb,
.tgMsgs::-webkit-scrollbar-thumb,
.tgInput textarea::-webkit-scrollbar-thumb,
.membersList::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}
.tgChats::-webkit-scrollbar-thumb:hover,
.tgMsgs::-webkit-scrollbar-thumb:hover,
.tgInput textarea::-webkit-scrollbar-thumb:hover,
.membersList::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

@media (max-width: 900px) {
  .groupTools input {
    width: 220px;
    max-width: 48vw;
  }
}
@media (max-width: 820px) {
  .groupTools {
    flex-wrap: wrap;
  }
  .groupTools input {
    width: 100%;
    max-width: 100%;
  }
}

.uiOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.uiOverlay.hidden {
  display: none;
}

.uiModal {
  width: min(520px, calc(100vw - 32px));
  background: #17212b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.uiModalTitle {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #fff;
}

.uiModalText {
  font-size: 14px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.85);
  white-space: pre-line;
  margin-bottom: 14px;
}

.uiModalInputWrap.hidden {
  display: none;
}

.uiModalInput {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0e1621;
  color: #fff;
  outline: none;
  margin-bottom: 14px;
}

.uiModalBtns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btnPrimary {
  background: #2a87ff;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
}

.btnGhost {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
}

/* спрячем старые поля создания */
.tgDm,
.tgGroup {
  display: none !important;
}

.tgLeft {
  position: relative;
} /* важно */

.fabPlus {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 28px;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(46, 166, 255, 0.25);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
  cursor: pointer;
}
.fabPlus:hover {
  border-color: rgba(46, 166, 255, 0.45);
  background: rgba(46, 166, 255, 0.3);
}

.chatSub {
  font-size: 12px;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.6);
}

.onlineDot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #27c93f;
  border-radius: 50%;
  margin-right: 6px;
  box-shadow: 0 0 6px #27c93f;
}

.uiChoiceBtns {
  display: flex;
  gap: 10px;
  margin: 10px 0 14px;
  flex-wrap: wrap;
}

.uiChoiceBtn {
  flex: 1 1 220px;
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-align: center;
}

.uiChoiceBtn:hover {
  border-color: rgba(46, 166, 255, 0.45);
  background: rgba(46, 166, 255, 0.18);
}

.meRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.meRow .tgMe {
  margin: 0;
  padding: 0;
  flex: 1;
}

#profileGear {
  flex: 0 0 auto;
  padding: 6px 10px;
}

.profileCard {
  width: 520px;
  max-width: 92vw;
}

.profileBody {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.profileField {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.profileLabel {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 6px;
}

.profileValue {
  font-size: 15px;
  color: #fff;
  word-break: break-word;
}

.profileBtns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.profileHint {
  min-height: 20px;
  font-size: 13px;
  color: #ff8e8e;
  margin-top: 2px;
}

.profileHint.ok {
  color: #7ee787;
}

.profileAvatarBlock {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.profileAvatarPreview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  flex: 0 0 auto;
}

.profileAvatarPreview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profileAvatarActions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cropCard {
  width: 760px;
  max-width: 96vw;
}

.cropBody {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cropHint {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.72);
}

.cropViewportWrap {
  display: flex;
  justify-content: center;
  align-items: center;
}

.cropViewport {
  position: relative;
  width: 360px;
  height: 360px;
  max-width: 80vw;
  max-height: 80vw;
  overflow: hidden;
  border-radius: 18px;
  background:
    linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.04) 25%,
      transparent 25%,
      transparent 75%,
      rgba(255, 255, 255, 0.04) 75%
    ),
    linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.04) 25%,
      transparent 25%,
      transparent 75%,
      rgba(255, 255, 255, 0.04) 75%
    );
  background-size: 24px 24px;
  background-position:
    0 0,
    12px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  user-select: none;
  touch-action: none;
  cursor: grab;
}

.cropViewport.dragging {
  cursor: grabbing;
}

.cropImage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: top left;
  will-change: transform;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.cropCircle {
  position: absolute;
  inset: 12px;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow:
    0 0 0 9999px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.15);
  pointer-events: none;
}

.cropControls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cropZoomLabel {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.72);
}

#cropZoom {
  width: 100%;
}

.clickableAvatar {
  cursor: pointer;
}

.clickableName {
  cursor: pointer;
}

.clickableName:hover {
  text-decoration: underline;
}

.avatarViewCard {
  width: min(760px, 96vw);
}

.avatarViewBody {
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  background: rgba(255, 255, 255, 0.03);
}

.avatarViewImage {
  max-width: 100%;
  max-height: 72vh;
  border-radius: 18px;
  display: block;
  object-fit: contain;
}

.avatarViewEmpty {
  color: rgba(255, 255, 255, 0.65);
  font-size: 14px;
}

.profileAvatarPreview.clickableAvatar {
  transition: transform 0.15s ease;
}

.profileAvatarPreview.clickableAvatar:hover {
  transform: scale(1.03);
}

.attachWrap {
  position: relative;
  display: flex;
  align-items: center;
}

#btnAttach {
  min-width: 48px;
  font-size: 20px;
  padding: 0 14px;
}

.tgRecordBtn {
  width: 56px;
  height: 56px;
  min-width: 56px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(180deg, #52a8ff 0%, #3290ec 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(50, 144, 236, 0.28);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease;
  flex-shrink: 0;
}

.tgRecordBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(50, 144, 236, 0.34);
}

.tgRecordBtn:active {
  transform: scale(0.97);
}

.tgRecordBtn.isRecording {
  background: linear-gradient(180deg, #ff5b5b 0%, #e23b3b 100%);
  box-shadow: 0 10px 26px rgba(226, 59, 59, 0.35);
}

.tgRecordBtn.hidden {
  display: none !important;
}

.tgRecordIcon {
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.tgRecordBtn[data-mode="voice"] .tgRecordIconMic {
  display: inline-flex;
}

.tgRecordBtn[data-mode="video"] .tgRecordIconVideo {
  display: inline-flex;
}

.tgRecordBtn svg {
  display: block;
}

#btnSend.hidden {
  display: none !important;
}

.attachMenu {
  position: absolute;
  bottom: 54px;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #17212b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  z-index: 50;
}

.attachMenu button {
  background: none;
  border: none;
  color: #fff;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.attachMenu button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.msgFile {
  display: block;
  margin-top: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  text-decoration: none;
  min-width: 220px;
}

.msgFile:hover {
  background: rgba(255, 255, 255, 0.09);
}

.msgFileName {
  font-weight: 700;
  word-break: break-word;
}

.msgFileMeta {
  margin-top: 4px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
}

.uploadStatus {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0 10px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.uploadSpinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: #fff;
  animation: uploadSpin 0.8s linear infinite;
}

.uploadStatusText {
  line-height: 1;
}

@keyframes uploadSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

#btnAttach[disabled],
#btnSend[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 760px) {
  .chatOnlineDot {
    width: 10px;
    height: 10px;
    border-width: 2px;
  }

  .mobileBackBtn {
    display: none;
    flex: 0 0 auto;
    padding: 8px 10px;
    border-radius: 12px;
  }

  .tgTopMain {
    min-width: 0;
    display: flex;
    flex-direction: column;
  }

  .tg.mobileListMode .tgLeft {
    display: flex;
    max-height: none;
    flex: 1;
  }

  .tg.mobileListMode .tgRight {
    display: none;
  }

  .tg.mobileChatMode .tgLeft {
    display: none;
  }

  .tg.mobileChatMode .tgRight {
    display: flex;
    flex: 1;
    min-height: 0;
  }

  .tg.mobileChatMode .mobileBackBtn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  .tg.mobileChatMode .tgTop {
    align-items: flex-start;
  }

  .tg.mobileListMode .fabPlus {
    right: 14px;
    bottom: 14px;
  }

  .tg {
    flex-direction: column;
    height: 100dvh;
  }

  .tgLeft {
    width: 100%;
    flex: 1;
    border-right: none;
    border-bottom: none;
    padding: 10px;
    gap: 10px;
    min-height: 0;
    max-height: none;
  }

  .tgLeftTop {
    gap: 8px;
  }

  .tgBrand {
    font-size: 18px;
  }

  .tgLogout {
    padding: 8px 10px;
  }

  .tgChats {
    gap: 6px;
    padding-right: 2px;
  }

  .chatCard {
    padding: 8px;
    border-radius: 12px;
  }

  .chatTitle {
    max-width: 160px;
    font-size: 15px;
  }

  .chatLast {
    font-size: 12px;
  }

  .avatar {
    width: 36px;
    height: 36px;
  }

  .tgRight {
    flex: 1;
    min-height: 0;
    padding: 0 10px;
  }

  .tgTop {
    padding: 10px 0;
    gap: 8px;
  }

  .tgTitle {
    font-size: 20px;
  }

  .chatSub {
    font-size: 11px;
    line-height: 1.25;
    white-space: normal;
  }

  .tgMsgsInner {
    max-width: 100%;
    padding: 10px 0;
    gap: 8px;
  }

  .bubble {
    max-width: 88%;
    min-width: 64px;
    padding: 9px 9px 6px;
    border-radius: 12px;
  }

  .msgAvatar {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
  }

  .msgImage {
    max-width: min(82vw, 320px);
    max-height: 280px;
  }

  .msgFile {
    min-width: 0;
    width: 100%;
    max-width: 72vw;
  }

  .tgInputInner {
    width: 100%;
    max-width: 100%;
    gap: 8px;
    padding: 10px 0;
  }

  .attachWrap {
    flex: 0 0 52px;
  }

  .tgInput textarea {
    min-width: 0;
    width: auto;
    flex: 1 1 auto;
    min-height: 40px;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 16px;
  }

  #btnAttach {
    width: 52px;
    height: 52px;
    min-width: 52px;
    padding: 0;
    border-radius: 12px;
  }

  #btnSend {
    min-width: 0;
    min-height: 52px;
    flex: 0 0 auto;
    padding: 10px 14px;
    border-radius: 12px;
    white-space: nowrap;
  }

  .tgRecordBtn {
    width: 52px;
    height: 52px;
    min-width: 52px;
  }

  .attachMenu {
    left: 0;
    bottom: 50px;
  }

  .kbdHint {
    width: 100%;
    padding-bottom: 8px;
    font-size: 11px;
  }

  .fabPlus {
    right: 14px;
    bottom: 18px;
    width: 54px;
    height: 54px;
    z-index: 15;
  }

  .modal {
    padding: 10px;
  }

  .modalCard,
  .profileCard,
  .avatarViewCard,
  .cropCard {
    width: 100%;
    max-width: 100%;
    border-radius: 16px;
  }

  .profileBody,
  .cropBody {
    padding: 12px;
  }

  .profileBtns {
    flex-direction: column;
  }

  .profileBtns button {
    width: 100%;
  }

  .cropViewport {
    width: min(86vw, 360px);
    height: min(86vw, 360px);
  }
}

.msgRow.mediaMsg .bubble {
  background: transparent;
  border: none;
  padding: 0;
  min-width: 0;
}

.msgRow.mediaMsg .meta {
  margin-top: 6px;
  padding: 0 4px;
}

.msgImageWrap {
  margin-top: 0;
}

.msgImage {
  display: block;
  max-width: 260px;
  max-height: 320px;
  width: auto;
  height: auto;
  border-radius: 14px;
  cursor: pointer;
  border: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.chatArea {
  position: relative;
}

.dropOverlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 17, 28, 0.45);
  backdrop-filter: blur(2px);
}

.dropOverlayCard {
  padding: 18px 22px;
  border-radius: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  background: rgba(23, 33, 43, 0.92);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.avatarOnlineWrap {
  position: relative;
}

.chatOnlineDot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #35c759;
  border: 2px solid #17212b;
  box-shadow: 0 0 8px rgba(53, 199, 89, 0.45);
}

.msgVideoWrap {
  margin-top: 0;
}

.msgVideo {
  display: block;
  width: min(360px, 72vw);
  max-height: 420px;
  border-radius: 14px;
  background: #000;
  border: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.msgVideoActions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.msgVoiceWrap {
  margin-top: 0;
}

.msgVoice {
  display: block;
  width: min(320px, 68vw);
  height: 40px;
  border-radius: 999px;
}

.msgDownload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
}

.msgDownload:hover {
  background: rgba(255, 255, 255, 0.09);
}

.chatCardActive {
  background: linear-gradient(180deg, rgba(72, 123, 179, 0.35), rgba(46, 87, 130, 0.3));
  border: 1px solid rgba(120, 180, 255, 0.35);
  box-shadow: 0 0 0 1px rgba(120, 180, 255, 0.1) inset;
}

.chatCardActive:hover {
  background: linear-gradient(180deg, rgba(78, 132, 192, 0.4), rgba(52, 95, 142, 0.34));
}

.replyPreview {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}

.replyPreview.hidden {
  display: none;
}

.replyPreview::before {
  content: "";
  width: 3px;
  align-self: stretch;
  border-radius: 999px;
  background: linear-gradient(180deg, #5aaaff 0%, #7cc4ff 100%);
  flex: 0 0 3px;
}

.replyPreview.isQuote::before {
  background: linear-gradient(180deg, #7bd66f 0%, #56c85d 100%);
}

.replyPreviewBody {
  min-width: 0;
  flex: 1;
}

.replyPreviewTitle {
  font-size: 12px;
  line-height: 1.2;
  font-weight: 700;
  color: #8fc7ff;
  margin-bottom: 4px;
}

.replyPreview.isQuote .replyPreviewTitle {
  color: #7bd66f;
}

.replyPreviewText {
  font-size: 13px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.replyPreviewClose {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 8px;
}

.replyPreviewClose:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.messageContextMenu {
  position: fixed;
  z-index: 3000;
  min-width: 180px;
  padding: 8px;
  border-radius: 16px;
  background: rgba(16, 22, 35, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}

.messageContextMenu.hidden {
  display: none;
}

.messageContextItem {
  width: 100%;
  border: none;
  background: transparent;
  color: #fff;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
}

.messageContextItem:hover {
  background: rgba(255, 255, 255, 0.06);
}

.messageContextItem.danger {
  color: #ff6b6b;
}

.forwardModal {
  position: fixed;
  inset: 0;
  z-index: 3500;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.forwardModal.hidden {
  display: none;
}

.forwardModalCard {
  width: min(460px, 100%);
  max-height: min(80vh, 720px);
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  background: #101623;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.forwardModalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.forwardModalTitle {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}

.forwardModalClose {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  font-size: 18px;
}

.forwardModalBody {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.forwardSearch {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
}

.forwardChatList {
  overflow: auto;
  min-height: 120px;
  max-height: 50vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.forwardChatItem {
  width: 100%;
  border: none;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
}

.forwardChatItem:hover {
  background: rgba(255, 255, 255, 0.08);
}

.forwardChatItemTitle {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}

.forwardChatItemMeta {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
}

.msgReplyBlock,
.msgForwardBlock {
  position: relative;
  margin: 0 0 8px;
  padding: 8px 10px 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  overflow: hidden;
}

.msgReplyBlock::before,
.msgForwardBlock::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, #5aaaff 0%, #7cc4ff 100%);
}

.msgForwardBlock::before {
  background: linear-gradient(180deg, #7bd66f 0%, #56c85d 100%);
}

.msgReplyBlock:hover,
.msgForwardBlock:hover {
  background: rgba(255, 255, 255, 0.1);
}

.msgReplyAuthor,
.msgForwardLabel {
  font-size: 12px;
  line-height: 1.2;
  font-weight: 700;
  color: #8fc7ff;
  margin-bottom: 3px;
}

.msgForwardLabel {
  color: #7bd66f;
}

.msgReplyText,
.msgForwardAuthor {
  font-size: 13px;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msgJumpFlash .bubble {
  animation: msgJumpFlashAnim 2.1s ease;
  position: relative;
}

.msgJumpFlash .bubble::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 18px;
  background: rgba(90, 170, 255, 0.16);
  pointer-events: none;
  animation: msgJumpFlashGlow 2.1s ease;
}

@keyframes msgJumpFlashAnim {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(90, 170, 255, 0);
  }
  18% {
    transform: scale(1.02);
    box-shadow:
      0 0 0 2px rgba(90, 170, 255, 0.95),
      0 0 24px rgba(90, 170, 255, 0.45);
  }
  55% {
    transform: scale(1.01);
    box-shadow:
      0 0 0 2px rgba(90, 170, 255, 0.45),
      0 0 14px rgba(90, 170, 255, 0.2);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(90, 170, 255, 0);
  }
}

@keyframes msgJumpFlashGlow {
  0% {
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  55% {
    opacity: 0.55;
  }
  100% {
    opacity: 0;
  }
}

.selectionToolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  margin: 10px 0 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.selectionToolbar.hidden {
  display: none;
}

.selectionToolbarCount {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex: 1;
}

.selectionToolbarActions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.selectionToolbarBtn {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
}

.selectionToolbarBtn:hover {
  background: rgba(255, 255, 255, 0.09);
}

.selectionToolbarBtn.danger {
  color: #ff6b6b;
}

#messages.selectionModeOn .msgRow {
  position: relative;
  padding-left: 46px;
}

#messages.selectionModeOn .msgRow::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-50%);
  box-sizing: border-box;
}

#messages.selectionModeOn .msgRow.msgSelected::before {
  background: #67c95d;
  border-color: #67c95d;
}

#messages.selectionModeOn .msgRow.msgSelected::after {
  content: "✓";
  position: absolute;
  left: 17px;
  top: 50%;
  transform: translateY(-58%);
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

#messages.selectionModeOn .msgRow .bubble {
  transition:
    box-shadow 0.15s ease,
    transform 0.15s ease,
    opacity 0.15s ease;
}

#messages.selectionModeOn .msgRow.msgSelected .bubble {
  box-shadow: 0 0 0 2px rgba(103, 201, 93, 0.45);
}

.chatUnreadBadge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #67c95d;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(103, 201, 93, 0.28);
}

.chatUnreadDot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff3b30;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.04);
  flex: 0 0 10px;
}

.chatUnreadBadge {
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ff3b30;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  flex: 0 0 auto;
}

.msgChecks {
  font-size: 12px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: -1px;
  user-select: none;
}

.msgChecks.isRead {
  color: #7cc4ff;
}

.typingWrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.78);
}

.typingDots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 12px;
}

.typingDots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #63a8ff;
  opacity: 0.35;
  animation: typingDotPulse 0.9s infinite ease-in-out;
}

.typingDots span:nth-child(1) {
  animation-delay: 0s;
}
.typingDots span:nth-child(2) {
  animation-delay: 0.12s;
}
.typingDots span:nth-child(3) {
  animation-delay: 0.24s;
}
.typingDots span:nth-child(4) {
  animation-delay: 0.36s;
}

@keyframes typingDotPulse {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.28;
  }
  50% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

.chatCloseBtn {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  margin-left: auto;
  padding: 0;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 12px;
  border: 1px solid rgba(255, 108, 108, 0.35);
  background: rgba(255, 75, 75, 0.1);
  color: #ff9c9c;

  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;

  transition:
    color 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}

.chatCloseBtn:hover {
  color: #ffffff;
  background: rgba(255, 75, 75, 0.28);
  border-color: rgba(255, 108, 108, 0.7);
}

.chatCloseBtn:active {
  transform: scale(0.94);
}

@media (max-width: 760px) {
  .chatCloseBtn {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }
}

.emojiWrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.emojiToggleBtn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  padding: 0;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 14px;
  font-size: 22px;
  line-height: 1;
}

.emojiPanel {
  position: absolute;
  left: 0;
  bottom: 58px;
  z-index: 100;

  width: 340px;
  max-width: calc(100vw - 24px);
  max-height: 330px;

  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(23, 33, 43, 0.98);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(12px);
}

.emojiPanelTitle {
  margin: 0 0 10px;
  padding: 0 2px;

  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 700;
}

.emojiGrid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;

  max-height: 270px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.emojiItem {
  width: 100%;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  border: none;
  border-radius: 10px;
  background: transparent;

  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.emojiItem:hover {
  background: rgba(255, 255, 255, 0.1);
}

.emojiItem:active {
  transform: scale(0.9);
}

@media (max-width: 760px) {
  .emojiWrap {
    flex: 0 0 44px;
  }

  .emojiToggleBtn {
    width: 44px;
    height: 52px;
    min-width: 44px;
    border-radius: 12px;
  }

  .emojiPanel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    max-height: 42vh;
  }

  .emojiGrid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    max-height: calc(42vh - 48px);
  }

  .emojiItem {
    font-size: 25px;
  }
}

#messages {
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

#messages.messagesLoading {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}

/* =========================================================
   MESSAGE IMAGE VIEWER
   ========================================================= */

.imageViewer {
  position: fixed;
  inset: 0;
  z-index: 5000;
  overflow: hidden;
  background: rgba(3, 7, 13, 0.96);
  backdrop-filter: blur(8px);
  user-select: none;
  -webkit-user-select: none;
}

.imageViewerTop {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;

  min-height: 72px;
  padding: 12px 18px;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;

  background: linear-gradient(180deg, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0));
}

.imageViewerAuthor {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.imageViewerAvatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;

  display: flex;
  align-items: center;
  justify-content: center;

  overflow: hidden;
  border-radius: 50%;

  color: #fff;
  font-size: 13px;
  font-weight: 800;

  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.imageViewerAvatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.imageViewerAuthorText {
  min-width: 0;
}

.imageViewerName {
  max-width: 320px;
  overflow: hidden;

  color: #fff;
  font-size: 15px;
  font-weight: 750;

  white-space: nowrap;
  text-overflow: ellipsis;
}

.imageViewerDate {
  margin-top: 3px;

  color: rgba(255, 255, 255, 0.65);
  font-size: 12px;
  white-space: nowrap;
}

.imageViewerActions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.imageViewerAction {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  padding: 0;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border: none;
  border-radius: 50%;

  color: rgba(255, 255, 255, 0.82);
  background: transparent;

  cursor: pointer;
  text-decoration: none;

  transition:
    color 0.15s ease,
    background 0.15s ease,
    transform 0.15s ease;
}

.imageViewerAction:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.imageViewerAction:active {
  transform: scale(0.94);
}

.imageViewerAction svg {
  width: 24px;
  height: 24px;
  display: block;
  fill: currentColor;
}

.imageViewerDanger {
  color: #ff7474;
}

.imageViewerDanger:hover {
  color: #ff9191;
  background: rgba(255, 80, 80, 0.14);
}

.imageViewerStage {
  position: absolute;
  inset: 0;

  padding: 82px 24px 24px;

  display: flex;
  align-items: center;
  justify-content: center;

  overflow: hidden;
  touch-action: none;
  cursor: default;
}

.imageViewerImage {
  display: block;

  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 108px);

  width: auto;
  height: auto;

  object-fit: contain;
  transform-origin: center center;
  will-change: transform;

  cursor: zoom-in;
  pointer-events: auto;
  -webkit-user-drag: none;

  transition: transform 0.16s ease;
}

.imageViewer.isZoomed .imageViewerStage,
.imageViewer.isZoomed .imageViewerImage {
  cursor: grab;
}

.imageViewer.dragging .imageViewerStage,
.imageViewer.dragging .imageViewerImage {
  cursor: grabbing;
}

.imageViewer.dragging .imageViewerImage {
  transition: none;
}

.imageViewerScale {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 20px;

  padding: 7px 12px;
  border-radius: 999px;

  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;

  background: rgba(0, 0, 0, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.12);

  transform: translateX(-50%);
  pointer-events: none;
}

@media (max-width: 760px) {
  .imageViewerTop {
    padding: 8px 10px 10px;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 6px;
  }

  .imageViewerAuthor {
    width: 100%;
  }

  .imageViewerAvatar {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .imageViewerName {
    max-width: calc(100vw - 74px);
    font-size: 14px;
  }

  .imageViewerActions {
    width: 100%;
    justify-content: flex-end;
    gap: 2px;
    overflow-x: auto;
  }

  .imageViewerAction {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .imageViewerAction svg {
    width: 22px;
    height: 22px;
  }

  .imageViewerStage {
    padding: 126px 10px 18px;
  }

  .imageViewerImage {
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 146px);
  }

  .imageViewerScale {
    bottom: 12px;
  }
}
