
/* oMATIC Minds v0.6.8.67 Image Studio mobile reference tray polish.
   Mobile-only cleanup for attached references so thumbnails do not smash into
   the upload/prompt controls and the red remove X stays top-right/centered. */

@media (max-width: 640px) {
  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    max-height: min(74dvh, 560px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 10px !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage.om-image-reference-stage-card {
    order: 1 !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-areas:
      "top"
      "refs" !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 8px !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-stage-head {
    grid-area: top !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-stage-head > div:first-child {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 6px !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-stage-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 6px !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-stage-actions button {
    width: 100% !important;
    min-width: 0 !important;
    height: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    padding: 0 10px !important;
    border-radius: 10px !important;
    font-size: .78rem !important;
    line-height: 1 !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-session-review {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-session-review span,
  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .status-pill {
    max-width: 100% !important;
    height: 24px !important;
    min-height: 24px !important;
    padding: 0 8px !important;
    font-size: .68rem !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* Thumbnail strip: smaller mobile thumbnails with enough breathing room for each X. */
  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-grid {
    grid-area: refs !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 74px !important;
    min-height: 74px !important;
    max-height: 74px !important;
    margin: 0 !important;
    padding: 7px 4px 4px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    box-sizing: border-box !important;
    scroll-padding-left: 4px !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-card {
    position: relative !important;
    flex: 0 0 56px !important;
    width: 56px !important;
    min-width: 56px !important;
    max-width: 56px !important;
    height: 56px !important;
    min-height: 56px !important;
    max-height: 56px !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    border-radius: 12px !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-preview,
  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-preview img {
    width: 56px !important;
    min-width: 56px !important;
    max-width: 56px !important;
    height: 56px !important;
    min-height: 56px !important;
    max-height: 56px !important;
    border-radius: 12px !important;
    object-fit: cover !important;
    overflow: hidden !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-body {
    position: static !important;
    width: 0 !important;
    height: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    pointer-events: none !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-body form {
    position: absolute !important;
    top: -7px !important;
    right: -7px !important;
    left: auto !important;
    bottom: auto !important;
    width: 22px !important;
    min-width: 22px !important;
    max-width: 22px !important;
    height: 22px !important;
    min-height: 22px !important;
    max-height: 22px !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 60 !important;
    overflow: visible !important;
    pointer-events: auto !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-body button {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 22px !important;
    min-width: 22px !important;
    max-width: 22px !important;
    height: 22px !important;
    min-height: 22px !important;
    max-height: 22px !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 999px !important;
    background: #bf1f2d !important;
    border: 1px solid rgba(255,255,255,.32) !important;
    box-shadow: 0 5px 14px rgba(0,0,0,.38) !important;
    color: transparent !important;
    font-size: 0 !important;
    line-height: 1 !important;
    overflow: hidden !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-body button::before {
    content: "×" !important;
    position: absolute !important;
    inset: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #fff !important;
    background: transparent !important;
    font-size: 14px !important;
    font-weight: 900 !important;
    line-height: 1 !important;
    transform: translateY(-1px) !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-body button::after {
    content: none !important;
    display: none !important;
  }

  /* Keep the warning, upload button, prompt, model, Advanced, and Send below the reference tray. */
  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references .om-image-live-confirm-row {
    order: 2 !important;
    margin: 0 !important;
    width: 100% !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references .om-image-generation-submit-status {
    order: 3 !important;
    margin: 0 !important;
    width: 100% !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #om-image-studio-generate-form:not(.is-dictating):not([data-om-dictating="1"]) {
    order: 4 !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  body.om-image-studio-route:has(.om-image-studio-composer-shell.has-image-references) {
    --om-image-studio-composer-clearance: 620px;
  }

  body.om-image-studio-route:has(.om-image-studio-composer-shell.has-image-references) .om-chat-messages,
  body.om-image-studio-route:has(.om-image-studio-composer-shell.has-image-references) .om-image-studio-messages {
    padding-bottom: 680px !important;
    scroll-padding-bottom: 680px !important;
  }
}
