/* Small message menus and focused form dialogs. */
#message-context-popover[data-mode="more"] {
  width: 184px;
  padding: 4px;
  border-radius: 8px;
}
#message-context-popover[data-mode="more"] .context-message-actions {
  border: 0;
  padding: 0;
  margin: 0;
  gap: 0;
}
#message-context-popover[data-mode="more"] .message-context-action {
  width: 100%;
  line-height: 20px;
}
body.form-modal-open {
  overflow: hidden;
}
.thread-list .list-heading > .thread-heading-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 2px;
}
.thread-list #open-phone-lookup {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 7px;
}
#phone-lookup-form-dialog {
  width: min(480px, calc(100vw - 20px));
}
.phone-lookup-result {
  padding: 12px;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}
.phone-result-identity {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  margin-bottom: 12px;
}
.phone-result-identity > div {
  min-width: 0;
}
.phone-result-identity strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}
.phone-result-identity p {
  margin: 4px 0 0;
  font-size: 11px;
}
#phone-result-avatar {
  position: relative;
  overflow: hidden;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}
#phone-result-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#phone-start-chat {
  width: 100%;
}
.phone-lookup-help,
#phone-demo-hint {
  font-size: 11px;
  line-height: 1.6;
  margin-top: 12px;
}
.phone-friendship {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 12px;
  flex-wrap: wrap;
}
.friendship-status {
  font-size: 11px;
  color: var(--text-secondary);
}
.friendship-outgoing,
.friendship-incoming,
.friendship-pending {
  color: var(--brand);
}
.friendship-friend {
  color: var(--success, #168a68);
}
body .friendship-add {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--brand);
  font-size: 12px;
}
.chat-identity:has(#chat-friendship:not([hidden])) #chat-subtitle {
  display: none;
}
.chat-identity #chat-friendship {
  font-size: 10px;
  line-height: 16px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#friend-request-form-dialog {
  width: min(420px, calc(100vw - 20px));
}
@media (max-width: 900px) {
  body .friendship-add {
    min-height: 44px;
  }
}
@media (max-width: 900px) {
  .thread-list #open-phone-lookup {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
}
dialog.form-modal:not([open]) {
  display: none;
}
dialog.form-modal {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(560px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 64px #07143733;
  overflow: hidden;
}
dialog.form-modal[open] {
  display: flex;
  flex-direction: column;
}
.form-modal::backdrop {
  background: #07143766;
}
.form-modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.form-modal-heading h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
body .form-modal-close {
  width: 36px;
  height: 36px;
  min-height: 36px;
  min-width: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 23px;
  border-radius: 6px;
}
.form-modal-close:hover {
  background: var(--surface-hover);
}
.form-modal-body {
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
}
.form-modal-body > form {
  border: 0 !important;
  box-shadow: none !important;
  border-radius: 0;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent;
}
.form-modal .mt-field {
  margin-bottom: 14px;
}
.form-modal-status {
  padding: 10px 12px;
  margin: 0 0 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  line-height: 1.6;
}
.tag-picker {
  min-width: 0;
  position: relative;
}
.tag-picker-box {
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--control-bg);
  padding: 6px 8px;
  cursor: text;
}
.tag-picker-box:focus-within {
  border-color: var(--control-focus);
  box-shadow: 0 0 0 2px
    color-mix(in srgb, var(--control-focus) 12%, transparent);
}
.tag-picker-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.tag-picker-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 2px 3px 2px 6px;
  border-radius: 4px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  line-height: 18px;
}
.tag-picker-chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body .tag-picker .tag-picker-remove {
  display: grid;
  place-items: center;
  width: 22px;
  min-width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 17px;
}
body .tag-picker input.tag-picker-search {
  width: 100%;
  height: 30px !important;
  min-height: 30px !important;
  padding: 3px 0 !important;
  margin: 0;
  border: 0 !important;
  border-radius: 0;
  box-shadow: none !important;
  background: transparent !important;
  color: var(--text);
  font-size: 12px;
}
.tag-picker-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  margin-top: 5px;
  padding: 4px;
  max-height: 176px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 4px 16px #07143718;
}
body .tag-picker .tag-picker-option {
  display: block;
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  margin: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  line-height: 20px;
  text-align: left;
  overflow-wrap: anywhere;
}
.tag-picker .tag-picker-option:hover,
.tag-picker .tag-picker-option[aria-selected="true"] {
  background: var(--brand-soft);
  color: var(--brand);
}
.tag-picker-hint,
.tag-picker-empty,
.tag-picker-error {
  margin: 5px 0 0;
  font-size: 10px;
  line-height: 1.6;
  color: var(--text-secondary);
}
.tag-picker-empty {
  padding: 6px;
  margin: 0;
}
.tag-picker-error {
  color: var(--danger, #c33b3b);
}
@media (max-width: 900px) {
  body .tag-picker input.tag-picker-search {
    font-size: 16px;
    min-height: 44px !important;
    height: 44px !important;
  }
  body .tag-picker .tag-picker-option {
    min-height: 44px;
    font-size: 14px;
    padding: 10px;
  }
  body .tag-picker .tag-picker-remove {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
  }
  .tag-picker-chip {
    font-size: 12px;
  }
}
.form-modal .kt-form-label {
  font-size: 12px;
}
.form-modal .kt-input,
.form-modal .kt-select {
  font-size: 13px;
  min-height: 40px;
  height: 40px;
}
.form-modal .kt-textarea {
  font-size: 13px;
  min-height: 90px;
}
.form-modal .columns {
  gap: 16px;
}
.form-modal .picker-panel {
  position: static;
  margin-top: 6px;
  max-height: 250px;
}
.form-modal .picker-options {
  max-height: 180px;
}
.modal-rule-test {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 16px;
}
.modal-rule-test > summary {
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding-block: 8px;
}
#customer-crm-form-dialog form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px 16px;
}
#customer-crm-form-dialog .mt-field {
  margin: 0;
}
#customer-crm-form-dialog .mt-field:has(textarea),
#customer-crm-form-dialog form > p,
#customer-crm-form-dialog form > button {
  grid-column: 1 / -1;
}
.form-modal .primary {
  min-height: 40px;
}
#rule-form-dialog {
  width: min(760px, calc(100vw - 32px));
}
.form-modal-trigger {
  margin-bottom: 12px;
}
#conversation-details .profile-summary {
  margin-top: 14px;
  padding-top: 12px;
}
.profile-summary p {
  margin: 0 0 8px;
  font-size: 11px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.profile-summary .profile-summary-note {
  color: var(--text-secondary);
  white-space: pre-wrap;
  max-height: 90px;
  overflow-y: auto;
}
body .profile-edit-trigger {
  width: 100%;
  min-height: 36px;
  font-size: 12px;
  background: var(--surface-soft);
  color: var(--brand);
  border: 1px solid var(--border);
  border-radius: 6px;
}
#customer-groups .form-modal-trigger {
  min-height: 36px;
  font-size: 12px;
  margin-top: 8px;
}
#conversation-details > .detail-section {
  padding-top: 12px;
  margin-top: 12px;
}
#conversation-details .detail-task-heading {
  min-height: 36px;
}
#conversation-details .detail-task-heading > .icon-button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 8px;
}
@media (max-width: 900px) {
  #message-context-popover[data-mode="more"] {
    width: 208px;
  }
  #message-context-popover .message-context-action {
    min-height: 44px;
    font-size: 13px;
  }
  dialog.form-modal {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 24px);
    border-radius: 10px;
  }
  .form-modal-heading {
    padding: 6px 12px;
  }
  body .form-modal-close {
    width: 44px;
    height: 44px;
    min-height: 44px;
  }
  .form-modal-body {
    padding: 16px;
  }
  .form-modal .columns {
    grid-template-columns: 1fr;
    gap: 0;
  }
  #customer-crm-form-dialog form {
    grid-template-columns: minmax(0, 1fr);
  }
  #conversation-details .detail-task-heading > .icon-button {
    min-width: 44px;
    min-height: 44px;
  }
  .form-modal .kt-input,
  .form-modal .kt-select,
  .form-modal .kt-textarea {
    font-size: 16px;
    min-height: 44px;
  }
  .form-modal .primary {
    min-height: 44px;
  }
}

