* {
  box-sizing: border-box;
}

:root {
  --bg-main: #12324e;
  --bg-deep: #0d2b46;
  --bg-card: rgba(26, 68, 96, 0.78);
  --bg-card-soft: rgba(32, 82, 108, 0.58);
  --bg-input: rgba(26, 60, 88, 0.58);

  --accent-cyan: #22d3ee;
  --accent-blue: #0ea5e9;
  --accent-green: #10b981;
  --accent-lime: #a3e635;

  --text-main: #f8fafc;
  --text-soft: #cbd5e1;
  --text-muted: #a4bfd0;

  --danger: #fb7185;
  --danger-bg: rgba(190, 24, 93, 0.18);

  --border-soft: rgba(148, 163, 184, 0.14);
  --border-bright: rgba(125, 211, 252, 0.26);

  --shadow-card: 0 22px 70px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 12px 34px rgba(0, 0, 0, 0.22);

  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Arial,
    sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 12% 12%, rgba(34, 211, 238, 0.17), transparent 30%),
    radial-gradient(circle at 86% 8%, rgba(16, 185, 129, 0.14), transparent 32%),
    radial-gradient(circle at 50% 92%, rgba(14, 165, 233, 0.12), transparent 38%),
    linear-gradient(135deg, #0d2b46 0%, #143a56 48%, #14545e 100%);
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: none;
  outline: none;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* =========================
   AUTH
========================= */

#auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 440px);
  padding: 30px;
  border-radius: 32px;
  background:
    linear-gradient(180deg, rgba(32, 82, 108, 0.78), rgba(30, 64, 94, 0.88)),
    rgba(26, 68, 96, 0.82);
  border: 1px solid rgba(125, 211, 252, 0.18);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: -80px -80px auto auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.3), transparent 66%);
  pointer-events: none;
}

.auth-card h1 {
  margin: 0 0 8px;
  text-align: center;
  font-size: 36px;
  line-height: 1;
  font-weight: 950;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #e0f2fe, #67e8f9 42%, #86efac);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-card p {
  margin: 0 0 22px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.45;
}

.auth-card input {
  width: 100%;
  height: 48px;
  margin-bottom: 12px;
  padding: 0 15px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.15);
  background: rgba(26, 60, 88, 0.58);
  color: var(--text-main);
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.auth-card input::placeholder {
  color: rgba(203, 213, 225, 0.48);
}

.auth-card input:focus {
  border-color: rgba(34, 211, 238, 0.52);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.1);
  background: rgba(26, 60, 88, 0.72);
}

.password-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 12px;
}

.password-wrap input {
  margin-bottom: 0;
  flex: 1;
  min-width: 0;
}

#togglePassword {
  height: 48px;
  padding: 0 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-soft);
  font-weight: 800;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}

#togglePassword:hover {
  background: rgba(255, 255, 255, 0.13);
  color: white;
  transform: translateY(-1px);
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 4px 0 16px;
  color: var(--text-muted);
  font-size: 14px;
  user-select: none;
}

.remember-row input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--accent-cyan);
}

/* кнопки входа и регистрации рядом */
.auth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

#loginBtn,
#registerBtn {
  flex: 1;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 17px;
  font-weight: 900;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease;
}

#loginBtn {
  margin: 0;
  color: white;
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  box-shadow: 0 14px 28px rgba(14, 165, 233, 0.18);
}

#registerBtn {
  margin: 0;
  color: #d9f99d;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(163, 230, 53, 0.22);
}

#loginBtn:hover,
#registerBtn:hover {
  transform: translateY(-1px);
}

#loginBtn:hover {
  box-shadow: 0 18px 36px rgba(16, 185, 129, 0.2);
}

#registerBtn:hover {
  background: rgba(163, 230, 53, 0.1);
  border-color: rgba(163, 230, 53, 0.34);
}

#authError {
  min-height: 20px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 14px;
  text-align: center;
}

/* =========================
   APP LAYOUT
========================= */

#app {
  width: 100vw;
  height: 100vh;
  padding: 18px;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
}

.sidebar,
.chat {
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(12, 42, 62, 0.82), rgba(4, 20, 34, 0.88)),
    rgba(9, 30, 46, 0.82);
  border: 1px solid rgba(125, 211, 252, 0.14);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(18px);
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.chat {
  display: flex;
  flex-direction: column;
}

/* =========================
   PROFILE / SIDEBAR
========================= */

.profile {
  min-height: 76px;
  padding: 13px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 90% 0%, rgba(34, 211, 238, 0.18), transparent 38%),
    linear-gradient(135deg, rgba(14, 165, 233, 0.14), rgba(16, 185, 129, 0.1));
  border: 1px solid rgba(125, 211, 252, 0.16);
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

#meName {
  color: var(--text-main);
  font-weight: 950;
  font-size: 15px;
  max-width: 148px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#meLogin {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 13px;
  max-width: 148px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#logoutBtn {
  min-width: 72px;
  height: 42px;
  margin-left: auto;
  padding: 0 14px;
  border-radius: 15px;
  background: rgba(251, 113, 133, 0.14);
  color: #fecdd3;
  font-weight: 900;
  border: 1px solid rgba(251, 113, 133, 0.18);
}

#profileAvatarBtn,
.callibri-avatar-btn {
  width: 52px !important;
  height: 52px !important;
  min-width: 52px !important;
  border-radius: 18px !important;
  overflow: hidden !important;
  background: linear-gradient(135deg, #0ea5e9, #10b981) !important;
  color: white !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-weight: 950 !important;
  font-size: 22px !important;
  padding: 0 !important;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.24) !important;
  border: 1px solid rgba(125, 211, 252, 0.25) !important;
  flex-shrink: 0 !important;
}

#profileAvatarBtn img,
.callibri-avatar-btn img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
}

#settingsBtn,
#callibriGearBtn,
.callibri-settings-btn,
.callibri-gear-btn {
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  margin-left: auto !important;
  border-radius: 16px !important;
  background: linear-gradient(135deg, #06b6d4, #10b981) !important;
  color: white !important;
  font-size: 20px !important;
  font-weight: 950 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow:
    0 12px 26px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.22) !important;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease !important;
}

#settingsBtn:hover,
#callibriGearBtn:hover,
.callibri-settings-btn:hover,
.callibri-gear-btn:hover {
  transform: translateY(-1px) rotate(8deg) !important;
  box-shadow:
    0 16px 34px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.28) !important;
}

#search {
  width: 100%;
  height: 46px;
  margin: 15px 0 12px;
  padding: 0 15px;
  border-radius: 17px;
  border: 1px solid rgba(148, 163, 184, 0.13);
  background: rgba(26, 60, 88, 0.48);
  color: var(--text-main);
  outline: none;
  flex-shrink: 0;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

#search::placeholder {
  color: rgba(203, 213, 225, 0.45);
}

#search:focus {
  border-color: rgba(34, 211, 238, 0.44);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.08);
  background: rgba(26, 60, 88, 0.64);
}

.sidebar-title {
  margin: 14px 6px 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

#users,
#recentChats,
#groups {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

#users {
  min-height: 0;
  overflow-y: auto;
  padding-right: 3px;
}

#recentChats,
#groups {
  flex-shrink: 0;
}

#createGroupBtn {
  width: 100%;
  height: 44px;
  margin: 4px 0 8px;
  border-radius: 16px;
  color: #d9f99d;
  font-weight: 900;
  background: rgba(163, 230, 53, 0.08);
  border: 1px solid rgba(163, 230, 53, 0.16);
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease;
}

#createGroupBtn:hover {
  transform: translateY(-1px);
  background: rgba(163, 230, 53, 0.12);
  border-color: rgba(163, 230, 53, 0.3);
}

.user {
  width: 100%;
  min-height: 66px;
  padding: 10px;
  border-radius: 19px;
  background: transparent;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  transition:
    background 0.15s ease,
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.user:hover {
  background: rgba(255, 255, 255, 0.055);
  transform: translateY(-1px);
}

.user.active {
  background:
    linear-gradient(135deg, rgba(14, 165, 233, 0.22), rgba(16, 185, 129, 0.16));
  box-shadow: inset 0 0 0 1px rgba(125, 211, 252, 0.16);
}

.avatar {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 950;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.group-avatar {
  background: linear-gradient(135deg, #155e75, #047857);
}

.user-info {
  min-width: 0;
  flex: 1;
}

.user-info b {
  display: flex;
  align-items: center;
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info span {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.online-dot {
  width: 9px;
  height: 9px;
  min-width: 9px;
  border-radius: 50%;
  margin-right: 6px;
  background: #64748b;
}

.online-dot.online {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.17);
}

.unread-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #0ea5e9, #22c55e);
  color: white;
  font-size: 12px;
  font-weight: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* =========================
   ARCHIVE
========================= */

.archive-btn {
  width: 100%;
  min-height: 60px;
  margin: 10px 0 10px;
  padding: 10px 12px;
  border: 1px solid rgba(34, 211, 238, 0.2);
  border-radius: 20px;
  background:
    radial-gradient(circle at 90% 0%, rgba(16, 185, 129, 0.13), transparent 42%),
    linear-gradient(135deg, rgba(14, 165, 233, 0.13), rgba(16, 185, 129, 0.08));
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease;
}

.archive-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(125, 211, 252, 0.34);
  background:
    radial-gradient(circle at 90% 0%, rgba(16, 185, 129, 0.18), transparent 42%),
    linear-gradient(135deg, rgba(14, 165, 233, 0.18), rgba(16, 185, 129, 0.12));
}

.archive-icon {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background: rgba(26, 60, 88, 0.52);
  color: #67e8f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 950;
  border: 1px solid rgba(125, 211, 252, 0.18);
  flex-shrink: 0;
}

.archive-info {
  min-width: 0;
  flex: 1;
}

.archive-info b {
  display: block;
  color: #f8fafc;
  font-size: 14px;
  font-weight: 950;
  margin-bottom: 3px;
}

.archive-info span {
  display: block;
  color: #9bd8e6;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.archive-badge {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #06b6d4, #10b981);
  color: white;
  font-size: 12px;
  font-weight: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.archive-context-menu,
.message-context-menu {
  position: fixed;
  z-index: 999999;
  width: 228px;
  padding: 8px;
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(45, 212, 191, 0.16) 0%, rgba(10, 34, 50, 0.55) 34%, rgba(3, 14, 26, 0.66) 100%);
  border: 1px solid rgba(148, 226, 213, 0.3);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.22), inset 0 -1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(26px) saturate(160%);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  animation: ctxPop 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  transform-origin: top left;
}

@keyframes ctxPop {
  from { opacity: 0; transform: scale(0.9) translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.archive-context-menu.hidden,
.message-context-menu.hidden {
  display: none;
}

.archive-context-menu button,
.message-context-menu button {
  width: 100%;
  height: 40px;
  border-radius: 13px;
  background: transparent;
  color: #e8f6f3;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 11px;
  font-size: 14px;
  font-weight: 800;
  text-align: left;
  transition: background 0.14s ease, padding-left 0.14s ease;
}

.archive-context-menu button span,
.message-context-menu button span {
  width: 20px;
  display: inline-flex;
  justify-content: center;
  flex-shrink: 0;
}

.archive-context-menu button:hover,
.message-context-menu button:hover {
  background: linear-gradient(90deg, rgba(45, 212, 191, 0.22), rgba(45, 212, 191, 0.06));
  padding-left: 15px;
}

.message-context-menu button.danger {
  color: #fb7185;
}

.message-context-menu button.danger:hover {
  background: linear-gradient(90deg, rgba(251, 113, 133, 0.24), rgba(251, 113, 133, 0.08));
}

/* =========================
   CHAT HEADER
========================= */

.chat-header {
  min-height: 78px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 13px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  background:
    radial-gradient(circle at 0% 0%, rgba(34, 211, 238, 0.12), transparent 40%),
    rgba(26, 60, 88, 0.25);
  flex-shrink: 0;
}

#chatAvatar {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: 17px;
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  color: white;
  font-weight: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.23);
}

#chatAvatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#chatName {
  color: var(--text-main);
  font-size: 17px;
  font-weight: 950;
  line-height: 1.2;
}

#chatStatus {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13px;
}

/* =========================
   MESSAGES
========================= */

