
/* oMATIC Minds v0.6.8.69 Image Studio mobile advanced overlay + reference box spacing.
   Fixes narrow/mobile overlap between Advanced options and the composer, and gives
   the reference box enough height/spacing for pills, add button, and thumbnails. */

@media (max-width: 640px) {
  /* Advanced should be a solid overlay panel, not transparent/floating pills over content. */
  body.om-image-studio-route .om-image-advanced-prompt-popover:not([hidden]) {
    position: fixed !important;
    left: var(--om-image-mobile-left-rail, 58px) !important;
    right: 10px !important;
    bottom: 10px !important;
    top: auto !important;
    width: auto !important;
    max-width: calc(100vw - var(--om-image-mobile-left-rail, 58px) - 18px) !important;
    max-height: min(74dvh, 560px) !important;
    transform: none !important;
    z-index: 9995 !important;
    display: block !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain !important;
    padding: 10px !important;
    border: 1px solid rgba(255,255,255,.16) !important;
    border-radius: 22px !important;
    background: rgba(30, 32, 38, .985) !important;
    box-shadow: 0 24px 70px rgba(0,0,0,.58) !important;
    box-sizing: border-box !important;
  }

  body.om-image-studio-route .om-image-advanced-prompt-popover .om-image-prompt-workspace-card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 12px !important;
    border-radius: 18px !important;
    border: 1px solid rgba(255,255,255,.12) !important;
    background: rgba(16,18,24,.96) !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
  }

  body.om-image-studio-route .om-image-advanced-prompt-popover .om-image-prompt-workspace-head {
    position: sticky !important;
    top: -12px !important;
    z-index: 3 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 40px !important;
    gap: 10px !important;
    align-items: start !important;
    margin: -12px -12px 12px !important;
    padding: 12px !important;
    border-bottom: 1px solid rgba(255,255,255,.10) !important;
    background: rgba(16,18,24,.985) !important;
    border-radius: 18px 18px 0 0 !important;
  }

  body.om-image-studio-route .om-image-advanced-prompt-popover .om-image-prompt-workspace-head h2 {
    font-size: 1rem !important;
    line-height: 1.2 !important;
    margin: 2px 0 4px !important;
  }

  body.om-image-studio-route .om-image-advanced-prompt-popover .om-image-prompt-workspace-head p:not(.eyebrow) {
    font-size: .78rem !important;
    line-height: 1.35 !important;
    margin: 0 !important;
  }

  body.om-image-studio-route .om-image-advanced-prompt-popover .om-image-advanced-close {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    padding: 0 !important;
    border-radius: 999px !important;
    border: 1px solid rgba(255,255,255,.18) !important;
    background: rgba(255,255,255,.10) !important;
    color: #fff !important;
    font-size: 1.25rem !important;
    font-weight: 900 !important;
    line-height: 1 !important;
  }

  body.om-image-studio-route .om-image-advanced-prompt-popover .om-image-template-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
    margin: 0 0 12px !important;
  }

  body.om-image-studio-route .om-image-advanced-prompt-popover .om-image-template-grid button {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 48px !important;
    padding: 8px 9px !important;
    border-radius: 16px !important;
    white-space: normal !important;
    line-height: 1.2 !important;
  }

  body.om-image-studio-route .om-image-advanced-prompt-popover .om-image-prompt-workspace-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  body.om-image-studio-route.om-image-advanced-open .om-image-studio-composer-shell {
    opacity: .88 !important;
  }

  /* Reference box: give the mobile tray a real layout and enough space so nothing collides. */
  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage.om-image-reference-stage-card {
    gap: 12px !important;
    min-height: 205px !important;
    padding: 12px 10px !important;
    overflow: visible !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-stage-head {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    min-height: 0 !important;
    overflow: visible !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: block !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-session-review {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 6px !important;
    width: 100% !important;
    margin: 0 !important;
    min-height: 0 !important;
    overflow: visible !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 {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 24px !important;
    max-height: none !important;
    padding: 5px 9px !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    line-height: 1.15 !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-stage-actions {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 36px !important;
    overflow: visible !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;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  body.om-image-studio-route .om-image-studio-composer-shell.has-image-references #image-reference-stage .om-image-reference-grid {
    height: 82px !important;
    min-height: 82px !important;
    max-height: 82px !important;
    padding: 10px 6px 6px !important;
    margin-top: 0 !important;
    align-items: center !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
  }

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

  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: 740px !important;
    scroll-padding-bottom: 740px !important;
  }
}
