.page-messages {
  background: #f7f9fc;
}

.header__actions a.icon-btn.is-on {
  color: var(--blue);
  background: #eaf1ff;
}

.msg-crumb {
  border-bottom: 1px solid #e8eef5;
  background: #fff;
}

.msg-crumb__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 10px var(--page-pad-x);
}

.msg-crumb .breadcrumb {
  margin: 0;
  font-size: var(--crumb-size);
  color: var(--crumb-color);
}

.msg-crumb .breadcrumb a {
  color: var(--crumb-color);
}

.msg-crumb .breadcrumb strong {
  color: var(--crumb-strong);
  font-weight: 600;
}

.msg-main {
  padding: var(--main-pad-top) 0 var(--main-pad-bottom);
}

.msg-main__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--page-pad-x);
  display: grid;
  grid-template-columns: var(--sidebar-left) minmax(280px, 0.92fr) minmax(0, 1.28fr);
  gap: var(--main-gap);
  align-items: start;
}

.msg-nav {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.msg-nav h2 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 800;
  color: var(--navy-deep);
}

.msg-nav__sub {
  margin-top: 18px !important;
}

.msg-nav__list {
  display: grid;
  gap: 2px;
}

.msg-nav__list a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: #4b5563;
}

.msg-nav__list a:hover {
  background: #f5f8fc;
  color: var(--blue);
}

.msg-nav__list a:hover .bn-ico,
.msg-nav__list a.is-on .bn-ico {
  color: var(--blue);
}

.msg-nav__list a.is-on {
  background: #eaf1ff;
  color: var(--blue);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--blue);
}

.msg-list-panel,
.msg-chat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(28, 55, 90, 0.04);
  display: flex;
  flex-direction: column;
  min-height: 680px;
}

.msg-list-panel {
  padding: 18px 14px 14px;
}

.msg-list-panel__head {
  margin-bottom: 14px;
  padding: 0 4px;
}

.msg-list-panel__head h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--navy-deep);
}

.msg-list-panel__head p {
  margin: 0;
  color: #5d6673;
  font-size: 13.5px;
}

.msg-search {
  position: relative;
  margin-bottom: 12px;
}

.msg-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9aa3af;
  pointer-events: none;
}

.msg-search input {
  width: 100%;
  height: 40px;
  border: 1px solid #e4eaf2;
  border-radius: 999px;
  padding: 0 12px 0 36px;
  font-size: 13px;
  outline: none;
  background: #f8fafc;
}

.msg-search input:focus {
  border-color: #9cbcff;
  background: #fff;
}

.msg-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.msg-filters button {
  height: 32px;
  padding: 0 12px;
  border: 1px solid #e4eaf2;
  border-radius: 999px;
  background: #fff;
  color: #4b5563;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.msg-filters button em {
  font-style: normal;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.msg-filters button.is-on {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.msg-filters button.is-on em {
  background: #fff;
  color: #ef4444;
}

.msg-chat__toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.msg-back {
  display: none;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: #f3f5f8;
  color: #334155;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.msg-more-wrap {
  position: relative;
}

.msg-more-menu {
  position: absolute;
  right: 0;
  top: 36px;
  min-width: 120px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(28, 55, 90, 0.12);
  padding: 6px;
  z-index: 5;
}

.msg-more-menu button {
  width: 100%;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  padding: 0 10px;
  cursor: pointer;
  font-size: 13px;
}

.msg-more-menu button:hover {
  background: #f5f8fc;
}

.msg-pending-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.msg-pending {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef1f5;
  font-size: 12px;
  color: #334155;
}

.msg-pending button {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: #6b7480;
}

.content-empty .msg-compose {
  margin-top: 12px;
}

.msg-picker {
  position: fixed;
  inset: 0;
  z-index: 80;
}

.msg-picker__overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
}

.msg-picker__card {
  position: relative;
  width: min(420px, calc(100% - 32px));
  max-height: min(560px, calc(100% - 48px));
  margin: 8vh auto 0;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(28, 55, 90, 0.18);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.msg-picker__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.msg-picker__head h2 {
  margin: 0;
  font-size: 18px;
  color: var(--navy-deep);
}

.msg-picker__head button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
}

.msg-picker__card input {
  height: 40px;
  border: 1px solid #e4eaf2;
  border-radius: 10px;
  padding: 0 12px;
  font: inherit;
  font-size: 13.5px;
}

.msg-picker__list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  max-height: 360px;
}