#messages {
  flex: 1;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  scroll-behavior: smooth;
  background:
    radial-gradient(circle at 20% 12%, rgba(34, 211, 238, 0.055), transparent 30%),
    radial-gradient(circle at 80% 90%, rgba(16, 185, 129, 0.055), transparent 34%);
}

.empty {
  height: 100%;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
}

.small-empty {
  min-height: 48px;
  height: auto;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
  font-size: 12px;
}

.message {
  width: fit-content;
  max-width: min(68%, 620px);
  margin: 9px 0;
  padding: 11px 13px 9px;
  border-radius: 21px 21px 21px 7px;
  background: rgba(15, 42, 61, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.1);
  color: var(--text-main);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  position: relative;
  overflow-wrap: anywhere;
}

.message.mine {
  margin-left: auto;
  border-radius: 21px 21px 7px 21px;
  background:
    linear-gradient(135deg, rgba(14, 165, 233, 0.88), rgba(16, 185, 129, 0.86));
  border-color: rgba(255, 255, 255, 0.16);
  color: white;
}

.message-name {
  margin-bottom: 5px;
  color: #9bd8e6;
  font-size: 12px;
  font-weight: 950;
}

.message.mine .message-name {
  color: rgba(255, 255, 255, 0.82);
}

.message-text {
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message-time {
  color: inherit;
  opacity: 0.72;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  color: rgba(203, 213, 225, 0.82);
}

.message.mine .message-meta {
  color: rgba(255, 255, 255, 0.82);
}

.message-edited {
  font-size: 11px;
  opacity: 0.68;
}

.message-status {
  position: relative;
  display: inline-flex;
  width: 20px;
  height: 13px;
  flex-shrink: 0;
}

.message-status__check {
  position: absolute;
  top: -2px;
  font-size: 13px;
  line-height: 1;
  font-weight: 950;
}

.message-status__check.first {
  left: 0;
}

.message-status__check.second {
  left: 7px;
}

/* Не прочитано: одна серая галочка */
.message-status.unread .message-status__check {
  color: rgba(148, 163, 184, 0.95);
}

.message-status.unread .message-status__check.first {
  left: 7px;
}

.message-status.unread .message-status__check.second {
  display: none;
}

/* Прочитано: две синие галочки */
.message-status.read .message-status__check {
  color: #34b7f1;
  text-shadow: 0 0 8px rgba(52, 183, 241, 0.45);
}

.message-reply-preview {
  margin-bottom: 8px;
  padding: 7px 9px;
  border-radius: 12px;
  border-left: 3px solid #22d3ee;
  background: rgba(34, 211, 238, 0.12);
  overflow: hidden;
}

.message.mine .message-reply-preview {
  border-left-color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.13);
}

.message-reply-author {
  margin-bottom: 2px;
  color: #67e8f9;
  font-size: 12px;
  font-weight: 950;
}

.message.mine .message-reply-author {
  color: rgba(255, 255, 255, 0.88);
}

.message-reply-text {
  color: rgba(226, 232, 240, 0.78);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================
   MEDIA / VOICE
========================= */

.message-media {
  margin-top: 5px;
}

.message-media img,
.message-media video {
  display: block;
  max-width: 100%;
  max-height: 360px;
  border-radius: 17px;
  object-fit: cover;
}

.message-media video {
  background: #000;
}

.voice-card {
  min-width: 290px;
  max-width: 380px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(26, 60, 88, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.voice-card__main {
  display: flex;
  align-items: center;
  gap: 11px;
}

.voice-card__play {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: white;
  font-weight: 950;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-card__body {
  flex: 1;
  min-width: 0;
}

.voice-card__top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
}

.voice-card__hint {
  opacity: 0.66;
}

.voice-card__wave {
  height: 42px;
  cursor: pointer;
}

.voice-card__fallback-wave {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.voice-wave-bar {
  width: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
}

.voice-card__footer {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.voice-card__footer-left,
.voice-card__footer-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.voice-card__clock {
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
}

.voice-card__delete,
.delete-message-btn {
  height: 28px;
  padding: 0 9px;
  border-radius: 10px;
  background: rgba(127, 29, 29, 0.46);
  color: white;
  font-size: 12px;
  font-weight: 850;
}

/* =========================
   INPUT
========================= */

.chat-input {
  padding: 14px 16px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(26, 60, 88, 0.26);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

#messageInput {
  flex: 1;
  min-height: 48px;
  max-height: 140px;
  padding: 13px 15px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(26, 60, 88, 0.58);
  color: var(--text-main);
  outline: none;
  resize: none;
  line-height: 1.4;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

#messageInput::placeholder {
  color: rgba(203, 213, 225, 0.46);
}

#messageInput:focus {
  border-color: rgba(34, 211, 238, 0.46);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.08);
  background: rgba(26, 60, 88, 0.72);
}

#sendBtn,
#attachBtn,
#videoNoteBtn,
#voiceBtn {
  height: 48px;
  min-width: 48px;
  border-radius: 17px;
  color: white;
  font-weight: 950;
  transition:
    transform 0.16s ease,
    opacity 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

#attachBtn,
#videoNoteBtn,
#voiceBtn {
  width: 48px;
  padding: 0;
  background: rgba(255, 255, 255, 0.08);
  color: #d9f99d;
  font-size: 18px;
}

#sendBtn {
  padding: 0 18px;
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  box-shadow: 0 12px 28px rgba(14, 165, 233, 0.14);
}

#sendBtn:hover,
#attachBtn:hover,
#videoNoteBtn:hover,
#voiceBtn:hover {
  transform: translateY(-1px);
}

#attachBtn:hover,
#videoNoteBtn:hover,
#voiceBtn:hover {
  background: rgba(255, 255, 255, 0.13);
}

#sendBtn:disabled,
#attachBtn:disabled,
#videoNoteBtn:disabled,
#voiceBtn:disabled,
#messageInput:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

#voiceBtn.recording {
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: white;
}

/* =========================
   REPLY / EDIT PANELS
========================= */

.mode-panel,
.dm-reply-panel,
.dm-edit-panel,
.reply-panel,
.edit-panel {
  margin: 8px 16px 0;
  padding: 10px 12px;
  border-radius: 17px;
  background: rgba(15, 42, 61, 0.88);
  border: 1px solid rgba(125, 211, 252, 0.16);
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-panel.hidden,
.dm-reply-panel.hidden,
.dm-edit-panel.hidden,
.reply-panel.hidden,
.edit-panel.hidden {
  display: none;
}

.mode-panel-line,
.dm-reply-line,
.dm-edit-line,
.reply-panel-line,
.edit-panel-line {
  width: 3px;
  align-self: stretch;
  min-height: 36px;
  border-radius: 999px;
  background: #22d3ee;
  flex-shrink: 0;
}

.mode-panel.edit .mode-panel-line,
.dm-edit-line,
.edit-panel-line {
  background: #f59e0b;
}

.mode-panel-content,
.dm-panel-content,
.reply-panel-content,
.edit-panel-content {
  flex: 1;
  min-width: 0;
}

.mode-panel-title,
.dm-panel-title,
.reply-panel-title,
.edit-panel-title {
  margin-bottom: 3px;
  color: #67e8f9;
  font-size: 12px;
  font-weight: 950;
}

.mode-panel.edit .mode-panel-title,
.dm-edit-panel .dm-panel-title,
.edit-panel-title {
  color: #fbbf24;
}

.mode-panel-text,
.dm-panel-text,
.reply-panel-text,
.edit-panel-text {
  color: var(--text-soft);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-panel-close,
.dm-panel-close,
.reply-panel-close,
.edit-panel-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.12);
  color: white;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* =========================
   RECORDING
========================= */

.recording-panel {
  margin: 8px 16px 0;
  padding: 10px 12px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(239, 68, 68, 0.12), rgba(14, 165, 233, 0.1)),
    rgba(15, 42, 61, 0.88);
  border: 1px solid rgba(251, 113, 133, 0.18);
  display: flex;
  align-items: center;
  gap: 12px;
}

.recording-panel.hidden {
  display: none;
}

.recording-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 70px;
}

.recording-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.14);
  animation: pulseDot 1s infinite;
}

@keyframes pulseDot {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.45;
  }
}

.recording-timer {
  color: white;
  font-weight: 900;
  font-size: 13px;
}

.recording-visualizer {
  flex: 1;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 3px;
  overflow: hidden;
}

.recording-bar {
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, #67e8f9, #86efac);
}

.recording-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.recording-action {
  height: 34px;
  padding: 0 12px;
  border-radius: 13px;
  color: white;
  font-weight: 850;
}

.recording-action.cancel {
  background: rgba(251, 113, 133, 0.18);
  color: #fecdd3;
}

.recording-action.send {
  background: linear-gradient(135deg, #0ea5e9, #10b981);
}

.recording-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* =========================
   MODALS
========================= */

.modal,
.callibri-clean-settings-modal,
.callibri-gear-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  padding: 20px;
  background: rgba(30, 58, 92, 0.72);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden,
.callibri-clean-settings-modal.hidden,
.callibri-gear-modal.hidden {
  display: none;
}

.modal-card,
.settings-modal-shell,
.callibri-clean-settings-card,
.callibri-settings-card {
  width: min(94vw, 560px);
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px;
  border-radius: 26px;
  background:
    radial-gradient(circle at 0% 0%, rgba(34, 211, 238, 0.18), transparent 34%),
    radial-gradient(circle at 100% 0%, rgba(16, 185, 129, 0.16), transparent 34%),
    linear-gradient(180deg, rgba(23, 62, 102, 0.98), rgba(16, 84, 96, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.55);
  color: var(--text-main);
}

.modal-card h2,
.settings-modal-shell h2,
.callibri-clean-settings-card h2,
.callibri-settings-card h2 {
  margin: 0 0 8px;
  color: white;
  font-size: 24px;
  font-weight: 950;
}

.modal-card p {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.45;
}

.modal-card input,
.modal-card textarea,
.settings-modal-shell input,
.settings-modal-shell textarea,
.settings-modal-shell select,
.callibri-clean-settings-card input,
.callibri-clean-settings-card textarea,
.callibri-clean-settings-card select,
.callibri-settings-card input,
.callibri-settings-card textarea,
.callibri-settings-card select {
  width: 100%;
  margin-bottom: 11px;
  padding: 12px 14px;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(30, 58, 92, 0.45);
  color: var(--text-main);
  outline: none;
}

.modal-card textarea,
.settings-modal-shell textarea,
.callibri-clean-settings-card textarea,
.callibri-settings-card textarea {
  min-height: 120px;
  resize: vertical;
}

.modal-actions,
.settings-row,
.callibri-clean-actions,
.callibri-settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 10px;
}

.modal-actions button,
.settings-row button,
.callibri-clean-actions button,
.callibri-settings-actions button,
.callibri-settings-footer button {
  min-height: 40px;
  padding: 0 15px;
  border-radius: 14px;
  color: white;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 850;
}

.modal-actions button:last-child,
.settings-row .primary,
.callibri-clean-actions .primary,
.callibri-settings-actions .primary,
.callibri-settings-footer .primary {
  background: linear-gradient(135deg, #0ea5e9, #10b981);
}

.settings-row .danger,
.callibri-clean-actions .danger,
.callibri-settings-actions .danger,
.callibri-settings-footer .danger {
  background: linear-gradient(135deg, rgba(190, 24, 93, 0.92), rgba(153, 27, 27, 0.96));
}

#groupError,
#profileError {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

/* =========================
   SCROLLBARS
========================= */

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.22);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.34);
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  #app {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .sidebar {
    max-height: 46vh;
  }

  .chat {
    min-height: 70vh;
  }

  .message {
    max-width: 86%;
  }
}

@media (max-width: 560px) {
  #auth {
    padding: 14px;
  }

  .auth-card {
    padding: 22px;
    border-radius: 26px;
  }

  #loginBtn,
  #registerBtn {
    width: 100%;
    margin: 0 0 10px;
  }

  #app {
    padding: 8px;
    gap: 10px;
  }

  .sidebar,
  .chat {
    border-radius: 22px;
  }

  .chat-input {
    flex-wrap: wrap;
  }

  #messageInput {
    flex-basis: 100%;
  }

  #sendBtn {
    flex: 1;
  }

  .message {
    max-width: 92%;
  }

  .voice-card {
    min-width: 240px;
  }
}