/* Shared, anchored actions for care, account, task and member dialogs. */
dialog.form-modal.with-form-footer {
  width: min(480px, calc(100vw - 32px));
  border-radius: 10px;
}
.form-modal.with-form-footer .form-modal-heading {
  padding: 12px 18px;
}
.form-modal.with-form-footer .form-modal-heading h2 {
  font-size: 16px;
  line-height: 24px;
}
.form-modal.with-form-footer .form-modal-body {
  padding: 18px 20px;
}
.form-modal.with-form-footer .mt-field {
  margin-bottom: 14px;
}
.form-modal.with-form-footer .kt-form-label {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.form-modal-footer {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin: 0;
}
body .form-modal-footer button {
  width: auto;
  min-width: 72px;
  min-height: 36px;
  height: 36px;
  margin: 0;
  padding: 7px 14px;
  font-size: 12px;
  border-radius: 6px;
  white-space: nowrap;
}
body .form-modal-footer button.primary {
  min-width: 108px;
}
.form-modal.with-form-footer .kt-input,
.form-modal.with-form-footer .kt-select {
  min-height: 38px;
  height: 38px;
  font-size: 13px;
}
.form-modal.with-form-footer .kt-textarea {
  font-size: 13px;
  line-height: 1.6;
}
#task-form-dialog.with-form-footer {
  width: min(620px, calc(100vw - 32px));
}
#rule-form-dialog.with-form-footer {
  width: min(720px, calc(100vw - 32px));
}
#member-form-dialog.with-form-footer {
  width: min(500px, calc(100vw - 32px));
}
.form-modal-footer button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#add-customer-group-form-dialog .form-modal-body {
  padding: 16px 18px 12px;
}
#add-customer-group-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.modal-recipient {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}
.modal-recipient > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}
.modal-recipient strong {
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.modal-recipient .small {
  font-size: 11px;
}
.group-recipient-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
}
.group-recipient-caption {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.group-search-field {
  position: relative;
}
.group-search-field > i {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  font-size: 17px;
  color: var(--text-secondary);
  pointer-events: none;
}
body #group-search {
  padding-left: 36px;
  margin: 0;
  min-height: 38px;
  height: 38px;
  font-size: 13px;
  border-radius: 7px;
  background: var(--surface);
  width: 100%;
}
.group-picker-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}
body #group-picker-refresh {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: auto;
  min-height: 28px;
  padding: 0;
  font-size: 11px;
}
#group-picker-refresh i {
  font-size: 14px;
}
.group-picker-list {
  max-height: 264px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  scrollbar-gutter: stable;
}
#add-customer-group-form .group-choice {
  display: flex;
  align-items: center;
  flex-direction: row;
  gap: 10px;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  min-height: 64px;
  color: var(--text);
}
#add-customer-group-form .group-choice:hover {
  background: var(--surface-hover);
}
#add-customer-group-form .group-choice:focus-within {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
#add-customer-group-form .group-choice.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.group-choice-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
}
.selected .group-choice-avatar {
  background: var(--surface);
  color: var(--brand);
}
.group-choice-identity {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.group-choice-identity strong {
  font-size: 12px;
  line-height: 18px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.group-choice-identity .small {
  font-size: 10px;
  line-height: 14px;
}
#add-customer-group-form .group-choice input[type="radio"] {
  appearance: auto;
  flex: none;
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.group-picker-selection {
  margin: 0;
  font-size: 11px;
  line-height: 18px;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}
.group-picker-selection.has-selection {
  color: var(--brand);
}
#customer-group-note {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 18px;
  color: var(--text-secondary);
}
.group-picker-empty {
  text-align: center;
  padding: 24px 12px;
  color: var(--text-secondary);
  display: grid;
  justify-items: center;
  gap: 8px;
}
.group-picker-empty > i {
  font-size: 28px;
  line-height: 36px;
  color: var(--text-secondary);
}
.group-picker-empty strong {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.group-picker-empty p {
  font-size: 11px;
  line-height: 18px;
  max-width: 280px;
  margin: 0;
}
.group-picker-empty button,
.group-picker-more {
  font-size: 12px;
  min-height: 32px;
}
.group-picker-list:has(input:disabled) {
  opacity: 0.65;
}
.form-modal.with-form-footer form > p.muted {
  font-size: 11px;
  line-height: 18px;
}
@media (max-width: 900px) {
  dialog.form-modal.with-form-footer,
  #task-form-dialog.with-form-footer,
  #rule-form-dialog.with-form-footer,
  #member-form-dialog.with-form-footer {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
  }
  .form-modal.with-form-footer .form-modal-heading {
    padding: 8px 14px;
  }
  .form-modal.with-form-footer .form-modal-body,
  #add-customer-group-form-dialog .form-modal-body {
    padding: 14px;
  }
  .form-modal-footer {
    padding: 10px 14px;
  }
  body .form-modal-footer button {
    min-height: 44px;
    height: 44px;
    font-size: 13px;
  }
  .form-modal.with-form-footer .kt-input,
  .form-modal.with-form-footer .kt-select,
  .form-modal.with-form-footer .kt-textarea,
  body #group-search {
    font-size: 16px;
    min-height: 44px;
  }
  .group-picker-list {
    max-height: min(264px, 32dvh);
  }
  #add-customer-group-form .group-choice {
    min-height: 64px;
    padding: 10px;
    gap: 10px;
  }
  .group-choice-identity strong {
    font-size: 13px;
  }
  .group-choice-identity .small {
    font-size: 11px;
  }
  .group-recipient-caption {
    display: none;
  }
  #group-picker-refresh {
    min-height: 36px;
  }
}
.group-choice-avatar i {
  font-size: 19px;
  line-height: 1;
}
.group-search-field > i {
  z-index: 1;
}
#add-customer-group-form .group-choice:focus-within {
  outline: 0;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 22%, transparent);
}
/* UI actions use the same KeenIcons glyphs; labels stay available to readers. */
.control-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  font-size: 16px;
  line-height: 1;
  pointer-events: none;
}
.form-modal-close > .control-glyph {
  font-size: 18px;
}
#message-context-popover .message-popover-close > .control-glyph,
.tag-picker-remove > .control-glyph {
  font-size: 14px;
}
#notification-close,
#close-thread-filters,
#close-details {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
summary:has(> .disclosure-chevron) {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
summary:has(> .disclosure-chevron)::-webkit-details-marker {
  display: none;
}
.disclosure-chevron {
  display: inline-flex;
  flex: none;
  align-items: center;
  font-size: 12px;
  line-height: 1;
  transition: transform 0.15s ease;
  pointer-events: none;
}
details[open] > summary > .disclosure-chevron {
  transform: rotate(180deg);
}
@media (prefers-reduced-motion: reduce) {
  .disclosure-chevron {
    transition: none;
  }
}
