/* ============================================================
   GetLauncher — веб-чаты
   Discord-подобная раскладка поверх общей базы лаунчера
   ============================================================ */

body.page-chats {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.page-chats #main {
  flex: 1 1 auto;
  min-height: 0;
}

body.page-chats .site-header {
  flex: 0 0 auto;
}

.chats-page {
  min-height: 0;
}

/* ------------------------------------------------------------ вход */

.chats-gate {
  height: 100%;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
}

.chats-gate-card {
  width: min(460px, 100%);
  padding: 26px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    radial-gradient(420px 240px at 100% 0%, rgba(87, 211, 100, 0.12), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.014));
  box-shadow: var(--shadow);
}

.chats-gate-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.chats-gate-logo img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
}

.chats-gate-logo b {
  display: block;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.chats-gate-logo span {
  display: block;
  color: var(--dim);
  font-size: 12px;
}

/* ------------------------------------------------------------ каркас */

.chats-app {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 76px 304px minmax(0, 1fr) 264px;
  background: rgba(5, 8, 11, 0.55);
  border-top: 1px solid var(--line);
}

.chats-app.mode-friends,
.chats-app.mode-settings {
  grid-template-columns: 76px minmax(0, 1fr);
}

.chats-app.mode-friends .chats-list,
.chats-app.mode-friends .chats-side,
.chats-app.mode-settings .chats-list,
.chats-app.mode-settings .chats-side {
  display: none;
}

/* ------------------------------------------------------------ рейл */

.chats-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(220px 220px at 50% 0%, rgba(87, 211, 100, 0.08), transparent 70%),
    rgba(8, 12, 16, 0.9);
}

.rail-logo {
  width: 46px;
  height: 46px;
  margin-bottom: 6px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  box-shadow: 0 0 0 4px rgba(87, 211, 100, 0.07);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.rail-logo:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 4px rgba(87, 211, 100, 0.16);
}

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

.rail-btn {
  position: relative;
  width: 46px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.rail-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  border-color: var(--line);
}

.rail-btn.active {
  color: var(--accent-2);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.rail-btn.active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(87, 211, 100, 0.65);
}

.rail-sep {
  width: 30px;
  height: 1px;
  margin: 4px 0;
  background: var(--line);
}

.rail-spacer {
  flex: 1;
}

/* ------------------------------------------------------------ список чатов */

.chats-list {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(11, 16, 22, 0.72);
}

.chats-list-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
}

.chats-list-head b {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.list-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line-strong);
}

.chats-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 14px 10px;
  padding: 0 11px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.26);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.chats-search:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px rgba(87, 211, 100, 0.11);
}

.chats-search svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--dim);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.chats-search input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}

.chats-search input::placeholder {
  color: var(--dim);
}

.chats-search input::-webkit-search-cancel-button {
  filter: invert(0.7);
}

.chats-list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 8px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.list-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 9px 6px;
  color: var(--dim);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.list-section-title span {
  color: var(--muted);
  letter-spacing: 0;
}

.list-empty {
  margin: 2px 6px 10px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 11px;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.55;
}

.chat-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 9px;
  margin-bottom: 2px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.chat-item:hover {
  background: rgba(255, 255, 255, 0.045);
}

.chat-item.active {
  background: linear-gradient(90deg, rgba(87, 211, 100, 0.15), rgba(87, 211, 100, 0.045));
  border-color: var(--accent-line);
}

.chat-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(145deg, #1b2b34, #111820);
  color: var(--accent-2);
  font-size: 15px;
  font-weight: 800;
  overflow: hidden;
  text-transform: uppercase;
}

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

.chat-avatar .letter {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(87, 211, 100, 0.2), rgba(20, 28, 37, 0.9));
}

.chat-avatar img + .letter {
  opacity: 0;
  transition: opacity 0.16s ease;
}

.chat-avatar.broken img {
  display: none;
}

.chat-avatar.broken img + .letter,
.chat-avatar img[src=""] + .letter {
  opacity: 1;
}

.chat-avatar.group {
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(87, 211, 100, 0.3), rgba(24, 38, 30, 0.95));
}

.chat-avatar .online-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border: 2px solid #0d1318;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(87, 211, 100, 0.7);
}

.chat-avatar .group-count {
  position: absolute;
  right: -5px;
  bottom: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border: 2px solid #0d1318;
  border-radius: 7px;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 800;
}

.chat-item-body {
  flex: 1;
  min-width: 0;
}

