/* ==================== SKYMAX MESSENGER — чёрное матовое стекло ==================== */
/* Монохром: фон #030304, панели — стекло rgba(10,10,12,.6) + blur, акцент — белый */

:root {
  --ms-bg: #030304;
  --ms-panel: rgba(10, 10, 12, .62);
  --ms-panel2: rgba(255, 255, 255, .045);
  --ms-line: rgba(255, 255, 255, .08);
  --ms-line2: rgba(255, 255, 255, .14);
  --ms-fg: #f2f2f4;
  --ms-dim: #a6a8af;
  --ms-dim2: #6b6d73;
  --ms-edge: linear-gradient(160deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, .03) 40%, rgba(255, 255, 255, .07));
  --ms-blur: blur(22px) saturate(130%);
  --ms-bad: #ff6b6b;
}

#mx-app {
  font: 14px/1.45 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ms-fg);
}
#mx-app button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
#mx-app img { -webkit-user-drag: none; }

/* ---------- иконки (маски, цвет = currentColor) ---------- */
.ic { display: inline-block; width: 17px; height: 17px; flex: none;
  background: currentColor; opacity: .92;
  -webkit-mask: var(--ic) center / contain no-repeat;
  mask: var(--ic) center / contain no-repeat; }
.ic-search { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E"); }
.ic-plus { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Cline x1='12' y1='5' x2='12' y2='19'/%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3C/svg%3E"); }
.ic-back { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='19' y1='12' x2='5' y2='12'/%3E%3Cpolyline points='12 19 5 12 12 5'/%3E%3C/svg%3E"); }
.ic-msg { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z'/%3E%3C/svg%3E"); }
.ic-users { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M23 21v-2a4 4 0 0 0-3-3.87'/%3E%3Cpath d='M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E"); }
.ic-user { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E"); }
.ic-gear { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z'/%3E%3C/svg%3E"); }
.ic-grid { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='7' height='7' rx='1.5'/%3E%3Crect x='14' y='3' width='7' height='7' rx='1.5'/%3E%3Crect x='3' y='14' width='7' height='7' rx='1.5'/%3E%3Crect x='14' y='14' width='7' height='7' rx='1.5'/%3E%3C/svg%3E"); }
.ic-more { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Ccircle cx='12' cy='5' r='2'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3Ccircle cx='12' cy='19' r='2'/%3E%3C/svg%3E"); }
.ic-x { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E"); }
.ic-reply { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 14 4 9 9 4'/%3E%3Cpath d='M20 20v-7a4 4 0 0 0-4-4H4'/%3E%3C/svg%3E"); }
.ic-clip { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48'/%3E%3C/svg%3E"); }
.ic-smile { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M8 14s1.5 2 4 2 4-2 4-2'/%3E%3Cline x1='9' y1='9' x2='9.01' y2='9'/%3E%3Cline x1='15' y1='9' x2='15.01' y2='9'/%3E%3C/svg%3E"); }
.ic-mic { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z'/%3E%3Cpath d='M19 10v2a7 7 0 0 1-14 0v-2'/%3E%3Cline x1='12' y1='19' x2='12' y2='23'/%3E%3C/svg%3E"); }
.ic-send { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='22' y1='2' x2='11' y2='13'/%3E%3Cpolygon points='22 2 15 22 11 13 2 9 22 2'/%3E%3C/svg%3E"); }
.ic-play { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black' stroke='none'%3E%3Cpolygon points='6 3 20 12 6 21'/%3E%3C/svg%3E"); }
.ic-pause { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'%3E%3Cline x1='9' y1='5' x2='9' y2='19'/%3E%3Cline x1='15' y1='5' x2='15' y2='19'/%3E%3C/svg%3E"); }
.ic-stop { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black' stroke='none'%3E%3Crect x='6' y='6' width='12' height='12' rx='1.5'/%3E%3C/svg%3E"); }
.ic-file { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z'/%3E%3Cpolyline points='13 2 13 9 20 9'/%3E%3C/svg%3E"); }
.ic-check { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E"); }
.ic-copy { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='13' height='13' rx='2'/%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'/%3E%3C/svg%3E"); }
.ic-trash { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 6 5 6 21 6'/%3E%3Cpath d='M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/%3E%3C/svg%3E"); }
.ic-bell { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9'/%3E%3Cpath d='M13.73 21a2 2 0 0 1-3.46 0'/%3E%3C/svg%3E"); }
.ic-info { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='16' x2='12' y2='12'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E"); }
.ic-phone { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z'/%3E%3C/svg%3E"); }
.ic-image { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpolyline points='21 15 16 10 5 21'/%3E%3C/svg%3E"); }
.ic-globe { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='2' y1='12' x2='22' y2='12'/%3E%3Cpath d='M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z'/%3E%3C/svg%3E"); }

/* сегментированный переключатель (режим прокси) */
.ms-seg { display: inline-flex; margin-top: 6px;
  border: 1px solid var(--ms-line); border-radius: 12px; overflow: hidden; }
.ms-seg button { padding: 9px 15px; font-size: 13px; color: var(--ms-dim);
  transition: background .12s, color .12s; }
.ms-seg button + button { border-left: 1px solid var(--ms-line); }
.ms-seg button:hover { color: #fff; }
.ms-seg button.on { background: rgba(255, 255, 255, .13); color: #fff; }
#ms-px-add { width: 100%; margin-top: 8px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--ms-line); background: rgba(255, 255, 255, .05);
  color: var(--ms-fg); font: inherit; resize: vertical; outline: none; }
#ms-px-add:focus { border-color: var(--ms-line2); }
#ms-px-add::placeholder { color: var(--ms-dim2); }
#ms-px-list code { font: 12.5px/1.5 Consolas, "Cascadia Mono", monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==================== каркас ==================== */
#ms-app { display: flex; height: 100%; }

/* ---------- рейл ---------- */
#ms-rail {
  width: 68px; flex: none; display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 14px 0; z-index: 30;
  border-right: 1px solid var(--ms-line);
  background: rgba(5, 5, 7, .72);
  -webkit-backdrop-filter: var(--ms-blur); backdrop-filter: var(--ms-blur);
}
.ms-logo {
  width: 38px; height: 38px; border-radius: 12px; margin-bottom: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 19px; color: #060607;
  background: linear-gradient(150deg, #ffffff, #c9c9cf);
  box-shadow: 0 4px 18px rgba(255, 255, 255, .14);
}
.ms-rail-group { position: relative; }
.ms-acc-ava {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff;
  background: linear-gradient(145deg, #3a3b41, #232429);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2), 0 0 0 2px var(--ms-bg);
  transition: box-shadow .15s;
}
#ms-acc-btn { padding: 2px; border-radius: 50%; }
#ms-acc-btn:hover .ms-acc-ava { box-shadow: inset 0 0 0 1px rgba(255,255,255,.3), 0 0 0 2px rgba(255,255,255,.25); }
#ms-acc-pop {
  position: absolute; left: 56px; top: 0; width: 250px; z-index: 60;
  border: 1px solid var(--ms-line2); border-radius: 16px; padding: 6px;
  background: rgba(12, 12, 14, .92);
  -webkit-backdrop-filter: var(--ms-blur); backdrop-filter: var(--ms-blur);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6);
}
.ms-acc-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: 11px; text-align: left;
}
.ms-acc-item:hover { background: rgba(255, 255, 255, .07); }
.ms-acc-item.active { background: rgba(255, 255, 255, .11); }
.ms-acc-item .ms-acc-info { min-width: 0; flex: 1; }
.ms-acc-item b { display: block; font-size: 13px; }
.ms-acc-item small { color: var(--ms-dim2); font-size: 11px; }

.ms-rail-btn {
  width: 44px; height: 44px; border-radius: 14px; position: relative;
  display: flex; align-items: center; justify-content: center;
  color: var(--ms-dim); transition: background .13s, color .13s;
}
.ms-rail-btn:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.ms-rail-btn.active { background: rgba(255, 255, 255, .12); color: #fff; }
.ms-rail-spacer { flex: 1; }

/* ---------- список чатов ---------- */
#ms-list {
  width: 330px; flex: none; display: flex; flex-direction: column; min-height: 0; z-index: 20;
  border-right: 1px solid var(--ms-line);
  background: rgba(7, 7, 9, .6);
  -webkit-backdrop-filter: var(--ms-blur); backdrop-filter: var(--ms-blur);
}
.ms-list-head { display: flex; align-items: center; justify-content: space-between;
  padding: 18px 16px 8px; }
.ms-list-head h1 { font-size: 22px; font-weight: 800; letter-spacing: .2px; }
.ms-icon-btn {
  width: 36px; height: 36px; border-radius: 11px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ms-dim); transition: background .12s, color .12s;
}
.ms-icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.ms-search {
  display: flex; align-items: center; gap: 9px; margin: 6px 14px 10px;
  padding: 9px 13px; border-radius: 999px; color: var(--ms-dim);
  background: rgba(255, 255, 255, .05); border: 1px solid var(--ms-line);
  transition: border-color .15s, background .15s;
}
.ms-search:focus-within { border-color: var(--ms-line2); background: rgba(255, 255, 255, .07); }
.ms-search input { flex: 1; background: none; border: none; outline: none;
  color: var(--ms-fg); font: inherit; padding: 0; }
.ms-search input::placeholder { color: var(--ms-dim2); }

/* сторис */
#ms-stories {
  display: flex; gap: 14px; padding: 4px 16px 12px; overflow-x: auto;
  scrollbar-width: none;
}
#ms-stories::-webkit-scrollbar { display: none; }
.ms-story { display: flex; flex-direction: column; align-items: center; gap: 5px;
  width: 62px; flex: none; cursor: pointer; }
.ms-story-ring {
  width: 56px; height: 56px; border-radius: 50%; padding: 2.5px;
  background: conic-gradient(from 210deg, #8f939e, #3d3f47, #8f939e);
  transition: filter .15s;
}
.ms-story:hover .ms-story-ring { filter: brightness(1.35); }
.ms-story-ring .ms-ava { width: 100%; height: 100%; }
.ms-story-ring .ms-ava-wrap { width: 100%; height: 100%; }
.ms-story span { font-size: 11px; color: var(--ms-dim); max-width: 62px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* аватарки */
.ms-ava-wrap { position: relative; display: inline-block; vertical-align: top;
  width: 52px; height: 52px; flex: none; }
.ms-ava {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 19px;
}
.ms-ava-img { position: absolute; inset: 0; width: 100%; height: 100%; }
.ms-ava-xl { width: 116px; height: 116px; }
.ms-ava-xl .ms-ava { font-size: 42px; }

/* элементы чата */
#ms-chats { flex: 1; overflow-y: auto; margin: 0; padding: 2px 8px 14px; list-style: none; }
.ms-chat {
  display: flex; gap: 12px; align-items: center; padding: 9px 10px;
  border-radius: 16px; cursor: pointer;
  border: 1px solid transparent; transition: background .12s, border-color .15s;
}
.ms-chat:hover { background: rgba(255, 255, 255, .05); }
.ms-chat.active { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .12); }
.ms-chat-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ms-chat-row { display: flex; align-items: center; gap: 8px; }
.ms-chat-title { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-chat-time { font-size: 11px; color: var(--ms-dim2); flex: none; }
.ms-chat-last { color: var(--ms-dim); font-size: 13px; flex: 1; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.ms-unread { background: #fff; color: #050506; border-radius: 10px; font-size: 11px;
  font-weight: 700; padding: 1px 7px; min-width: 18px; text-align: center; flex: none; }

/* ==================== основная область ==================== */
#ms-main { flex: 1; display: flex; min-width: 0; position: relative; }
.ms-center { flex: 1; display: flex; flex-direction: column; gap: 12px;
  align-items: center; justify-content: center; color: var(--ms-dim2); }
.ms-center .ic { width: 52px; height: 52px; opacity: .25; }

#ms-chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* шапка чата */
#ms-header {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--ms-line);
  background: rgba(8, 8, 10, .58);
  -webkit-backdrop-filter: var(--ms-blur); backdrop-filter: var(--ms-blur);
}
#ms-header .ms-ava-wrap { width: 44px; height: 44px; }
.ms-header-col { display: flex; flex-direction: column; min-width: 0; flex: 1; }
#ms-header-text { font-weight: 700; font-size: 15px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
#ms-header-sub { color: var(--ms-dim2); font-size: 12px; }
.ms-header-actions { display: flex; gap: 4px; }

/* поиск в чате */
#ms-find-bar {
  display: flex; align-items: center; gap: 9px; padding: 8px 14px;
  border-bottom: 1px solid var(--ms-line); color: var(--ms-dim);
  background: rgba(10, 10, 12, .6);
}
#ms-find-bar input { flex: 1; background: none; border: none; outline: none;
  color: var(--ms-fg); font: inherit; }
#ms-find-count { font-size: 12px; color: var(--ms-dim2); flex: none; }

/* ---------- сообщения ---------- */
#ms-messages { flex: 1; overflow-y: auto; padding: 18px 6%;
  display: flex; flex-direction: column; gap: 2px; }
.ms-empty { margin: auto; text-align: center; color: var(--ms-dim2); line-height: 2.1; }
.ms-day { flex: none; align-self: center; margin: 16px 0 10px; max-width: 86%;
  background: rgba(0, 0, 0, .42); border: 1px solid var(--ms-line);
  border-radius: 999px; padding: 4px 14px; font-size: 12.5px; color: var(--ms-dim); }
.ms-day-start { border-style: dashed; opacity: .8; }

.mx-msg {
  flex: none; /* сообщения никогда не сжимаются в flex-колонке */
  max-width: min(66%, 520px); border-radius: 18px; padding: 8px 12px 6px;
  font-size: 14px; align-self: flex-start; position: relative;
  background: rgba(255, 255, 255, .055);
  border: 1px solid rgba(255, 255, 255, .075);
  -webkit-backdrop-filter: blur(18px) saturate(130%); backdrop-filter: blur(18px) saturate(130%);
  box-shadow: 0 6px 22px rgba(0, 0, 0, .35);
  margin-top: 10px; animation: mxMsgIn .14s ease;
}
@keyframes mxMsgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }
.mx-msg.grouped { margin-top: 3px; }
.mx-msg.mx-out {
  align-self: flex-end;
  background: linear-gradient(180deg, rgba(255, 255, 255, .17), rgba(255, 255, 255, .10));
  border-color: rgba(255, 255, 255, .18);
}
.mx-msg.bare { background: none; border: none; box-shadow: none; padding: 2px;
  -webkit-backdrop-filter: none; backdrop-filter: none; }
.mx-msg.hit { outline: 1.5px solid rgba(255, 255, 255, .55); }
.mx-msg-head { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.mx-msg-ava { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.mx-msg-sender { font-size: 12px; font-weight: 700; color: #cfd3dc; }
.mx-sender-link { cursor: pointer; }
.mx-sender-link:hover .mx-msg-sender { text-decoration: underline; }
.mx-msg-text { white-space: pre-wrap; word-break: break-word; line-height: 1.38; }
.mx-msg-text mark { background: rgba(255, 255, 255, .3); color: #fff; border-radius: 3px; padding: 0 1px; }
.mx-msg-time { font-size: 10px; opacity: .55; text-align: right; margin-top: 3px;
  display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.mx-msg.mx-out .mx-msg-time::after { content: ""; width: 11px; height: 11px;
  background: currentColor; opacity: .8;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat; }

.mx-svc { flex: none; align-self: center; margin: 6px 0; max-width: 86%;
  background: rgba(0, 0, 0, .42); border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 999px; padding: 4px 14px; font-size: 12.5px;
  color: var(--ms-dim); text-align: center; }

/* ответ-цитата */
.mx-reply { display: flex; gap: 8px; align-items: center; margin: 2px 0 6px;
  padding: 4px 8px; border-left: 2px solid rgba(255, 255, 255, .45);
  border-radius: 6px; background: rgba(0, 0, 0, .25); overflow: hidden; }
.mx-reply-text { font-size: 12.5px; color: var(--ms-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 380px; }

/* вложения */
.mx-att-photo { border-radius: 14px; overflow: hidden; margin: 2px 0 4px; }
.mx-att-img { max-width: 100%; max-height: 320px; border-radius: 14px;
  display: block; margin-bottom: 4px; cursor: pointer; }
.mx-att-video { background: #000; }
.mx-att-sticker { max-width: 180px; max-height: 180px; display: block; }
.mx-att-filecard {
  display: flex; align-items: center; gap: 10px; margin: 2px 0 4px;
  padding: 10px 12px; border-radius: 12px; text-decoration: none; color: var(--ms-fg);
  background: rgba(0, 0, 0, .3); border: 1px solid var(--ms-line);
  transition: background .12s;
}
.mx-att-filecard:hover { background: rgba(0, 0, 0, .45); }
.mx-att-fname { font-size: 13px; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.mx-att-filecard em { font-style: normal; color: var(--ms-dim2); font-size: 11.5px; flex: none; }
.mx-att-card { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 4px;
  padding: 9px 12px; border-radius: 12px; background: rgba(0, 0, 0, .3);
  border: 1px solid var(--ms-line); color: var(--ms-fg); text-decoration: none; }
.mx-att-card:hover { background: rgba(0, 0, 0, .45); }
.mx-att-card b { font-size: 13px; }
.mx-att-card span { font-size: 12px; color: var(--ms-dim); }
.mx-att-card em { font-style: normal; font-size: 12px; color: var(--ms-dim2); }
.mx-call-line { display: flex; align-items: center; gap: 7px; font-size: 13px;
  color: var(--ms-dim); margin: 2px 0; }

/* голосовые */
.mx-voice { display: flex; align-items: center; gap: 10px; min-width: 220px;
  padding: 4px 2px; }
.mx-voice-play {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #060607; background: rgba(255, 255, 255, .92);
  transition: transform .12s, background .12s;
}
.mx-voice-play:hover { background: #fff; transform: scale(1.05); }
.mx-voice.playing .mx-voice-play { background: #fff; }
.mx-voice-play .ic { width: 15px; height: 15px; }
.mx-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 30px;
  cursor: pointer; min-width: 110px; }
.mx-wave i { flex: 1; min-width: 2px; max-width: 4px; border-radius: 2px;
  background: rgba(255, 255, 255, .38); height: 30%; transition: background .15s; }
.mx-wave i.on { background: #fff; }
.mx-voice-dur { font-size: 12px; color: var(--ms-dim); flex: none; }

/* ---------- композер ---------- */
#ms-reply {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  border-top: 1px solid var(--ms-line); color: var(--ms-dim);
  background: rgba(8, 8, 10, .58);
}
.ms-reply-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ms-reply-body b { font-size: 12px; color: var(--ms-fg); }
.ms-reply-body span { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#ms-composer {
  display: flex; align-items: flex-end; gap: 6px; padding: 10px 12px;
  border-top: 1px solid var(--ms-line);
  background: rgba(8, 8, 10, .58);
  -webkit-backdrop-filter: var(--ms-blur); backdrop-filter: var(--ms-blur);
}
#ms-text {
  flex: 1; resize: none; max-height: 140px; padding: 10px 14px;
  border-radius: 18px; border: 1px solid var(--ms-line); outline: none;
  background: rgba(255, 255, 255, .055); color: var(--ms-fg); font: inherit;
  transition: border-color .15s, background .15s;
}
#ms-text:focus { border-color: var(--ms-line2); background: rgba(255, 255, 255, .08); }
#ms-text::placeholder { color: var(--ms-dim2); }
.ms-send-btn {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #060607; background: #fff;
  box-shadow: 0 4px 16px rgba(255, 255, 255, .16);
  transition: transform .12s, opacity .12s;
}
.ms-send-btn:hover { transform: scale(1.06); }
.ms-send-btn:disabled { opacity: .5; transform: none; }
#ms-mic.rec { color: #ff5f5f; background: rgba(255, 95, 95, .12); animation: mxRecPulse 1.2s infinite; }
@keyframes mxRecPulse { 50% { box-shadow: 0 0 0 7px rgba(255, 95, 95, .08); } }
#ms-preview { display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border-radius: 14px; background: rgba(255, 255, 255, .06);
  border: 1px solid var(--ms-line); }
#ms-preview img { width: 38px; height: 38px; border-radius: 9px; object-fit: cover; }
.ms-preview-name { font-size: 12.5px; color: var(--ms-dim); max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- панель профиля ---------- */
#ms-profile {
  width: 330px; flex: none; display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--ms-line);
  background: rgba(7, 7, 9, .62);
  -webkit-backdrop-filter: var(--ms-blur); backdrop-filter: var(--ms-blur);
  animation: msSlideIn .16s ease;
}
@keyframes msSlideIn { from { transform: translateX(16px); opacity: 0; } to { opacity: 1; } }
#ms-profile header, #ms-set-nav h1 { display: flex; align-items: center;
  justify-content: space-between; padding: 16px; font-weight: 800; }
#ms-profile-body { flex: 1; overflow-y: auto; padding: 0 18px 20px; }
.ms-profile-loading { color: var(--ms-dim2); text-align: center; padding: 40px 0; }
.ms-profile-hero { display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 8px 0 16px; }
.ms-profile-hero h2 { font-size: 19px; margin-top: 12px; }
.ms-profile-hero small { color: var(--ms-dim2); font-size: 12.5px; }
.ms-actions { display: flex; justify-content: center; gap: 10px; padding: 6px 0 14px; }
.ms-action {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ms-fg); background: rgba(255, 255, 255, .07);
  border: 1px solid var(--ms-line); transition: background .12s, transform .12s;
}
.ms-action:hover { background: rgba(255, 255, 255, .13); transform: translateY(-1px); }
.ms-action.on { color: #060607; background: #fff; }
.ms-card { border-radius: 16px; padding: 14px 16px; margin-bottom: 12px;
  background: rgba(255, 255, 255, .045); border: 1px solid var(--ms-line); }
.ms-card h3 { font-size: 13px; font-weight: 700; color: var(--ms-dim);
  text-transform: uppercase; letter-spacing: .6px; margin-bottom: 10px; }
.ms-row { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 7px 0; font-size: 13.5px; }
.ms-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-note { font-size: 12.5px; line-height: 1.5; }
.ms-dim { color: var(--ms-dim); }
.ms-media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ms-media-grid img { width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 10px; cursor: pointer; transition: opacity .12s; }
.ms-media-grid img:hover { opacity: .85; }

/* ---------- настройки ---------- */
#ms-settings { flex: 1; display: flex; min-width: 0;
  animation: msFadeIn .16s ease; }
@keyframes msFadeIn { from { opacity: 0; } to { opacity: 1; } }
#ms-set-nav {
  width: 250px; flex: none; display: flex; flex-direction: column;
  padding: 14px 10px; border-right: 1px solid var(--ms-line);
  background: rgba(7, 7, 9, .5);
}
.ms-set-link {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border-radius: 13px; color: var(--ms-dim); font-weight: 600; text-align: left;
  transition: background .12s, color .12s;
}
.ms-set-link:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.ms-set-link.active { background: rgba(255, 255, 255, .11); color: #fff; }
#ms-set-body { flex: 1; overflow-y: auto; padding: 26px 30px; max-width: 640px; }
.ms-set-page { animation: msFadeIn .15s ease; }
.ms-set-page h2 { font-size: 20px; margin-bottom: 16px; }
.ms-profile-hero .ms-ava-xl { margin: 0 auto; }
.ms-toggle { display: flex; align-items: center; gap: 12px; padding: 9px 0;
  cursor: pointer; user-select: none; }
.ms-toggle input { display: none; }
.ms-toggle span { width: 40px; height: 23px; border-radius: 999px; flex: none;
  position: relative; background: rgba(255, 255, 255, .12);
  border: 1px solid var(--ms-line); transition: background .15s; }
.ms-toggle span::after { content: ""; position: absolute; top: 2px; left: 2px;
  width: 17px; height: 17px; border-radius: 50%; background: #fff;
  transition: transform .15s; }
.ms-toggle input:checked + span { background: #fff; border-color: #fff; }
.ms-toggle input:checked + span::after { transform: translateX(17px); background: #060607; }
.ms-primary {
  display: inline-flex; align-items: center; gap: 9px; margin-top: 14px;
  padding: 11px 18px; border-radius: 13px; font-weight: 700;
  color: #060607; background: #fff; text-decoration: none;
  transition: transform .12s;
}
.ms-primary:hover { transform: translateY(-1px); }
.ms-danger { display: inline-block; margin-top: 10px; padding: 10px 16px;
  border-radius: 12px; font-weight: 700; color: var(--ms-bad);
  border: 1px solid rgba(255, 107, 107, .35); transition: background .12s; }
.ms-danger:hover { background: rgba(255, 107, 107, .1); }

/* ---------- оверлеи ---------- */
#ms-lightbox {
  position: fixed; inset: 0; z-index: 100; display: flex; cursor: zoom-out;
  align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .88); animation: msFadeIn .14s ease;
}
#ms-lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 12px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .8); }

#ms-menu, #ms-chatmenu {
  position: fixed; z-index: 110; display: flex; flex-direction: column;
  min-width: 190px; padding: 5px; border-radius: 15px;
  background: rgba(14, 14, 16, .95); border: 1px solid var(--ms-line2);
  -webkit-backdrop-filter: var(--ms-blur); backdrop-filter: var(--ms-blur);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .65);
  animation: msPop .12s ease;
}
@keyframes msPop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; } }
#ms-menu button, #ms-chatmenu button {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; font-size: 13.5px; text-align: left;
}
#ms-menu button:hover, #ms-chatmenu button:hover { background: rgba(255, 255, 255, .08); }
#ms-menu button .ic, #ms-chatmenu button .ic { width: 15px; height: 15px; color: var(--ms-dim); }
.ms-danger-item { color: #ff8080 !important; }
.ms-danger-item .ic { color: #ff8080 !important; }

/* ---------- скроллбары ---------- */
#ms-chats::-webkit-scrollbar, #ms-messages::-webkit-scrollbar,
#ms-profile-body::-webkit-scrollbar, #ms-set-body::-webkit-scrollbar { width: 8px; }
#ms-chats::-webkit-scrollbar-thumb, #ms-messages::-webkit-scrollbar-thumb,
#ms-profile-body::-webkit-scrollbar-thumb, #ms-set-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .09); border-radius: 4px; }
#ms-chats::-webkit-scrollbar-thumb:hover, #ms-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, .17); }

/* ---------- адаптив ---------- */
.ms-only-mobile { display: none !important; }
@media (max-width: 1100px) {
  #ms-profile { position: absolute; right: 0; top: 0; bottom: 0; z-index: 40;
    box-shadow: -20px 0 60px rgba(0, 0, 0, .5); }
  #ms-set-nav { width: 200px; }
}
@media (max-width: 860px) {
  #ms-list { position: absolute; left: 68px; top: 0; bottom: 0; z-index: 25;
    box-shadow: 20px 0 50px rgba(0, 0, 0, .45); }
  #ms-app.ms-chat-open #ms-list { display: none; }
  /* экран настроек на телефоне — во всю ширину, список чатов прячем */
  #ms-app:has(#ms-settings:not(.hidden)) #ms-list { display: none; }
  .ms-only-mobile { display: inline-flex !important; }
  #ms-messages { padding: 14px 4%; }
  .mx-msg { max-width: 84%; }
  #ms-set-nav { width: 60px; padding: 14px 8px; }
  #ms-set-nav h1 { display: none; }
  .ms-set-link { justify-content: center; padding: 12px 0; }
  .ms-set-link span { display: none; }
  #ms-set-body { padding: 20px 16px; }
}
@media (max-width: 560px) {
  #ms-rail { width: 56px; }
  #ms-list { left: 56px; width: calc(100vw - 56px); }
  #ms-stories { display: none; }
}

/* ==================== МОБИЛЬНАЯ ДОВОДКА ==================== */
@media (max-width: 560px) {
  /* рейл-кнопки — крупные и тапабельные */
  .ms-rail-btn { width: 46px; height: 46px; }

  /* список чатов во всю ширину, без отступа под рейл */
  #ms-list { left: 56px; width: calc(100vw - 56px); }
  #ms-chats { padding: 2px 6px 14px; }
  #ms-search { font-size: 16px; /* против автозума iOS */ }

  /* сам чат: сообщения шире, шапка компактнее */
  #ms-messages { padding: 12px 10px; }
  .mx-msg { max-width: 86%; }
  #ms-header { padding: 8px 10px; }
  #ms-header .ms-ava-wrap { width: 38px; height: 38px; }

  /* композер — с запасом под жестовую полосу iPhone */
  #ms-composer {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  #ms-text { font-size: 16px; /* против автозума iOS */ }

  /* профиль поверх всего экрана */
  #ms-profile { width: 100vw; }
}

/* экран < 400px — совсем узкий */
@media (max-width: 400px) {
  .mx-msg { max-width: 90%; }
  #ms-rail { width: 52px; }
  #ms-list { left: 52px; width: calc(100vw - 52px); }
}