.archive-btn {
  width: 100%;
  min-height: 60px;
  margin: 10px 0 10px;
  padding: 10px 12px;
  border: 1px solid rgba(34, 211, 238, 0.2);
  border-radius: 20px;
  background:
    radial-gradient(circle at 90% 0%, rgba(16, 185, 129, 0.13), transparent 42%),
    linear-gradient(135deg, rgba(14, 165, 233, 0.13), rgba(16, 185, 129, 0.08));
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease;
}

.archive-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(125, 211, 252, 0.34);
  background:
    radial-gradient(circle at 90% 0%, rgba(16, 185, 129, 0.18), transparent 42%),
    linear-gradient(135deg, rgba(14, 165, 233, 0.18), rgba(16, 185, 129, 0.12));
}

.archive-icon {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background: rgba(26, 60, 88, 0.52);
  color: #67e8f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 950;
  border: 1px solid rgba(125, 211, 252, 0.18);
  flex-shrink: 0;
}

.archive-info {
  min-width: 0;
  flex: 1;
}

.archive-info b {
  display: block;
  color: #f8fafc;
  font-size: 14px;
  font-weight: 950;
  margin-bottom: 3px;
}

.archive-info span {
  display: block;
  color: #9bd8e6;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.archive-badge {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #06b6d4, #10b981);
  color: white;
  font-size: 12px;
  font-weight: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* =========================
   AUTH TABS
========================= */

.auth-tabs {
  width: 100%;
  height: 48px;
  margin: 0 0 16px;
  padding: 5px;
  border-radius: 18px;
  background: rgba(26, 60, 88, 0.45);
  border: 1px solid rgba(125, 211, 252, 0.12);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.auth-tab {
  border-radius: 14px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 900;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease,
    box-shadow 0.16s ease;
}

.auth-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.auth-tab.active {
  color: white;
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  box-shadow: 0 10px 22px rgba(14, 165, 233, 0.18);
}

.auth-mode-fields {
  width: 100%;
}

.auth-card.auth-register-mode #username::placeholder {
  color: transparent;
}

.auth-switch-hint {
  width: 100%;
  margin-top: 12px;
  padding: 0;
  background: transparent;
  color: #9bd8e6;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.auth-switch-hint:hover {
  color: #d9f99d;
}

.auth-card.auth-register-mode .remember-row {
  display: none;
}

.auth-card.auth-register-mode #username::placeholder {
  color: rgba(203, 213, 225, 0.48);
}

.auth-card.auth-register-mode #username {
  margin-bottom: 12px;
}

.auth-card.auth-register-mode #username + .password-wrap {
  margin-top: 0;
}

/* =========================
   PINNED CHATS
========================= */

.chat-title-line {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  min-width: 0 !important;
}

.chat-title-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-pin-icon {
  width: 15px;
  height: 15px;
  min-width: 15px;
  border-radius: 5px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.95), rgba(16, 185, 129, 0.95));
  box-shadow:
    0 0 0 2px rgba(34, 211, 238, 0.12),
    0 6px 14px rgba(0, 0, 0, 0.22);
  transform: rotate(45deg);
}

.chat-pin-icon::after {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.45);
}

.chat-context-menu {
  position: fixed;
  z-index: 999999;
  width: 190px;
  padding: 7px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(18px);
}

.chat-context-menu.hidden {
  display: none;
}

.chat-context-menu button {
  width: 100%;
  height: 42px;
  border: none;
  outline: none;
  background: transparent;
  color: #e5e7eb;
  border-radius: 12px;
  padding: 0 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 14px;
  font-weight: 800;
  text-align: left;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.chat-context-menu button:hover {
  background: rgba(34, 211, 238, 0.12);
  color: #d9f99d;
}

.chat-context-icon {
  width: 22px;
  height: 22px;
  min-width: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-context-pin {
  width: 13px;
  height: 13px;
  border-radius: 5px;
  background: linear-gradient(135deg, #22d3ee, #10b981);
  transform: rotate(45deg);
  box-shadow:
    0 0 0 2px rgba(34, 211, 238, 0.12),
    0 6px 12px rgba(0, 0, 0, 0.25);
}

.chat-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.chat-title-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-pin-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(44, 210, 193, 0.14);
  border: 1px solid rgba(44, 210, 193, 0.28);
  color: #35e0c6;
  box-shadow: 0 0 10px rgba(53, 224, 198, 0.12);
  flex-shrink: 0;
}

.chat-pin-badge svg {
  width: 12px;
  height: 12px;
  display: block;
  fill: currentColor;
}

.chat-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.chat-title-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-pin-wing {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #67f2dd;
  opacity: 0.95;
}

.chat-pin-wing svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: currentColor;
  transform: rotate(-14deg);
  filter: drop-shadow(0 0 8px rgba(103, 242, 221, 0.35));
  transition: transform 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
}

.recent-chat-item:hover .chat-pin-wing svg {
  transform: rotate(-10deg) scale(1.06);
  filter: drop-shadow(0 0 10px rgba(103, 242, 221, 0.5));
}

/* =========================
   HUMMINGBIRD PIN ICON
========================= */

.recent-chat-item.pinned-chat-item {
  position: relative;
  background:
    linear-gradient(135deg, rgba(34, 211, 238, 0.13), rgba(16, 185, 129, 0.11)),
    rgba(255, 255, 255, 0.035);
  box-shadow:
    inset 3px 0 0 rgba(103, 242, 221, 0.9),
    inset 0 0 0 1px rgba(103, 242, 221, 0.12);
}

.chat-title-line {
  display: flex !important;
  align-items: center !important;
  gap: 7px !important;
  width: 100% !important;
  min-width: 0 !important;
}

.chat-title-name {
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.hummingbird-pin {
  margin-left: auto;
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #7df9e5;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.26), transparent 28%),
    linear-gradient(135deg, rgba(34, 211, 238, 0.22), rgba(16, 185, 129, 0.16));
  border: 1px solid rgba(125, 249, 229, 0.24);
  box-shadow:
    0 0 0 2px rgba(103, 242, 221, 0.07),
    0 8px 18px rgba(0, 0, 0, 0.22),
    0 0 16px rgba(103, 242, 221, 0.16);
  flex-shrink: 0;
}

.hummingbird-pin svg {
  width: 15px;
  height: 15px;
  display: block;
  fill: currentColor;
  transform: rotate(-16deg);
  filter: drop-shadow(0 0 7px rgba(125, 249, 229, 0.45));
}

.recent-chat-item:hover .hummingbird-pin svg {
  transform: rotate(-10deg) scale(1.08);
}

/* Выпадающий поиск пользователей */
aside {
  position: relative;
}
#users {
  display: none;
  position: absolute;
  left: 12px;
  right: 12px;
  max-height: 320px;
  overflow-y: auto;
  background: #17394f;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  z-index: 100;
  padding: 8px;
}
#users.open {
  display: block;
}
/* ===== НОВЫЙ ДИЗАЙН: ЭТАП 1 — пузыри сообщений ===== */

#messages {
  padding: 18px max(24px, 9%);
}

.message {
  max-width: min(64%, 480px);
  margin: 3px 0;
  padding: 7px 12px 5px;
  border-radius: 16px 16px 16px 5px;
  border: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.message.mine {
  border-radius: 16px 16px 5px 16px;
}

/* своё имя над своими сообщениями не показываем — и так ясно */
.message.mine .message-name {
  display: none;
}

.message-text {
  font-size: 15px;
  line-height: 1.35;
}

.message-meta {
  margin-top: 2px;
  font-size: 11px;
}

/* соседние сообщения одного человека — плотнее, как в Telegram */
.message + .message {
  margin-top: 3px;
}
/* разделители дат в переписке */
.date-divider {
  display: flex;
  justify-content: center;
  margin: 14px 0 8px;
}

.date-divider span {
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(26, 60, 88, 0.45);
  color: rgba(226, 232, 240, 0.85);
  font-size: 12px;
  font-weight: 600;
}
/* ===== НОВЫЙ ДИЗАЙН: ЭТАП 2 — список чатов ===== */

.recent-chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 12px;
}

.recent-chat-item .user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

.recent-chat-item .user-info b {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-chat-item .user-info > span {
  font-size: 13px;
  color: rgba(226, 232, 240, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-chat-item.active {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.35), rgba(16, 185, 129, 0.3));
}

.recent-chat-item:hover:not(.active) {
  background: rgba(255, 255, 255, 0.05);
}
/* ===== НОВЫЙ ДИЗАЙН: ЭТАП 3 — строка ввода ===== */

#search {
  border-radius: 999px;
}

#messageInput {
  border-radius: 24px;
}

#attachBtn,
#videoNoteBtn,
#voiceBtn {
  width: 48px;
  border-radius: 50%;
  background: transparent;
  color: rgba(203, 213, 225, 0.78);
  font-size: 20px;
}

#attachBtn:hover,
#voiceBtn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: white;
}

#sendBtn {
  width: 48px;
  min-width: 48px;
  padding: 0;
  border-radius: 50%;
  font-size: 0;
}

#sendBtn::after {
  content: "➤";
  font-size: 18px;
  margin-left: 2px;
}

.composer-hidden {
  display: none;
}

/* ===== НОВЫЙ ДИЗАЙН: ЭТАП 4 — шапка и настройки ===== */

#chatAvatar {
  border-radius: 50%;
}

.settings-avatar {
  width: 92px;
  height: 92px;
  min-width: 92px;
  margin: 4px auto 10px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  color: white;
  font-size: 36px;
  font-weight: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(125, 211, 252, 0.35);
  cursor: pointer;
}

.settings-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.settings-me {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: 16px;
}

.settings-me b {
  color: white;
  font-size: 19px;
}

.settings-me span {
  color: var(--text-muted);
  font-size: 13px;
}

.settings-mobile-header {
  display: none;
}

.settings-mobile-back {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.settings-mobile-title {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}

.settings-mobile-spacer {
  width: 38px;
  height: 38px;
}

.settings-modal-shell .remember-row {
  justify-content: center;
  gap: 8px;
}

/* ===== ПЕРЕДЕЛКА МОДАЛКИ НАСТРОЕК ===== */

.modal {
  backdrop-filter: blur(6px);
  animation: modalFade 0.15s ease;
}

@keyframes modalFade {
  from { opacity: 0; }
}

.settings-modal-shell {
  width: min(94vw, 400px) !important;
  padding: 28px 22px 16px !important;
  border-radius: 22px !important;
  background: linear-gradient(180deg, rgba(9, 38, 60, 0.99), rgba(7, 44, 52, 0.99)) !important;
  animation: settingsPop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}

@keyframes settingsPop {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

.settings-modal-shell textarea {
  min-height: 84px !important;
}

.settings-modal-shell .remember-row {
  flex-direction: row-reverse;
  justify-content: space-between;
  width: 100%;
  margin: 2px 0 16px;
  padding: 13px 14px;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(30, 58, 92, 0.45);
  color: var(--text-main);
  cursor: pointer;
}

.settings-modal-shell .remember-row input {
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 0;
  padding: 0;
  flex: 0 0 18px;
}

.settings-modal-shell .modal-actions {
  flex-direction: column;
  gap: 8px;
}

.settings-modal-shell .modal-actions button {
  width: 100%;
  min-height: 46px;
  border-radius: 15px;
  font-size: 15px;
}

#settingsSaveBtn { order: 1; }

#settingsCloseBtn {
  order: 2;
  background: rgba(255, 255, 255, 0.07);
}

#settingsLogoutBtn {
  order: 3;
  background: transparent;
  color: #fb7185;
}

#settingsLogoutBtn:hover {
  background: rgba(251, 113, 133, 0.12);
}

#settingsStatus {
  min-height: 18px;
  margin-top: 8px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* шестерёнка — спокойнее */
#callibriGearBtn {
  background: rgba(255, 255, 255, 0.08) !important;
  box-shadow: none !important;
  font-size: 18px !important;
}

#callibriGearBtn:hover {
  background: rgba(255, 255, 255, 0.14) !important;
  transform: none !important;
}

/* ===== ИЗБРАННОЕ — чат-закладка ===== */
.favorites-avatar {
  background: linear-gradient(135deg, #06b6d4, #0284c7);
  font-size: 20px;
}

/* ===== ОСВЕЖЕНИЕ ДИЗАЙНА: колонка сообщений ===== */

#usersTitle {
  display: none;
}