.chat-item-top {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.chat-item-top b {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 700;
}

.chat-item-top time {
  flex: 0 0 auto;
  color: var(--dim);
  font-size: 10.5px;
}

.chat-item-bottom {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 2px;
}

.chat-item-preview {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dim);
  font-size: 12px;
}

.chat-item.unread .chat-item-preview {
  color: var(--muted);
}

.chat-item.unread .chat-item-top b {
  color: #fff;
}

.unread-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 9px rgba(87, 211, 100, 0.75);
}

.request-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--accent);
  color: #071008;
  font-size: 10px;
  font-weight: 900;
}

/* ------------------------------------------------------------ моя карточка */

.me-card {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: rgba(7, 11, 15, 0.72);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s ease;
}

.me-card:hover {
  background: rgba(255, 255, 255, 0.045);
}

.me-card .chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 13px;
}

.me-card-body {
  flex: 1;
  min-width: 0;
}

.me-card-body b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}

.me-card-body span {
  display: block;
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
}

/* ------------------------------------------------------------ основная зона */

.chat-area {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(700px 380px at 52% -8%, rgba(87, 211, 100, 0.055), transparent 70%),
    rgba(8, 12, 16, 0.5);
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}

.chat-empty-art {
  position: relative;
  width: 118px;
  height: 84px;
  margin-bottom: 22px;
}

.chat-empty-art::before,
.chat-empty-art::after,
.chat-empty-art span {
  content: "";
  position: absolute;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(87, 211, 100, 0.14), rgba(20, 28, 37, 0.65));
}

.chat-empty-art::before {
  left: 0;
  top: 20px;
  width: 68px;
  height: 52px;
  transform: rotate(-7deg);
}

.chat-empty-art::after {
  right: 0;
  top: 6px;
  width: 66px;
  height: 50px;
  transform: rotate(8deg);
}

.chat-empty-art span {
  left: 26px;
  top: 0;
  width: 64px;
  height: 46px;
  border-color: var(--accent-line);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
}

.chat-empty-art span:nth-child(2) {
  left: 39px;
  top: 13px;
  width: 38px;
  height: 5px;
  border: 0;
  border-radius: 4px;
  background: rgba(87, 211, 100, 0.5);
  box-shadow: none;
}

.chat-empty-art span:nth-child(3) {
  left: 39px;
  top: 23px;
  width: 24px;
  height: 4px;
  border: 0;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

.chat-empty h2 {
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.chat-empty p {
  max-width: 360px;
  margin: 0;
  color: var(--dim);
  font-size: 13.5px;
  line-height: 1.6;
}

/* ------------------------------------------------------------ диалог */

.conversation {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.conv-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 64px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 14, 18, 0.72);
  backdrop-filter: blur(12px);
}

.conv-back {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: none;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}

.conv-back:hover {
  color: var(--text);
}

.conv-back svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.conv-head .chat-avatar {
  width: 38px;
  height: 38px;
}

.conv-title {
  flex: 1;
  min-width: 0;
}

.conv-title b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14.5px;
  letter-spacing: -0.01em;
}

.conv-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dim);
  font-size: 11.5px;
}

.conv-title span.online {
  color: var(--accent);
}

.conv-actions {
  display: flex;
  gap: 6px;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 18px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.messages-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 140px;
  gap: 8px;
  color: var(--dim);
  font-size: 13px;
  text-align: center;
}

.messages-empty b {
  color: var(--muted);
  font-size: 15px;
}

