.button.button-danger { color: var(--danger-ink); }
.profile-delete, .desk-card > .button-danger { margin-top: 10px; }
.desk-user-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.delete-confirm-actions, .chat-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.chat-dialog-actions { flex-direction: column; }

.chat-layout {
  display: grid;
  grid-template-columns: minmax(270px, 360px) minmax(0, 1fr);
  height: clamp(510px, calc(100dvh - 146px), 840px);
  min-height: 0;
  border-radius: 28px;
}
.chat-layout .chat-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: auto;
  overflow: hidden;
  border-right: 1px solid var(--line);
}
.chat-sidebar-head { padding: 20px 20px 12px; }
.chat-sidebar-head h1 { font-size: 22px; letter-spacing: -.025em; margin: 0 0 14px; }
.chat-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding-inline: 12px;
  border-radius: 14px;
  background: var(--soft);
  color: var(--muted);
}
.chat-search svg { width: 17px; height: 17px; flex: none; }
.chat-search input {
  width: 100%;
  min-width: 0;
  padding: 8px 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
}
.chat-filters { display: flex; gap: 6px; padding: 0 20px 10px; overflow-x: auto; }
.chat-filters button, .chat-quick-replies button {
  border: 1px solid var(--line);
  border-radius: 99px;
  min-height: 34px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.chat-filters button[aria-pressed="true"], .chat-deal {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 8px; }
.chat-list-empty { color: var(--muted); font-size: 13px; padding: 12px; }
.chat-list .chat-list-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px 10px;
  border: 0;
  border-radius: 18px;
}
.chat-list-item .avatar { width: 48px; height: 48px; }
.chat-list .chat-list-item[aria-current="true"] { background: var(--accent-soft); }
.chat-list-copy strong, .chat-list-copy p, .chat-list-copy small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chat-list-copy strong { font-size: 14px; }
.chat-list-copy p { color: var(--accent-text); font-size: 12px; font-weight: 700; }
.chat-list-copy small { margin-top: 2px; font-size: 12px; }
.chat-list-meta { display: grid; justify-items: end; gap: 5px; font-size: 11px; color: var(--muted); }
.chat-unread {
  min-width: 20px;
  padding: 2px 5px;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  text-align: center;
  font-weight: 800;
}
.chat-support {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  margin: 6px 20px 16px;
  padding: 9px 12px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  font-size: 12px;
  color: var(--muted);
}
.chat-support strong { color: var(--ink); }
.chat-support[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent-text); }
.chat-support-desk { display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; }
.chat-support-desk .chat-header h2 { flex: 1; min-width: 0; font-size: clamp(13px, 2vw, 17px); }
.chat-support-desk .chat-header > a, .chat-support-desk .chat-header > button { flex: none; }
.chat-support-desk .desk-content { flex: 1; min-height: 0; align-content: start; overflow-y: auto; padding: 12px; }
.chat-support-desk .desk-messages .desk-message { width: fit-content; max-width: 90%; }
.chat-support-desk .desk-messages .desk-mine { background: var(--accent-soft); }
.chat-support-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--surface);
}
.chat-support-icon svg { width: 18px; height: 18px; }

.chat-handoff {
  display: flex;
  flex: none;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  padding: 5px 20px 7px;
}
.chat-handoff-plan { background: var(--surface); border-bottom: 1px solid var(--line); }
.chat-handoff-info { display: flex; flex: 1 1 165px; min-width: 0; gap: 7px; font-size: 12px; }
.chat-handoff-info svg { width: 16px; height: 16px; color: var(--accent-text); }
.chat-handoff-info div { min-width: 0; overflow-wrap: anywhere; }
.chat-handoff-info strong, .chat-handoff-info time, .chat-handoff-info span { display: block; }
.chat-handoff-info :is(time,span) { color: var(--muted); }
.chat-handoff-info span { max-height: 3em; overflow: auto; }
.chat-handoff-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.chat-handoff :is(.button,.text-link) { min-height: 36px; font-size: 12px; }
.chat-handoff .button { padding: 7px 9px; }
.meeting-form-time { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.meeting-form-time .field { min-width: 0; }
.meeting-form-time input { min-width: 0; width: 100%; }
.meeting-timezone { margin-bottom: 10px; color: var(--muted); font-size: 13px; }
.chat-keyboard .chat-handoff { display: none; }
@media (max-width: 700px) {
  .chat-handoff { padding-inline: 12px; }
  .chat-handoff :is(.button,.text-link) { min-height: 40px; }
}

.chat-pane .chat-placeholder { flex: 1; }
.chat-pane .chat-header { gap: 10px; padding: 12px 20px; flex: none; }
.chat-header > .avatar { width: 40px; height: 40px; }
.chat-who strong { font-size: 14px; }
.chat-who small { font-size: 12px; margin: 0; }
.chat-header .chat-deal { flex: none; min-height: 36px; padding: 6px 12px; font-size: 12px; }
.chat-header .chat-more { flex: none; width: 40px; height: 40px; }
.chat-pane .chat-item {
  flex: none;
  min-width: 0;
  margin: 12px 20px 0;
  padding: 8px 12px 8px 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--soft);
}
.chat-pane .chat-item > div { min-width: 0; flex: 1; }
.chat-pane .chat-item h3 { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; }
.chat-pane .chat-item small { display: block; font-size: 11px; color: var(--muted); }
.chat-thumb {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-text);
  overflow: hidden;
}
.chat-pane .chat-thumb img, .chat-thumb .image-fallback { width: 100%; height: 100%; object-fit: cover; }
.chat-item-open { font-size: 12px; font-weight: 800; color: var(--accent-text); }
.chat-pane .messages { gap: 7px; padding: 12px 20px; overscroll-behavior: contain; }
.chat-day, .chat-pane .system-message {
  align-self: center;
  margin: 4px 0;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
}
.chat-pane .message {
  max-width: min(520px, 83%);
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 19px 19px 19px 5px;
  background: var(--bg);
  font-size: 13px;
  line-height: 1.55;
}
.chat-pane .message.mine {
  border-color: transparent;
  border-radius: 19px 19px 5px 19px;
  background: var(--accent);
  color: #fff;
}
.chat-pane .message time { margin-top: 0; font-size: 10px; }
.chat-pane .message.mine time { color: inherit; opacity: .85; }
.chat-pane .message.mine .message-attachment { color: var(--ink); }