#messages {
  padding: 20px 26px;
  background:
    radial-gradient(rgba(148, 163, 184, 0.05) 1px, transparent 1.4px),
    radial-gradient(circle at 20% 12%, rgba(34, 211, 238, 0.05), transparent 30%),
    radial-gradient(circle at 80% 90%, rgba(16, 185, 129, 0.05), transparent 34%);
  background-size: 22px 22px, auto, auto;
}

/* ===== МОБИЛЬНАЯ ВЕРСИЯ ===== */

#mobileBackBtn {
  display: none;
}

@media (max-width: 768px) {
  body {
    overflow: hidden;
  }

  #app {
    display: block;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding: 0;
    gap: 0;
  }

  .sidebar {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    overflow-y: auto;
  }

  .chat {
    position: fixed;
    inset: 0;
    z-index: 60;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    border-radius: 0;
  }

  #mobileBackBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-main);
    font-size: 20px;
    cursor: pointer;
  }

  .chat-input {
    flex-wrap: nowrap;
  }

  #messageInput {
    flex-basis: auto;
  }

  #sendBtn {
    flex: 0 0 auto;
  }

  .message {
    max-width: 84%;
  }

  #messages {
    padding: 14px 12px;
  }

  .settings-modal-shell {
    width: min(400px, calc(100vw - 28px));
  }

  body.settings-open-mobile #appRail,
  body.settings-open-mobile .sidebar,
  body.settings-open-mobile .chat {
    visibility: hidden;
    pointer-events: none;
  }

  #callibriSettingsModal.mobile-settings-page {
    position: fixed;
    inset: 0;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    align-items: flex-start;
    justify-content: stretch;
    background: #16405e;
    backdrop-filter: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  #callibriSettingsModal.mobile-settings-page::-webkit-scrollbar {
    width: 0;
    height: 0;
  }

  #callibriSettingsModal.mobile-settings-page .settings-modal-shell {
    width: 100vw !important;
    max-width: none !important;
    min-height: 100vh;
    min-height: 100dvh;
    max-height: none;
    overflow: visible;
    margin: 0;
    box-sizing: border-box;
    border-radius: 0 !important;
    border: none;
    box-shadow: none;
    padding: calc(6px + env(safe-area-inset-top)) 14px calc(22px + env(safe-area-inset-bottom));
    background: transparent !important;
    animation: none;
    color: #f4fbff;
  }

  #callibriSettingsModal.mobile-settings-page .settings-modal-shell,
  #callibriSettingsModal.mobile-settings-page .settings-modal-shell * {
    box-sizing: border-box;
  }

  #callibriSettingsModal.mobile-settings-page .settings-mobile-header {
    display: grid;
    grid-template-columns: 38px 1fr 38px;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    margin: 0 -14px 14px;
    position: sticky;
    top: 0;
    z-index: 5;
    padding: calc(10px + env(safe-area-inset-top)) 14px 12px;
    background: rgba(11, 33, 51, 0.96);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
  }

  #callibriSettingsModal.mobile-settings-page .settings-mobile-title {
    text-align: center;
    letter-spacing: 0.01em;
    color: #ffffff;
  }

  #callibriSettingsModal.mobile-settings-page .settings-mobile-back {
    background: rgba(255, 255, 255, 0.08);
  }

  #callibriSettingsModal.mobile-settings-page .settings-avatar {
    width: 108px;
    height: 108px;
    min-width: 108px;
    margin: 18px auto 12px;
    border-width: 3px;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
    background: linear-gradient(135deg, #14384f, #17495d);
  }

  #callibriSettingsModal.mobile-settings-page .settings-me {
    margin-bottom: 20px;
  }

  #callibriSettingsModal.mobile-settings-page .settings-me b {
    font-size: 19px;
    color: #ffffff;
  }

  #callibriSettingsModal.mobile-settings-page .settings-me span {
    font-size: 13px;
    color: #a9c0cf;
    opacity: 1;
  }

  #callibriSettingsModal.mobile-settings-page .settings-section {
    margin: 0 0 14px;
    padding: 14px;
    border-radius: 20px;
    background: #143247;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
  }

  #callibriSettingsModal.mobile-settings-page .settings-section-title {
    margin-bottom: 12px;
    font-size: 12px;
    letter-spacing: 0.08em;
    color: #a9bfd0;
    opacity: 1;
  }

  #callibriSettingsModal.mobile-settings-page .settings-row {
    display: block;
    margin: 10px 0 12px;
  }

  #callibriSettingsModal.mobile-settings-page .settings-row > span {
    display: block;
    margin: 0 0 8px;
    font-size: 14px;
    color: #eef8ff;
  }

  #callibriSettingsModal.mobile-settings-page input,
  #callibriSettingsModal.mobile-settings-page select {
    width: 100%;
    margin-bottom: 10px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    background: #16405e;
    color: #ffffff;
    box-shadow: none;
  }

  #callibriSettingsModal.mobile-settings-page input::placeholder {
    color: #9db3c2;
  }

  #callibriSettingsModal.mobile-settings-page .settings-row select {
    width: 100%;
    max-width: none;
    flex: 1 1 auto;
  }

  #callibriSettingsModal.mobile-settings-page .settings-mini-btn {
    min-height: 48px;
    border-radius: 16px;
    background: rgba(39, 211, 193, 0.08);
    border-color: rgba(39, 211, 193, 0.18);
    color: #f4fbff;
  }

  #callibriSettingsModal.mobile-settings-page .remember-row {
    margin: 0 0 10px;
    min-height: 56px;
    padding: 14px 14px;
    border-radius: 16px;
    background: #16405e;
    border: 1px solid rgba(255, 255, 255, 0.04);
  }

  #callibriSettingsModal.mobile-settings-page .remember-row span {
    flex: 1;
    font-size: 14px;
    color: #f4fbff;
  }

  #callibriSettingsModal.mobile-settings-page .remember-row input {
    accent-color: #27d3c1;
  }

  #callibriSettingsModal.mobile-settings-page .modal-actions {
    position: static;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
    padding: 4px 0 0;
    background: transparent;
  }

  #callibriSettingsModal.mobile-settings-page .modal-actions button {
    width: 100%;
    min-height: 52px;
    margin: 0;
    border-radius: 18px;
  }

  #callibriSettingsModal.mobile-settings-page #settingsCloseBtn {
    display: none;
  }

  #callibriSettingsModal.mobile-settings-page #settingsSaveBtn {
    box-shadow: 0 10px 26px rgba(20, 184, 166, 0.18);
  }

  #callibriSettingsModal.mobile-settings-page #settingsLogoutBtn {
    min-height: 44px;
    background: transparent;
    border: none;
    color: #ff8ea1;
  }

  #callibriSettingsModal.mobile-settings-page #settingsStatus {
    margin-top: 10px;
    text-align: center;
    font-size: 13px;
    color: #a9c0cf;
  }
}

/* ===== КНОПКА «СКАЧАТЬ ПРИЛОЖЕНИЕ» В ПРОФИЛЕ ===== */

.app-download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 10px;
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid rgba(34, 211, 238, 0.25);
  background: rgba(34, 211, 238, 0.08);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.app-download-btn:hover {
  background: rgba(34, 211, 238, 0.16);
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  .app-download-btn {
    display: none;
  }
}

/* ===== ПРОФИЛЬ (как в Telegram) И РАСШИРЕННЫЕ НАСТРОЙКИ ===== */

.profile-modal-shell {
  width: min(380px, calc(100vw - 28px));
  text-align: center;
  position: relative;
  padding-top: 54px;
}

/* Цветной баннер-обложка сверху карточки */
.profile-modal-shell::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 132px;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 25%, rgba(244, 114, 182, 0.55), transparent 46%),
    radial-gradient(circle at 85% 15%, rgba(129, 140, 248, 0.6), transparent 50%),
    radial-gradient(circle at 55% 95%, rgba(34, 211, 238, 0.55), transparent 55%),
    linear-gradient(120deg, #0ea5e9, #8b5cf6 55%, #10b981);
  background-size: 220% 220%;
  animation: profileBannerShift 10s ease-in-out infinite alternate;
  -webkit-mask-image: linear-gradient(180deg, #000 52%, transparent);
  mask-image: linear-gradient(180deg, #000 52%, transparent);
}

@keyframes profileBannerShift {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

.profile-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(26, 56, 84, 0.35);
  backdrop-filter: blur(6px);
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: background 0.2s ease, transform 0.25s ease;
}

.profile-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

.profile-big-avatar {
  position: relative;
  z-index: 1;
  width: 108px;
  height: 108px;
  margin: 0 auto 14px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #38bdf8, #34d399);
  box-shadow:
    0 0 0 4px rgba(30, 64, 94, 0.95),
    0 0 0 7px rgba(34, 211, 238, 0.85),
    0 16px 44px rgba(139, 92, 246, 0.45);
}

.profile-big-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-name {
  position: relative;
  z-index: 1;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.2px;
  background: linear-gradient(90deg, #e0f2fe, #a5f3fc 45%, #bbf7d0);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.profile-status {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px auto 16px;
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.2);
  opacity: 1;
}

.profile-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
}

.profile-status.online {
  color: #34d399;
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.38);
  opacity: 1;
}

.profile-status.online::before {
  background: #34d399;
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.95);
  animation: profileDotPulse 1.6s ease-in-out infinite;
}

@keyframes profileDotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.7; }
}

.profile-info-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 12px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.1), rgba(139, 92, 246, 0.1));
  border: 1px solid rgba(125, 211, 252, 0.22);
  text-align: left;
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}

.profile-info-row:hover {
  transform: translateY(-1px);
  border-color: rgba(167, 139, 250, 0.45);
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.16), rgba(139, 92, 246, 0.16));
}

.profile-info-value {
  color: #7dd3fc;
  font-size: 15px;
  font-weight: 700;
}

.profile-info-label {
  font-size: 12px;
  letter-spacing: 0.02em;
  opacity: 0.65;
}

/* Кнопка действия в профиле */
.profile-modal-shell .modal-actions {
  margin-top: 16px;
}

.profile-modal-shell .modal-actions button {
  flex: 1;
  min-height: 46px;
  border-radius: 15px;
  font-size: 15px;
  background: linear-gradient(135deg, #0ea5e9, #8b5cf6 50%, #10b981);
  background-size: 200% 200%;
  background-position: 0% 50%;
  box-shadow: 0 10px 26px rgba(14, 165, 233, 0.35);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-position 0.35s ease;
}

.profile-modal-shell .modal-actions button:hover {
  transform: translateY(-1px);
  background-position: 100% 50%;
  box-shadow: 0 14px 34px rgba(139, 92, 246, 0.45);
}

/* Разделы настроек */
.settings-section {
  margin-top: 12px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(148, 163, 184, 0.09);
  text-align: left;
}

.settings-section-title {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.65;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0;
  font-size: 14px;
}

.settings-row select {
  flex: 0 1 60%;
  max-width: 60%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(26, 60, 88, 0.55);
  color: inherit;
  font-size: 13px;
}

.settings-mini-btn {
  width: 100%;
  margin-top: 6px;
  padding: 9px 12px;
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: 12px;
  background: rgba(34, 211, 238, 0.07);
  color: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.settings-mini-btn:hover {
  background: rgba(34, 211, 238, 0.16);
}

.mic-meter {
  height: 10px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.mic-meter-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22d3ee, #34d399);
  transition: width 0.08s linear;
}

/* Длинные модалки: прокрутка и на ПК, и на телефоне */
.settings-modal-shell,
.profile-modal-shell {
  max-height: 88dvh;
  overflow-y: auto;
}

/* Подсказка в настройках приватности */
.settings-hint {
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.55;
}

/* Зеленый статус «в сети» */
.status-online {
  color: #34d399;
}

/* Долгое нажатие на телефоне: без выделения текста и системного меню */
@media (max-width: 768px) {
  .message {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
}

/* ===== КРАСИВЫЙ РЕЖИМ ВЫБОРА СООБЩЕНИЙ ===== */

.callibri-selection-toolbar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(4, 18, 32, 0.92);
  border: 1px solid rgba(34, 211, 238, 0.25);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  animation: selectionBarIn 0.22s ease;
}

@keyframes selectionBarIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.callibri-selected-count {
  padding: 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: #7dd3fc;
  white-space: nowrap;
}

.callibri-selection-toolbar button {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.15s ease;
}

.callibri-selection-toolbar button:hover {
  background: rgba(255, 255, 255, 0.13);
  transform: translateY(-1px);
}

.callibri-selection-toolbar button.primary {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.85), rgba(16, 185, 129, 0.85));
  border-color: transparent;
  color: #fff;
  font-weight: 700;
}

