/*
  v6.5.41 composer attachment preview fix
  Keeps staged image/file chips visible above the input in Focus and Messenger,
  instead of forcing them into the 26px icon row where they were clipped.
*/

:root {
  --fm-composer-with-attachments-h: 154px;
  --fm-attachment-row-h: 50px;
}

body .stage > section.view.focus-view.is-active[data-view="focus"] .focus-stage.has-composer-attachments {
  grid-template-rows: minmax(52px, auto) minmax(0, 1fr) minmax(138px, var(--fm-composer-with-attachments-h)) !important;
}

body .stage > section.view.page-view.is-active[data-view="messenger"] .thread-main.has-composer-attachments {
  grid-template-rows: minmax(58px, 72px) minmax(0, 1fr) minmax(138px, var(--fm-composer-with-attachments-h)) !important;
}

body .stage > section.view.focus-view.is-active[data-view="focus"] .focus-console.has-composer-attachments,
body .stage > section.view.page-view.is-active[data-view="messenger"] .thread-compose.has-composer-attachments {
  max-height: var(--fm-composer-with-attachments-h) !important;
  min-height: 138px !important;
  grid-template-rows: 26px minmax(44px, var(--fm-attachment-row-h)) minmax(48px, 1fr) !important;
  gap: 6px !important;
  overflow: hidden !important;
}

body .stage > section.view.focus-view.is-active[data-view="focus"] .focus-console.has-composer-attachments .composer-actions,
body .stage > section.view.page-view.is-active[data-view="messenger"] .thread-compose.has-composer-attachments .composer-actions {
  grid-row: 1 !important;
  grid-column: 1 !important;
}

body .stage > section.view.focus-view.is-active[data-view="focus"] .focus-console.has-composer-attachments .attachment-tray.has-attachments,
body .stage > section.view.page-view.is-active[data-view="messenger"] .thread-compose.has-composer-attachments .attachment-tray.has-attachments {
  grid-row: 2 !important;
  grid-column: 1 !important;
  align-self: stretch !important;
  justify-self: stretch !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  height: var(--fm-attachment-row-h) !important;
  max-height: var(--fm-attachment-row-h) !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  scrollbar-width: thin !important;
  overscroll-behavior: contain !important;
}

body .stage > section.view.focus-view.is-active[data-view="focus"] .focus-console.has-composer-attachments .terminal,
body .stage > section.view.page-view.is-active[data-view="messenger"] .thread-compose.has-composer-attachments .terminal {
  grid-row: 3 !important;
  grid-column: 1 !important;
  min-height: 48px !important;
  max-height: 60px !important;
}

body .stage > section.view.focus-view.is-active[data-view="focus"] .focus-console.has-composer-attachments .attachment-chip,
body .stage > section.view.page-view.is-active[data-view="messenger"] .thread-compose.has-composer-attachments .attachment-chip {
  flex: 0 0 min(320px, 88vw) !important;
  width: min(320px, 88vw) !important;
  max-width: min(320px, 88vw) !important;
  height: 44px !important;
  min-height: 44px !important;
  max-height: 44px !important;
  padding: 5px 7px !important;
  grid-template-columns: 32px minmax(0, 1fr) 26px !important;
  gap: 8px !important;
  cursor: pointer !important;
  box-sizing: border-box !important;
}

body .stage > section.view.focus-view.is-active[data-view="focus"] .focus-console.has-composer-attachments .attachment-chip:hover,
body .stage > section.view.focus-view.is-active[data-view="focus"] .focus-console.has-composer-attachments .attachment-chip:focus-visible,
body .stage > section.view.page-view.is-active[data-view="messenger"] .thread-compose.has-composer-attachments .attachment-chip:hover,
body .stage > section.view.page-view.is-active[data-view="messenger"] .thread-compose.has-composer-attachments .attachment-chip:focus-visible {
  border-color: color-mix(in srgb, var(--amber, #c77a4b) 42%, transparent) !important;
  background: color-mix(in srgb, var(--amber, #c77a4b) 8%, rgba(0, 0, 0, 0.18)) !important;
  outline: none !important;
}

body .stage > section.view.focus-view.is-active[data-view="focus"] .focus-console.has-composer-attachments .attachment-preview,
body .stage > section.view.page-view.is-active[data-view="messenger"] .thread-compose.has-composer-attachments .attachment-preview {
  width: 32px !important;
  height: 32px !important;
}

body .stage > section.view.focus-view.is-active[data-view="focus"] .focus-console.has-composer-attachments .attachment-preview svg,
body .stage > section.view.page-view.is-active[data-view="messenger"] .thread-compose.has-composer-attachments .attachment-preview svg {
  width: 18px !important;
  height: 18px !important;
}

body .stage > section.view.focus-view.is-active[data-view="focus"] .focus-console.has-composer-attachments .attachment-name,
body .stage > section.view.page-view.is-active[data-view="messenger"] .thread-compose.has-composer-attachments .attachment-name {
  font-size: 11px !important;
  line-height: 1.15 !important;
}

body .stage > section.view.focus-view.is-active[data-view="focus"] .focus-console.has-composer-attachments .attachment-kind,
body .stage > section.view.page-view.is-active[data-view="messenger"] .thread-compose.has-composer-attachments .attachment-kind {
  margin-top: 3px !important;
  font-size: 9px !important;
  line-height: 1.1 !important;
}

body .stage > section.view.focus-view.is-active[data-view="focus"] .focus-console.has-composer-attachments .attachment-remove,
body .stage > section.view.page-view.is-active[data-view="messenger"] .thread-compose.has-composer-attachments .attachment-remove {
  width: 24px !important;
  height: 24px !important;
  cursor: pointer !important;
}

@media (max-width: 820px) {
  :root {
    --fm-composer-with-attachments-h: 148px;
    --fm-attachment-row-h: 48px;
  }

  body .stage > section.view.focus-view.is-active[data-view="focus"] .focus-stage.has-composer-attachments,
  body .stage > section.view.page-view.is-active[data-view="messenger"] .thread-main.has-composer-attachments {
    grid-template-rows: minmax(42px, auto) minmax(0, 1fr) minmax(132px, var(--fm-composer-with-attachments-h)) !important;
  }

  body .stage > section.view.focus-view.is-active[data-view="focus"] .focus-console.has-composer-attachments,
  body .stage > section.view.page-view.is-active[data-view="messenger"] .thread-compose.has-composer-attachments {
    min-height: 132px !important;
  }
}