.msg-picker__item {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.msg-picker__item:hover {
  background: #f5f8fc;
}

.msg-picker__item strong,
.msg-picker__item em {
  display: block;
}

.msg-picker__item em {
  font-style: normal;
  font-size: 12px;
  color: #8b93a0;
}

.msg-threads {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-content: flex-start;
  gap: 2px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.msg-thread {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  flex: 0 0 auto;
  min-height: 64px;
  max-height: 80px;
  padding: 10px;
  margin: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.msg-thread:hover {
  background: #f5f8fc;
}

.msg-thread.is-on {
  background: #eaf1ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.msg-thread.is-hidden {
  display: none;
}

.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(145deg, #9bbcff, #2f6bff);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

.msg-avatar--sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.msg-avatar--2 { background: linear-gradient(145deg, #7dd3c0, #2f9e44); }
.msg-avatar--3 { background: linear-gradient(145deg, #ffb4c8, #d6336c); }
.msg-avatar--4 { background: linear-gradient(145deg, #ffd58a, #d97706); }
.msg-avatar--5 { background: linear-gradient(145deg, #c4b5fd, #6d4aff); }

.msg-thread__body {
  min-width: 0;
  display: grid;
  gap: 2px;
  align-content: center;
}

.msg-thread__body strong {
  font-size: 13.5px;
  color: var(--navy-deep);
}

.msg-thread__body em {
  font-style: normal;
  font-size: 12.5px;
  color: #6b7480;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-thread__meta {
  display: grid;
  justify-items: end;
  gap: 6px;
  align-content: start;
}

.msg-thread__meta time {
  font-size: 11.5px;
  color: #93a0ae;
  white-space: nowrap;
}

.msg-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}

.msg-pagination {
  margin-top: 12px;
  justify-content: center;
}

.msg-chat__toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 12px 14px 0;
}

.msg-compose {
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.msg-compose:hover {
  background: var(--blue-deep);
}

.msg-chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 14px;
  border-bottom: 1px solid #eef1f5;
}

.msg-chat__user {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.msg-chat__name {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.msg-chat__name .js-member-profile {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.msg-chat__name strong {
  font-size: 15px;
  color: var(--navy-deep);
}

.msg-chat .member-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eaf1ff;
  color: var(--blue);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}

.msg-chat__user p {
  margin: 0;
  font-size: 12.5px;
  color: #8b93a0;
}

.msg-more {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #8b93a0;
  font-size: 18px;
  cursor: pointer;
}

.msg-more:hover {
  background: #f3f5f8;
}

.msg-chat__body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: grid;
  gap: 14px;
  align-content: start;
  background: #fafbfd;
}

.msg-date {
  display: flex;
  justify-content: center;
  margin: 4px 0 8px;
}

.msg-date span {
  font-size: 12px;
  color: #8b93a0;
  background: #eef1f5;
  border-radius: 999px;
  padding: 4px 10px;
}

.msg-bubble {
  display: flex;
  gap: 8px;
  max-width: 85%;
}

.msg-bubble--out {
  margin-left: auto;
  justify-content: flex-end;
}

.msg-bubble__meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
  font-size: 12px;
  color: #8b93a0;
}

.msg-bubble__meta strong {
  color: #334155;
  font-size: 12.5px;
}

.msg-bubble__meta--out {
  justify-content: flex-end;
}

.msg-bubble__text {
  display: inline-block;
  padding: 10px 12px;
  border-radius: 14px;
  background: #eef1f5;
  color: #334155;
  font-size: 13.5px;
  line-height: 1.55;
}

.msg-bubble--out .msg-bubble__text {
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-bubble--in .msg-bubble__text {
  border-bottom-left-radius: 4px;
}

.msg-read {
  margin-top: 4px;
  font-size: 11px;
  color: #93a0ae;
  text-align: right;
}

.msg-file {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 28px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid #e4eaf2;
  border-radius: 10px;
  background: #fff;
  max-width: 280px;
}

.msg-file__ico {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #e03131;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.msg-file strong {
  display: block;
  font-size: 12.5px;
  color: #334155;
}

.msg-file em {
  font-style: normal;
  font-size: 11px;
  color: #93a0ae;
}

.msg-file button {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: #6b7480;
}

.msg-composer {
  border-top: 1px solid #eef1f5;
  padding: 12px 14px 14px;
  display: grid;
  gap: 8px;
  background: #fff;
  border-radius: 0 0 14px 14px;
}

.msg-composer__tools {
  display: flex;
  gap: 4px;
}

.msg-composer__tools button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
}

.msg-composer__tools button:hover {
  background: #f3f5f8;
}

.msg-composer textarea {
  width: 100%;
  min-height: 72px;
  border: 1px solid #e4eaf2;
  border-radius: 12px;
  padding: 12px;
  resize: vertical;
  font: inherit;
  font-size: 13.5px;
  outline: none;
}

.msg-composer textarea:focus {
  border-color: #9cbcff;
}

.msg-composer__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.msg-composer__foot span {
  font-size: 12px;
  color: #93a0ae;
}

.msg-composer__foot button {
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
}

.msg-composer__foot button:hover {
  background: var(--blue-deep);
}

@media (max-width: 1199px) {
  .msg-main__inner {
    grid-template-columns: 200px 1fr;
  }

  .msg-chat {
    grid-column: 1 / -1;
  }
}

@media (max-width: 767px) {
  .msg-main__inner {
    grid-template-columns: 1fr;
  }

  .msg-back {
    display: inline-flex;
    align-items: center;
  }

  body:not(.msg-chat-open) .msg-chat {
    display: none;
  }

  body.msg-chat-open .msg-list-panel,
  body.msg-chat-open .msg-nav {
    display: none;
  }

  .msg-list-panel,
  .msg-chat {
    min-height: 520px;
  }
}

@media (max-width: 480px) {
  .msg-main__inner,
  .msg-crumb__inner {
    padding-left: 16px;
    padding-right: 16px;
  }

  .msg-list-panel__head h1 {
    font-size: 22px;
  }
}