.callibri-selection-toolbar button.danger {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
  color: #f87171;
}

.callibri-selection-toolbar button.danger:hover {
  background: rgba(248, 113, 113, 0.22);
}

/* Сообщения в режиме выбора */
.message.callibri-selection-mode {
  cursor: pointer;
}

.message.callibri-selection-mode:hover {
  filter: brightness(1.1);
}

.message.callibri-selected {
  position: relative;
  outline: 2px solid rgba(34, 211, 238, 0.75);
  outline-offset: 2px;
}

.message.callibri-selected::after {
  content: "\2713";
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

@media (max-width: 768px) {
  .callibri-selection-toolbar {
    bottom: 10px;
    width: calc(100vw - 20px);
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
    border-radius: 18px;
  }

  .callibri-selection-toolbar button {
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* ===== ХВОСТИКИ И АНИМАЦИЯ ПУЗЫРЕЙ ===== */

.message {
  position: relative;
}

.message:not(.mine) {
  border-bottom-left-radius: 4px;
}

.message:not(.mine)::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: -6px;
  width: 12px;
  height: 12px;
  z-index: -1;
  background: rgba(15, 42, 61, 0.95);
  clip-path: path("M12 0 C10.5 6.5, 6.5 10.5, 0 12 L12 12 Z");
  pointer-events: none;
}

.message.mine {
  border-bottom-right-radius: 4px;
}

.message.mine::before {
  content: "";
  position: absolute;
  bottom: 0;
  right: -6px;
  width: 12px;
  height: 12px;
  z-index: -1;
  background: rgba(16, 185, 129, 0.95);
  clip-path: path("M0 0 C1.5 6.5, 5.5 10.5, 12 12 L0 12 Z");
  pointer-events: none;
}

/* Анимация появления — только у действительно нового сообщения,
   чтобы при перерисовке чата пузыри не дёргались повторно */
#messages .message.msg-appear {
  animation: msgIn 0.22s ease;
}

/* Часики у сообщения, которое ещё отправляется */
.message-status.pending {
  font-size: 11px;
  opacity: 0.85;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ===== ВРЕМЯ В СПИСКЕ ЧАТОВ ===== */

.user-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.user-top-row b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-time {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  opacity: 0.85;
  white-space: nowrap;
}

/* ===== ОБОИ ЧАТА ===== */

#messages.wp-classic {
  background:
    radial-gradient(rgba(148, 163, 184, 0.13) 1px, transparent 1.4px),
    radial-gradient(circle at 20% 12%, rgba(34, 211, 238, 0.055), transparent 30%),
    radial-gradient(circle at 80% 90%, rgba(16, 185, 129, 0.055), transparent 34%);
  background-size: 22px 22px, auto, auto;
}

#messages.wp-gradient {
  background:
    linear-gradient(160deg, rgba(14, 165, 233, 0.14), transparent 35%),
    linear-gradient(340deg, rgba(16, 185, 129, 0.12), transparent 40%),
    radial-gradient(circle at 50% 120%, rgba(34, 211, 238, 0.1), transparent 55%);
}

#messages.wp-pattern {
  background:
    repeating-linear-gradient(45deg, rgba(148, 163, 184, 0.045) 0 2px, transparent 2px 16px),
    repeating-linear-gradient(-45deg, rgba(34, 211, 238, 0.035) 0 2px, transparent 2px 16px),
    radial-gradient(circle at 80% 90%, rgba(16, 185, 129, 0.05), transparent 34%);
}

#messages.wp-clean {
  background: none;
}

/* ===== СТЕКЛЯННАЯ ШАПКА ЧАТА ===== */

@media (min-width: 769px) {
  .chat {
    position: relative;
  }
}

.chat-header {
  background: rgba(3, 14, 26, 0.58);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(34, 211, 238, 0.14);
}

@media (min-width: 769px) {
  .chat-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
  }

  #messages {
    padding-top: 104px;
  }
}

/* ===== ЭКРАН ЗАГРУЗКИ ===== */

#callibriSplash {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background:
    radial-gradient(circle at 30% 20%, rgba(14, 165, 233, 0.16), transparent 45%),
    radial-gradient(circle at 75% 80%, rgba(16, 185, 129, 0.14), transparent 45%),
    #10304c;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

#callibriSplash.splash-hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-logo {
  width: 84px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 28px;
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  color: #fff;
  font-size: 42px;
  font-weight: 950;
  box-shadow: 0 20px 60px rgba(14, 165, 233, 0.35);
  animation: splashPulse 1.6s ease infinite;
}

@keyframes splashPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

.splash-name {
  font-size: 22px;
  font-weight: 900;
  color: #e2f4ff;
  letter-spacing: 0.5px;
}

.splash-dots {
  display: flex;
  gap: 6px;
}

.splash-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22d3ee;
  animation: splashDot 1s ease infinite;
}

.splash-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.splash-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes splashDot {
  0%, 100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-4px);
  }
}


/* ===== НОВЫЕ ГОЛОСОВЫЕ, РЕАКЦИИ, ПОИСК, АВАТАРКИ ГРУПП ===== */
.cb-voice { display: flex; align-items: center; gap: 10px; min-width: 220px; max-width: 320px; padding: 4px 2px; cursor: pointer; }
.cb-voice-play { width: 38px; height: 38px; min-width: 38px; border-radius: 50%; border: none; background: linear-gradient(135deg, #0ea5e9, #10b981); color: #fff; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28); transition: transform 0.15s ease; }
.cb-voice-play:hover { transform: scale(1.07); }
.cb-voice-wave { display: flex; align-items: center; gap: 2px; height: 30px; flex: 1; }
.cb-voice-wave i { display: block; width: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.45); transition: background 0.2s ease; }
.message:not(.mine) .cb-voice-wave i { background: rgba(125, 211, 252, 0.35); }
.cb-voice-wave i.played { background: #ffffff; }
.message:not(.mine) .cb-voice-wave i.played { background: #22d3ee; }
.cb-voice-dur { font-size: 11px; opacity: 0.8; white-space: nowrap; }
.cb-voice.playing .cb-voice-play { box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.25); }

.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.msg-reaction { border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(26, 60, 88, 0.3); color: inherit; border-radius: 999px; padding: 2px 9px; font-size: 13px; cursor: pointer; line-height: 1.5; transition: transform 0.12s ease, background 0.12s ease; }
.msg-reaction:hover { transform: scale(1.08); }
.msg-reaction b { font-size: 11px; font-weight: 800; }
.msg-reaction.mine-reaction { background: rgba(34, 211, 238, 0.25); border-color: rgba(34, 211, 238, 0.6); }
.reaction-row { display: flex; justify-content: space-between; gap: 0; padding: 4px 2px 8px; border-bottom: 1px solid rgba(148, 226, 213, 0.18); margin-bottom: 6px; }
.reaction-row .reaction-pick { flex: 1 1 0; min-width: 0; border: none; background: transparent; font-size: 19px; padding: 6px 0; cursor: pointer; border-radius: 12px; line-height: 1; text-align: center; transition: transform 0.14s ease, background 0.14s ease; }
.reaction-row .reaction-pick:hover { transform: scale(1.3) translateY(-2px); background: rgba(45, 212, 191, 0.16); }

.chat-search-btn { margin-left: auto; width: 38px; height: 38px; min-width: 38px; border-radius: 50%; border: none; background: rgba(255, 255, 255, 0.07); color: inherit; font-size: 16px; cursor: pointer; transition: background 0.15s ease; }
.chat-search-btn:hover { background: rgba(255, 255, 255, 0.16); }
.chat-search-bar { position: absolute; left: auto; right: 12px; top: calc(100% + 8px); width: min(440px, calc(100% - 24px)); z-index: 45; display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 16px; border-radius: 999px; background: linear-gradient(135deg, rgba(7, 32, 50, 0.97), rgba(3, 16, 28, 0.95)); border: 1px solid rgba(45, 212, 191, 0.26); box-shadow: 0 18px 42px rgba(0, 0, 0, 0.5); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); animation: searchDrop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.1); }
.chat-search-bar::before { content: "🔍"; font-size: 13px; opacity: 0.65; }
.chat-search-bar:focus-within { border-color: rgba(45, 212, 191, 0.55); box-shadow: 0 18px 42px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(45, 212, 191, 0.14); }
.chat-search-bar.hidden { display: none; }
.chat-search-bar input { flex: 1; min-width: 0; background: transparent; border: none; outline: none; color: inherit; font-size: 14px; }
.chat-search-bar input::placeholder { color: rgba(148, 163, 184, 0.55); }
#chatSearchCount { font-size: 12px; color: #5eead4; background: rgba(45, 212, 191, 0.12); border: 1px solid rgba(45, 212, 191, 0.3); padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
#chatSearchCount:empty { display: none; }
#chatSearchClose { width: 28px; height: 28px; min-width: 28px; border: none; border-radius: 50%; background: rgba(255, 255, 255, 0.08); color: inherit; opacity: 0.85; cursor: pointer; font-size: 12px; line-height: 1; transition: background 0.15s ease, transform 0.18s ease, opacity 0.15s ease; }
#chatSearchClose:hover { opacity: 1; background: rgba(45, 212, 191, 0.22); transform: rotate(90deg); }
.message.search-hidden { display: none; }
#messages .message.search-match { box-shadow: 0 0 0 1.5px rgba(45, 212, 191, 0.4); }
@keyframes searchDrop { from { opacity: 0; transform: translateY(-10px) scale(0.97); } to { opacity: 1; transform: none; } }

.group-avatar { overflow: hidden; }
.group-avatar img { width: 100%; height: 100%; object-fit: cover; }
#chatAvatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

@media (max-width: 768px) {
  .chat-header { position: relative; }
  .chat-search-bar { left: 8px; right: 8px; width: auto; border-radius: 20px; }
}


/* ===== ДИЗАЙН КАК В TELEGRAM: РЕЙЛ, СПИСОК ЧАТОВ, КАНАЛЫ ===== */
.profile { display: none !important; }
.sidebar-title { display: none !important; }
#groups { display: none !important; }
#createGroupBtn { display: none !important; }

@media (min-width: 769px) {
  #app { grid-template-columns: 76px 330px minmax(0, 1fr); }
}

#appRail { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px; border-radius: var(--radius-xl); background: rgba(4, 18, 32, 0.55); border: 1px solid rgba(148, 163, 184, 0.12); }
.rail-logo { width: 36px; height: 36px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 900; color: #fff; background: linear-gradient(135deg, #0ea5e9, #10b981); margin-bottom: 10px; }
.rail-btn { width: 60px; padding: 8px 2px; border: none; background: transparent; color: #8ea3b8; border-radius: 12px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; transition: background 0.15s ease, color 0.15s ease; }
.rail-btn span { font-size: 19px; line-height: 1.2; }
.rail-btn small { font-size: 10px; }
.rail-btn:hover { background: rgba(255, 255, 255, 0.06); color: #cbd5e1; }
.rail-btn.active { background: rgba(34, 211, 238, 0.14); color: #e2e8f0; }
.rail-spacer { flex: 1; }

.sidebar-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; padding: 2px; position: relative; }
.sidebar-heading { font-size: 20px; font-weight: 800; }
#newChatBtn { width: 34px; height: 34px; min-width: 34px; flex: 0 0 34px; box-sizing: border-box; padding: 0 0 2px; margin: 0; display: inline-flex; align-items: center; justify-content: center; text-align: center; border-radius: 50%; border: none; color: #fff; font-size: 20px; line-height: 1; font-weight: 600; cursor: pointer; background: linear-gradient(135deg, #0ea5e9, #10b981); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3); transition: transform 0.15s ease; }
#newChatBtn:hover { transform: scale(1.08); }
/* Liquid Glass — жидкое стекло */
.new-chat-menu {
  position: absolute;
  top: 42px;
  right: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  min-width: 190px;
  padding: 6px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(10, 25, 35, 0.65), rgba(5, 15, 25, 0.85));
  backdrop-filter: blur(25px) saturate(160%);
  -webkit-backdrop-filter: blur(25px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.1), 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: menuGlassIn 0.18s ease-out;
}

@keyframes menuGlassIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.new-chat-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: #e2e8f0;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: background 0.15s ease;
}

.new-chat-menu button:hover {
  background: rgba(255, 255, 255, 0.09);
}

#messages > .empty { height: 100%; margin: 0; width: 100%; max-width: none; background: transparent; border: none; border-radius: 0; padding: 0; font-size: 14px; }
body:not(.chat-open) #messages {
  background:
    repeating-linear-gradient(45deg, rgba(148, 163, 184, 0.05) 0 2px, transparent 2px 18px),
    repeating-linear-gradient(-45deg, rgba(34, 211, 238, 0.04) 0 2px, transparent 2px 18px),
    radial-gradient(circle at 78% 86%, rgba(16, 185, 129, 0.06), transparent 40%),
    radial-gradient(circle at 18% 12%, rgba(34, 211, 238, 0.05), transparent 36%);
}