.load-older {
  display: block;
  margin: 0 auto 14px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.load-older:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.day-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 12px;
  color: var(--dim);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.day-sep::before,
.day-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.msg {
  position: relative;
  display: flex;
  gap: 11px;
  padding: 3px 8px;
  margin: 0 -8px;
  border-radius: 10px;
  transition: background 0.13s ease;
}

.msg:hover {
  background: rgba(255, 255, 255, 0.028);
}

.msg + .msg.compact {
  margin-top: -2px;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  align-self: flex-start;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: linear-gradient(145deg, #1b2b34, #111820);
}

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

.msg-avatar .letter {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, rgba(87, 211, 100, 0.2), rgba(20, 28, 37, 0.9));
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.msg-avatar.broken img {
  display: none;
}

.msg-avatar.broken .letter {
  display: grid;
}

.msg-avatar:not(.broken) .letter {
  display: none;
}

.msg-avatar.spacer {
  background: transparent;
  border-color: transparent;
}

.msg-body {
  flex: 1;
  min-width: 0;
  padding-top: 1px;
}

.msg.compact .msg-body {
  padding-top: 0;
}

.msg-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-height: 18px;
}

.msg-head b {
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.005em;
}

.msg-tag {
  color: var(--dim);
  font-size: 10.5px;
  font-weight: 600;
}

.msg-time {
  color: var(--dim);
  font-size: 10px;
}

.msg-role {
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(87, 211, 100, 0.12);
  color: var(--accent-2);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.msg-text {
  margin-top: 2px;
  color: #dfe7ee;
  font-size: 13.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.msg.deleted .msg-text {
  color: var(--dim);
  font-style: italic;
}

.msg-reply {
  margin: 4px 0 5px;
  padding: 5px 9px;
  border-left: 2px solid var(--accent-line);
  border-radius: 0 7px 7px 0;
  background: rgba(255, 255, 255, 0.028);
  color: var(--dim);
  font-size: 11.5px;
  line-height: 1.4;
}

.msg-reply b {
  color: var(--muted);
}

.msg-image {
  display: block;
  max-width: min(420px, 100%);
  max-height: 320px;
  margin-top: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  object-fit: cover;
  cursor: zoom-in;
}

.msg-file {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: 100%;
  margin-top: 6px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  font-size: 12.5px;
  text-decoration: none;
}

.msg-file:hover {
  border-color: var(--accent-line);
  background: rgba(87, 211, 100, 0.07);
}

.msg-file svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.msg-file i {
  color: var(--dim);
  font-style: normal;
  font-size: 10.5px;
}

.msg-audio {
  display: block;
  width: min(340px, 100%);
  margin-top: 6px;
  height: 36px;
}

.msg-server {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 10px;
  border: 1px solid var(--accent-line);
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.msg-server:hover {
  background: rgba(87, 211, 100, 0.18);
}

.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.reaction b {
  font-size: 10px;
  font-weight: 800;
}

.reaction.mine {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-2);
}

.reaction:hover {
  border-color: var(--line-strong);
}

.msg-actions {
  position: absolute;
  top: -10px;
  right: 8px;
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #121a22;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity 0.13s ease, transform 0.13s ease;
}

.msg:hover .msg-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.msg-action {
  width: 27px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.msg-action:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.msg-action.danger:hover {
  background: rgba(255, 122, 122, 0.14);
  color: var(--danger);
}

/* ------------------------------------------------------------ поле ввода */

.composer {
  flex: 0 0 auto;
  padding: 8px 16px 12px;
  border-top: 1px solid var(--line);
  background: rgba(9, 14, 18, 0.66);
}

.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
  padding: 6px 10px;
  border-left: 2px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: rgba(87, 211, 100, 0.06);
  color: var(--muted);
  font-size: 11.5px;
}

.reply-bar b {
  color: var(--accent-2);
}

.reply-bar span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-bar button {
  border: 0;
  background: none;
  color: var(--dim);
  font-size: 16px;
  cursor: pointer;
}

.reply-bar button:hover {
  color: var(--danger);
}

.attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 7px;
}

.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 11.5px;
}

.attach-chip img {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  object-fit: cover;
}

.attach-chip span {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-chip button {
  border: 0;
  background: none;
  color: var(--dim);
  font-size: 15px;
  cursor: pointer;
}

.attach-chip button:hover {
  color: var(--danger);
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.composer-row:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px rgba(87, 211, 100, 0.11);
}

.composer-attach {
  flex: 0 0 auto;
  border-color: transparent;
  background: transparent;
}

#msg-input {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  max-height: 150px;
  padding: 6px 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.45;
  resize: none;
  outline: none;
  overflow-y: auto;
}

#msg-input::placeholder {
  color: var(--dim);
}

.send-btn {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #08110a;
  cursor: pointer;
  transition: filter 0.16s ease, transform 0.16s ease;
}

.send-btn:hover {
  filter: brightness(1.06);
}

.send-btn:active {
  transform: scale(0.96);
}

.send-btn:disabled {
  filter: grayscale(0.6) brightness(0.7);
  cursor: default;
}

.send-btn svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.typing-line {
  min-height: 15px;
  margin-top: 5px;
  padding-left: 4px;
  color: var(--dim);
  font-size: 10.5px;
}

/* ------------------------------------------------------------ правая панель */