.chat-pane .message:has(.message-photo) { padding: 5px 5px 3px; }
.chat-pane .message:has(.message-photo) > p { padding: 4px 5px; }
.chat-pane .message:has(.message-photo) > .message-meta { padding-inline: 4px; }
.message-photo {
  display: grid;
  place-items: center;
  width: min(232px,62vw);
  max-width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  border-radius: 13px;
  background: var(--soft);
  overflow: hidden;
}
.message-photo + .message-photo { margin-top: 4px; }
.message-photo :is(img,.image-fallback) { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.draft-photo { position: relative; flex: 0 0 64px; height: 56px; }
.draft-photo img { width: 56px; height: 56px; border-radius: 9px; object-fit: cover; }
.draft-photo button {
  position: absolute;
  top: 1px;
  right: 1px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--surface);
}
.dialog.chat-photo-dialog { width: min(640px,calc(100% - 24px)); }
.chat-photo-view { display: grid; justify-items: center; gap: 12px; }
.chat-photo-view img { width: 100%; max-height: 68dvh; object-fit: contain; }
.chat-photo-view .button { min-height: 44px; }


.message-receipt { display: inline-grid; place-items: center; min-width: 16px; color: rgba(255,255,255,.82); }
.message-receipt svg { width: 16px; height: 16px; stroke-width: 2.1; }
.message-receipt[data-receipt="read"] { color: #d4ffe4; }
.message-receipt[data-receipt="read"] svg { stroke-width: 2.8; }

.message-meta .chat-message-action, .message-meta .chat-report-message {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  color: inherit;
}
.message-meta button:hover { background: color-mix(in srgb, currentColor 15%, transparent); }
.message-meta button svg { width: 14px; height: 14px; }
.chat-pane .message-form { padding: 5px 20px 14px; border: 0; flex: none; }
.chat-quick-replies { display: flex; gap: 6px; overflow-x: auto; padding: 0 0 7px; }
.chat-quick-replies[hidden] { display: none; }
.chat-quick-replies button:hover { border-color: var(--accent-text); color: var(--accent-text); }
.chat-composer-field {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
  padding: 0 12px 0 4px;
  border-radius: 99px;
  background: var(--soft);
}
.chat-composer-field .attach-button { background: transparent; border-color: transparent; }
.chat-pane .chat-composer-field input { background: transparent; border: 0; border-radius: 0; padding: 8px 0; }
.chat-pane #message-input:focus { outline: none; }
.chat-composer-field:has(#message-input:focus-visible) { box-shadow: inset 0 0 0 2px var(--accent-text); }
.chat-pane .send-button { width: 48px; height: 48px; }
@media (max-width: 820px) {
  .chat-layout {
    grid-template-columns: minmax(0, 1fr);
    border-radius: 18px;
  }
  .chat-layout .chat-sidebar { border: 0; }
  .chat-layout.has-chat .chat-sidebar, .chat-layout:not(.has-chat) .chat-pane { display: none; }
  .chat-layout .chat-back { display: grid; flex: none; width: 34px; height: 34px; }
  .chat-sidebar-head { padding: 14px 14px 10px; }
  .chat-sidebar-head h1 { font-size: 24px; margin-bottom: 10px; }
  .chat-search input, .chat-pane #message-input { font-size: 16px; }
  .chat-filters { padding-inline: 14px; }
  .chat-list { padding-inline: 5px; }
  .chat-support { margin: 5px 14px 10px; }
  .chat-support-desk .field input, .chat-support-desk .field textarea { font-size: 16px; }
  .chat-pane .chat-header { padding: 8px; gap: 6px; }
  .chat-header > .avatar { width: 34px; height: 34px; }
  .chat-header .chat-more { width: 36px; height: 36px; }
  .chat-header .chat-deal { padding-inline: 8px; font-size: 11px; }
  .chat-pane .chat-item { margin: 8px 10px 0; }
  .chat-thumb { width: 38px; height: 38px; }
  .chat-pane .messages { padding: 8px 10px; }
  .chat-pane .message { max-width: 88%; }
  .chat-pane .message-form { padding: 4px 10px 8px; }
  .chat-pane .send-button { width: 44px; height: 44px; }
}
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  body:has(.chat-layout) {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
  }
  :root:not(.chat-keyboard) body:has(.chat-layout) { height: 100dvh; }
  body:has(.chat-layout) .site-header { flex: none; }
  body:has(.chat-layout) .site-footer { display: none; }
  #main:has(.chat-layout) {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    padding-top: 8px;
    padding-bottom: calc(var(--mobile-nav-height) + 8px);
  }
  .chat-layout, .chat-layout.has-chat { flex: 1; min-height: 0; height: auto; }
  .chat-keyboard #main:has(.chat-layout) { min-height: var(--chat-main-height); }
}
.chat-keyboard .chat-pane .chat-item, .chat-keyboard .chat-quick-replies,
.chat-keyboard .chat-header .chat-deal { display: none; }
.chat-keyboard .chat-pane .chat-header { padding: 4px 8px; }
.chat-keyboard .chat-pane .message-form { padding: 4px 8px; }
