/* INSIDE 2.0 rich messaging */
.sidebar-header-actions,
.quick-chat-actions,
.file-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-header-actions button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--brand-strong);
}

.sidebar-header-actions button:hover,
.quick-chat-actions button:hover {
  border-color: #a8d7c0;
  background: var(--brand-pale);
}

.quick-chat-actions {
  margin-top: 10px;
}

.quick-chat-actions button {
  display: inline-flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-soft);
  font-size: 11px;
}

.quick-chat-actions svg {
  width: 14px;
  height: 14px;
  color: var(--brand);
}

.settings-profile-button {
  width: calc(100% - 24px);
  margin: 8px 12px 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: inherit;
  text-align: left;
}

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

.avatar-button {
  align-self: flex-end;
  padding: 0;
  border-radius: 11px;
  background: transparent;
}

.message-mention {
  display: inline-block;
  padding: 0 3px;
  border-radius: 4px;
  background: rgba(38, 143, 105, 0.12);
  color: var(--brand-strong);
  font-weight: 700;
}

.message-recall {
  padding: 2px 4px;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
}

.message-recall:hover {
  background: var(--surface-muted);
  color: var(--danger);
}

.message-recalled {
  max-width: 100%;
  justify-content: center;
}

.message-recalled .message-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 10px;
}

.message-recalled svg {
  width: 12px;
  height: 12px;
}

.composer-toolbar button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.composer-toolbar button.is-recording {
  background: #fff0ed;
  color: var(--danger);
  animation: recording-pulse 1.3s infinite;
}

@keyframes recording-pulse {
  50% { box-shadow: 0 0 0 4px rgba(220, 92, 77, 0.12); }
}

.mention-popover {
  width: min(320px, calc(100vw - 28px));
}

.mention-list {
  display: grid;
  max-height: 280px;
  gap: 3px;
  overflow-y: auto;
}

.mention-list > button,
.member-detail-list > button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.mention-list > button:hover,
.member-detail-list > button:hover {
  background: var(--brand-pale);
}

.mention-list .avatar,
.member-detail-list .avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  aspect-ratio: 1;
  display: inline-grid;
  place-items: center;
}

.mention-list > button > span:not(.avatar),
.mention-list strong,
.mention-list small,
.member-detail-list > button > span:not(.avatar),
.member-detail-list strong,
.member-detail-list small {
  display: block;
}

.mention-list > button > span:not(.avatar),
.member-detail-list > button > span:not(.avatar) {
  min-width: 0;
  flex: 1;
}

.mention-list strong,
.member-detail-list strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-list small,
.member-detail-list small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.image-message,
.video-message {
  position: relative;
  width: min(360px, 58vw);
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #17221e;
  color: #fff;
  text-align: left;
}

.image-message {
  display: grid;
  padding: 0;
}

.video-message {
  display: block;
}

.image-message-preview img,
.video-message video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 300px;
  object-fit: contain;
}

.video-message > span {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 24px 10px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.68));
  font-size: 10px;
}

.image-message-preview {
  display: grid;
  width: 100%;
  max-height: 300px;
  overflow: hidden;
  place-items: center;
  background: #edf3f0;
}

.image-message-caption {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #20302a;
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
}

.image-message-caption > span {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-message-caption > svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  opacity: .72;
}

.media-message {
  display: flex;
  min-width: min(360px, 60vw);
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.media-message audio {
  min-width: 180px;
  flex: 1;
  height: 34px;
}

.media-message small {
  max-width: 100px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-message {
  max-width: min(430px, 70vw);
}

.file-message > button + button {
  margin-left: -6px;
}

.file-center .file-table-head,
.file-center .file-table-row {
  grid-template-columns: minmax(220px, 1.6fr) minmax(140px, 0.8fr) 90px 110px 112px;
}

.file-row-actions {
  justify-content: flex-end;
}

.file-row-actions button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-strong);
}

.file-row-actions button:hover {
  background: var(--surface-muted);
  color: var(--brand);
}

.file-row-actions button:last-child:hover {
  background: #fff0ed;
  color: var(--danger);
}

.profile-summary-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(135deg, #f2fbf6, #fffaf0);
}

.profile-summary-card .avatar {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  font-size: 24px;
}

.profile-avatar-large {
  padding: 0;
  border-radius: 18px;
  background: transparent;
}

.profile-summary-card h3 {
  margin: 0;
  font-size: 18px;
}

.profile-summary-card p,
.profile-summary-card span {
  display: block;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.profile-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.profile-fields > span {
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.profile-fields > span:last-child {
  border-right: 0;
}

.profile-fields small,
.profile-fields strong {
  display: block;
}

.profile-fields small {
  color: var(--muted);
  font-size: 9px;
}

.profile-fields strong {
  margin-top: 5px;
  font-size: 11px;
}

.app-dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: min(780px, calc(100vh - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(25, 50, 40, 0.28);
  color: var(--ink);
}

.app-dialog::backdrop {
  background: rgba(23, 38, 32, 0.44);
  backdrop-filter: blur(4px);
}

.app-dialog > header,
.app-dialog form > header,
.app-dialog > footer,
.app-dialog form > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
}

.app-dialog > header,
.app-dialog form > header {
  border-bottom: 1px solid var(--line);
}

.app-dialog > footer,
.app-dialog form > footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.app-dialog header h2,
.app-dialog header p {
  margin: 0;
}

.app-dialog header h2 {
  font-size: 16px;
}

.app-dialog header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.app-dialog header > button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--muted-strong);
}