.chats-side {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px;
  border-left: 1px solid var(--line);
  background: rgba(10, 15, 20, 0.6);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.side-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 10px 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background:
    radial-gradient(240px 120px at 50% 0%, rgba(87, 211, 100, 0.12), transparent 70%),
    rgba(255, 255, 255, 0.025);
  text-align: center;
}

.side-profile .chat-avatar {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  font-size: 26px;
  margin-bottom: 10px;
}

.side-profile .chat-avatar .online-dot {
  width: 15px;
  height: 15px;
  border-width: 3px;
}

.side-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.side-tag {
  color: var(--dim);
  font-size: 11px;
  font-weight: 600;
}

.side-status {
  margin-top: 7px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
}

.side-status.online {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-2);
}

.side-block {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.022);
}

.side-block h4 {
  margin: 0 0 8px;
  color: var(--dim);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.side-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  font-size: 11.5px;
}

.side-line span {
  color: var(--dim);
}

.side-line b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-weight: 600;
  font-family: var(--mono);
  font-size: 10.5px;
}

.side-member {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.side-member:hover {
  background: rgba(255, 255, 255, 0.05);
}

.side-member .chat-avatar {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 10px;
}

.side-member span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.side-member em {
  color: var(--dim);
  font-style: normal;
  font-size: 9.5px;
}

.side-member em.online {
  color: var(--accent);
}

.side-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.side-btn {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.side-btn:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.side-btn.danger {
  border-color: rgba(255, 122, 122, 0.25);
  color: #ffb3b3;
}

.side-btn.danger:hover {
  background: rgba(255, 122, 122, 0.09);
}

/* ------------------------------------------------------------ друзья / настройки */

.chat-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 26px clamp(18px, 4vw, 46px) 40px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.panel-head {
  margin-bottom: 20px;
}

.panel-head .eyebrow {
  margin-bottom: 10px;
}

.panel-head h2 {
  margin: 0 0 6px;
  font-size: clamp(22px, 2.4vw, 30px);
  letter-spacing: -0.03em;
}

.panel-head p {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.friends-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.friends-toolbar input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.friends-toolbar input:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px rgba(87, 211, 100, 0.12);
}

.friends-toolbar input::placeholder {
  color: var(--dim);
}

.friends-toolbar .btn {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 18px;
  white-space: nowrap;
}

.panel-section {
  margin-bottom: 24px;
}

.panel-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  color: var(--dim);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.panel-section h3 span {
  color: var(--muted);
  letter-spacing: 0;
}

.friends-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 9px;
}

.friend-card,
.result-row,
.request-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.friend-card {
  transition: border-color 0.15s ease, background 0.15s ease;
}

.friend-card:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
}

.friend-card .chat-avatar,
.result-row .chat-avatar,
.request-row .chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 13px;
}

.friend-card-body,
.result-body,
.request-body {
  flex: 1;
  min-width: 0;
}

.friend-card-body b,
.result-body b,
.request-body b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}

.friend-card-body span,
.result-body span,
.request-body span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dim);
  font-size: 10.5px;
}

.friend-card-body span.online,
.result-body span.online {
  color: var(--accent);
}

.mini-btn {
  flex: 0 0 auto;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
}

.mini-btn:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.mini-btn.primary {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-2);
}

.mini-btn.danger {
  border-color: rgba(255, 122, 122, 0.25);
  color: #ffb3b3;
}

.mini-btn.danger:hover {
  background: rgba(255, 122, 122, 0.1);
}

.request-actions {
  display: flex;
  gap: 5px;
}

.panel-empty {
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--dim);
  font-size: 12.5px;
  line-height: 1.55;
}

.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 620px;
}

.settings-card {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
}

.settings-card h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.settings-card > p {
  margin: 0 0 12px;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.55;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-row input[type="text"] {
  flex: 1;
  min-width: 180px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}

.settings-row input[type="text"]:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px rgba(87, 211, 100, 0.12);
}

.settings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  font-size: 12.5px;
}

.settings-toggle span {
  color: var(--muted);
}

.switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.16s ease, background 0.16s ease;
}

.switch.on {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.switch.on::after {
  transform: translateX(18px);
  background: var(--accent);
}

.settings-code {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
}

/* ------------------------------------------------------------ модалка */

.chats-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 5, 7, 0.72);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(470px, 100%);
  max-height: min(640px, calc(100vh - 40px));
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    radial-gradient(340px 180px at 100% 0%, rgba(87, 211, 100, 0.1), transparent 70%),
    #111820;
  box-shadow: var(--shadow);
}