@media (max-width: 768px) {
  /* Нижняя панель как в Telegram iOS: плотное жидкое стекло */
  #appRail {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    top: auto;
    z-index: 40;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    border-radius: 0;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
    background: rgba(20, 20, 20, 0.4);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: none;
  }

  /* Три вкладки: Контакты, Чаты, Настройки */
  #appRail .rail-btn[data-rail="contacts"] { order: 1; }
  #appRail .rail-btn[data-rail="all"] { order: 2; }
  #railSettingsBtn { order: 3; }
  #appRail .rail-btn[data-rail="groups"],
  #appRail .rail-btn[data-rail="channels"],
  #railSlider { display: none !important; }

  #appRail .rail-btn {
    position: relative;
    flex-direction: row;
    align-items: center;
    gap: 7px;
    min-width: 0;
    padding: 9px 16px;
    border-radius: 20px;
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    transition: background 0.25s ease, color 0.25s ease;
  }

  #appRail .rail-btn span { font-size: 20px; line-height: 1; }
  #appRail .rail-btn small { font-size: 13px; font-weight: 600; }

  /* Овальная подложка активной вкладки */
  #appRail .rail-btn.active {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
  }

  /* Красный круглый индикатор непрочитанных на вкладке "Чаты" */
  .rail-badge {
    position: absolute;
    top: 2px;
    right: 8px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #ff3b30;
    color: #fff;
    font-size: 10.5px;
    font-weight: 800;
    font-style: normal;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.45);
  }

  .rail-badge.hidden { display: none; }
  .rail-logo { display: none; }
  .rail-spacer { display: none; }
  .rail-btn { width: auto; min-width: 52px; padding: 6px 4px; }
  body.chat-open #appRail { display: none; }
  .sidebar { padding-bottom: 84px; }
}

/* Когда чат не выбран — прячем шапку и поле ввода */
body:not(.chat-open) .chat > header,
body:not(.chat-open) .chat-input {
  display: none;
}

/* Контекстное меню списка чатов */
.callibri-sidebar-context-menu { position: fixed; z-index: 120; min-width: 230px; display: flex; flex-direction: column; padding: 7px; border-radius: 20px; background: linear-gradient(160deg, rgba(45, 212, 191, 0.16) 0%, rgba(10, 34, 50, 0.55) 34%, rgba(3, 14, 26, 0.66) 100%); border: 1px solid rgba(148, 226, 213, 0.3); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.22), inset 0 -1px 0 rgba(255, 255, 255, 0.05); backdrop-filter: blur(26px) saturate(160%); -webkit-backdrop-filter: blur(26px) saturate(160%); animation: ctxPop 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2); transform-origin: top left; }
.callibri-sidebar-context-menu button { display: flex; align-items: center; gap: 10px; border: none; background: transparent; color: #e8f6f3; padding: 9px 10px; border-radius: 13px; cursor: pointer; font-size: 14px; text-align: left; transition: background 0.14s ease, padding-left 0.14s ease; }
.callibri-sidebar-context-menu button:hover { background: linear-gradient(90deg, rgba(45, 212, 191, 0.22), rgba(45, 212, 191, 0.06)); padding-left: 14px; }
.callibri-sidebar-context-menu button.danger-item { color: #f87171; }
.callibri-sidebar-context-menu button.danger-item:hover { background: rgba(248, 113, 113, 0.12); }
.callibri-sidebar-context-separator { height: 1px; margin: 4px 8px; background: rgba(148, 163, 184, 0.18); }


/* ===== НОВЫЙ ЛОГОТИП CALLIBRI (v=callibri-20) ===== */

.splash-logo {
  background: none;
  border-radius: 19px;
  box-shadow: 0 20px 60px rgba(45, 212, 191, 0.35);
  object-fit: contain;
  font-size: 0;
}

img.rail-logo {
  background: none;
  border-radius: 8px;
  object-fit: contain;
}

.auth-logo {
  display: block;
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  border-radius: 17px;
  box-shadow: 0 12px 32px rgba(45, 212, 191, 0.3);
}

/* ===== LIQUID GLASS — всё приложение (v=callibri-26) ===== */
/* Боковая панель со списком чатов */
.sidebar {
  background: linear-gradient(165deg, rgba(45, 212, 191, 0.07) 0%, rgba(9, 30, 46, 0.62) 30%, rgba(3, 14, 26, 0.66) 100%);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

/* Шапка чата */
.chat-header {
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.08), rgba(6, 22, 36, 0.55));
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border-bottom: 1px solid rgba(148, 226, 213, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

/* Поле ввода сообщения */
.chat-input {
  background: linear-gradient(0deg, rgba(45, 212, 191, 0.06), rgba(4, 16, 28, 0.55));
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border-top: 1px solid rgba(148, 226, 213, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Левый рейл (на телефоне — нижняя панель вкладок) */
#appRail {
  background: linear-gradient(165deg, rgba(45, 212, 191, 0.10) 0%, rgba(8, 28, 44, 0.60) 40%, rgba(3, 14, 26, 0.70) 100%);
  border: 1px solid rgba(148, 226, 213, 0.20);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

/* Модальные карточки (настройки, профиль, группы) */
.callibri-settings-card,
.modal-card {
  background: linear-gradient(160deg, rgba(45, 212, 191, 0.14) 0%, rgba(10, 34, 50, 0.60) 34%, rgba(3, 14, 26, 0.72) 100%) !important;
  border: 1px solid rgba(148, 226, 213, 0.28) !important;
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.20), inset 0 -1px 0 rgba(255, 255, 255, 0.05) !important;
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
}

/* Экран входа */
.auth-card {
  background: linear-gradient(160deg, rgba(45, 212, 191, 0.13) 0%, rgba(10, 34, 50, 0.58) 34%, rgba(3, 14, 26, 0.70) 100%);
  border: 1px solid rgba(148, 226, 213, 0.26);
  backdrop-filter: blur(26px) saturate(160%);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

/* Пузыри сообщений: лёгкий стеклянный блик без размытия (бережём производительность) */
#messages .message {
  border-color: rgba(148, 226, 213, 0.14);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.09);
}
#messages .message.mine {
  border-color: rgba(148, 226, 213, 0.24);
}

/* Панели редактирования, записи голосового и выделения */
.edit-panel,
.recording-panel,
.callibri-selection-toolbar {
  background: linear-gradient(160deg, rgba(45, 212, 191, 0.12), rgba(6, 22, 36, 0.68));
  border: 1px solid rgba(148, 226, 213, 0.24);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

/* Кнопки рейла и элементы списка — стеклянный отклик */
.rail-btn:hover { background: rgba(45, 212, 191, 0.12); }
.rail-btn.active { background: linear-gradient(135deg, rgba(45, 212, 191, 0.22), rgba(14, 165, 233, 0.14)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14); }
.recent-chat-item:hover { background: rgba(45, 212, 191, 0.08); }
.recent-chat-item.active { background: linear-gradient(135deg, rgba(45, 212, 191, 0.16), rgba(14, 165, 233, 0.10)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10); }

/* На телефоне боковая панель во весь экран — без рамок по краям */
@media (max-width: 768px) {
  .sidebar { border: none; box-shadow: none; }
  #appRail { border-left: none; border-right: none; border-bottom: none; box-shadow: none; }
}

/* ===== НАСТРОЙКИ НА ПК В СТИЛЕ TELEGRAM (мобильные не трогаем) ===== */
@media (min-width: 769px) {
  #callibriSettingsModal .settings-modal-shell {
    width: min(94vw, 424px) !important;
    padding: 34px 0 16px !important;
    border-radius: 20px !important;
    background: linear-gradient(180deg, rgba(23, 52, 78, 0.99), rgba(18, 58, 70, 0.99)) !important;
    position: relative;
  }

  /* Цветная обложка сверху, как у профиля */
  #callibriSettingsModal .settings-modal-shell::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 148px;
    z-index: 0;
    pointer-events: none;
    background:
      radial-gradient(circle at 18% 30%, rgba(244, 114, 182, 0.45), transparent 48%),
      radial-gradient(circle at 82% 15%, rgba(129, 140, 248, 0.55), transparent 50%),
      radial-gradient(circle at 55% 95%, rgba(34, 211, 238, 0.5), transparent 55%),
      linear-gradient(120deg, #0ea5e9, #8b5cf6 55%, #10b981);
    background-size: 220% 220%;
    animation: profileBannerShift 10s ease-in-out infinite alternate;
    -webkit-mask-image: linear-gradient(180deg, #000 52%, transparent);
    mask-image: linear-gradient(180deg, #000 52%, transparent);
  }

  #callibriSettingsModal .settings-avatar {
    position: relative;
    z-index: 1;
    margin: 0 auto 10px;
    border: none;
    box-shadow:
      0 0 0 4px rgba(20, 45, 70, 0.95),
      0 0 0 7px rgba(34, 211, 238, 0.85),
      0 14px 38px rgba(139, 92, 246, 0.4);
  }

  #callibriSettingsModal .settings-me {
    position: relative;
    z-index: 1;
    margin-bottom: 14px;
  }

  #callibriSettingsModal .settings-me b {
    font-size: 20px;
    font-weight: 900;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  }

  #callibriSettingsModal .settings-me span {
    color: rgba(226, 232, 240, 0.85);
  }

  /* Секции — плоские панели, как в Telegram */
  #callibriSettingsModal .settings-section {
    margin: 12px 16px 0;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
  }

  #callibriSettingsModal .settings-section-title {
    margin-bottom: 10px;
    color: #5cb9f8;
    opacity: 1;
    font-size: 12px;
    letter-spacing: 0.08em;
  }

  /* Поля ввода */
  #callibriSettingsModal .settings-section input[type="text"] {
    margin-bottom: 10px;
    padding: 11px 13px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.05);
    transition: border-color 0.15s ease, background 0.15s ease;
  }

  #callibriSettingsModal .settings-section input[type="text"]:focus {
    border-color: #3390ec;
    background: rgba(51, 144, 236, 0.08);
  }

  /* Строки с выпадающими списками */
  #callibriSettingsModal .settings-row {
    margin: 6px 0;
    padding: 6px 8px;
    border-radius: 10px;
    transition: background 0.15s ease;
  }

  #callibriSettingsModal .settings-row:hover {
    background: rgba(255, 255, 255, 0.05);
  }

  #callibriSettingsModal .settings-row select {
    padding: 8px 12px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    cursor: pointer;
  }

  /* Чекбоксы -> переключатели, как в Telegram */
  #callibriSettingsModal .remember-row {
    margin: 2px 0 8px;
    padding: 10px 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    transition: background 0.15s ease;
  }

  #callibriSettingsModal .remember-row:hover {
    background: rgba(255, 255, 255, 0.05);
  }

  #callibriSettingsModal .remember-row input {
    appearance: none;
    -webkit-appearance: none;
    width: 40px;
    height: 22px;
    flex: 0 0 40px;
    min-width: 40px;
    margin: 0;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.35);
    position: relative;
    cursor: pointer;
    transition: background 0.2s ease;
  }

  #callibriSettingsModal .remember-row input::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s ease;
  }

  #callibriSettingsModal .remember-row input:checked {
    background: #3390ec;
  }

  #callibriSettingsModal .remember-row input:checked::after {
    transform: translateX(18px);
  }

  /* Кнопка проверки микрофона — текстовая, как в Telegram */
  #callibriSettingsModal .settings-mini-btn {
    border: none;
    background: transparent;
    color: #5cb9f8;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 12.5px;
  }

  #callibriSettingsModal .settings-mini-btn:hover {
    background: rgba(51, 144, 236, 0.12);
  }

  #callibriSettingsModal .settings-hint {
    padding: 0 10px;
  }

  /* Кнопка скачивания и действия */
  #callibriSettingsModal .app-download-btn {
    width: calc(100% - 32px);
    margin: 14px 16px 0;
  }

  #callibriSettingsModal .modal-actions {
    margin: 14px 16px 0;
  }

  #callibriSettingsModal #settingsSaveBtn {
    background: linear-gradient(135deg, #2b9df4, #4fc3f7);
    box-shadow: 0 10px 24px rgba(51, 144, 236, 0.35);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
  }

  #callibriSettingsModal #settingsSaveBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(51, 144, 236, 0.45);
  }

  #callibriSettingsModal #settingsStatus {
    margin: 8px 16px 0;
  }

  /* Тонкий скроллбар */
  #callibriSettingsModal .settings-modal-shell::-webkit-scrollbar {
    width: 6px;
  }

  #callibriSettingsModal .settings-modal-shell::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 999px;
  }
}

