.chat-workspace {
  --message-bg: #edf4f6;
  --message-own: #dcefee;
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  height: clamp(520px, 74dvh, 900px);
  min-width: 0;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
}

.chat-sidebar, .chat-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-sidebar { border-inline-end: 1px solid var(--line); }
.chat-sidebar-head { display: grid; gap: 14px; padding: 20px 17px 13px; }
.chat-sidebar-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.chat-sidebar-title h3 { font-size: 19px; }
.chat-sidebar-title > span { color: var(--pri); display: grid; place-items: center; }
.chat-new-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.chat-new-actions .btn { display: flex; justify-content: center; gap: 6px; align-items: center; min-width: 0; padding-inline: 7px; font-size: 13px; }
.chat-new-actions svg, .chat-search svg { width: 17px; height: 17px; flex-shrink: 0; }
.chat-search {
  display: flex; align-items: center; gap: 7px; padding-inline: 11px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 11px; color: var(--mut);
}
.chat-search:focus-within { border-color: var(--pri); }
.chat-search input { min-width: 0; width: 100%; font-size: 13px; min-height: 40px; padding-inline: 0; border: 0; background: transparent; }
.chat-search input:focus { outline: none; box-shadow: none; }
.chat-filters { display: flex; align-items: center; gap: 6px; }
.chat-filters button, .chat-back, .chat-edit, .person-message-icon {
  border: 0; cursor: pointer; background: transparent; color: var(--mut);
}
.chat-filters button { padding: 5px 12px; border-radius: 999px; min-height: 35px; font-size: 12px; }
.chat-filters button:hover, .chat-filters [aria-pressed="true"] { color: var(--pri); background: #e8f1f4; }
.chat-list { flex: 1; overflow: auto; padding: 3px 8px 10px; }
.chat-list-item {
  display: grid; grid-template-columns: 41px minmax(0, 1fr) auto; align-items: center;
  gap: 9px; width: 100%; min-height: 68px; text-align: start; border: 1px solid transparent;
  background: none; color: var(--ink); padding: 8px; border-radius: 12px; cursor: pointer;
}
.chat-list-item:hover { background: var(--bg); }
.chat-list-item[aria-current] { background: #eaf4f5; border-color: #d3e6e8; }
.chat-list-copy { min-width: 0; display: grid; gap: 3px; }
.chat-list-copy b, .chat-list-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list-copy b { font-size: 13px; }
.chat-list-copy small, .chat-list time { color: var(--mut); font-size: 11px; }
.chat-list-empty { text-align: center; color: var(--mut); padding: 16px; font-size: 13px; }
.chat-avatar, .people-avatar {
  flex: 0 0 auto; display: grid; place-items: center; width: 40px; height: 40px;
  border-radius: 13px; background: color-mix(in srgb, var(--person-color) 13%, white);
  color: var(--person-color); font-size: 14px; font-weight: 800;
}
.chat-avatar svg { width: 20px; height: 20px; }
.chat-welcome {
  flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column;
  gap: 10px; padding: 22px; text-align: center; background: var(--message-bg);
}
.chat-welcome > span {
  width: 64px; height: 64px; display: grid; place-items: center;
  background: var(--card); color: var(--pri); border: 1px solid #d6e5e8; border-radius: 22px;
}
.chat-welcome > span svg { width: 32px; height: 32px; }
.chat-welcome p { color: var(--mut); font-size: 13px; }
.chat-thread-head { display: flex; align-items: center; gap: 11px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.chat-thread-title { flex: 1; min-width: 0; }
.chat-thread-title h3 { font-size: 16px; overflow-wrap: anywhere; }
.chat-thread-title small { display: block; color: var(--mut); margin-top: 2px; }
.chat-thread-title .person-link { font-size: inherit; color: inherit; text-decoration: none; }
.chat-thread-title .person-message-icon { display: none; }
.chat-members { min-height: 38px; padding: 5px 12px; }
.chat-back { display: none; place-items: center; height: 38px; width: 38px; border-radius: 9px; }
.chat-back:hover { background: var(--bg); color: var(--pri); }
.chat-history {
  flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 7px; overflow: auto;
  background: var(--message-bg); padding: 14px 20px 18px; overflow-anchor: none;
}
.chat-date { text-align: center; margin: 8px 0; font-size: 11px; color: #456474; }
.chat-date span { border-radius: 999px; padding: 4px 12px; background: #dfecee; }
.chat-message {
  flex: 0 0 auto; max-width: min(80%, 620px); min-width: 100px;
  padding: 7px 12px 5px; border-radius: 15px; border: 1px solid #dbe7ea; background: #fff;
}
.chat-incoming { align-self: flex-start; border-start-start-radius: 5px; }
.chat-outgoing { align-self: flex-end; border-start-end-radius: 5px; background: var(--message-own); border-color: #c8e5e2; }
.chat-message-sender { color: var(--pri); font-size: 12px; font-weight: 750; margin-bottom: 3px; }
.chat-message-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.8; }
.chat-message footer { display: flex; align-items: center; justify-content: flex-end; gap: 7px; color: #456474; font-size: 10px; }
.chat-edit { padding: 2px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; color: #38615f; }
.chat-edit svg { height: 15px; width: 15px; }
.chat-edit:hover { background: #c6e7e3; color: #165d5a; }
.chat-history-empty { text-align: center; margin: auto; color: var(--mut); font-size: 13px; }
.chat-older { align-self: center; margin-bottom: 4px; }
.chat-compose { display: grid; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--line); }
.chat-compose-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.chat-compose-row textarea { display: block; padding: 8px 11px; min-height: 48px; max-height: 150px; width: 100%; resize: vertical; }
.chat-compose-row textarea:placeholder-shown, .people-picker input:placeholder-shown { direction: rtl; }
.chat-send { display: flex; justify-content: center; align-items: center; gap: 6px; min-height: 48px; }
.chat-send svg { width: 18px; height: 18px; }
.chat-edit-banner { display: flex; align-items: center; gap: 6px; color: var(--pri); font-size: 12px; }
.chat-edit-banner .link-btn { margin-inline-start: auto; }
.chat-compose .collab-error:empty, .people-picker .collab-error:empty { display: none; }
.chat-member-list { display: grid; gap: 8px; padding: 0; margin: 0; list-style: none; }
.chat-member-list li { display: flex; align-items: center; gap: 9px; }
.chat-member-list small { display: block; color: var(--mut); }

.people-picker { position: relative; min-width: 0; }
.people-picker [hidden], .chat-workspace [hidden] { display: none; }
.people-suggestions {
  position: relative; display: flex; flex-direction: column; margin-block: 5px 3px;
  max-height: 220px; overflow: auto; padding: 4px;
  border: 1px solid var(--line); background: var(--card); border-radius: 11px;
  box-shadow: 0 7px 18px #10415d12;
}
.people-suggestions button {
  display: flex; align-items: center; flex: 0 0 auto; gap: 9px; text-align: start;
  width: 100%; min-height: 50px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); padding: 5px 7px; cursor: pointer;
}
.people-suggestions button:hover, .people-suggestions [aria-selected="true"] { background: #eaf4f5; }
.people-suggestions button > span:last-child { min-width: 0; }
.people-avatar { width: 33px; height: 33px; border-radius: 9px; font-size: 12px; }
.people-suggestions small { display: block; color: var(--mut); font-size: 11px; overflow-wrap: anywhere; }
.people-feedback { margin-block: 6px 2px; font-size: 12px; }
.people-selected { display: flex; flex-wrap: wrap; gap: 5px; }
.people-selected:not(:empty) { margin-top: 7px; }
.people-selected button {
  display: flex; align-items: center; gap: 8px; border: 1px solid #cee3e7; border-radius: 999px;
  background: #eaf4f5; color: var(--pri); padding: 3px 8px; min-height: 33px; cursor: pointer; font-size: 12px;
}

.person-ref { display: inline-flex; align-items: center; vertical-align: middle; max-width: 100%; gap: 2px; }
.person-ref .person-link { text-align: start; }
.person-message-icon { padding: 2px; display: inline-grid; place-items: center; border-radius: 7px; width: 26px; height: 26px; color: var(--pri); }
.person-message-icon svg, .person-message-button svg, .chat-edit-banner svg { width: 16px; height: 16px; }
.person-message-button { display: inline-flex; align-items: center; gap: 6px; }
.person-message-icon:hover, .person-message-icon:focus-visible { background: #e1eef0; }
.colleague-profile-head { display: flex; align-items: center; gap: 12px; }
.colleague-profile-head .avatar { color: white; }
.staff-contact { position: relative; min-width: 0; }
.staff-contact > .staff-card { width: 100%; height: 100%; }
.staff-contact > .person-message-icon { position: absolute; inset-inline-end: 10px; top: 9px; background: var(--card); }
.staff-contact .staff-card-top { padding-inline-end: 22px; }

@media (hover: hover) and (pointer: fine) {
  .person-message-icon { opacity: 0; }
  .person-ref:hover .person-message-icon, .person-ref:focus-within .person-message-icon,
  .staff-contact:hover > .person-message-icon, .staff-contact:focus-within > .person-message-icon { opacity: 1; }
}

@media (max-width: 759px) {
  .chat-workspace { grid-template-columns: minmax(0, 1fr); height: max(390px, calc(100dvh - 169px - env(safe-area-inset-bottom, 0px))); border-radius: 15px; }
  .chat-workspace:not(.chat-has-active) .chat-thread, .chat-has-active .chat-sidebar { display: none; }
  .chat-sidebar { border: 0; }
  .chat-sidebar-head { padding: 13px; }
  .chat-thread-head { padding: 8px 10px; gap: 7px; }
  .chat-back { display: grid; flex: 0 0 auto; }
  .chat-history { padding-inline: 10px; }
  .chat-message { max-width: 89%; }
  .chat-compose { padding: 8px; }
  .chat-compose-row textarea { font-size: 16px; resize: none; }
  .chat-send { padding-inline: 10px; }
  .person-message-icon { width: 31px; height: 31px; }
}
