.messages-layout { grid-template-columns: 252px minmax(0, 1fr); }
.messages-page-column { min-width: 0; }
.messages-page-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0 2px 18px; }
.messages-page-heading h1 { margin: 0; font: 800 22px "Segoe UI", Arial, sans-serif; letter-spacing: -.5px; }
.messages-page-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.messages-workspace { min-height: 590px; display: grid; grid-template-columns: minmax(245px, 34%) minmax(0, 1fr); overflow: hidden; }
.chat-list-panel { min-width: 0; padding: 18px 0; border-right: 1px solid var(--line); }
.chat-list-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 16px 13px; }
.chat-list-heading h2 { margin: 0; font: 800 14px "Segoe UI", Arial, sans-serif; }
.chat-list-heading h2 span { margin-left: 5px; color: #999bad; font-size: 10px; font-weight: 500; }
.chat-list-action, .thread-back, .thread-more { width: 30px; height: 30px; border: 0; border-radius: 8px; color: #73768a; background: transparent; cursor: pointer; font-size: 18px; }
.chat-list-action:hover, .thread-back:hover, .thread-more:hover { background: #f5f4fb; }
.chat-search { height: 35px; display: flex; align-items: center; gap: 8px; margin: 0 13px 12px; padding: 0 10px; border: 1px solid #eeeff5; border-radius: 8px; color: #989bad; background: #fafafd; }
.chat-search span { font-size: 17px; }
.chat-search input { width: 100%; min-width: 0; border: 0; outline: 0; color: #33364a; background: transparent; font-size: 10px; }
.chat-search input::placeholder { color: #a1a3b2; }
.chat-filters { display: flex; gap: 7px; padding: 0 13px 10px; border-bottom: 1px solid var(--line); }
.chat-filter { padding: 6px 10px; border: 0; border-radius: 7px; color: #818496; background: transparent; cursor: pointer; font-size: 9px; font-weight: 600; }
.chat-filter.active { color: var(--purple-dark); background: #f1efff; }
.chat-filter span { margin-left: 4px; }
.chat-list { max-height: 475px; overflow-y: auto; }
.chat-list-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 0; border-bottom: 1px solid #f3f3f7; background: #fff; text-align: left; cursor: pointer; }
.chat-list-item:hover { background: #faf9ff; }
.chat-list-item.selected { background: #f5f3ff; box-shadow: inset 3px 0 var(--purple); }
.chat-list-item .avatar { position: relative; width: 39px; height: 39px; font-size: 13px; }
.chat-list-item .presence { width: 9px; height: 9px; }
.chat-item-copy { min-width: 0; flex: 1; display: grid; gap: 5px; }
.chat-item-top, .chat-item-bottom { display: flex; justify-content: space-between; align-items: center; gap: 5px; }
.chat-item-top strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-top time { flex: 0 0 auto; color: #999bad; font-size: 8px; }
.chat-item-bottom > span:first-child { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-bottom .unread-badge { width: 17px; height: 17px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--purple); font-size: 8px; font-weight: 700; }
.chat-empty { padding: 16px; color: var(--muted); font-size: 10px; text-align: center; }
#chat-empty[hidden], #thread-empty[hidden], #thread-content[hidden] { display: none !important; }
.thread-panel { min-width: 0; min-height: 590px; }
.thread-empty { height: 100%; min-height: 590px; display: grid; align-content: center; justify-items: center; padding: 25px; text-align: center; }
.thread-empty-icon { width: 55px; height: 55px; display: grid; place-items: center; margin-bottom: 13px; border-radius: 17px; color: var(--purple); background: #f1efff; font-size: 24px; }
.thread-empty h2 { margin: 0; font: 800 15px "Segoe UI", Arial, sans-serif; }
.thread-empty p { margin: 7px 0 0; color: var(--muted); font-size: 10px; }
.thread-content { height: 100%; min-height: 590px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.thread-header { display: flex; align-items: center; gap: 10px; padding: 14px 17px; border-bottom: 1px solid var(--line); }
.thread-header > .avatar { width: 38px; height: 38px; font-size: 13px; }
.thread-back { display: none; }
.thread-contact { flex: 1; min-width: 0; }
.thread-contact h2 { margin: 0; font-size: 11px; }
.thread-contact p { margin: 4px 0 0; color: var(--muted); font-size: 9px; }
.thread-contact .online-dot { margin-right: 4px; }
.thread-messages { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding: 20px; background: #fcfcfe; }
.thread-date { align-self: center; margin: 0 0 6px; color: #a0a2b1; font-size: 8px; }
.thread-bubble { max-width: min(78%, 390px); padding: 10px 12px; border-radius: 13px; color: #55576b; background: #efeff5; font-size: 10px; line-height: 1.55; overflow-wrap: anywhere; }
.thread-bubble.mine { align-self: flex-end; color: #fff; background: var(--purple); }
.thread-time { margin-top: -6px; color: #a0a2b1; font-size: 8px; }
.thread-time.mine { align-self: flex-end; }
.thread-compose { display: flex; gap: 9px; padding: 12px; border-top: 1px solid var(--line); }
.thread-compose input { min-width: 0; flex: 1; padding: 10px 12px; border: 1px solid #e9e9f1; border-radius: 9px; outline-color: var(--purple); font-size: 10px; }
.messages-footer { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 3px; color: #989bad; font-size: 9px; }

@media (max-width: 1100px) {
    .messages-layout { grid-template-columns: 220px minmax(0, 1fr); }
}

@media (max-width: 720px) {
    .messages-layout { display: flex; flex-direction: column; }
    .messages-layout > .left-column { display: block; width: 100%; }
    .messages-layout > .left-column .sidebar-footer { display: none; }
    .messages-page-column { width: 100%; }
    .messages-page-heading { align-items: flex-start; }
    .messages-page-heading h1 { font-size: 19px; }
    .messages-page-subtitle { max-width: 220px; line-height: 1.45; }
    .messages-workspace { min-height: 540px; grid-template-columns: minmax(0, 1fr); }
    .chat-list-panel { min-height: 540px; border-right: 0; }
    .chat-list { max-height: 430px; }
    .thread-panel { display: none; min-height: 540px; }
    .thread-panel.mobile-open { display: block; }
    .thread-empty, .thread-content { min-height: 540px; }
    .messages-workspace.mobile-thread-open .chat-list-panel { display: none; }
    .messages-workspace.mobile-thread-open .thread-panel { display: block; }
    .thread-back { display: inline-grid; place-items: center; flex: 0 0 auto; }
}

@media (max-width: 410px) {
    .messages-page-heading { align-items: center; }
    .messages-page-heading .primary-button { padding: 8px 10px; font-size: 9px; white-space: nowrap; }
}