/* ===== ЗВОНКИ ===== */
.chat-call-btn {
  margin-left: auto;
  width: 38px;
  height: 38px;
  min-width: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.chat-call-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 22px rgba(16, 185, 129, 0.45);
}

#chatCallBtn:not(.hidden) + #chatSearchBtn {
  margin-left: 8px;
}

#callibriCallUI {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 16, 30, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: modalFade 0.15s ease;
}

.call-card {
  width: min(92vw, 340px);
  padding: 34px 24px 26px;
  border-radius: 26px;
  text-align: center;
  background:
    radial-gradient(circle at 20% 0%, rgba(34, 211, 238, 0.16), transparent 40%),
    radial-gradient(circle at 85% 10%, rgba(139, 92, 246, 0.16), transparent 45%),
    linear-gradient(180deg, rgba(23, 62, 102, 0.98), rgba(16, 84, 96, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.55);
  animation: settingsPop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}

.call-avatar {
  width: 96px;
  height: 96px;
  margin: 0 auto 14px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #38bdf8, #34d399);
  box-shadow: 0 0 0 4px rgba(5, 22, 38, 0.9), 0 0 0 7px rgba(34, 211, 238, 0.7);
  animation: callPulse 1.8s ease-in-out infinite;
}

.call-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@keyframes callPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(5, 22, 38, 0.9), 0 0 0 7px rgba(34, 211, 238, 0.7); }
  50% { box-shadow: 0 0 0 4px rgba(5, 22, 38, 0.9), 0 0 0 13px rgba(34, 211, 238, 0.16); }
}

.call-name {
  font-size: 20px;
  font-weight: 900;
  color: #fff;
}

.call-sub {
  min-height: 18px;
  margin: 4px 0 22px;
  font-size: 13.5px;
  color: rgba(226, 232, 240, 0.75);
}

.call-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
}

.call-btn {
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.call-btn:hover {
  transform: translateY(-2px) scale(1.05);
}

.call-btn.accept {
  background: linear-gradient(135deg, #22c55e, #10b981);
  box-shadow: 0 12px 28px rgba(34, 197, 94, 0.45);
}

.call-btn.hangup {
  background: linear-gradient(135deg, #f43f5e, #dc2626);
  box-shadow: 0 12px 28px rgba(244, 63, 94, 0.45);
}

.call-btn.hangup > * {
  display: inline-block;
}

.call-btn.hangup {
  transform: rotate(135deg);
}

.call-btn.hangup:hover {
  transform: rotate(135deg) translateY(-2px) scale(1.05);
}

.call-btn.mute {
  width: 50px;
  height: 50px;
  font-size: 18px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.call-btn.mute.muted {
  background: rgba(244, 63, 94, 0.25);
  border-color: rgba(244, 63, 94, 0.5);
  opacity: 0.9;
}

@media (max-width: 768px) {
  .chat-call-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
  }
}

/* ===== ВИДЕОСООБЩЕНИЯ (кружочки) ===== */
.message-media-videonote {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}

.cb-videonote {
  position: relative;
  width: 216px;
  height: 216px;
  cursor: pointer;
  user-select: none;
}

.cb-videonote video {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #0b2133;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.cb-vn-ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
  pointer-events: none;
}

.cb-vn-ring-bg,
.cb-vn-ring-fg {
  fill: none;
  stroke-width: 3;
}

.cb-vn-ring-bg {
  stroke: rgba(255, 255, 255, 0.18);
}

.cb-vn-ring-fg {
  stroke: #34d399;
  stroke-linecap: round;
  stroke-dasharray: 298.45;
  stroke-dashoffset: 298.45;
  transition: stroke-dashoffset 0.25s linear;
}

.cb-vn-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: #fff;
  background: rgba(4, 16, 30, 0.35);
  border-radius: 50%;
  transition: opacity 0.18s ease;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.cb-videonote.playing .cb-vn-badge {
  opacity: 0;
}

.cb-vn-dur {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: #fff;
  background: rgba(4, 16, 30, 0.6);
  pointer-events: none;
}

@media (max-width: 768px) {
  .cb-videonote {
    width: 180px;
    height: 180px;
  }
}

/* Оверлей записи кружочка */
#videoNoteRecUI {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(4, 16, 30, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: modalFade 0.15s ease;
}

.vn-rec-circle {
  width: min(72vw, 300px);
  height: min(72vw, 300px);
  border-radius: 50%;
  overflow: hidden;
  box-shadow:
    0 0 0 4px rgba(5, 22, 38, 0.9),
    0 0 0 7px rgba(52, 211, 153, 0.8),
    0 24px 70px rgba(0, 0, 0, 0.55);
  animation: callPulse 1.8s ease-in-out infinite;
}

.vn-rec-circle video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.vn-rec-timer {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.vn-rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f43f5e;
  animation: profileDotPulse 1.2s ease-in-out infinite;
}

.vn-rec-hint {
  font-size: 12.5px;
  color: rgba(226, 232, 240, 0.65);
}

.vn-rec-actions {
  display: flex;
  align-items: center;
  gap: 26px;
  margin-top: 6px;
}

.vn-rec-btn {
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.vn-rec-btn:hover {
  transform: translateY(-2px) scale(1.05);
}

.vn-rec-btn.cancel {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.vn-rec-btn.send {
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  box-shadow: 0 12px 28px rgba(16, 185, 129, 0.45);
}

/* ===== "печатает..." — блекло-бирюзовый, с плавным появлением ===== */
#chatStatus.status-typing {
  color: rgba(94, 234, 212, 0.78);
  animation: typingFadeIn 0.25s ease;
}

@keyframes typingFadeIn {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: none; }
}

/* ===== Скрытие контейнера на время первичного рендера чата (анти-прыжок скролла) ===== */
#messages.messages-prerender {
  visibility: hidden;
  scroll-behavior: auto !important;
}

/* ===== КНОПКА-СТРЕЛОЧКА "ВНИЗ" ===== */
.chat {
  position: relative;
}

.scroll-down-btn {
  position: absolute;
  right: 18px;
  bottom: 96px;
  z-index: 30;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(45, 212, 191, 0.35);
  border-radius: 50%;
  background: rgba(4, 18, 32, 0.78);
  color: #2dd4bf;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  animation: scrollBtnIn 0.2s ease;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.scroll-down-btn:hover {
  transform: translateY(-2px);
  background: rgba(8, 32, 52, 0.9);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55), 0 0 0 3px rgba(45, 212, 191, 0.14);
}

.scroll-down-btn.hidden {
  display: none;
}

@keyframes scrollBtnIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Индикатор непрочитанного на стрелочке */
.scroll-down-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #2dd4bf;
  border: 2px solid rgba(4, 18, 32, 0.95);
  box-shadow: 0 0 10px rgba(45, 212, 191, 0.9);
  animation: profileDotPulse 1.4s ease-in-out infinite;
}

.scroll-down-dot.hidden {
  display: none;
}

@media (max-width: 768px) {
  .scroll-down-btn {
    right: 12px;
    bottom: 86px;
    width: 40px;
    height: 40px;
  }
}

/* ===== Мобильные тапы: мгновенный отклик списка чатов ===== */
.user,
.recent-chat-item,
.group-item {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(45, 212, 191, 0.12);
}

@media (max-width: 768px) {
  .user:active {
    background: rgba(45, 212, 191, 0.1);
  }
}

/* ===== МОБИЛЬНОЕ РАЗДЕЛЕНИЕ ЭКРАНОВ: сайдбар и чат по 100% ширины, внахлёст ===== */
@media (max-width: 768px) {
  .sidebar {
    width: 100vw;
    max-width: 100vw;
  }

  /* По умолчанию виден только сайдбар; чат ждёт за правым краем экрана */
  .chat {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    display: flex;
    transform: translateX(100%);
    transition: transform 0.25s ease-out;
    z-index: 999;
    will-change: transform;
  }

  /* Выбран чат: плавно выезжает справа налево (обе метки — страховка от рассинхрона) */
  .chat.active,
  body.chat-open .chat {
    transform: translateX(0);
  }

  /* Сайдбар при открытом чате: лёгкий параллакс-уход влево (остаётся в DOM для анимации) */
  .sidebar {
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
  }

  .sidebar.hidden {
    display: block !important;
    transform: translateX(-14%);
    opacity: 0.35;
    pointer-events: none;
  }
}


/* Ползунок вкладок — только на мобильных */
@media (min-width: 769px) {
  #railSlider { display: none; }
  .rail-badge { display: none; }
}

