/* ── native CRM ─────────────────────────────────────────────────────────── */
.crm-view {
  min-height: 0;
}
.crm-card {
  min-width: 0;
}
.crm-subnav {
  max-width: var(--content-max);
}
.crm-toolbar,
.crm-message-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.crm-search {
  flex: 1 1 320px;
  max-width: 520px;
}
.crm-search-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--muted2);
}
.crm-search-icon .ic {
  width: 17px;
  height: 17px;
}
.crm-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.crm-spinner {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: crm-spin 0.7s linear infinite;
}
@keyframes crm-spin {
  to {
    transform: rotate(360deg);
  }
}

.crm-status {
  width: 100%;
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  padding: 16px;
  border-radius: var(--radius-sm);
  color: var(--muted);
}
.crm-status-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--txt);
  background: rgba(var(--fg-rgb), 0.065);
  border: 1px solid rgba(var(--fg-rgb), 0.1);
}
.crm-status-icon .ic {
  width: 19px;
  height: 19px;
}
.crm-status-loading .crm-status-icon {
  animation: crm-spin 1.4s linear infinite;
}
.crm-status-error {
  border-color: rgba(var(--err-rgb), 0.25);
  background: rgba(var(--err-rgb), 0.045);
}
.crm-status-error .crm-status-icon {
  color: var(--err);
  border-color: rgba(var(--err-rgb), 0.25);
  background: rgba(var(--err-rgb), 0.08);
}
.crm-status-scope .crm-status-icon {
  color: var(--warn);
  border-color: rgba(var(--warn-rgb), 0.25);
  background: rgba(var(--warn-rgb), 0.07);
}
.crm-status-copy {
  min-width: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 3px;
}
.crm-status-copy b {
  color: var(--txt);
  font-size: 13px;
}
.crm-status-copy span {
  font-size: 11.5px;
  line-height: 1.45;
}
.crm-status > .btn {
  flex: 0 0 auto;
}

.crm-avatar {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 15px;
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), rgba(var(--accent-rgb), 0.68));
  border: 1px solid rgba(var(--fg-rgb), 0.18);
  box-shadow:
    inset 0 1px 0 rgba(var(--fg-rgb), 0.26),
    0 7px 18px rgba(0, 0, 0, 0.24);
  font-size: 17px;
  font-weight: 800;
}
.crm-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.crm-avatar.is-small {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 14px;
}
.crm-avatar.is-picker {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  font-size: 13px;
}
.crm-avatar.is-conversation {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  font-size: 14px;
}
.crm-avatar.is-thread {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  font-size: 13px;
}