.modal-card h3 {
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.modal-card > p {
  margin: 0 0 16px;
  color: var(--dim);
  font-size: 12.5px;
  line-height: 1.55;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.modal-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.modal-field input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  outline: none;
}

.modal-field input:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px rgba(87, 211, 100, 0.12);
}

.modal-list {
  max-height: 260px;
  overflow-y: auto;
  margin: 0 -4px 14px;
  padding: 0 4px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 6px;
  border-radius: 8px;
  cursor: pointer;
}

.check-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.check-row input {
  accent-color: var(--accent);
}

.check-row .chat-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 11px;
}

.check-row span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.modal-actions .btn {
  min-height: 40px;
  padding: 0 16px;
}

/* ------------------------------------------------------------ тосты */

.chats-toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 320px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #131c24;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.18s ease;
}

.toast.ok {
  border-color: var(--accent-line);
  color: var(--accent-2);
}

.toast.error {
  border-color: rgba(255, 122, 122, 0.35);
  color: #ffb3b3;
}

.toast.out {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.compact .msg-head {
  display: none;
}

.reaction-menu {
  position: fixed;
  z-index: 400;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  max-width: 280px;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: #131c24;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
}

.reaction-menu button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 17px;
  cursor: pointer;
}

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

.lightbox-image {
  width: 100%;
  max-height: 70vh;
  border-radius: 12px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.3);
}

/* ------------------------------------------------------------ скроллбары */

.chats-list-scroll::-webkit-scrollbar,
.messages::-webkit-scrollbar,
.chats-side::-webkit-scrollbar,
.chat-panel::-webkit-scrollbar,
.modal-card::-webkit-scrollbar,
.modal-list::-webkit-scrollbar {
  width: 8px;
}

.chats-list-scroll::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb,
.chats-side::-webkit-scrollbar-thumb,
.chat-panel::-webkit-scrollbar-thumb,
.modal-card::-webkit-scrollbar-thumb,
.modal-list::-webkit-scrollbar-thumb {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.13);
}

/* ------------------------------------------------------------ адаптив */

@media (max-width: 1180px) {
  .chats-app {
    grid-template-columns: 72px 286px minmax(0, 1fr);
  }

  .chats-side {
    display: none;
  }

  .chats-side.open {
    display: block;
    position: fixed;
    top: 74px;
    right: 0;
    bottom: 0;
    width: min(300px, 86vw);
    z-index: 40;
    box-shadow: -18px 0 40px rgba(0, 0, 0, 0.48);
  }
}

@media (max-width: 860px) {
  .chats-app,
  .chats-app.mode-friends,
  .chats-app.mode-settings {
    grid-template-columns: 62px minmax(0, 1fr);
  }

  .chats-rail {
    padding: 9px 0;
    gap: 6px;
  }

  .rail-logo {
    width: 40px;
    height: 40px;
  }

  .rail-btn {
    width: 42px;
    height: 40px;
  }

  .rail-btn.active::before {
    left: -10px;
  }

  .chats-list {
    grid-column: 2;
  }

  .chat-area {
    display: none;
  }

  .chats-app.chat-open .chats-list {
    display: none;
  }

  .chats-app.chat-open .chat-area,
  .chats-app.mode-friends .chat-area,
  .chats-app.mode-settings .chat-area {
    display: flex;
    grid-column: 2;
  }

  .chats-app.mode-friends .chats-list,
  .chats-app.mode-settings .chats-list {
    display: none;
  }

  .conv-back {
    display: grid;
  }

  .messages {
    padding: 14px 12px 6px;
  }

  .composer {
    padding: 8px 10px 10px;
  }
}

@media (max-width: 560px) {
  .chats-app,
  .chats-app.mode-friends,
  .chats-app.mode-settings {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .rail-logo {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }

  .rail-btn {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }

  .rail-btn svg {
    width: 20px;
    height: 20px;
  }

  .chats-list-head {
    padding: 12px 12px 9px;
  }

  .chat-panel {
    padding: 20px 14px 32px;
  }

  .friends-toolbar {
    flex-direction: column;
  }

  .friends-grid {
    grid-template-columns: 1fr;
  }

  .msg-actions {
    opacity: 1;
    pointer-events: auto;
    position: static;
    justify-content: flex-end;
    margin-top: 4px;
    border: 0;
    background: transparent;
    box-shadow: none;
    padding: 0;
    transform: none;
  }

  .chats-toasts {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .toast {
    max-width: none;
  }
}