/* =========================
   НАСТРОЙКИ В СТИЛЕ MAX
========================= */
#callibriSettingsModal { background: rgba(0, 0, 0, 0.55); }
#callibriSettingsModal .mx-shell { display: flex; width: min(96vw, 1080px); height: min(88vh, 720px); background: #060607; border: 1px solid rgba(255,255,255,0.07); border-radius: 14px; overflow: hidden; box-shadow: 0 34px 100px rgba(0,0,0,0.6); color: #f2f3f5; }
#callibriSettingsModal .mx-nav { width: 292px; flex: none; display: flex; flex-direction: column; background: #101216; border-right: 1px solid #1d2026; }
#callibriSettingsModal .mx-nav-title { font-size: 17px; font-weight: 700; padding: 16px 18px 10px; color: #f2f3f5; }
#callibriSettingsModal .mx-nav-scroll { flex: 1; overflow-y: auto; padding: 0 8px 14px; display: flex; flex-direction: column; }
#callibriSettingsModal .mx-profile-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer; text-align: left; }
#callibriSettingsModal .mx-profile-row:hover { background: #191d23; }
#callibriSettingsModal .mx-profile-row.active { background: #22262e; }
#callibriSettingsModal .mx-ava { width: 42px; height: 42px; flex: none; border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; color: #fff; background: linear-gradient(135deg, #2a7ef2, #22d3ee); }
#callibriSettingsModal .mx-ava img { width: 100%; height: 100%; object-fit: cover; }
#callibriSettingsModal .mx-ptxt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#callibriSettingsModal .mx-ptxt b { font-size: 14px; font-weight: 600; color: #f2f3f5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#callibriSettingsModal .mx-ptxt small { font-size: 12px; color: #8b909a; }
#callibriSettingsModal .mx-chev { margin-left: auto; width: 7px; height: 7px; flex: none; border-right: 1.6px solid #5d636c; border-top: 1.6px solid #5d636c; transform: rotate(45deg); }
#callibriSettingsModal .mx-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; color: #e6e8eb; font-size: 13.5px; cursor: pointer; text-align: left; position: relative; }
#callibriSettingsModal .mx-row:hover { background: #191d23; }
#callibriSettingsModal .mx-row.active { background: #22262e; }
#callibriSettingsModal .mx-ic { color: #9aa1ab; flex: none; }
#callibriSettingsModal .mx-invite { color: #8b7cf6; }
#callibriSettingsModal .mx-invite .mx-ic { color: #8b7cf6; }
#callibriSettingsModal .mx-r-security, #callibriSettingsModal .mx-r-appearance, #callibriSettingsModal .mx-r-business, #callibriSettingsModal .mx-r-help { margin-top: 13px; }
#callibriSettingsModal .mx-r-security::before, #callibriSettingsModal .mx-r-appearance::before, #callibriSettingsModal .mx-r-business::before, #callibriSettingsModal .mx-r-help::before { content: ""; position: absolute; top: -7px; left: -8px; right: -8px; height: 1px; background: #1d2026; }
#callibriSettingsModal .mx-body { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #060607; }
#callibriSettingsModal .mx-head { position: relative; height: 52px; flex: none; display: flex; align-items: center; justify-content: center; border-bottom: 1px solid rgba(255,255,255,0.04); }
#callibriSettingsModal .mx-head-title { font-size: 15px; font-weight: 600; color: #f2f3f5; }
#callibriSettingsModal .mx-back { display: none; position: absolute; left: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: #4ea1ff; font-size: 30px; line-height: 1; padding: 4px 12px; cursor: pointer; }
#callibriSettingsModal .mx-close { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: #8b909a; font-size: 15px; padding: 6px; cursor: pointer; }
#callibriSettingsModal .mx-close:hover { color: #f2f3f5; }
#callibriSettingsModal .mx-panes { flex: 1; overflow-y: auto; }
#callibriSettingsModal .mx-pane { display: none; }
#callibriSettingsModal .mx-pane.active { display: block; }
#callibriSettingsModal .mx-pane-inner { max-width: 480px; margin: 26px auto 0; padding: 0 20px 44px; }
#callibriSettingsModal .mx-bigava { position: relative; display: flex; align-items: center; justify-content: center; width: 96px; height: 96px; margin: 4px auto 22px; border: 0; border-radius: 50%; font-size: 36px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #2a7ef2, #22d3ee); cursor: pointer; }
#callibriSettingsModal .mx-bigava img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
#callibriSettingsModal .mx-cam { position: absolute; right: -2px; bottom: -2px; width: 30px; height: 30px; border-radius: 50%; background: #2a7ef2; border: 3px solid #060607; color: #fff; display: flex; align-items: center; justify-content: center; }
#callibriSettingsModal .mx-field { position: relative; display: block; margin: 12px 0; }
#callibriSettingsModal .mx-field input, #callibriSettingsModal .mx-field textarea { width: 100%; box-sizing: border-box; background: #1d2127; border: 0; border-radius: 12px; padding: 14px 46px 14px 14px; color: #eef0f3; font-size: 14px; font-family: inherit; }
#callibriSettingsModal .mx-field textarea { min-height: 110px; resize: vertical; padding-right: 14px; }
#callibriSettingsModal .mx-field input::placeholder, #callibriSettingsModal .mx-field textarea::placeholder { color: #7f858e; }
#callibriSettingsModal .mx-field input:focus, #callibriSettingsModal .mx-field textarea:focus { outline: 1px solid rgba(42, 126, 242, 0.6); }
#callibriSettingsModal .mx-count { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 11px; color: #7f858e; pointer-events: none; }
#callibriSettingsModal .mx-logout-row { display: flex; gap: 10px; margin-top: 14px; }
#callibriSettingsModal .mx-logout { flex: 1; height: 48px; border: 0; border-radius: 12px; background: #262a31; color: #eef0f3; font-size: 14px; font-weight: 600; cursor: pointer; }
#callibriSettingsModal .mx-logout:hover, #callibriSettingsModal .mx-more:hover { background: #2d323a; }
#callibriSettingsModal .mx-more { width: 48px; height: 48px; flex: none; border: 0; border-radius: 12px; background: #262a31; color: #eef0f3; font-size: 20px; cursor: pointer; }
#callibriSettingsModal .mx-status { min-height: 16px; margin-top: 10px; text-align: center; font-size: 12px; color: #8b909a; }
#callibriSettingsModal .mx-card { background: #15181d; border-radius: 14px; overflow: hidden; }
#callibriSettingsModal .mx-card > * + * { border-top: 1px solid #1f232a; }
#callibriSettingsModal .mx-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; font-size: 14px; color: #eef0f3; }
#callibriSettingsModal a.mx-link-row { text-decoration: none; color: #4ea1ff; }
#callibriSettingsModal .mx-select-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; font-size: 14px; color: #eef0f3; }
#callibriSettingsModal .mx-select-row select { max-width: 55%; background: #262a31; color: #eef0f3; border: 0; border-radius: 8px; padding: 7px 10px; font-size: 13px; }
#callibriSettingsModal input.mx-switch { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; flex: none; margin: 0; padding: 0; border: 0; border-radius: 14px; background: #3a3f47; position: relative; cursor: pointer; transition: background 0.2s ease; }
#callibriSettingsModal input.mx-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.2s ease; }
#callibriSettingsModal input.mx-switch:checked { background: #2a7ef2; }
#callibriSettingsModal input.mx-switch:checked::after { transform: translateX(18px); }
#callibriSettingsModal .mx-mini-btn { margin-top: 12px; padding: 10px 14px; border: 0; border-radius: 10px; background: #1d2127; color: #eef0f3; font-size: 13px; cursor: pointer; }
#callibriSettingsModal .mx-hint { margin: 10px 4px 0; font-size: 12px; color: #7f858e; }
#callibriSettingsModal .mx-stub { text-align: center; padding: 56px 16px; color: #8b909a; font-size: 13.5px; }
#callibriSettingsModal .mx-stub .mx-ic { width: 44px; height: 44px; color: #5d636c; }
#callibriSettingsModal .mx-stub b { display: block; margin: 12px 0 6px; font-size: 16px; color: #eef0f3; }
#callibriSettingsModal .mx-stub a { color: #4ea1ff; }
#callibriSettingsModal .mx-about-logo { width: 72px; height: 72px; border-radius: 18px; }
#callibriSettingsModal .mx-kbd { background: #262a31; border-radius: 6px; padding: 2px 8px; font-size: 12px; color: #cfd3d9; }
#callibriSettingsModal .mx-check { color: #2a7ef2; font-size: 16px; }
#callibriSettingsModal .mx-soon { font-size: 12px; color: #7f858e; }
#callibriSettingsModal .mx-dim > span:first-child { color: #8b909a; }
#mxToast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(8px); background: rgba(24, 26, 31, 0.96); color: #fff; font-size: 13px; padding: 10px 16px; border-radius: 12px; z-index: 100001; opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease; }
#mxToast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Мобильные настройки: список как на iOS --- */
@media (max-width: 768px) {
  body.settings-open-mobile #appRail { visibility: visible; pointer-events: auto; }
  body.settings-open-mobile.mx-sub-open #appRail { visibility: hidden; pointer-events: none; }
  #callibriSettingsModal.mobile-settings-page { background: #050506; }
  #callibriSettingsModal.mobile-settings-page .mx-shell { flex-direction: column; width: 100vw; height: auto; min-height: 100dvh; border: 0; border-radius: 0; box-shadow: none; background: #050506; }
  #callibriSettingsModal.mobile-settings-page .mx-body { display: none; }
  #callibriSettingsModal.mobile-settings-page.mx-sub .mx-nav { display: none; }
  #callibriSettingsModal.mobile-settings-page.mx-sub .mx-body { display: flex; min-height: 100dvh; }
  #callibriSettingsModal.mobile-settings-page .mx-nav { width: 100%; border: 0; background: transparent; }
  #callibriSettingsModal.mobile-settings-page .mx-nav-title { font-size: 34px; font-weight: 800; padding: calc(18px + env(safe-area-inset-top)) 16px 6px; }
  #callibriSettingsModal.mobile-settings-page .mx-nav-scroll { padding: 0 0 calc(92px + env(safe-area-inset-bottom)); overflow: visible; display: flex; flex-direction: column; }
  #callibriSettingsModal.mobile-settings-page .mx-profile-row { padding: 12px 16px; border-radius: 0; order: 0; }
  #callibriSettingsModal.mobile-settings-page .mx-ava { width: 62px; height: 62px; font-size: 24px; }
  #callibriSettingsModal.mobile-settings-page .mx-ptxt { gap: 3px; margin-left: 6px; }
  #callibriSettingsModal.mobile-settings-page .mx-ptxt b { font-size: 21px; font-weight: 700; }
  #callibriSettingsModal.mobile-settings-page .mx-ptxt small { font-size: 15px; color: #8e8e93; }
  #callibriSettingsModal.mobile-settings-page .mx-row { padding: 14px 16px; border-radius: 0; font-size: 17px; gap: 16px; }
  #callibriSettingsModal.mobile-settings-page .mx-row:hover { background: transparent; }
  #callibriSettingsModal.mobile-settings-page .mx-row:active { background: #1c1c1e; }
  #callibriSettingsModal.mobile-settings-page .mx-ic { width: 25px; height: 25px; color: #d7dade; }
  #callibriSettingsModal.mobile-settings-page .mx-invite .mx-ic { color: #8b7cf6; }
  #callibriSettingsModal.mobile-settings-page .mx-row::after { content: ""; position: absolute; left: 57px; right: 0; top: 0; height: 1px; background: rgba(84, 84, 88, 0.32); }
  #callibriSettingsModal.mobile-settings-page .mx-r-security::before, #callibriSettingsModal.mobile-settings-page .mx-r-appearance::before, #callibriSettingsModal.mobile-settings-page .mx-r-business::before, #callibriSettingsModal.mobile-settings-page .mx-r-help::before { display: none; }
  #callibriSettingsModal.mobile-settings-page .mx-r-security, #callibriSettingsModal.mobile-settings-page .mx-r-appearance { margin-top: 0; }
  #callibriSettingsModal.mobile-settings-page .mx-r-data, #callibriSettingsModal.mobile-settings-page .mx-r-hotkeys, #callibriSettingsModal.mobile-settings-page .mx-r-about { display: none; }
  #callibriSettingsModal.mobile-settings-page .mx-invite { order: 1; }
  #callibriSettingsModal.mobile-settings-page .mx-invite::after { left: 0; }
  #callibriSettingsModal.mobile-settings-page .mx-r-folders { order: 2; margin-top: 22px; }
  #callibriSettingsModal.mobile-settings-page .mx-r-folders::after { display: none; }
  #callibriSettingsModal.mobile-settings-page .mx-r-security { order: 3; }
  #callibriSettingsModal.mobile-settings-page .mx-r-devices { order: 4; }
  #callibriSettingsModal.mobile-settings-page .mx-r-notify { order: 5; }
  #callibriSettingsModal.mobile-settings-page .mx-r-appearance { order: 6; }
  #callibriSettingsModal.mobile-settings-page .mx-r-language { order: 7; }
  #callibriSettingsModal.mobile-settings-page .mx-r-business { order: 8; margin-top: 22px; }
  #callibriSettingsModal.mobile-settings-page .mx-r-business::after { display: none; }
  #callibriSettingsModal.mobile-settings-page .mx-r-help { order: 9; margin-top: 22px; }
  #callibriSettingsModal.mobile-settings-page .mx-r-help::after { display: none; }
  #callibriSettingsModal.mobile-settings-page .mx-head { position: sticky; top: 0; z-index: 5; height: auto; min-height: 50px; padding: calc(6px + env(safe-area-inset-top)) 0 6px; background: rgba(5, 5, 6, 0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
  #callibriSettingsModal.mobile-settings-page .mx-head-title { font-size: 17px; }
  #callibriSettingsModal.mobile-settings-page .mx-back { display: block; }
  #callibriSettingsModal.mobile-settings-page .mx-close { display: none; }
  #callibriSettingsModal.mobile-settings-page .mx-panes { overflow: visible; }
  #callibriSettingsModal.mobile-settings-page .mx-pane-inner { margin-top: 14px; padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  #callibriSettingsModal.mobile-settings-page .mx-bigava { width: 108px; height: 108px; font-size: 40px; }
  #callibriSettingsModal.mobile-settings-page .mx-cam { border-color: #050506; }
  #callibriSettingsModal.mobile-settings-page .mx-field input, #callibriSettingsModal.mobile-settings-page .mx-field textarea { background: #1c1f26; font-size: 16px; padding: 14px 46px 14px 14px; border-radius: 12px; width: 100%; margin: 0; }
  #callibriSettingsModal.mobile-settings-page .mx-field textarea { padding-right: 14px; }
  #callibriSettingsModal.mobile-settings-page input.mx-switch { width: 50px; height: 30px; border-radius: 15px; padding: 0; }
  #callibriSettingsModal.mobile-settings-page input.mx-switch::after { width: 26px; height: 26px; }
  #callibriSettingsModal.mobile-settings-page input.mx-switch:checked::after { transform: translateX(20px); }
  #callibriSettingsModal.mobile-settings-page .mx-select-row select { width: auto; margin: 0; padding: 7px 10px; }
  #callibriSettingsModal.mobile-settings-page .mx-logout { height: 50px; font-size: 16px; }
  #mxToast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