/* CRM accounts */
.crm-account-content,
.crm-links-content {
  min-height: 110px;
}
.crm-account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr));
  gap: 12px;
}
.crm-account-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-radius: 17px;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease;
}
.crm-account-head {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
}
.crm-account-identity {
  min-width: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
}
.crm-account-name,
.crm-account-handle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-account-name {
  color: var(--txt);
  font-size: 14px;
}
.crm-account-handle {
  color: var(--muted);
  font-size: 11.5px;
}
.crm-account-badges {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
}
.crm-badge {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(var(--fg-rgb), 0.045);
  border: 1px solid rgba(var(--fg-rgb), 0.1);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  white-space: nowrap;
}
.crm-badge.is-ok {
  color: var(--ok);
  background: rgba(var(--ok-rgb), 0.07);
  border-color: rgba(var(--ok-rgb), 0.25);
}
.crm-badge.is-missing {
  color: var(--warn);
  background: rgba(var(--warn-rgb), 0.06);
  border-color: rgba(var(--warn-rgb), 0.24);
}
.crm-badge.is-muted {
  color: var(--muted2);
  border-style: dashed;
}
.crm-account-meta,
.crm-token-meta {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
.crm-account-meta > div,
.crm-token-meta > div {
  min-width: 0;
  min-height: 49px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 9px 10px;
  border-radius: 11px;
  background: rgba(var(--fg-rgb), 0.028);
  border: 1px solid rgba(var(--fg-rgb), 0.065);
}
.crm-account-meta dt,
.crm-token-meta dt {
  margin-bottom: 3px;
  color: var(--muted2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.crm-account-meta dd,
.crm-token-meta dd {
  margin: 0;
  overflow: hidden;
  color: var(--txt);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-account-meta .is-danger dd {
  color: var(--err);
}
.crm-scope-line {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(var(--fg-rgb), 0.055);
}
.crm-scope-line > span {
  flex: 0 0 auto;
  color: var(--muted2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.crm-scope-line code {
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  color: var(--muted);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 10px;
  scrollbar-width: none;
  white-space: nowrap;
}
.crm-scope-line code::-webkit-scrollbar {
  display: none;
}
.crm-account-card > .crm-status {
  min-height: 0;
  justify-content: flex-start;
  padding: 10px;
}
.crm-account-card > .crm-status .crm-status-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}
.crm-account-card > .crm-status .crm-status-icon .ic {
  width: 16px;
  height: 16px;
}
.crm-account-reconnect {
  padding: 8px 10px;
  font-size: 10.5px;
}
.crm-account-actions {
  display: grid;
  grid-template-columns:
    minmax(0, 0.85fr) minmax(0, 0.95fr) minmax(0, 1.2fr)
    minmax(0, 0.85fr) minmax(0, 1fr);
  gap: 6px;
  margin-top: auto;
  padding-top: 2px;
}
.crm-account-action {
  min-width: 0;
  min-height: 42px;
  padding: 9px 6px;
  font-size: 10.5px;
  line-height: 1;
  white-space: nowrap;
}
.crm-account-action .btn-ic {
  display: inline-flex;
}
.crm-account-action .btn-ic .ic {
  width: 15px;
  height: 15px;
}

/* CRM dialogs and token handling */
.crm-dialog {
  width: min(560px, 100%);
}
.crm-dialog-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}
.crm-dialog-error {
  min-height: 18px;
  margin: 7px 2px 0;
  color: var(--err);
  font-size: 11.5px;
  line-height: 1.4;
}
.crm-dialog-account {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 13px;
  padding: 9px 10px;
  border-radius: 13px;
}
.crm-dialog-account > span:last-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.crm-dialog-account b,
.crm-dialog-account small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-dialog-account b {
  color: var(--txt);
  font-size: 13px;
}
.crm-dialog-account small {
  color: var(--muted);
  font-size: 10.5px;
}
.crm-token-box {
  position: relative;
  min-height: 62px;
  display: flex;
  align-items: center;
  padding: 13px;
  overflow: hidden;
  border-radius: 13px;
}
.crm-token-value {
  width: 100%;
  overflow-wrap: anywhere;
  color: var(--txt);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}
.crm-token-meta {
  margin-top: 11px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.crm-token-dialog .modal-actions {
  flex-wrap: wrap;
}
.crm-json-dialog {
  width: min(720px, 100%);
}
.crm-json {
  max-height: min(500px, 55dvh);
  margin: 0;
  padding: 13px;
  overflow: auto;
  border-radius: 13px;
  color: #d4d4d8;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid rgba(var(--fg-rgb), 0.08);
  font:
    11px/1.55 ui-monospace,
    "Cascadia Code",
    Consolas,
    monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.crm-compose-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 12px;
}
.crm-compose-field > span:first-child {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}
.crm-compose-text {
  min-height: 126px;
  padding: 12px 13px;
  resize: vertical;
  border-radius: var(--radius-sm);
  background: rgba(var(--fg-rgb), 0.045);
  border: 1px solid rgba(var(--fg-rgb), 0.12);
  font-family: inherit;
  font-size: 13px;
}
.crm-compose-text:focus {
  border-color: rgba(var(--fg-rgb), 0.5);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}
.crm-compose-counter {
  display: block;
  margin: -5px 2px 4px;
  color: var(--muted2);
  font-size: 10.5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.crm-compose-counter.is-over {
  color: var(--err);
}

/* CRM connect links */
.crm-link-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.crm-link-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border-radius: 15px;
}
.crm-link-row.is-inactive {
  opacity: 0.56;
}
.crm-link-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--txt);
  background: rgba(var(--fg-rgb), 0.065);
  border: 1px solid rgba(var(--fg-rgb), 0.1);
}
.crm-link-icon .ic {
  width: 18px;
  height: 18px;
}
.crm-link-main {
  min-width: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 5px;
}
.crm-link-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.crm-link-title b {
  overflow: hidden;
  color: var(--txt);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-link-url {
  overflow: hidden;
  color: var(--muted);
  font:
    10.5px/1.4 ui-monospace,
    "Cascadia Code",
    Consolas,
    monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-link-meta {
  color: var(--muted2);
  font-size: 9.5px;
  line-height: 1.4;
}
.crm-link-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}
.crm-link-open {
  text-decoration: none;
}

/* CRM message account picker */
.crm-messages {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.crm-messages > .page-head {
  margin-bottom: 12px;
}
.crm-message-toolbar {
  position: relative;
  z-index: 40;
  overflow: visible;
}
.crm-account-picker-host {
  position: relative;
  z-index: 1;
  min-width: 0;
  flex: 1 1 auto;
  overflow: visible;
}
.crm-account-picker {
  position: relative;
  width: min(390px, 100%);
  overflow: visible;
}
.crm-account-picker.is-open {
  z-index: 50;
}
.crm-account-trigger {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 14px;
  color: var(--txt);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition:
    border-color 0.16s,
    background 0.16s,
    box-shadow 0.16s;
}
.crm-account-trigger:disabled {
  cursor: default;
  opacity: 0.58;
}
.crm-account-picker.is-open .crm-account-trigger {
  border-color: rgba(var(--fg-rgb), 0.36);
  background: rgba(var(--fg-rgb), 0.085);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}
.crm-account-trigger-copy,
.crm-account-option-copy {
  min-width: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 1px;
}
.crm-account-trigger-copy b,
.crm-account-option-copy b,
.crm-account-trigger-copy small,
.crm-account-option-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-account-trigger-copy b,
.crm-account-option-copy b {
  color: var(--txt);
  font-size: 12.5px;
}
.crm-account-trigger-copy small,
.crm-account-option-copy small {
  color: var(--muted);
  font-size: 10.5px;
}
.crm-account-trigger-placeholder {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--muted);
  background: rgba(var(--fg-rgb), 0.055);
}
.crm-account-trigger-placeholder .ic {
  width: 17px;
  height: 17px;
}
.crm-account-trigger-arrow {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--muted2);
  transition: transform 0.16s;
}
.crm-account-trigger-arrow .ic {
  width: 17px;
  height: 17px;
}
.crm-account-picker.is-open .crm-account-trigger-arrow {
  transform: rotate(180deg);
}
.crm-account-menu {
  position: absolute;
  z-index: 100;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  max-height: min(360px, calc(100dvh - 190px));
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 7px;
  overflow: hidden;
  border-radius: 16px;
  border-color: rgba(var(--fg-rgb), 0.17);
  background:
    linear-gradient(145deg, rgba(var(--fg-rgb), 0.065), transparent 56%),
    color-mix(in srgb, var(--bg2) 95%, #050506);
  box-shadow:
    inset 0 1px 0 rgba(var(--fg-rgb), 0.13),
    0 18px 48px rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(28px) saturate(125%);
  -webkit-backdrop-filter: blur(28px) saturate(125%);
}
.crm-account-menu[hidden] {
  display: none;
}
.crm-account-menu-search {
  min-height: 40px;
  flex: 0 0 auto;
  padding: 0 10px;
  border-radius: 11px;
  background: rgba(var(--fg-rgb), 0.055);
  border-color: rgba(var(--fg-rgb), 0.1);
}
.crm-account-menu-search input {
  min-width: 0;
  padding: 8px 0;
  font-size: 11.5px;
}
.crm-account-options {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.crm-account-menu-empty {
  padding: 16px 10px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
.crm-account-menu-empty[hidden] {
  display: none;
}
.crm-account-option {
  width: 100%;
  min-width: 0;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--txt);
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.crm-account-option[hidden] {
  display: none;
}
.crm-account-option.is-selected {
  background: rgba(var(--fg-rgb), 0.095);
  border-color: rgba(var(--fg-rgb), 0.17);
  box-shadow: inset 3px 0 0 rgba(var(--accent-rgb), 0.82);
}
.crm-account-option.is-focused {
  background: rgba(var(--fg-rgb), 0.12);
  outline: none;
}
.crm-account-option-check {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--txt);
  border-radius: 9px;
  background: rgba(var(--fg-rgb), 0.07);
}
.crm-account-option-check .ic {
  width: 16px;
  height: 16px;
}
.crm-permission-banner {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 13px;
  color: var(--warn);
  border-color: rgba(var(--warn-rgb), 0.2);
  background: rgba(var(--warn-rgb), 0.045);
}
.crm-permission-banner[hidden] {
  display: none;
}
.crm-permission-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.crm-permission-icon .ic {
  width: 17px;
  height: 17px;
}
.crm-permission-copy {
  min-width: 0;
  flex: 1 1 auto;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
}

/* CRM inbox and conversations */
.crm-inbox {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  overflow: hidden;
  border-radius: 17px;
  background: rgba(0, 0, 0, 0.15);
}
.crm-conversation-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(var(--fg-rgb), 0.08);
  background: rgba(var(--fg-rgb), 0.014);
}
.crm-conversation-head {
  flex: 0 0 auto;
  padding: 11px;
  border-bottom: 1px solid rgba(var(--fg-rgb), 0.07);
}
.crm-conversation-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 1px 2px 9px;
}
.crm-conversation-title b {
  color: var(--txt);
  font-size: 12px;
}
.crm-conversation-count {
  min-width: 23px;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(var(--fg-rgb), 0.06);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.crm-conversation-search {
  min-height: 38px;
  padding: 0 10px;
  background: rgba(var(--fg-rgb), 0.035);
  border: 1px solid rgba(var(--fg-rgb), 0.07);
}
.crm-conversation-search input {
  padding: 8px 0;
  font-size: 11.5px;
}
.crm-conversation-list {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.crm-conversation-list > .crm-status {
  min-height: 100%;
  align-content: center;
  flex-direction: column;
  text-align: center;
}
.crm-conversation-list > .crm-status .crm-status-copy {
  flex: 0 1 auto;
}
.crm-load-more {
  flex: 0 0 auto;
  justify-content: center;
  margin: 10px auto;
}
.crm-conversation-list > .crm-load-more {
  width: calc(100% - 20px);
}
.crm-load-more .ic {
  transform: rotate(90deg);
}
.crm-conversation {
  position: relative;
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 0;
  border-bottom: 1px solid rgba(var(--fg-rgb), 0.055);
  color: var(--txt);
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition:
    background 0.16s,
    box-shadow 0.16s;
}
.crm-conversation.is-active {
  background: rgba(var(--fg-rgb), 0.085);
  box-shadow: inset 3px 0 0 rgba(var(--accent-rgb), 0.8);
}
.crm-conversation-body {
  min-width: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 4px;
}
.crm-conversation-top {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.crm-conversation-top b {
  min-width: 0;
  overflow: hidden;
  flex: 1 1 auto;
  color: var(--txt);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-conversation-top time {
  flex: 0 0 auto;
  color: var(--muted2);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}
.crm-conversation-unread {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.5);
}
.crm-conversation-preview {
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* CRM thread */
.crm-thread-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    radial-gradient(70% 60% at 100% 0%, rgba(var(--accent-rgb), 0.035), transparent 72%),
    rgba(0, 0, 0, 0.08);
}
.crm-thread-head {
  min-width: 0;
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-bottom: 1px solid rgba(var(--fg-rgb), 0.07);
  background: rgba(var(--fg-rgb), 0.018);
}
.crm-thread-head[hidden] {
  display: none;
}
.crm-thread-avatar {
  flex: 0 0 auto;
}
.crm-thread-identity {
  min-width: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 1px;
}
.crm-thread-identity b,
.crm-thread-identity small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-thread-identity b {
  color: var(--txt);
  font-size: 12px;
}
.crm-thread-identity small {
  color: var(--muted);
  font-size: 10px;
}
.crm-mobile-back {
  display: none;
  transform: rotate(90deg);
}
.crm-message-list {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.crm-message-list > .crm-status {
  min-height: 100%;
  align-self: center;
}
.crm-message-list > .crm-load-more {
  align-self: center;
}
.crm-day-separator {
  align-self: center;
  margin: 9px 0 6px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--muted2);
  background: rgba(var(--fg-rgb), 0.045);
  border: 1px solid rgba(var(--fg-rgb), 0.065);
  font-size: 11px;
  letter-spacing: 0.035em;
}
.crm-system-message {
  align-self: center;
  max-width: 80%;
  margin: 4px 0;
  color: var(--muted2);
  font-size: 9.5px;
  text-align: center;
}
.crm-message {
  width: 100%;
  display: flex;
}
.crm-message.is-me {
  justify-content: flex-end;
}
.crm-message.is-them {
  justify-content: flex-start;
}
.crm-message-bubble {
  max-width: min(78%, 560px);
  padding: 9px 11px 6px;
  border-radius: 15px;
  color: var(--txt);
  background: rgba(var(--fg-rgb), 0.065);
  border: 1px solid rgba(var(--fg-rgb), 0.09);
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.12);
}
.crm-message.is-me .crm-message-bubble {
  color: var(--on-accent);
  background: linear-gradient(145deg, var(--accent), rgba(var(--accent-rgb), 0.76));
  border-color: rgba(var(--accent-rgb), 0.52);
  border-bottom-right-radius: 5px;
}
.crm-message.is-them .crm-message-bubble {
  border-bottom-left-radius: 5px;
}
.crm-message-text {
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.crm-message-meta {
  margin-top: 3px;
  color: var(--muted2);
  font-size: 11px;
  text-align: right;
}
.crm-message.is-me .crm-message-meta {
  color: color-mix(in srgb, var(--on-accent) 62%, transparent);
}
.crm-message.is-fresh {
  animation: crm-message-in 0.2s ease-out both;
}
@keyframes crm-message-in {
  from {
    opacity: 0;
    transform: translateY(5px) scale(0.985);
  }
}
.crm-message.is-pending {
  opacity: 0.68;
}
.crm-message.is-failed .crm-message-bubble {
  color: var(--txt);
  background: rgba(var(--err-rgb), 0.12);
  border-color: rgba(var(--err-rgb), 0.38);
}
.crm-message.is-failed .crm-message-meta {
  color: var(--err);
  cursor: pointer;
  text-decoration: underline;
}
.crm-jump {
  position: absolute;
  z-index: 3;
  right: 15px;
  bottom: 72px;
  padding: 7px 10px;
  border: 1px solid rgba(var(--fg-rgb), 0.16);
  border-radius: 999px;
  color: var(--txt);
  background: rgba(18, 18, 21, 0.92);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
  cursor: pointer;
  font: inherit;
  font-size: 9.5px;
  font-weight: 600;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translateY(5px);
  transition:
    opacity 0.16s,
    transform 0.16s;
}
.crm-jump.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}
.crm-reply-composer {
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 9px;
  border-top: 1px solid rgba(var(--fg-rgb), 0.07);
  background: rgba(0, 0, 0, 0.12);
}
.crm-reply-composer[hidden] {
  display: none;
}
.crm-reply-text {
  min-width: 0;
  min-height: 42px;
  max-height: 150px;
  flex: 1 1 auto;
  padding: 10px 11px;
  resize: none;
  border-radius: 13px;
  background: rgba(var(--fg-rgb), 0.05);
  border: 1px solid rgba(var(--fg-rgb), 0.1);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.45;
}
.crm-reply-text:focus {
  border-color: rgba(var(--fg-rgb), 0.4);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}
.crm-reply-text:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.crm-reply-send {
  min-height: 42px;
  padding: 10px 14px;
  font-size: 11.5px;
}

@media (hover: hover) {
  .crm-account-card:hover {
    transform: translateY(-2px);
    border-color: rgba(var(--fg-rgb), 0.15);
    background: rgba(var(--fg-rgb), 0.055);
  }
  .crm-conversation:hover:not(.is-active),
  .crm-account-option:hover:not(.is-selected) {
    background: rgba(var(--fg-rgb), 0.05);
  }
  .crm-account-trigger:hover:not(:disabled) {
    border-color: rgba(var(--fg-rgb), 0.2);
    background: rgba(var(--fg-rgb), 0.065);
  }
}

.crm-account-trigger:focus-visible,
.crm-account-menu-search:focus-within,
.crm-account-option:focus-visible,
.crm-conversation:focus-visible,
.crm-jump:focus-visible,
.crm-compose-text:focus-visible,
.crm-reply-text:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

@media (max-width: 980px) {
  .crm-account-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .crm-messages {
    min-height: 0;
  }
  .crm-inbox {
    height: min(650px, calc(100dvh - 255px));
    min-height: 455px;
    display: block;
  }
  .crm-conversation-pane {
    width: 100%;
    height: 100%;
    border-right: 0;
  }
  .crm-thread-pane {
    position: absolute;
    z-index: 4;
    inset: 0;
    width: 100%;
    height: 100%;
    visibility: hidden;
    background:
      radial-gradient(70% 60% at 100% 0%, rgba(var(--accent-rgb), 0.055), transparent 72%),
      color-mix(in srgb, var(--bg1) 96%, #000);
    transform: translateX(102%);
    transition:
      transform 0.24s cubic-bezier(0.22, 0.61, 0.36, 1),
      visibility 0s linear 0.24s;
  }
  .crm-messages.crm-thread-open .crm-thread-pane {
    visibility: visible;
    transform: none;
    transition-delay: 0s;
  }
  .crm-mobile-back {
    display: grid;
  }
  .crm-message-bubble {
    max-width: 84%;
  }
}

@media (max-width: 560px) {
  .crm-toolbar,
  .crm-message-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .crm-search,
  .crm-account-picker,
  .crm-account-picker-host {
    width: 100%;
    max-width: none;
    flex-basis: auto;
  }
  .crm-count {
    align-self: flex-end;
  }
  .crm-refresh-conversations {
    width: 100%;
  }
  .crm-account-menu {
    position: static;
    width: 100%;
    max-height: min(340px, calc(100dvh - 180px));
    margin-top: 8px;
  }
  .crm-status {
    align-items: center;
    flex-direction: column;
    text-align: center;
  }
  .crm-status-copy {
    flex: 0 1 auto;
  }
  .crm-status > .btn {
    width: 100%;
  }
  .crm-account-head {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }
  .crm-account-identity {
    padding-top: 0;
  }
  .crm-account-badges {
    grid-column: 1 / -1;
    width: 100%;
    align-items: flex-start;
    justify-content: flex-start;
    flex-direction: row;
    padding-left: 0;
    margin-top: 1px;
  }
  .crm-account-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }
  .crm-account-action:last-child {
    grid-column: 1 / -1;
  }
  .crm-account-card > .crm-status {
    align-items: stretch;
    text-align: left;
  }
  .crm-account-card > .crm-status .crm-status-icon {
    display: none;
  }
  .crm-link-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .crm-link-main {
    width: calc(100% - 52px);
  }
  .crm-link-actions {
    width: 100%;
    padding-left: 50px;
  }
  .crm-link-actions .btn {
    flex: 1 1 auto;
  }
  .crm-permission-banner {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .crm-permission-copy {
    padding-top: 2px;
  }
  .crm-permission-banner .btn {
    width: 100%;
  }
  .crm-messages {
    min-height: 0;
  }
  .crm-inbox {
    height: min(610px, calc(100dvh - 315px));
    min-height: 420px;
  }
  .crm-message-list {
    padding: 11px;
  }
  .crm-message-bubble {
    max-width: 88%;
  }
  .crm-reply-send {
    width: 42px;
    padding: 10px;
  }
  .crm-reply-send > span:last-child {
    display: none;
  }
  .crm-dialog .modal-actions {
    flex-wrap: wrap;
  }
  .crm-dialog .modal-actions .btn {
    flex: 1 1 auto;
  }
}

@media (max-width: 420px) {
  .crm-account-meta,
  .crm-token-meta {
    grid-template-columns: 1fr;
  }
  .crm-scope-line {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .crm-spinner,
  .crm-status-loading .crm-status-icon {
    animation-duration: 2.4s;
  }
  .crm-thread-pane,
  .crm-message.is-fresh {
    transition: none;
    animation: none;
  }
}