.dialog-body {
  max-height: 58vh;
  padding: 20px;
  overflow-y: auto;
}

.dialog-field {
  display: grid;
  gap: 7px;
}

.dialog-field > span {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
}

.dialog-field input,
.dialog-field select,
.dialog-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  background: #fff;
  color: var(--ink);
}

.dialog-field input:focus,
.dialog-field select:focus,
.dialog-field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(38, 143, 105, 0.1);
}

.contact-picker {
  display: grid;
  max-height: 360px;
  gap: 4px;
  margin: 18px 0 0;
  padding: 0;
  overflow-y: auto;
  border: 0;
}

.contact-picker legend {
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
}

.contact-picker label {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border-radius: 8px;
}

.contact-picker label:hover {
  background: var(--brand-pale);
}

.contact-picker label > span:not(.avatar) {
  min-width: 0;
  flex: 1;
}

.contact-picker strong,
.contact-picker small {
  display: block;
}

.contact-picker strong {
  font-size: 11px;
}

.contact-picker small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.profile-dialog-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 24px;
  background: linear-gradient(135deg, var(--brand-pale), #fff9e7);
}

.profile-avatar-xl {
  padding: 0;
  border-radius: 22px;
  background: transparent;
  transition: transform 180ms ease;
}

.profile-avatar-xl .avatar {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  font-size: 30px;
}

.profile-avatar-xl.is-expanded {
  transform: scale(1.8);
  transform-origin: left center;
  z-index: 2;
}

.profile-dialog-hero h3,
.profile-dialog-hero p {
  margin: 0;
}

.profile-dialog-hero h3 {
  font-size: 20px;
}

.profile-dialog-hero p,
.profile-dialog-hero small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.profile-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin: 0;
  padding: 18px 24px;
}

.profile-detail-grid > div {
  padding: 10px;
  border-right: 1px solid var(--line);
}

.profile-detail-grid > div:nth-child(3) {
  border-right: 0;
}

.profile-detail-grid .wide {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  border-right: 0;
}

.profile-detail-grid dt {
  color: var(--muted);
  font-size: 9px;
}

.profile-detail-grid dd {
  margin: 5px 0 0;
  font-size: 11px;
}

.profile-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.profile-form-grid .wide,
.avatar-upload-field {
  grid-column: 1 / -1;
}

.avatar-upload-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px dashed #add5c1;
  border-radius: 10px;
  background: var(--brand-pale);
  cursor: pointer;
}

.avatar-upload-field span,
.avatar-upload-field strong,
.avatar-upload-field small {
  display: block;
}

.avatar-upload-field span {
  flex: 1;
}

.avatar-upload-field strong {
  font-size: 11px;
}

.avatar-upload-field small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.avatar-upload-field input {
  max-width: 200px;
  font-size: 9px;
}

.preview-dialog {
  width: min(1000px, calc(100vw - 32px));
}

.preview-stage {
  display: grid;
  min-height: 320px;
  max-height: calc(100vh - 190px);
  place-items: center;
  overflow: auto;
  background: #17211d;
}

.preview-stage img,
.preview-stage video {
  max-width: 100%;
  max-height: calc(100vh - 210px);
}

.preview-stage audio {
  width: min(520px, 90%);
}

.preview-stage iframe {
  width: 100%;
  height: calc(100vh - 190px);
  border: 0;
  background: #fff;
}

.preview-unavailable {
  display: grid;
  place-items: center;
  color: #d9e6df;
  text-align: center;
}

.preview-unavailable svg {
  width: 42px;
  height: 42px;
}

.preview-unavailable p {
  margin: 6px 0 0;
  color: #9fb2a8;
  font-size: 10px;
}

@media (max-width: 720px) {
  .sidebar-header-actions { display: flex; }
  .quick-chat-actions { gap: 8px; }
  .chat-view { grid-template-rows: 64px minmax(0, 1fr) 142px; }
  .composer { padding-right: 10px; padding-left: 10px; }
  .composer-toolbar > div { gap: 0; }
  .composer-toolbar button { width: 28px; }
  .emoji-popover {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 116px;
    width: auto;
    max-width: calc(100vw - 16px);
  }
  .emoji-panel-scroll { max-height: min(286px, calc(100vh - 180px)); }
  .emoji-grid { grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); }
  .image-message,
  .video-message { width: 72vw; }
  .media-message { min-width: 76vw; flex-wrap: wrap; }
  .media-message audio { width: 100%; }
  .profile-form-grid,
  .profile-fields,
  .profile-detail-grid { grid-template-columns: 1fr; }
  .profile-fields > span { border-right: 0; border-bottom: 1px solid var(--line); }
  .profile-fields > span:last-child { border-bottom: 0; }
  .profile-detail-grid > div,
  .profile-detail-grid > div:nth-child(3) { border-right: 0; border-bottom: 1px solid var(--line); }
  .profile-detail-grid .wide { grid-column: 1; }
  .avatar-upload-field { align-items: flex-start; flex-wrap: wrap; }
  .app-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .dialog-body { max-height: 62vh; padding: 16px; }
  .file-center .file-table-head,
  .file-center .file-table-row { grid-template-columns: minmax(220px, 1.6fr) 140px 90px 110px 112px; }
}
